mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +00:00
* wsdot component adopts wsdot package * update generated files * format code * move wsdot to async_setup_platform * Fix tests * cast wsdot travel id * bump wsdot to 0.0.1 --------- Co-authored-by: Joostlek <joostlek@outlook.com>
25 lines
744 B
Python
25 lines
744 B
Python
"""Provide common WSDOT fixtures."""
|
|
|
|
from collections.abc import AsyncGenerator
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
from wsdot import TravelTime
|
|
|
|
from homeassistant.components.wsdot.sensor import DOMAIN
|
|
|
|
from tests.common import load_json_object_fixture
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_travel_time() -> AsyncGenerator[TravelTime]:
|
|
"""WsdotTravelTimes.get_travel_time is mocked to return a TravelTime data based on test fixture payload."""
|
|
with patch(
|
|
"homeassistant.components.wsdot.sensor.WsdotTravelTimes", autospec=True
|
|
) as mock:
|
|
client = mock.return_value
|
|
client.get_travel_time.return_value = TravelTime(
|
|
**load_json_object_fixture("wsdot.json", DOMAIN)
|
|
)
|
|
yield mock
|