-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Bugfix: Electric Kiwi migrate unique id #135231
base: dev
Are you sure you want to change the base?
Conversation
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
But I am missing, why do we do this? What was the unique id before and what will it be now? |
Unique id was "electric_kiwi" and now it will be their customer number. I do not believe the array of customers is ever greater than 1 but for the sake of completeness/safety I've used join. |
if config_entry.unique_id is not None and config_entry.unique_id.startswith( | ||
DOMAIN | ||
): |
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.
why would this not be the case?
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.
removed, your right it will always be the case. FYI I'm updating the PR for the new release of the API, it fixes a few of the weird items with the unique id so now its just the customer number which is part of the session object, instead of out of an array. Otherwise not much changes. Updating tests as well.
@@ -27,6 +27,17 @@ | |||
type ComponentSetup = Callable[[], Awaitable[bool]] | |||
|
|||
|
|||
@pytest.fixture |
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.
@pytest.fixture | |
@pytest.fixture(autouse=True) |
There are not a lot of tests where you don't need this
aioclient_mock.get( | ||
"https://api.electrickiwi.co.nz/session/", | ||
json=load_json_value_fixture("session.json", DOMAIN), | ||
) |
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.
I am not sure about the state of the rest of the tests, but ideally we don't mock direct aiohttp calls, but rather patch out the library.
(Although, with oauth there's a part where HA makes calls to an endpoint, in those cases its fine)
config_entry: MockConfigEntry, | ||
setup_credentials: None, | ||
) -> None: | ||
"""Test Electric Kiwi reauthentication.""" | ||
config_entry.add_to_hass(hass) | ||
|
||
hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = {} |
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.
Let's not touch internals
|
||
await hass.config_entries.async_setup(config_entry.entry_id) | ||
|
||
await electric_kiwi.async_migrate_entry(hass, config_entry) |
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.
await electric_kiwi.async_migrate_entry(hass, config_entry) |
This should happen automatically when setting up the integration
|
||
|
||
@pytest.mark.usefixtures("setup_credentials") | ||
async def test_cloud_unique_id_migration( |
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.
Let's also add tests for what happens when the migration fails
entity_registry: er.EntityRegistry, | ||
aioclient_mock: AiohttpClientMocker, |
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.
entity_registry: er.EntityRegistry, | |
aioclient_mock: AiohttpClientMocker, |
Migrate from a unique id of DOMAIN to customer number
Breaking change
Proposed change
Fix unique id and migrate, fix small issue where title would be Home Assistant Cloud, now is the customer id
Type of change
Additional information
Checklist
ruff format 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
.To help with the load of incoming pull requests: