-
-
Notifications
You must be signed in to change notification settings - Fork 38.3k
Fix hassio discovery #17275
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
Fix hassio discovery #17275
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4c6b8d1
Update discovery.py
pvizeli 2a04aed
Update test_discovery.py
pvizeli 83e1093
Update test_discovery.py
pvizeli 2d539fd
Update test_discovery.py
pvizeli c5f1c96
Update test_discovery.py
pvizeli 46f99fc
Update test_discovery.py
pvizeli 45eebfe
Update test_discovery.py
pvizeli a2b33dc
Fix tests
pvizeli 4f19111
fix lint
pvizeli 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,55 @@ async def test_hassio_discovery_startup(hass, aioclient_mock, hassio_client): | |
| }) | ||
|
|
||
|
|
||
| async def test_hassio_discovery_startup_done(hass, aioclient_mock, | ||
| hassio_client): | ||
| """Test startup and discovery with hass discovery.""" | ||
| aioclient_mock.get( | ||
| "http://127.0.0.1/discovery", json={ | ||
| 'result': 'ok', 'data': {'discovery': [ | ||
| { | ||
| "service": "mqtt", "uuid": "test", | ||
| "addon": "mosquitto", "config": | ||
| { | ||
| 'broker': 'mock-broker', | ||
| 'port': 1883, | ||
| 'username': 'mock-user', | ||
| 'password': 'mock-pass', | ||
| 'protocol': '3.1.1' | ||
| } | ||
| } | ||
| ]}}) | ||
| aioclient_mock.get( | ||
| "http://127.0.0.1/addons/mosquitto/info", json={ | ||
| 'result': 'ok', 'data': {'name': "Mosquitto Test"} | ||
| }) | ||
|
|
||
| with patch('homeassistant.components.hassio.HassIO.update_hass_api', | ||
| Mock(return_value=mock_coro({"result": "ok"}))), \ | ||
| patch('homeassistant.components.hassio.HassIO.' | ||
| 'get_homeassistant_info', | ||
| Mock(side_effect=HassioAPIError()), | ||
| patch('homeassistant.components.mqtt.' | ||
|
pvizeli marked this conversation as resolved.
|
||
| 'config_flow.FlowHandler.async_step_hassio', | ||
|
pvizeli marked this conversation as resolved.
|
||
| Mock(return_value=mock_coro({"type": "abort"})) | ||
|
pvizeli marked this conversation as resolved.
|
||
| ) as mock_mqtt:): | ||
|
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. closing bracket does not match visual indentation |
||
| await hass.async_start() | ||
| await async_setup_component(hass, 'hassio', { | ||
|
pvizeli marked this conversation as resolved.
|
||
| 'http': { | ||
| 'api_password': API_PASSWORD | ||
| } | ||
| }) | ||
| await hass.async_block_till_done() | ||
|
|
||
| assert aioclient_mock.call_count == 2 | ||
| assert mock_mqtt.called | ||
| mock_mqtt.assert_called_with({ | ||
| 'broker': 'mock-broker', 'port': 1883, 'username': 'mock-user', | ||
| 'password': 'mock-pass', 'protocol': '3.1.1', | ||
| 'addon': 'Mosquitto Test', | ||
| }) | ||
|
|
||
|
|
||
| async def test_hassio_discovery_webhook(hass, aioclient_mock, hassio_client): | ||
| """Test discovery webhook.""" | ||
| aioclient_mock.get( | ||
|
|
||
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.
trailing whitespace