2021-02-03 16:38:12 +00:00
|
|
|
"""Tests for the Mazda Connected Services integration."""
|
|
|
|
|
2023-10-12 11:13:44 +00:00
|
|
|
from homeassistant.components.mazda import DOMAIN
|
2021-05-20 17:19:20 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntryState
|
2021-02-03 16:38:12 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2023-10-12 11:13:44 +00:00
|
|
|
from homeassistant.helpers import issue_registry as ir
|
2022-01-15 19:05:06 +00:00
|
|
|
|
2023-10-12 11:13:44 +00:00
|
|
|
from tests.common import MockConfigEntry
|
2022-01-15 19:05:06 +00:00
|
|
|
|
|
|
|
|
2023-10-12 11:13:44 +00:00
|
|
|
async def test_mazda_repair_issue(
|
|
|
|
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
2023-02-15 09:31:43 +00:00
|
|
|
) -> None:
|
2023-10-12 11:13:44 +00:00
|
|
|
"""Test the Mazda configuration entry loading/unloading handles the repair."""
|
|
|
|
config_entry_1 = MockConfigEntry(
|
|
|
|
title="Example 1",
|
|
|
|
domain=DOMAIN,
|
2021-05-26 14:36:36 +00:00
|
|
|
)
|
2023-10-12 11:13:44 +00:00
|
|
|
config_entry_1.add_to_hass(hass)
|
|
|
|
await hass.config_entries.async_setup(config_entry_1.entry_id)
|
2021-05-28 15:54:19 +00:00
|
|
|
await hass.async_block_till_done()
|
2023-10-12 11:13:44 +00:00
|
|
|
assert config_entry_1.state is ConfigEntryState.LOADED
|
2021-05-26 14:36:36 +00:00
|
|
|
|
2023-10-12 11:13:44 +00:00
|
|
|
# Add a second one
|
|
|
|
config_entry_2 = MockConfigEntry(
|
|
|
|
title="Example 2",
|
|
|
|
domain=DOMAIN,
|
2021-05-26 14:36:36 +00:00
|
|
|
)
|
2023-10-12 11:13:44 +00:00
|
|
|
config_entry_2.add_to_hass(hass)
|
|
|
|
await hass.config_entries.async_setup(config_entry_2.entry_id)
|
|
|
|
await hass.async_block_till_done()
|
2021-05-26 14:36:36 +00:00
|
|
|
|
2023-10-12 11:13:44 +00:00
|
|
|
assert config_entry_2.state is ConfigEntryState.LOADED
|
|
|
|
assert issue_registry.async_get_issue(DOMAIN, DOMAIN)
|
2021-05-26 14:36:36 +00:00
|
|
|
|
2023-10-12 11:13:44 +00:00
|
|
|
# Remove the first one
|
|
|
|
await hass.config_entries.async_remove(config_entry_1.entry_id)
|
|
|
|
await hass.async_block_till_done()
|
2021-05-26 14:36:36 +00:00
|
|
|
|
2023-10-12 11:13:44 +00:00
|
|
|
assert config_entry_1.state is ConfigEntryState.NOT_LOADED
|
|
|
|
assert config_entry_2.state is ConfigEntryState.LOADED
|
|
|
|
assert issue_registry.async_get_issue(DOMAIN, DOMAIN)
|
2021-05-26 14:36:36 +00:00
|
|
|
|
2023-10-12 11:13:44 +00:00
|
|
|
# Remove the second one
|
|
|
|
await hass.config_entries.async_remove(config_entry_2.entry_id)
|
|
|
|
await hass.async_block_till_done()
|
2021-05-26 14:36:36 +00:00
|
|
|
|
2023-10-12 11:13:44 +00:00
|
|
|
assert config_entry_1.state is ConfigEntryState.NOT_LOADED
|
|
|
|
assert config_entry_2.state is ConfigEntryState.NOT_LOADED
|
|
|
|
assert issue_registry.async_get_issue(DOMAIN, DOMAIN) is None
|