2026-02-16 10:47:24 -05:00
|
|
|
"""Test the MTA sensor platform."""
|
|
|
|
|
|
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
from syrupy.assertion import SnapshotAssertion
|
|
|
|
|
|
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
|
from homeassistant.helpers import entity_registry as er
|
|
|
|
|
|
|
|
|
|
from tests.common import MockConfigEntry, snapshot_platform
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.freeze_time("2023-10-21")
|
|
|
|
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
2026-02-24 10:11:13 -05:00
|
|
|
async def test_subway_sensor(
|
2026-02-16 10:47:24 -05:00
|
|
|
hass: HomeAssistant,
|
2026-02-24 10:11:13 -05:00
|
|
|
mock_config_entry_with_subway_subentry: MockConfigEntry,
|
2026-02-16 10:47:24 -05:00
|
|
|
mock_subway_feed: MagicMock,
|
|
|
|
|
entity_registry: er.EntityRegistry,
|
|
|
|
|
snapshot: SnapshotAssertion,
|
|
|
|
|
) -> None:
|
2026-02-24 10:11:13 -05:00
|
|
|
"""Test the subway sensor entities."""
|
2026-02-16 10:47:24 -05:00
|
|
|
await hass.config.async_set_time_zone("UTC")
|
|
|
|
|
|
2026-02-24 10:11:13 -05:00
|
|
|
mock_config_entry_with_subway_subentry.add_to_hass(hass)
|
|
|
|
|
await hass.config_entries.async_setup(
|
|
|
|
|
mock_config_entry_with_subway_subentry.entry_id
|
|
|
|
|
)
|
2026-02-16 10:47:24 -05:00
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
2026-02-24 10:11:13 -05:00
|
|
|
await snapshot_platform(
|
|
|
|
|
hass, entity_registry, snapshot, mock_config_entry_with_subway_subentry.entry_id
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.freeze_time("2023-10-21")
|
|
|
|
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
|
|
|
|
async def test_bus_sensor(
|
|
|
|
|
hass: HomeAssistant,
|
|
|
|
|
mock_config_entry_with_bus_subentry: MockConfigEntry,
|
|
|
|
|
mock_bus_feed: MagicMock,
|
|
|
|
|
entity_registry: er.EntityRegistry,
|
|
|
|
|
snapshot: SnapshotAssertion,
|
|
|
|
|
) -> None:
|
|
|
|
|
"""Test the bus sensor entities."""
|
|
|
|
|
await hass.config.async_set_time_zone("UTC")
|
|
|
|
|
|
|
|
|
|
mock_config_entry_with_bus_subentry.add_to_hass(hass)
|
|
|
|
|
await hass.config_entries.async_setup(mock_config_entry_with_bus_subentry.entry_id)
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
|
|
await snapshot_platform(
|
|
|
|
|
hass, entity_registry, snapshot, mock_config_entry_with_bus_subentry.entry_id
|
|
|
|
|
)
|