hass-core/tests/components/here_travel_time/conftest.py
Kevin Stillhammer f1ac9f8cca
Add ConfigFlow for here_travel_time (#69212)
* Add ConfigFlow for here_travel_time

* Use Selectors and Menu

* Use separate config flow steps for menus

* Move time options together

* Update homeassistant/components/here_travel_time/config_flow.py

Co-authored-by: Allen Porter <allen.porter@gmail.com>

* Blacken config_flow

* Initialize _config

* Only catch HERE errors

* Fix unknown error test

* Implement async_step_import

* Only catch errors for validate_api_key

* Split lat/lon

* Add additional test coverage

* Use TimeSelector in option flow

* Assert config entry data/option

Co-authored-by: Allen Porter <allen.porter@gmail.com>
2022-05-21 07:36:02 -07:00

38 lines
1.2 KiB
Python

"""Fixtures for HERE Travel Time tests."""
import json
from unittest.mock import patch
from herepy.models import RoutingResponse
import pytest
from tests.common import load_fixture
RESPONSE = RoutingResponse.new_from_jsondict(
json.loads(load_fixture("here_travel_time/car_response.json"))
)
RESPONSE.route_short = "US-29 - K St NW; US-29 - Whitehurst Fwy; I-495 N - Capital Beltway; MD-187 S - Old Georgetown Rd"
EMPTY_ATTRIBUTION_RESPONSE = RoutingResponse.new_from_jsondict(
json.loads(load_fixture("here_travel_time/empty_attribution_response.json"))
)
EMPTY_ATTRIBUTION_RESPONSE.route_short = "US-29 - K St NW; US-29 - Whitehurst Fwy; I-495 N - Capital Beltway; MD-187 S - Old Georgetown Rd"
@pytest.fixture(name="valid_response")
def valid_response_fixture():
"""Return valid api response."""
with patch(
"herepy.RoutingApi.public_transport_timetable",
return_value=RESPONSE,
) as mock:
yield mock
@pytest.fixture(name="empty_attribution_response")
def empty_attribution_response_fixture():
"""Return valid api response with an empty attribution."""
with patch(
"herepy.RoutingApi.public_transport_timetable",
return_value=EMPTY_ATTRIBUTION_RESPONSE,
) as mock:
yield mock