Fix flapping trafikverket tests (#116238)

* Fix flapping trafikverket tests

* Fix copy-paste mistake
This commit is contained in:
Erik Montnemery 2024-04-26 13:49:43 +02:00 committed by GitHub
parent 09a18459ff
commit 56f2f10a17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,24 +25,9 @@ async def load_integration_from_entry(
get_train_stop: TrainStop,
) -> MockConfigEntry:
"""Set up the Trafikverket Train integration in Home Assistant."""
config_entry = MockConfigEntry(
domain=DOMAIN,
source=SOURCE_USER,
data=ENTRY_CONFIG,
options=OPTIONS_CONFIG,
entry_id="1",
unique_id="stockholmc-uppsalac--['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']",
)
config_entry.add_to_hass(hass)
config_entry2 = MockConfigEntry(
domain=DOMAIN,
source=SOURCE_USER,
data=ENTRY_CONFIG2,
entry_id="2",
unique_id="stockholmc-uppsalac-1100-['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']",
)
config_entry2.add_to_hass(hass)
async def setup_config_entry_with_mocked_data(config_entry_id: str) -> None:
"""Set up a config entry with mocked trafikverket data."""
with (
patch(
"homeassistant.components.trafikverket_train.coordinator.TrafikverketTrain.async_get_next_train_stops",
@ -56,9 +41,30 @@ async def load_integration_from_entry(
"homeassistant.components.trafikverket_train.TrafikverketTrain.async_get_train_station",
),
):
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.config_entries.async_setup(config_entry_id)
await hass.async_block_till_done()
config_entry = MockConfigEntry(
domain=DOMAIN,
source=SOURCE_USER,
data=ENTRY_CONFIG,
options=OPTIONS_CONFIG,
entry_id="1",
unique_id="stockholmc-uppsalac--['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']",
)
config_entry.add_to_hass(hass)
await setup_config_entry_with_mocked_data(config_entry.entry_id)
config_entry2 = MockConfigEntry(
domain=DOMAIN,
source=SOURCE_USER,
data=ENTRY_CONFIG2,
entry_id="2",
unique_id="stockholmc-uppsalac-1100-['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']",
)
config_entry2.add_to_hass(hass)
await setup_config_entry_with_mocked_data(config_entry2.entry_id)
return config_entry