mirror of
https://github.com/home-assistant/core.git
synced 2025-08-10 22:10:02 +00:00
.devcontainer
.github
.vscode
docs
homeassistant
machine
pylint
rootfs
script
tests
auth
components
fixtures
hassfest
helpers
__init__.py
conftest.py
test_aiohttp_client.py
test_area_registry.py
test_check_config.py
test_collection.py
test_condition.py
test_config_entry_flow.py
test_config_entry_oauth2_flow.py
test_config_validation.py
test_debounce.py
test_deprecation.py
test_device_registry.py
test_discovery.py
test_discovery_flow.py
test_dispatcher.py
test_entity.py
test_entity_component.py
test_entity_platform.py
test_entity_registry.py
test_entity_values.py
test_entityfilter.py
test_event.py
test_frame.py
test_httpx_client.py
test_icon.py
test_init.py
test_instance_id.py
test_integration_platform.py
test_intent.py
test_json.py
test_location.py
test_network.py
test_ratelimit.py
test_recorder.py
test_reload.py
test_restore_state.py
test_script.py
test_script_variables.py
test_selector.py
test_service.py
test_significant_change.py
test_singleton.py
test_start.py
test_state.py
test_storage.py
test_storage_remove.py
test_sun.py
test_system_info.py
test_temperature.py
test_template.py
test_translation.py
test_trigger.py
test_update_coordinator.py
mock
resources
scripts
test_util
testing_config
util
__init__.py
bandit.yaml
common.py
conftest.py
ignore_uncaught_exceptions.py
test_bootstrap.py
test_config.py
test_config_entries.py
test_core.py
test_data_entry_flow.py
test_exceptions.py
test_loader.py
test_main.py
test_requirements.py
test_runner.py
test_setup.py
test_test_fixtures.py
.coveragerc
.dockerignore
.gitattributes
.gitignore
.hadolint.yaml
.ignore
.pre-commit-config.yaml
.prettierignore
.readthedocs.yml
.strict-typing
.yamllint
CLA.md
CODEOWNERS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile
Dockerfile.dev
LICENSE.md
MANIFEST.in
README.rst
build.json
codecov.yml
mypy.ini
pyproject.toml
requirements.txt
requirements_all.txt
requirements_docs.txt
requirements_test.txt
requirements_test_all.txt
requirements_test_pre_commit.txt
setup.cfg
setup.py
tox.ini
27 lines
817 B
Python
27 lines
817 B
Python
"""Tests for instance ID helper."""
|
|
from unittest.mock import patch
|
|
|
|
|
|
async def test_get_id_empty(hass, hass_storage):
|
|
"""Get unique ID."""
|
|
uuid = await hass.helpers.instance_id.async_get()
|
|
assert uuid is not None
|
|
# Assert it's stored
|
|
assert hass_storage["core.uuid"]["data"]["uuid"] == uuid
|
|
|
|
|
|
async def test_get_id_migrate(hass, hass_storage):
|
|
"""Migrate existing file."""
|
|
with patch(
|
|
"homeassistant.util.json.load_json", return_value={"uuid": "1234"}
|
|
), patch("os.path.isfile", return_value=True), patch("os.remove") as mock_remove:
|
|
uuid = await hass.helpers.instance_id.async_get()
|
|
|
|
assert uuid == "1234"
|
|
|
|
# Assert it's stored
|
|
assert hass_storage["core.uuid"]["data"]["uuid"] == uuid
|
|
|
|
# assert old deleted
|
|
assert len(mock_remove.mock_calls) == 1
|