-
-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Bump pydaikin 2.10.5 #95656
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
Bump pydaikin 2.10.5 #95656
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0824e7f
Bump pydaikin to 2.10.5
mover85 5050e46
Added migration for daikin
mover85 8d51765
Merge branch 'dev' into update-pydaikin
mover85 4d7c1cf
Add tests for migration
mover85 b0d36fa
Fix migration test
mover85 6cdc531
Mock pydaikin
mover85 9a19b08
Fix stale comment
mover85 7baf11d
Add more tests for daikin
mover85 d67ce78
Refactor init for testing
mover85 d1606df
Fix logging and rework migration
mover85 7663d1d
Update new name value
mover85 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 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,86 @@ | ||
| """Define tests for the Airzone init.""" | ||
|
mover85 marked this conversation as resolved.
Outdated
|
||
| from unittest.mock import AsyncMock, PropertyMock, patch | ||
|
|
||
| import pytest | ||
|
|
||
| from homeassistant.components.daikin.const import DOMAIN, KEY_MAC | ||
| from homeassistant.const import CONF_HOST | ||
| from homeassistant.core import HomeAssistant | ||
| from homeassistant.helpers import device_registry as dr, entity_registry as er | ||
|
|
||
| from .test_config_flow import HOST, MAC | ||
|
|
||
| from tests.common import MockConfigEntry | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_daikin(): | ||
| """Mock pydaikin.""" | ||
|
|
||
| async def mock_daikin_factory(*args, **kwargs): | ||
| """Mock the init function in pydaikin.""" | ||
| return Appliance | ||
|
|
||
| with patch("homeassistant.components.daikin.Appliance") as Appliance: | ||
| Appliance.factory.side_effect = mock_daikin_factory | ||
| type(Appliance).update_status = AsyncMock() | ||
| type(Appliance).inside_temperature = PropertyMock(return_value=22) | ||
| type(Appliance).target_temperature = PropertyMock(return_value=22) | ||
| type(Appliance).zones = PropertyMock(return_value=[("Zone 1", "0", 0)]) | ||
| type(Appliance).fan_rate = PropertyMock(return_value=[]) | ||
| type(Appliance).swing_modes = PropertyMock(return_value=[]) | ||
| yield Appliance | ||
|
|
||
|
|
||
| DATA = { | ||
| "ver": "1_1_8", | ||
| "name": "DaikinAP00000", | ||
| "mac": MAC, | ||
| "model": "NOTSUPPORT", | ||
| } | ||
|
mover85 marked this conversation as resolved.
|
||
|
|
||
|
|
||
| INVALID_DATA = {**DATA, "name": None, "mac": HOST} | ||
|
|
||
|
|
||
| async def test_unique_id_migrate(hass: HomeAssistant, mock_daikin) -> None: | ||
| """Test unique id migration.""" | ||
| config_entry = MockConfigEntry( | ||
| domain=DOMAIN, | ||
| unique_id=HOST, | ||
| title=None, | ||
| data={CONF_HOST: HOST, KEY_MAC: HOST}, | ||
| ) | ||
| config_entry.add_to_hass(hass) | ||
| entity_registry = er.async_get(hass) | ||
| device_registry = dr.async_get(hass) | ||
|
|
||
| type(mock_daikin).mac = PropertyMock(return_value=HOST) | ||
| type(mock_daikin).values = PropertyMock(return_value=INVALID_DATA) | ||
|
|
||
| assert await hass.config_entries.async_setup(config_entry.entry_id) | ||
| await hass.async_block_till_done() | ||
|
|
||
| assert config_entry.unique_id == HOST | ||
|
|
||
| assert device_registry.async_get_device({}, {(KEY_MAC, HOST)}).name is None | ||
|
|
||
| assert entity_registry.async_get("climate.daikin_127_0_0_1").unique_id == HOST | ||
| assert entity_registry.async_get("switch.none_zone_1").unique_id.startswith(HOST) | ||
|
|
||
| type(mock_daikin).mac = PropertyMock(return_value=MAC) | ||
| type(mock_daikin).values = PropertyMock(return_value=DATA) | ||
|
|
||
| assert config_entry.unique_id != MAC | ||
|
|
||
| assert await hass.config_entries.async_reload(config_entry.entry_id) | ||
| await hass.async_block_till_done() | ||
|
|
||
| assert config_entry.unique_id == MAC | ||
|
|
||
| assert ( | ||
| device_registry.async_get_device({}, {(KEY_MAC, MAC)}).name == "DaikinAP00000" | ||
| ) | ||
|
|
||
| assert entity_registry.async_get("climate.daikin_127_0_0_1").unique_id == MAC | ||
| assert entity_registry.async_get("switch.none_zone_1").unique_id.startswith(MAC) | ||
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.