Incorporate various improvements for the ws66i integration#71717
Merged
MartinHjelmare merged 5 commits intohome-assistant:devfrom May 29, 2022
Merged
Incorporate various improvements for the ws66i integration#71717MartinHjelmare merged 5 commits intohome-assistant:devfrom
MartinHjelmare merged 5 commits intohome-assistant:devfrom
Conversation
This was referenced May 12, 2022
Contributor
Author
|
I apologize for the delay. I was in Berlin last week and I am on vacation
all this week. I will look at these on the weekend.
…On Thu, May 19, 2022, 12:39 AM Martin Hjelmare ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In homeassistant/components/ws66i/config_flow.py
<#71717 (comment)>:
>
- # Validation done. No issues. Close the connection
- ws66i.close()
+ return bool(ret_val)
+
+ is_valid: bool = await hass.async_add_executor_job(_verify_connection, ws66i)
+ if not is_valid:
+ raise ConnectionError("Not a valid WS66i connection")
We prefer to raise a custom exception that inherits HomeAssistantError
instead of using a built in exception. I'd suggest to use the exception
CannotConnect for this purpose. If the device can raise ConnectionError
we can catch that here and raise CannotConnect.
------------------------------
In tests/components/ws66i/test_init.py
<#71717 (comment)>:
> +CONFIG = {CONF_IP_ADDRESS: "1.1.1.1"}
+
+ZONE_1_ID = "media_player.zone_11"
+
+
+async def test_cannot_connect(hass):
+ """Test connection error."""
+ with patch(
+ "homeassistant.components.ws66i.get_ws66i",
+ new=lambda *a: MockWs66i(fail_open=True),
+ ):
+ config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG)
+ config_entry.add_to_hass(hass)
+ await hass.config_entries.async_setup(config_entry.entry_id)
+ await hass.async_block_till_done()
+ assert hass.states.get(ZONE_1_ID) is None
We should also assert the state of the config entry.
https://github.com/home-assistant/core/blob/1d6e40451274cbe8ccc6be256146193bcfe97df5/homeassistant/config_entries.py#L78-L92
------------------------------
In tests/components/ws66i/test_media_player.py
<#71717 (comment)>:
> @@ -635,58 +512,3 @@ async def test_unload_config_entry(hass):
assert method_call.called
assert not hass.data[DOMAIN]
The test_unload_config_entry test should move to the test_init.py module.
—
Reply to this email directly, view it on GitHub
<#71717 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGZYALH52DZ7FSYA53A2ZJTVKXV3PANCNFSM5VWZQYUA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Member
|
Adding this to the milestone to avoid releasing the integration with the custom services which would make it a breaking change later when we remove the services. |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Proposed change
This PR contains 3 commits:
If #3 doesn't belong to this PR, I can create a new PR just for it.
Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: