-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing translations and descriptions for notification fields in UI #132676
Draft
yazan-abdalrahman
wants to merge
12
commits into
home-assistant:dev
Choose a base branch
from
yazan-abdalrahman:fix-html5-translations
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+251
−15
Draft
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fb757bc
Add missing translations for HTML5 Push Notifications UI
yazan-abdalrahman 8e259ff
capitalization of HTML5 in notification description
yazan-abdalrahman 6a90354
Add missing translations and descriptions for notification fields in UI
yazan-abdalrahman 302112e
Update legacy.py
yazan-abdalrahman 2a73769
Use active language for dynamic translation in notify services
yazan-abdalrahman e6c7f5c
fix tests 1
yazan-abdalrahman 13baaa7
Trigger pipeline
yazan-abdalrahman a9c1687
Merge branch 'dev' into fix-html5-translations
yazan-abdalrahman 5a1170c
Merge branch 'dev' into fix-html5-translations
yazan-abdalrahman fd0102b
Merge branch 'dev' into fix-html5-translations
yazan-abdalrahman fc1255d
Add tests for service description translations
yazan-abdalrahman b68c080
Merge branch 'dev' into fix-html5-translations
yazan-abdalrahman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,13 @@ | |
from unittest.mock import Mock, call, patch | ||
|
||
import pytest | ||
import voluptuous as vol | ||
|
||
from homeassistant import loader | ||
from homeassistant.const import EVENT_CORE_CONFIG_UPDATE | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.helpers import translation | ||
import homeassistant.helpers.config_validation as cv | ||
from homeassistant.setup import async_setup_component | ||
|
||
|
||
|
@@ -712,3 +714,57 @@ async def test_get_translations_still_has_title_without_translations_files( | |
assert translations == { | ||
"component.component1.title": "Component 1", | ||
} | ||
|
||
|
||
@pytest.fixture | ||
async def mock_integration(hass: HomeAssistant): | ||
"""Set up a mock notification service.""" | ||
|
||
async def test_service(call): | ||
pass | ||
|
||
hass.services.async_register( | ||
"test_notify", | ||
"send_message", | ||
test_service, | ||
schema=vol.Schema( | ||
{ | ||
vol.Required("message"): cv.string, | ||
vol.Optional("title"): cv.string, | ||
} | ||
), | ||
) | ||
|
||
|
||
async def test_translation_for_notify_service( | ||
hass: HomeAssistant, mock_integration | ||
) -> None: | ||
"""Test that the notification service description is translated correctly.""" | ||
translations = { | ||
"component.test_notify.services.send_message.description": "Send a translated test notification", | ||
"component.test_notify.services.send_message.fields.message.description": "Translated message description", | ||
"component.test_notify.services.send_message.fields.title.description": "Translated title description", | ||
} | ||
|
||
with patch( | ||
"homeassistant.helpers.translation.async_get_translations", | ||
return_value=translations, | ||
): | ||
descriptions = await translation.async_get_translations(hass, "en", "services") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't testing any production code. The call here is calling the mock patched above. |
||
|
||
assert ( | ||
descriptions["component.test_notify.services.send_message.description"] | ||
== "Send a translated test notification" | ||
) | ||
assert ( | ||
descriptions[ | ||
"component.test_notify.services.send_message.fields.message.description" | ||
] | ||
== "Translated message description" | ||
) | ||
assert ( | ||
descriptions[ | ||
"component.test_notify.services.send_message.fields.title.description" | ||
] | ||
== "Translated title description" | ||
) |
3 changes: 3 additions & 0 deletions
3
tests/testing_config/custom_components/test_notify/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""notify.""" | ||
|
||
DOMAIN = "test_notify" |
8 changes: 8 additions & 0 deletions
8
tests/testing_config/custom_components/test_notify/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"domain": "test_notify", | ||
"name": "Test Notify", | ||
"documentation": "https://example.com", | ||
"dependencies": [], | ||
"codeowners": [], | ||
"requirements": [] | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/testing_config/custom_components/test_notify/services.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
send_message: | ||
description: "Sends a test notification" | ||
fields: | ||
message: | ||
description: "The message to send" | ||
title: | ||
description: "The title of the message" |
15 changes: 15 additions & 0 deletions
15
tests/testing_config/custom_components/test_notify/strings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"services": { | ||
"send_message": { | ||
"description": "Send a translated test notification", | ||
"fields": { | ||
"message": { | ||
"description": "Translated message description" | ||
}, | ||
"title": { | ||
"description": "Translated title description" | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we want to test the notify integration service descriptions I'd expect this test to be part of the notify integration (legacy) tests.