-
-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Add shared notify service migration repair helper #117213
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fbb6626
Add shared notifiy service migration repair helper
jbouwh 545edb2
Delete ecobee repairs.py
jbouwh 65616d0
Update dependency
jbouwh 9854535
Fix file test
jbouwh 146e6c8
Fix homematic tests
jbouwh d9637d2
Improve tests for file and homematic
jbouwh 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,84 @@ | ||
| """Test repairs for notify entity component.""" | ||
|
|
||
| from http import HTTPStatus | ||
| from unittest.mock import AsyncMock | ||
|
|
||
| from homeassistant.components.notify import ( | ||
| DOMAIN as NOTIFY_DOMAIN, | ||
| migrate_notify_issue, | ||
| ) | ||
| from homeassistant.components.repairs.issue_handler import ( | ||
| async_process_repairs_platforms, | ||
| ) | ||
| from homeassistant.components.repairs.websocket_api import ( | ||
| RepairsFlowIndexView, | ||
| RepairsFlowResourceView, | ||
| ) | ||
| from homeassistant.core import HomeAssistant | ||
| from homeassistant.helpers import issue_registry as ir | ||
| from homeassistant.setup import async_setup_component | ||
|
|
||
| from tests.common import MockConfigEntry, MockModule, mock_integration | ||
| from tests.typing import ClientSessionGenerator | ||
|
|
||
| THERMOSTAT_ID = 0 | ||
|
|
||
|
|
||
| async def test_notify_migration_repair_flow( | ||
| hass: HomeAssistant, | ||
| hass_client: ClientSessionGenerator, | ||
| issue_registry: ir.IssueRegistry, | ||
| config_flow_fixture: None, | ||
| ) -> None: | ||
| """Test the notify service repair flow is triggered.""" | ||
| await async_setup_component(hass, NOTIFY_DOMAIN, {}) | ||
| await hass.async_block_till_done() | ||
| await async_process_repairs_platforms(hass) | ||
|
|
||
| http_client = await hass_client() | ||
| await hass.async_block_till_done() | ||
| config_entry = MockConfigEntry(domain="test") | ||
| config_entry.add_to_hass(hass) | ||
| mock_integration( | ||
| hass, | ||
| MockModule( | ||
| "test", | ||
| async_setup_entry=AsyncMock(return_value=True), | ||
| ), | ||
| ) | ||
| assert await hass.config_entries.async_setup(config_entry.entry_id) | ||
|
|
||
| # Simulate legacy service being used and issue being registered | ||
| migrate_notify_issue(hass, "test", "Test", "2024.12.0") | ||
| await hass.async_block_till_done() | ||
| # Assert the issue is present | ||
| assert issue_registry.async_get_issue( | ||
| domain=NOTIFY_DOMAIN, | ||
| issue_id="migrate_notify_test", | ||
| ) | ||
| assert len(issue_registry.issues) == 1 | ||
|
|
||
| url = RepairsFlowIndexView.url | ||
| resp = await http_client.post( | ||
| url, json={"handler": NOTIFY_DOMAIN, "issue_id": "migrate_notify_test"} | ||
| ) | ||
| assert resp.status == HTTPStatus.OK | ||
| data = await resp.json() | ||
|
|
||
| flow_id = data["flow_id"] | ||
| assert data["step_id"] == "confirm" | ||
|
|
||
| url = RepairsFlowResourceView.url.format(flow_id=flow_id) | ||
| resp = await http_client.post(url) | ||
| assert resp.status == HTTPStatus.OK | ||
| data = await resp.json() | ||
| assert data["type"] == "create_entry" | ||
| # Test confirm step in repair flow | ||
| await hass.async_block_till_done() | ||
|
|
||
| # Assert the issue is no longer present | ||
| assert not issue_registry.async_get_issue( | ||
| domain=NOTIFY_DOMAIN, | ||
| issue_id="migrate_notify_test", | ||
| ) | ||
| assert len(issue_registry.issues) == 0 |
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.
Uh oh!
There was an error while loading. Please reload this page.