mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Ensure github tests add config entry before updating it (#110430)
This commit is contained in:
parent
704ad67917
commit
0e1cdc1f79
@ -18,6 +18,7 @@ async def setup_github_integration(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
|
add_entry_to_hass: bool = True,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Mock setting up the integration."""
|
"""Mock setting up the integration."""
|
||||||
headers = json.loads(load_fixture("base_headers.json", DOMAIN))
|
headers = json.loads(load_fixture("base_headers.json", DOMAIN))
|
||||||
@ -41,7 +42,8 @@ async def setup_github_integration(
|
|||||||
json=json.loads(load_fixture("graphql.json", DOMAIN)),
|
json=json.loads(load_fixture("graphql.json", DOMAIN)),
|
||||||
headers=headers,
|
headers=headers,
|
||||||
)
|
)
|
||||||
mock_config_entry.add_to_hass(hass)
|
if add_entry_to_hass:
|
||||||
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
setup_result = await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
setup_result = await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -260,13 +260,13 @@ async def test_options_flow(
|
|||||||
mock_setup_entry: None,
|
mock_setup_entry: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test options flow."""
|
"""Test options flow."""
|
||||||
|
mock_config_entry.add_to_hass(hass)
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
mock_config_entry,
|
mock_config_entry,
|
||||||
options={
|
options={
|
||||||
CONF_REPOSITORIES: ["homeassistant/core", "homeassistant/architecture"]
|
CONF_REPOSITORIES: ["homeassistant/core", "homeassistant/architecture"]
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
mock_config_entry.add_to_hass(hass)
|
|
||||||
|
|
||||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -25,6 +25,7 @@ async def test_entry_diagnostics(
|
|||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test config entry diagnostics."""
|
"""Test config entry diagnostics."""
|
||||||
|
mock_config_entry.add_to_hass(hass)
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
mock_config_entry,
|
mock_config_entry,
|
||||||
options={CONF_REPOSITORIES: ["home-assistant/core"]},
|
options={CONF_REPOSITORIES: ["home-assistant/core"]},
|
||||||
@ -43,7 +44,9 @@ async def test_entry_diagnostics(
|
|||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
)
|
)
|
||||||
|
|
||||||
await setup_github_integration(hass, mock_config_entry, aioclient_mock)
|
await setup_github_integration(
|
||||||
|
hass, mock_config_entry, aioclient_mock, add_entry_to_hass=False
|
||||||
|
)
|
||||||
result = await get_diagnostics_for_config_entry(
|
result = await get_diagnostics_for_config_entry(
|
||||||
hass,
|
hass,
|
||||||
hass_client,
|
hass_client,
|
||||||
|
@ -21,11 +21,14 @@ async def test_device_registry_cleanup(
|
|||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that we remove untracked repositories from the decvice registry."""
|
"""Test that we remove untracked repositories from the decvice registry."""
|
||||||
|
mock_config_entry.add_to_hass(hass)
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
mock_config_entry,
|
mock_config_entry,
|
||||||
options={CONF_REPOSITORIES: ["home-assistant/core"]},
|
options={CONF_REPOSITORIES: ["home-assistant/core"]},
|
||||||
)
|
)
|
||||||
await setup_github_integration(hass, mock_config_entry, aioclient_mock)
|
await setup_github_integration(
|
||||||
|
hass, mock_config_entry, aioclient_mock, add_entry_to_hass=False
|
||||||
|
)
|
||||||
|
|
||||||
devices = dr.async_entries_for_config_entry(
|
devices = dr.async_entries_for_config_entry(
|
||||||
registry=device_registry,
|
registry=device_registry,
|
||||||
@ -62,12 +65,15 @@ async def test_subscription_setup(
|
|||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that we setup event subscription."""
|
"""Test that we setup event subscription."""
|
||||||
|
mock_config_entry.add_to_hass(hass)
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
mock_config_entry,
|
mock_config_entry,
|
||||||
options={CONF_REPOSITORIES: ["home-assistant/core"]},
|
options={CONF_REPOSITORIES: ["home-assistant/core"]},
|
||||||
pref_disable_polling=False,
|
pref_disable_polling=False,
|
||||||
)
|
)
|
||||||
await setup_github_integration(hass, mock_config_entry, aioclient_mock)
|
await setup_github_integration(
|
||||||
|
hass, mock_config_entry, aioclient_mock, add_entry_to_hass=False
|
||||||
|
)
|
||||||
assert (
|
assert (
|
||||||
"https://api.github.com/repos/home-assistant/core/events" in x[1]
|
"https://api.github.com/repos/home-assistant/core/events" in x[1]
|
||||||
for x in aioclient_mock.mock_calls
|
for x in aioclient_mock.mock_calls
|
||||||
@ -82,12 +88,15 @@ async def test_subscription_setup_polling_disabled(
|
|||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that we do not setup event subscription if polling is disabled."""
|
"""Test that we do not setup event subscription if polling is disabled."""
|
||||||
|
mock_config_entry.add_to_hass(hass)
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
mock_config_entry,
|
mock_config_entry,
|
||||||
options={CONF_REPOSITORIES: ["home-assistant/core"]},
|
options={CONF_REPOSITORIES: ["home-assistant/core"]},
|
||||||
pref_disable_polling=True,
|
pref_disable_polling=True,
|
||||||
)
|
)
|
||||||
await setup_github_integration(hass, mock_config_entry, aioclient_mock)
|
await setup_github_integration(
|
||||||
|
hass, mock_config_entry, aioclient_mock, add_entry_to_hass=False
|
||||||
|
)
|
||||||
assert (
|
assert (
|
||||||
"https://api.github.com/repos/home-assistant/core/events" not in x[1]
|
"https://api.github.com/repos/home-assistant/core/events" not in x[1]
|
||||||
for x in aioclient_mock.mock_calls
|
for x in aioclient_mock.mock_calls
|
||||||
|
Loading…
x
Reference in New Issue
Block a user