mirror of
https://github.com/home-assistant/core.git
synced 2025-07-04 03:47:09 +00:00
Use async_load_fixture in async test functions (l-z) (#145717)
* Use async_load_fixture in async test functions (l-z) * Adjust
This commit is contained in:
parent
b318644998
commit
a007e8dc26
@ -13,7 +13,7 @@ from homeassistant.core import HomeAssistant
|
||||
from . import setup_integration
|
||||
from .conftest import HOST, mock_lp_aiohttp_client
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
@ -39,12 +39,12 @@ async def test_diagnostics(
|
||||
for endpoint in endpoints:
|
||||
mock_session.get(
|
||||
API_ENDPOINT.format(str(endpoint), "getPlayerStatusEx"),
|
||||
text=load_fixture("getPlayerEx.json", DOMAIN),
|
||||
text=await async_load_fixture(hass, "getPlayerEx.json", DOMAIN),
|
||||
)
|
||||
|
||||
mock_session.get(
|
||||
API_ENDPOINT.format(str(endpoint), "getStatusEx"),
|
||||
text=load_fixture("getStatusEx.json", DOMAIN),
|
||||
text=await async_load_fixture(hass, "getStatusEx.json", DOMAIN),
|
||||
)
|
||||
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
@ -8,7 +8,7 @@ from homeassistant.components.london_air.sensor import CONF_LOCATIONS, URL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
|
||||
VALID_CONFIG = {"sensor": {"platform": "london_air", CONF_LOCATIONS: ["Merton"]}}
|
||||
|
||||
@ -19,7 +19,7 @@ async def test_valid_state(
|
||||
"""Test for operational london_air sensor with proper attributes."""
|
||||
requests_mock.get(
|
||||
URL,
|
||||
text=load_fixture("london_air.json", "london_air"),
|
||||
text=await async_load_fixture(hass, "london_air.json", "london_air"),
|
||||
status_code=HTTPStatus.OK,
|
||||
)
|
||||
assert await async_setup_component(hass, "sensor", VALID_CONFIG)
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
from london_tube_status import API_URL
|
||||
|
||||
from homeassistant.components.london_underground.const import CONF_LINE
|
||||
from homeassistant.components.london_underground.const import CONF_LINE, DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
VALID_CONFIG = {
|
||||
@ -20,7 +20,7 @@ async def test_valid_state(
|
||||
"""Test for operational london_underground sensor with proper attributes."""
|
||||
aioclient_mock.get(
|
||||
API_URL,
|
||||
text=load_fixture("line_status.json", "london_underground"),
|
||||
text=await async_load_fixture(hass, "line_status.json", DOMAIN),
|
||||
)
|
||||
|
||||
assert await async_setup_component(hass, "sensor", VALID_CONFIG)
|
||||
|
@ -14,14 +14,14 @@ from homeassistant.const import CONF_API_TOKEN, CONF_NAME, CONF_WEBHOOK_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
|
||||
@pytest.fixture(name="config_entry")
|
||||
def config_entry_fixture() -> MockConfigEntry:
|
||||
async def config_entry_fixture(hass: HomeAssistant) -> MockConfigEntry:
|
||||
"""Mock config entry."""
|
||||
|
||||
config = load_fixture("loqed/integration_config.json")
|
||||
config = await async_load_fixture(hass, "integration_config.json", DOMAIN)
|
||||
json_config = json.loads(config)
|
||||
return MockConfigEntry(
|
||||
version=1,
|
||||
@ -41,11 +41,13 @@ def config_entry_fixture() -> MockConfigEntry:
|
||||
|
||||
|
||||
@pytest.fixture(name="cloud_config_entry")
|
||||
def cloud_config_entry_fixture() -> MockConfigEntry:
|
||||
async def cloud_config_entry_fixture(hass: HomeAssistant) -> MockConfigEntry:
|
||||
"""Mock config entry."""
|
||||
|
||||
config = load_fixture("loqed/integration_config.json")
|
||||
webhooks_fixture = json.loads(load_fixture("loqed/get_all_webhooks.json"))
|
||||
config = await async_load_fixture(hass, "integration_config.json", DOMAIN)
|
||||
webhooks_fixture = json.loads(
|
||||
await async_load_fixture(hass, "get_all_webhooks.json", DOMAIN)
|
||||
)
|
||||
json_config = json.loads(config)
|
||||
return MockConfigEntry(
|
||||
version=1,
|
||||
@ -66,9 +68,11 @@ def cloud_config_entry_fixture() -> MockConfigEntry:
|
||||
|
||||
|
||||
@pytest.fixture(name="lock")
|
||||
def lock_fixture() -> loqed.Lock:
|
||||
async def lock_fixture(hass: HomeAssistant) -> loqed.Lock:
|
||||
"""Set up a mock implementation of a Lock."""
|
||||
webhooks_fixture = json.loads(load_fixture("loqed/get_all_webhooks.json"))
|
||||
webhooks_fixture = json.loads(
|
||||
await async_load_fixture(hass, "get_all_webhooks.json", DOMAIN)
|
||||
)
|
||||
|
||||
mock_lock = Mock(spec=loqed.Lock, id="Foo", last_key_id=2)
|
||||
mock_lock.name = "LOQED smart lock"
|
||||
@ -86,7 +90,7 @@ async def integration_fixture(
|
||||
config: dict[str, Any] = {DOMAIN: {CONF_API_TOKEN: ""}}
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
lock_status = json.loads(load_fixture("loqed/status_ok.json"))
|
||||
lock_status = json.loads(await async_load_fixture(hass, "status_ok.json", DOMAIN))
|
||||
|
||||
with (
|
||||
patch("loqedAPI.loqed.LoqedAPI.async_get_lock", return_value=lock),
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
zeroconf_data = ZeroconfServiceInfo(
|
||||
@ -30,7 +30,7 @@ zeroconf_data = ZeroconfServiceInfo(
|
||||
|
||||
async def test_create_entry_zeroconf(hass: HomeAssistant) -> None:
|
||||
"""Test we get can create a lock via zeroconf."""
|
||||
lock_result = json.loads(load_fixture("loqed/status_ok.json"))
|
||||
lock_result = json.loads(await async_load_fixture(hass, "status_ok.json", DOMAIN))
|
||||
|
||||
with patch(
|
||||
"loqedAPI.loqed.LoqedAPI.async_get_lock_details",
|
||||
@ -47,7 +47,9 @@ async def test_create_entry_zeroconf(hass: HomeAssistant) -> None:
|
||||
|
||||
mock_lock = Mock(spec=loqed.Lock, id="Foo")
|
||||
webhook_id = "Webhook_ID"
|
||||
all_locks_response = json.loads(load_fixture("loqed/get_all_locks.json"))
|
||||
all_locks_response = json.loads(
|
||||
await async_load_fixture(hass, "get_all_locks.json", DOMAIN)
|
||||
)
|
||||
|
||||
with (
|
||||
patch(
|
||||
@ -104,10 +106,12 @@ async def test_create_entry_user(
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
lock_result = json.loads(load_fixture("loqed/status_ok.json"))
|
||||
lock_result = json.loads(await async_load_fixture(hass, "status_ok.json", DOMAIN))
|
||||
mock_lock = Mock(spec=loqed.Lock, id="Foo")
|
||||
webhook_id = "Webhook_ID"
|
||||
all_locks_response = json.loads(load_fixture("loqed/get_all_locks.json"))
|
||||
all_locks_response = json.loads(
|
||||
await async_load_fixture(hass, "get_all_locks.json", DOMAIN)
|
||||
)
|
||||
found_lock = all_locks_response["data"][0]
|
||||
|
||||
with (
|
||||
@ -191,7 +195,9 @@ async def test_invalid_auth_when_lock_not_found(
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
all_locks_response = json.loads(load_fixture("loqed/get_all_locks.json"))
|
||||
all_locks_response = json.loads(
|
||||
await async_load_fixture(hass, "get_all_locks.json", DOMAIN)
|
||||
)
|
||||
|
||||
with patch(
|
||||
"loqedAPI.cloud_loqed.LoqedCloudAPI.async_get_locks",
|
||||
@ -219,7 +225,9 @@ async def test_cannot_connect_when_lock_not_reachable(
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
all_locks_response = json.loads(load_fixture("loqed/get_all_locks.json"))
|
||||
all_locks_response = json.loads(
|
||||
await async_load_fixture(hass, "get_all_locks.json", DOMAIN)
|
||||
)
|
||||
|
||||
with (
|
||||
patch(
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.network import get_url
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
@ -27,10 +27,12 @@ async def test_webhook_accepts_valid_message(
|
||||
"""Test webhook called with valid message."""
|
||||
await async_setup_component(hass, "http", {"http": {}})
|
||||
client = await hass_client_no_auth()
|
||||
processed_message = json.loads(load_fixture("loqed/lock_going_to_nightlock.json"))
|
||||
processed_message = json.loads(
|
||||
await async_load_fixture(hass, "lock_going_to_nightlock.json", DOMAIN)
|
||||
)
|
||||
lock.receiveWebhook = AsyncMock(return_value=processed_message)
|
||||
|
||||
message = load_fixture("loqed/battery_update.json")
|
||||
message = await async_load_fixture(hass, "battery_update.json", DOMAIN)
|
||||
timestamp = 1653304609
|
||||
await client.post(
|
||||
f"/api/webhook/{integration.data[CONF_WEBHOOK_ID]}",
|
||||
@ -47,8 +49,10 @@ async def test_setup_webhook_in_bridge(
|
||||
config: dict[str, Any] = {DOMAIN: {}}
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
lock_status = json.loads(load_fixture("loqed/status_ok.json"))
|
||||
webhooks_fixture = json.loads(load_fixture("loqed/get_all_webhooks.json"))
|
||||
lock_status = json.loads(await async_load_fixture(hass, "status_ok.json", DOMAIN))
|
||||
webhooks_fixture = json.loads(
|
||||
await async_load_fixture(hass, "get_all_webhooks.json", DOMAIN)
|
||||
)
|
||||
lock.getWebhooks = AsyncMock(side_effect=[[], webhooks_fixture])
|
||||
|
||||
with (
|
||||
@ -86,8 +90,10 @@ async def test_setup_cloudhook_in_bridge(
|
||||
config: dict[str, Any] = {DOMAIN: {}}
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
lock_status = json.loads(load_fixture("loqed/status_ok.json"))
|
||||
webhooks_fixture = json.loads(load_fixture("loqed/get_all_webhooks.json"))
|
||||
lock_status = json.loads(await async_load_fixture(hass, "status_ok.json", DOMAIN))
|
||||
webhooks_fixture = json.loads(
|
||||
await async_load_fixture(hass, "get_all_webhooks.json", DOMAIN)
|
||||
)
|
||||
lock.getWebhooks = AsyncMock(side_effect=[[], webhooks_fixture])
|
||||
|
||||
with (
|
||||
@ -114,12 +120,14 @@ async def test_setup_cloudhook_from_entry_in_bridge(
|
||||
hass: HomeAssistant, cloud_config_entry: MockConfigEntry, lock: loqed.Lock
|
||||
) -> None:
|
||||
"""Test webhook setup in loqed bridge."""
|
||||
webhooks_fixture = json.loads(load_fixture("loqed/get_all_webhooks.json"))
|
||||
webhooks_fixture = json.loads(
|
||||
await async_load_fixture(hass, "get_all_webhooks.json", DOMAIN)
|
||||
)
|
||||
|
||||
config: dict[str, Any] = {DOMAIN: {}}
|
||||
cloud_config_entry.add_to_hass(hass)
|
||||
|
||||
lock_status = json.loads(load_fixture("loqed/status_ok.json"))
|
||||
lock_status = json.loads(await async_load_fixture(hass, "status_ok.json", DOMAIN))
|
||||
|
||||
lock.getWebhooks = AsyncMock(side_effect=[[], webhooks_fixture])
|
||||
|
||||
|
@ -26,7 +26,7 @@ from . import setup_integration
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
async_fire_time_changed,
|
||||
load_fixture,
|
||||
async_load_fixture,
|
||||
snapshot_platform,
|
||||
)
|
||||
from tests.typing import WebSocketGenerator
|
||||
@ -341,7 +341,7 @@ async def test_runtime_management(
|
||||
) -> None:
|
||||
"""Test for creating and deleting shopping lists."""
|
||||
response = ShoppingListsResponse.from_json(
|
||||
load_fixture("get_shopping_lists.json", DOMAIN)
|
||||
await async_load_fixture(hass, "get_shopping_lists.json", DOMAIN)
|
||||
).items
|
||||
mock_mealie_client.get_shopping_lists.return_value = ShoppingListsResponse(
|
||||
items=[response[0]]
|
||||
|
@ -22,7 +22,7 @@ from .const import (
|
||||
TEST_SITE_NAME_WAVERTREE,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
|
||||
async def test_form(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -> None:
|
||||
@ -31,7 +31,7 @@ async def test_form(hass: HomeAssistant, requests_mock: requests_mock.Mocker) ->
|
||||
hass.config.longitude = TEST_LONGITUDE_WAVERTREE
|
||||
|
||||
# all metoffice test data encapsulated in here
|
||||
mock_json = json.loads(load_fixture("metoffice.json", "metoffice"))
|
||||
mock_json = json.loads(await async_load_fixture(hass, "metoffice.json", DOMAIN))
|
||||
wavertree_daily = json.dumps(mock_json["wavertree_daily"])
|
||||
requests_mock.get(
|
||||
"https://data.hub.api.metoffice.gov.uk/sitespecific/v0/point/daily",
|
||||
@ -72,7 +72,7 @@ async def test_form_already_configured(
|
||||
hass.config.longitude = TEST_LONGITUDE_WAVERTREE
|
||||
|
||||
# all metoffice test data encapsulated in here
|
||||
mock_json = json.loads(load_fixture("metoffice.json", "metoffice"))
|
||||
mock_json = json.loads(await async_load_fixture(hass, "metoffice.json", DOMAIN))
|
||||
wavertree_daily = json.dumps(mock_json["wavertree_daily"])
|
||||
requests_mock.get(
|
||||
"https://data.hub.api.metoffice.gov.uk/sitespecific/v0/point/daily",
|
||||
@ -146,7 +146,7 @@ async def test_reauth_flow(
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test handling authentication errors and reauth flow."""
|
||||
mock_json = json.loads(load_fixture("metoffice.json", "metoffice"))
|
||||
mock_json = json.loads(await async_load_fixture(hass, "metoffice.json", DOMAIN))
|
||||
wavertree_daily = json.dumps(mock_json["wavertree_daily"])
|
||||
wavertree_hourly = json.dumps(mock_json["wavertree_hourly"])
|
||||
requests_mock.get(
|
||||
|
@ -13,7 +13,7 @@ from homeassistant.util import utcnow
|
||||
|
||||
from .const import METOFFICE_CONFIG_WAVERTREE
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, load_fixture
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, async_load_fixture
|
||||
|
||||
|
||||
@pytest.mark.freeze_time(datetime.datetime(2024, 11, 23, 12, tzinfo=datetime.UTC))
|
||||
@ -23,7 +23,7 @@ async def test_reauth_on_auth_error(
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test handling authentication errors and reauth flow."""
|
||||
mock_json = json.loads(load_fixture("metoffice.json", "metoffice"))
|
||||
mock_json = json.loads(await async_load_fixture(hass, "metoffice.json", DOMAIN))
|
||||
wavertree_daily = json.dumps(mock_json["wavertree_daily"])
|
||||
wavertree_hourly = json.dumps(mock_json["wavertree_hourly"])
|
||||
requests_mock.get(
|
||||
|
@ -24,7 +24,7 @@ from .const import (
|
||||
WAVERTREE_SENSOR_RESULTS,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry, get_sensor_display_state, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture, get_sensor_display_state
|
||||
|
||||
|
||||
@pytest.mark.freeze_time(datetime.datetime(2024, 11, 23, 12, tzinfo=datetime.UTC))
|
||||
@ -36,7 +36,7 @@ async def test_one_sensor_site_running(
|
||||
) -> None:
|
||||
"""Test the Met Office sensor platform."""
|
||||
# all metoffice test data encapsulated in here
|
||||
mock_json = json.loads(load_fixture("metoffice.json", "metoffice"))
|
||||
mock_json = json.loads(await async_load_fixture(hass, "metoffice.json", DOMAIN))
|
||||
wavertree_hourly = json.dumps(mock_json["wavertree_hourly"])
|
||||
wavertree_daily = json.dumps(mock_json["wavertree_daily"])
|
||||
|
||||
@ -87,7 +87,7 @@ async def test_two_sensor_sites_running(
|
||||
"""Test we handle two sets of sensors running for two different sites."""
|
||||
|
||||
# all metoffice test data encapsulated in here
|
||||
mock_json = json.loads(load_fixture("metoffice.json", "metoffice"))
|
||||
mock_json = json.loads(await async_load_fixture(hass, "metoffice.json", DOMAIN))
|
||||
wavertree_hourly = json.dumps(mock_json["wavertree_hourly"])
|
||||
wavertree_daily = json.dumps(mock_json["wavertree_daily"])
|
||||
kingslynn_hourly = json.dumps(mock_json["kingslynn_hourly"])
|
||||
@ -180,7 +180,7 @@ async def test_legacy_entities_are_removed(
|
||||
old_unique_id: str,
|
||||
) -> None:
|
||||
"""Test the expected entities are deleted."""
|
||||
mock_json = json.loads(load_fixture("metoffice.json", "metoffice"))
|
||||
mock_json = json.loads(await async_load_fixture(hass, "metoffice.json", DOMAIN))
|
||||
wavertree_hourly = json.dumps(mock_json["wavertree_hourly"])
|
||||
wavertree_daily = json.dumps(mock_json["wavertree_daily"])
|
||||
|
||||
|
@ -29,7 +29,7 @@ from .const import (
|
||||
WAVERTREE_SENSOR_RESULTS,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, load_fixture
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, async_load_fixture
|
||||
from tests.typing import WebSocketGenerator
|
||||
|
||||
|
||||
@ -43,10 +43,12 @@ def no_sensor():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def wavertree_data(requests_mock: requests_mock.Mocker) -> dict[str, _Matcher]:
|
||||
async def wavertree_data(
|
||||
hass: HomeAssistant, requests_mock: requests_mock.Mocker
|
||||
) -> dict[str, _Matcher]:
|
||||
"""Mock data for the Wavertree location."""
|
||||
# all metoffice test data encapsulated in here
|
||||
mock_json = json.loads(load_fixture("metoffice.json", "metoffice"))
|
||||
mock_json = json.loads(await async_load_fixture(hass, "metoffice.json", DOMAIN))
|
||||
wavertree_hourly = json.dumps(mock_json["wavertree_hourly"])
|
||||
wavertree_daily = json.dumps(mock_json["wavertree_daily"])
|
||||
|
||||
@ -194,7 +196,7 @@ async def test_two_weather_sites_running(
|
||||
"""Test we handle two different weather sites both running."""
|
||||
|
||||
# all metoffice test data encapsulated in here
|
||||
mock_json = json.loads(load_fixture("metoffice.json", "metoffice"))
|
||||
mock_json = json.loads(await async_load_fixture(hass, "metoffice.json", DOMAIN))
|
||||
kingslynn_hourly = json.dumps(mock_json["kingslynn_hourly"])
|
||||
kingslynn_daily = json.dumps(mock_json["kingslynn_daily"])
|
||||
|
||||
|
@ -21,7 +21,7 @@ from homeassistant.const import ATTR_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import assert_setup_component, load_fixture
|
||||
from tests.common import assert_setup_component, async_load_fixture
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
|
||||
@ -136,15 +136,15 @@ async def test_setup_component_test_entities(
|
||||
"""Set up component."""
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups"),
|
||||
text=load_fixture("persongroups.json", "microsoft_face"),
|
||||
text=await async_load_fixture(hass, "persongroups.json", DOMAIN),
|
||||
)
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups/test_group1/persons"),
|
||||
text=load_fixture("persons.json", "microsoft_face"),
|
||||
text=await async_load_fixture(hass, "persons.json", DOMAIN),
|
||||
)
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups/test_group2/persons"),
|
||||
text=load_fixture("persons.json", "microsoft_face"),
|
||||
text=await async_load_fixture(hass, "persons.json", DOMAIN),
|
||||
)
|
||||
|
||||
with assert_setup_component(3, mf.DOMAIN):
|
||||
@ -204,15 +204,15 @@ async def test_service_person(
|
||||
"""Set up component, test person services."""
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups"),
|
||||
text=load_fixture("persongroups.json", "microsoft_face"),
|
||||
text=await async_load_fixture(hass, "persongroups.json", DOMAIN),
|
||||
)
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups/test_group1/persons"),
|
||||
text=load_fixture("persons.json", "microsoft_face"),
|
||||
text=await async_load_fixture(hass, "persons.json", DOMAIN),
|
||||
)
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups/test_group2/persons"),
|
||||
text=load_fixture("persons.json", "microsoft_face"),
|
||||
text=await async_load_fixture(hass, "persons.json", DOMAIN),
|
||||
)
|
||||
|
||||
with assert_setup_component(3, mf.DOMAIN):
|
||||
@ -222,7 +222,7 @@ async def test_service_person(
|
||||
|
||||
aioclient_mock.post(
|
||||
ENDPOINT_URL.format("persongroups/test_group1/persons"),
|
||||
text=load_fixture("create_person.json", "microsoft_face"),
|
||||
text=await async_load_fixture(hass, "create_person.json", DOMAIN),
|
||||
)
|
||||
aioclient_mock.delete(
|
||||
ENDPOINT_URL.format(
|
||||
@ -276,15 +276,15 @@ async def test_service_face(
|
||||
"""Set up component, test person face services."""
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups"),
|
||||
text=load_fixture("persongroups.json", "microsoft_face"),
|
||||
text=await async_load_fixture(hass, "persongroups.json", DOMAIN),
|
||||
)
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups/test_group1/persons"),
|
||||
text=load_fixture("persons.json", "microsoft_face"),
|
||||
text=await async_load_fixture(hass, "persons.json", DOMAIN),
|
||||
)
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups/test_group2/persons"),
|
||||
text=load_fixture("persons.json", "microsoft_face"),
|
||||
text=await async_load_fixture(hass, "persons.json", DOMAIN),
|
||||
)
|
||||
|
||||
CONFIG["camera"] = {"platform": "demo"}
|
||||
|
@ -10,7 +10,7 @@ from homeassistant.const import ATTR_ENTITY_PICTURE
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import assert_setup_component, load_fixture
|
||||
from tests.common import assert_setup_component, async_load_fixture
|
||||
from tests.components.image_processing import common
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
@ -97,15 +97,17 @@ async def test_ms_detect_process_image(
|
||||
"""Set up and scan a picture and test plates from event."""
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups"),
|
||||
text=load_fixture("persongroups.json", "microsoft_face_detect"),
|
||||
text=await async_load_fixture(
|
||||
hass, "persongroups.json", "microsoft_face_detect"
|
||||
),
|
||||
)
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups/test_group1/persons"),
|
||||
text=load_fixture("persons.json", "microsoft_face_detect"),
|
||||
text=await async_load_fixture(hass, "persons.json", "microsoft_face_detect"),
|
||||
)
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups/test_group2/persons"),
|
||||
text=load_fixture("persons.json", "microsoft_face_detect"),
|
||||
text=await async_load_fixture(hass, "persons.json", "microsoft_face_detect"),
|
||||
)
|
||||
|
||||
await async_setup_component(hass, IP_DOMAIN, CONFIG)
|
||||
@ -127,7 +129,7 @@ async def test_ms_detect_process_image(
|
||||
|
||||
aioclient_mock.post(
|
||||
ENDPOINT_URL.format("detect"),
|
||||
text=load_fixture("detect.json", "microsoft_face_detect"),
|
||||
text=await async_load_fixture(hass, "detect.json", "microsoft_face_detect"),
|
||||
params={"returnFaceAttributes": "age,gender"},
|
||||
)
|
||||
|
||||
|
@ -10,7 +10,7 @@ from homeassistant.const import ATTR_ENTITY_PICTURE, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import assert_setup_component, load_fixture
|
||||
from tests.common import assert_setup_component, async_load_fixture
|
||||
from tests.components.image_processing import common
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
@ -99,15 +99,17 @@ async def test_ms_identify_process_image(
|
||||
"""Set up and scan a picture and test plates from event."""
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups"),
|
||||
text=load_fixture("persongroups.json", "microsoft_face_identify"),
|
||||
text=await async_load_fixture(
|
||||
hass, "persongroups.json", "microsoft_face_identify"
|
||||
),
|
||||
)
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups/test_group1/persons"),
|
||||
text=load_fixture("persons.json", "microsoft_face_identify"),
|
||||
text=await async_load_fixture(hass, "persons.json", "microsoft_face_identify"),
|
||||
)
|
||||
aioclient_mock.get(
|
||||
ENDPOINT_URL.format("persongroups/test_group2/persons"),
|
||||
text=load_fixture("persons.json", "microsoft_face_identify"),
|
||||
text=await async_load_fixture(hass, "persons.json", "microsoft_face_identify"),
|
||||
)
|
||||
|
||||
await async_setup_component(hass, IP_DOMAIN, CONFIG)
|
||||
@ -129,11 +131,11 @@ async def test_ms_identify_process_image(
|
||||
|
||||
aioclient_mock.post(
|
||||
ENDPOINT_URL.format("detect"),
|
||||
text=load_fixture("detect.json", "microsoft_face_identify"),
|
||||
text=await async_load_fixture(hass, "detect.json", "microsoft_face_identify"),
|
||||
)
|
||||
aioclient_mock.post(
|
||||
ENDPOINT_URL.format("identify"),
|
||||
text=load_fixture("identify.json", "microsoft_face_identify"),
|
||||
text=await async_load_fixture(hass, "identify.json", "microsoft_face_identify"),
|
||||
)
|
||||
|
||||
common.async_scan(hass, entity_id="image_processing.test_local")
|
||||
|
@ -15,7 +15,7 @@ from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from . import init_integration
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ async def test_full_user_flow_implementation(
|
||||
"""Test the full manual user flow from start to finish."""
|
||||
aioclient_mock.post(
|
||||
"http://192.168.1.123:80/mf",
|
||||
text=load_fixture("modern_forms/device_info.json"),
|
||||
text=await async_load_fixture(hass, "device_info.json", DOMAIN),
|
||||
headers={"Content-Type": CONTENT_TYPE_JSON},
|
||||
)
|
||||
|
||||
@ -59,7 +59,7 @@ async def test_full_zeroconf_flow_implementation(
|
||||
"""Test the full manual user flow from start to finish."""
|
||||
aioclient_mock.post(
|
||||
"http://192.168.1.123:80/mf",
|
||||
text=load_fixture("modern_forms/device_info.json"),
|
||||
text=await async_load_fixture(hass, "device_info.json", DOMAIN),
|
||||
headers={"Content-Type": CONTENT_TYPE_JSON},
|
||||
)
|
||||
|
||||
@ -191,7 +191,7 @@ async def test_user_device_exists_abort(
|
||||
"""Test we abort zeroconf flow if Modern Forms device already configured."""
|
||||
aioclient_mock.post(
|
||||
"http://192.168.1.123:80/mf",
|
||||
text=load_fixture("modern_forms/device_info.json"),
|
||||
text=await async_load_fixture(hass, "device_info.json", DOMAIN),
|
||||
headers={"Content-Type": CONTENT_TYPE_JSON},
|
||||
)
|
||||
|
||||
|
@ -20,7 +20,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
SERVER_INFO = {
|
||||
"server_id": "1234",
|
||||
@ -186,7 +186,7 @@ async def test_flow_user_server_version_invalid(
|
||||
|
||||
mock_get_server_info.side_effect = None
|
||||
mock_get_server_info.return_value = ServerInfoMessage.from_json(
|
||||
load_fixture("server_info_message.json", DOMAIN)
|
||||
await async_load_fixture(hass, "server_info_message.json", DOMAIN)
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
@ -16,7 +16,7 @@ from homeassistant.components.netatmo import DATA_CAMERAS, DATA_EVENTS, DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
|
||||
|
||||
async def test_async_browse_media(hass: HomeAssistant) -> None:
|
||||
@ -26,7 +26,7 @@ async def test_async_browse_media(hass: HomeAssistant) -> None:
|
||||
# Prepare cached Netatmo event date
|
||||
hass.data[DOMAIN] = {}
|
||||
hass.data[DOMAIN][DATA_EVENTS] = ast.literal_eval(
|
||||
load_fixture("netatmo/events.txt")
|
||||
await async_load_fixture(hass, "events.txt", DOMAIN)
|
||||
)
|
||||
|
||||
hass.data[DOMAIN][DATA_CAMERAS] = {
|
||||
|
@ -24,7 +24,7 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from . import ENTRY_CONFIG
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ async def test_reconfigure_cleans_up_device(
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test clean up devices due to reconfiguration."""
|
||||
nl_json_file = load_fixture("delivery_period_nl.json", DOMAIN)
|
||||
nl_json_file = await async_load_fixture(hass, "delivery_period_nl.json", DOMAIN)
|
||||
load_nl_json = json.loads(nl_json_file)
|
||||
|
||||
entry = MockConfigEntry(
|
||||
|
@ -5,7 +5,7 @@ from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.nut.const import INTEGRATION_SUPPORTED_COMMANDS
|
||||
from homeassistant.components.nut.const import DOMAIN, INTEGRATION_SUPPORTED_COMMANDS
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
@ -19,7 +19,7 @@ from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@ -82,8 +82,8 @@ async def test_switch_pdu_dynamic_outlets(
|
||||
command = f"outlet.{num!s}.load.off"
|
||||
list_commands_return_value[command] = command
|
||||
|
||||
ups_fixture = f"nut/{model}.json"
|
||||
list_vars = json.loads(load_fixture(ups_fixture))
|
||||
ups_fixture = f"{model}.json"
|
||||
list_vars = json.loads(await async_load_fixture(hass, ups_fixture, DOMAIN))
|
||||
|
||||
run_command = AsyncMock()
|
||||
|
||||
|
@ -15,7 +15,7 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
|
||||
def _get_mock_nutclient(
|
||||
@ -59,9 +59,9 @@ async def async_init_integration(
|
||||
list_ups = {"ups1": "UPS 1"}
|
||||
|
||||
if ups_fixture is not None:
|
||||
ups_fixture = f"nut/{ups_fixture}.json"
|
||||
ups_fixture = f"{ups_fixture}.json"
|
||||
if list_vars is None:
|
||||
list_vars = json.loads(load_fixture(ups_fixture))
|
||||
list_vars = json.loads(await async_load_fixture(hass, ups_fixture, DOMAIN))
|
||||
|
||||
mock_pynut = _get_mock_nutclient(
|
||||
list_ups=list_ups,
|
||||
|
@ -18,7 +18,7 @@ from . import setup_integration
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
async_fire_time_changed,
|
||||
load_fixture,
|
||||
async_load_fixture,
|
||||
snapshot_platform,
|
||||
)
|
||||
|
||||
@ -70,7 +70,7 @@ async def test_new_account(
|
||||
) -> None:
|
||||
"""Test handling an exception during update."""
|
||||
mock_nyt_games_client.get_latest_stats.return_value = WordleStats.from_json(
|
||||
load_fixture("new_account.json", DOMAIN)
|
||||
await async_load_fixture(hass, "new_account.json", DOMAIN)
|
||||
).player.stats
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
|
@ -9,7 +9,11 @@ from homeassistant.components.openalpr_cloud.image_processing import OPENALPR_AP
|
||||
from homeassistant.core import Event, HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import assert_setup_component, async_capture_events, load_fixture
|
||||
from tests.common import (
|
||||
assert_setup_component,
|
||||
async_capture_events,
|
||||
async_load_fixture,
|
||||
)
|
||||
from tests.components.image_processing import common
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
@ -136,7 +140,7 @@ async def test_openalpr_process_image(
|
||||
aioclient_mock.post(
|
||||
OPENALPR_API_URL,
|
||||
params=PARAMS,
|
||||
text=load_fixture("alpr_cloud.json", "openalpr_cloud"),
|
||||
text=await async_load_fixture(hass, "alpr_cloud.json", "openalpr_cloud"),
|
||||
status=200,
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import requests_mock
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
|
||||
|
||||
async def test_setup(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -> None:
|
||||
@ -20,7 +20,9 @@ async def test_setup(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -
|
||||
|
||||
requests_mock.get(
|
||||
"http://localhost:8085/data.json",
|
||||
text=load_fixture("openhardwaremonitor.json", "openhardwaremonitor"),
|
||||
text=await async_load_fixture(
|
||||
hass, "openhardwaremonitor.json", "openhardwaremonitor"
|
||||
),
|
||||
)
|
||||
|
||||
await async_setup_component(hass, "sensor", config)
|
||||
|
@ -8,12 +8,13 @@ from renault_api.kamereon import schemas
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
||||
from homeassistant.components.renault.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from tests.common import load_fixture, snapshot_platform
|
||||
from tests.common import async_load_fixture, snapshot_platform
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicles")
|
||||
|
||||
@ -116,7 +117,7 @@ async def test_button_start_charge(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_charge_start",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleHvacStartActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_charge_start.json")
|
||||
await async_load_fixture(hass, "action.set_charge_start.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
) as mock_action:
|
||||
@ -144,7 +145,7 @@ async def test_button_stop_charge(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_charge_stop",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleChargingStartActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_charge_stop.json")
|
||||
await async_load_fixture(hass, "action.set_charge_stop.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
) as mock_action:
|
||||
@ -172,7 +173,7 @@ async def test_button_start_air_conditioner(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_ac_start",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleHvacStartActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_ac_start.json")
|
||||
await async_load_fixture(hass, "action.set_ac_start.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
) as mock_action:
|
||||
|
@ -19,7 +19,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
from tests.common import MockConfigEntry, get_schema_suggested_value, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture, get_schema_suggested_value
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||
|
||||
@ -76,7 +76,7 @@ async def test_config_flow_single_account(
|
||||
type(renault_account).account_id = PropertyMock(return_value="account_id_1")
|
||||
renault_account.get_vehicles.return_value = (
|
||||
schemas.KamereonVehiclesResponseSchema.loads(
|
||||
load_fixture("renault/vehicle_zoe_40.json")
|
||||
await async_load_fixture(hass, "vehicle_zoe_40.json", DOMAIN)
|
||||
)
|
||||
)
|
||||
|
||||
@ -305,7 +305,7 @@ async def test_reconfigure(
|
||||
type(renault_account).account_id = PropertyMock(return_value="account_id_1")
|
||||
renault_account.get_vehicles.return_value = (
|
||||
schemas.KamereonVehiclesResponseSchema.loads(
|
||||
load_fixture("renault/vehicle_zoe_40.json")
|
||||
await async_load_fixture(hass, "vehicle_zoe_40.json", DOMAIN)
|
||||
)
|
||||
)
|
||||
|
||||
@ -360,7 +360,7 @@ async def test_reconfigure_mismatch(
|
||||
type(renault_account).account_id = PropertyMock(return_value="account_id_other")
|
||||
renault_account.get_vehicles.return_value = (
|
||||
schemas.KamereonVehiclesResponseSchema.loads(
|
||||
load_fixture("renault/vehicle_zoe_40.json")
|
||||
await async_load_fixture(hass, "vehicle_zoe_40.json", DOMAIN)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -7,6 +7,7 @@ import pytest
|
||||
from renault_api.kamereon import schemas
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.renault.const import DOMAIN
|
||||
from homeassistant.components.select import (
|
||||
ATTR_OPTION,
|
||||
DOMAIN as SELECT_DOMAIN,
|
||||
@ -19,7 +20,7 @@ from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .const import MOCK_VEHICLES
|
||||
|
||||
from tests.common import load_fixture, snapshot_platform
|
||||
from tests.common import async_load_fixture, snapshot_platform
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicles")
|
||||
|
||||
@ -126,7 +127,7 @@ async def test_select_charge_mode(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_charge_mode",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleHvacStartActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_charge_mode.json")
|
||||
await async_load_fixture(hass, "action.set_charge_mode.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
) as mock_action:
|
||||
|
@ -26,7 +26,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicles")
|
||||
|
||||
@ -67,7 +67,7 @@ async def test_service_set_ac_cancel(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_ac_stop",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleHvacStartActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_ac_stop.json")
|
||||
await async_load_fixture(hass, "action.set_ac_stop.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
) as mock_action:
|
||||
@ -95,7 +95,7 @@ async def test_service_set_ac_start_simple(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_ac_start",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleHvacStartActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_ac_start.json")
|
||||
await async_load_fixture(hass, "action.set_ac_start.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
) as mock_action:
|
||||
@ -125,7 +125,7 @@ async def test_service_set_ac_start_with_date(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_ac_start",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleHvacStartActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_ac_start.json")
|
||||
await async_load_fixture(hass, "action.set_ac_start.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
) as mock_action:
|
||||
@ -154,14 +154,16 @@ async def test_service_set_charge_schedule(
|
||||
patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.http_get",
|
||||
return_value=schemas.KamereonResponseSchema.loads(
|
||||
load_fixture("renault/charging_settings.json")
|
||||
await async_load_fixture(hass, "charging_settings.json", DOMAIN)
|
||||
),
|
||||
),
|
||||
patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_charge_schedules",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleHvacStartActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_charge_schedules.json")
|
||||
await async_load_fixture(
|
||||
hass, "action.set_charge_schedules.json", DOMAIN
|
||||
)
|
||||
)
|
||||
),
|
||||
) as mock_action,
|
||||
@ -204,14 +206,16 @@ async def test_service_set_charge_schedule_multi(
|
||||
patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.http_get",
|
||||
return_value=schemas.KamereonResponseSchema.loads(
|
||||
load_fixture("renault/charging_settings.json")
|
||||
await async_load_fixture(hass, "charging_settings.json", DOMAIN)
|
||||
),
|
||||
),
|
||||
patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_charge_schedules",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleHvacStartActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_charge_schedules.json")
|
||||
await async_load_fixture(
|
||||
hass, "action.set_charge_schedules.json", DOMAIN
|
||||
)
|
||||
)
|
||||
),
|
||||
) as mock_action,
|
||||
@ -250,14 +254,16 @@ async def test_service_set_ac_schedule(
|
||||
patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.get_hvac_settings",
|
||||
return_value=schemas.KamereonVehicleDataResponseSchema.loads(
|
||||
load_fixture("renault/hvac_settings.json")
|
||||
await async_load_fixture(hass, "hvac_settings.json", DOMAIN)
|
||||
).get_attributes(schemas.KamereonVehicleHvacSettingsDataSchema),
|
||||
),
|
||||
patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_hvac_schedules",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleHvacScheduleActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_ac_schedules.json")
|
||||
await async_load_fixture(
|
||||
hass, "action.set_ac_schedules.json", DOMAIN
|
||||
)
|
||||
)
|
||||
),
|
||||
) as mock_action,
|
||||
@ -299,14 +305,16 @@ async def test_service_set_ac_schedule_multi(
|
||||
patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.get_hvac_settings",
|
||||
return_value=schemas.KamereonVehicleDataResponseSchema.loads(
|
||||
load_fixture("renault/hvac_settings.json")
|
||||
await async_load_fixture(hass, "hvac_settings.json", DOMAIN)
|
||||
).get_attributes(schemas.KamereonVehicleHvacSettingsDataSchema),
|
||||
),
|
||||
patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.set_hvac_schedules",
|
||||
return_value=(
|
||||
schemas.KamereonVehicleHvacScheduleActionDataSchema.loads(
|
||||
load_fixture("renault/action.set_ac_schedules.json")
|
||||
await async_load_fixture(
|
||||
hass, "action.set_ac_schedules.json", DOMAIN
|
||||
)
|
||||
)
|
||||
),
|
||||
) as mock_action,
|
||||
|
@ -11,7 +11,7 @@ from homeassistant.components.roku.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
|
||||
def app_icon_url(*args, **kwargs):
|
||||
@ -40,6 +40,7 @@ def mock_setup_entry() -> Generator[None]:
|
||||
|
||||
@pytest.fixture
|
||||
async def mock_device(
|
||||
hass: HomeAssistant,
|
||||
request: pytest.FixtureRequest,
|
||||
) -> RokuDevice:
|
||||
"""Return the mocked roku device."""
|
||||
@ -47,7 +48,7 @@ async def mock_device(
|
||||
if hasattr(request, "param") and request.param:
|
||||
fixture = request.param
|
||||
|
||||
return RokuDevice(json.loads(load_fixture(fixture)))
|
||||
return RokuDevice(json.loads(await async_load_fixture(hass, fixture)))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||
|
||||
@ -46,7 +46,7 @@ async def test_config_flow_skip_auth(
|
||||
with patch(
|
||||
"homeassistant.components.sfr_box.config_flow.SFRBox.system_get_info",
|
||||
return_value=SystemInfo(
|
||||
**json.loads(load_fixture("system_getInfo.json", DOMAIN))
|
||||
**json.loads(await async_load_fixture(hass, "system_getInfo.json", DOMAIN))
|
||||
),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -84,7 +84,7 @@ async def test_config_flow_with_auth(
|
||||
with patch(
|
||||
"homeassistant.components.sfr_box.config_flow.SFRBox.system_get_info",
|
||||
return_value=SystemInfo(
|
||||
**json.loads(load_fixture("system_getInfo.json", DOMAIN))
|
||||
**json.loads(await async_load_fixture(hass, "system_getInfo.json", DOMAIN))
|
||||
),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -150,7 +150,9 @@ async def test_config_flow_duplicate_host(
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
system_info = SystemInfo(**json.loads(load_fixture("system_getInfo.json", DOMAIN)))
|
||||
system_info = SystemInfo(
|
||||
**json.loads(await async_load_fixture(hass, "system_getInfo.json", DOMAIN))
|
||||
)
|
||||
# Ensure mac doesn't match existing mock entry
|
||||
system_info.mac_addr = "aa:bb:cc:dd:ee:ff"
|
||||
with patch(
|
||||
@ -184,7 +186,9 @@ async def test_config_flow_duplicate_mac(
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
system_info = SystemInfo(**json.loads(load_fixture("system_getInfo.json", DOMAIN)))
|
||||
system_info = SystemInfo(
|
||||
**json.loads(await async_load_fixture(hass, "system_getInfo.json", DOMAIN))
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.sfr_box.config_flow.SFRBox.system_get_info",
|
||||
return_value=system_info,
|
||||
|
@ -38,7 +38,7 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from . import setup_integration, trigger_update
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
|
||||
async def test_devices(
|
||||
@ -140,7 +140,9 @@ async def test_create_subscription(
|
||||
devices.subscribe.assert_called_once_with(
|
||||
"397678e5-9995-4a39-9d9f-ae6ba310236c",
|
||||
"5aaaa925-2be1-4e40-b257-e4ef59083324",
|
||||
Subscription.from_json(load_fixture("subscription.json", DOMAIN)),
|
||||
Subscription.from_json(
|
||||
await async_load_fixture(hass, "subscription.json", DOMAIN)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@ -371,11 +373,11 @@ async def test_hub_via_device(
|
||||
) -> None:
|
||||
"""Test hub with child devices."""
|
||||
mock_smartthings.get_devices.return_value = DeviceResponse.from_json(
|
||||
load_fixture("devices/hub.json", DOMAIN)
|
||||
await async_load_fixture(hass, "devices/hub.json", DOMAIN)
|
||||
).items
|
||||
mock_smartthings.get_device_status.side_effect = [
|
||||
DeviceStatus.from_json(
|
||||
load_fixture(f"device_status/{fixture}.json", DOMAIN)
|
||||
await async_load_fixture(hass, f"device_status/{fixture}.json", DOMAIN)
|
||||
).components
|
||||
for fixture in ("hub", "multipurpose_sensor")
|
||||
]
|
||||
|
@ -9,7 +9,7 @@ from homeassistant.core import HomeAssistant
|
||||
|
||||
from .conftest import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
@ -22,7 +22,9 @@ async def test_entry_diagnostics(
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
mock_smlight_client.get.return_value = load_fixture("logs.txt", DOMAIN)
|
||||
mock_smlight_client.get.return_value = await async_load_fixture(
|
||||
hass, "logs.txt", DOMAIN
|
||||
)
|
||||
entry = await setup_integration(hass, mock_config_entry)
|
||||
|
||||
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)
|
||||
|
@ -56,7 +56,7 @@ from . import setup_integration
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
async_fire_time_changed,
|
||||
load_fixture,
|
||||
async_load_fixture,
|
||||
snapshot_platform,
|
||||
)
|
||||
|
||||
@ -95,7 +95,7 @@ async def test_podcast(
|
||||
"""Test the Spotify entities while listening a podcast."""
|
||||
freezer.move_to("2023-10-21")
|
||||
mock_spotify.return_value.get_playback.return_value = PlaybackState.from_json(
|
||||
load_fixture("playback_episode.json", DOMAIN)
|
||||
await async_load_fixture(hass, "playback_episode.json", DOMAIN)
|
||||
)
|
||||
with (
|
||||
patch("secrets.token_hex", return_value="mock-token"),
|
||||
@ -599,7 +599,9 @@ async def test_fallback_show_image(
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test the Spotify media player with a fallback image."""
|
||||
playback = PlaybackState.from_json(load_fixture("playback_episode.json", DOMAIN))
|
||||
playback = PlaybackState.from_json(
|
||||
await async_load_fixture(hass, "playback_episode.json", DOMAIN)
|
||||
)
|
||||
playback.item.images = []
|
||||
mock_spotify.return_value.get_playback.return_value = playback
|
||||
with patch("secrets.token_hex", return_value="mock-token"):
|
||||
@ -619,7 +621,9 @@ async def test_no_episode_images(
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test the Spotify media player with no episode images."""
|
||||
playback = PlaybackState.from_json(load_fixture("playback_episode.json", DOMAIN))
|
||||
playback = PlaybackState.from_json(
|
||||
await async_load_fixture(hass, "playback_episode.json", DOMAIN)
|
||||
)
|
||||
playback.item.images = []
|
||||
playback.item.show.images = []
|
||||
mock_spotify.return_value.get_playback.return_value = playback
|
||||
|
@ -18,7 +18,7 @@ from .conftest import (
|
||||
advance_time_to_next_fetch,
|
||||
)
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
from tests.components.diagnostics import (
|
||||
get_diagnostics_for_config_entry,
|
||||
get_diagnostics_for_device,
|
||||
@ -58,7 +58,7 @@ async def test_device_diagnostics(
|
||||
)
|
||||
assert reg_device is not None
|
||||
|
||||
raw_data = json.loads(load_fixture("subaru/raw_api_data.json"))
|
||||
raw_data = json.loads(await async_load_fixture(hass, "raw_api_data.json", DOMAIN))
|
||||
with patch(MOCK_API_GET_RAW_DATA, return_value=raw_data) as mock_get_raw_data:
|
||||
assert (
|
||||
await get_diagnostics_for_device(
|
||||
|
@ -25,7 +25,7 @@ from . import setup_integration
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
async_fire_time_changed,
|
||||
load_fixture,
|
||||
async_load_fixture,
|
||||
snapshot_platform,
|
||||
)
|
||||
from tests.test_config_entries import FrozenDateTimeFactory
|
||||
@ -94,7 +94,7 @@ async def test_fetching_data(
|
||||
|
||||
# Set new data and verify it
|
||||
mock_opendata_client.connections = json.loads(
|
||||
load_fixture("connections.json", DOMAIN)
|
||||
await async_load_fixture(hass, "connections.json", DOMAIN)
|
||||
)[3:6]
|
||||
freezer.tick(DEFAULT_UPDATE_TIME)
|
||||
async_fire_time_changed(hass)
|
||||
@ -114,7 +114,7 @@ async def test_fetching_data(
|
||||
# Recover and fetch new data again
|
||||
mock_opendata_client.async_get_data.side_effect = None
|
||||
mock_opendata_client.connections = json.loads(
|
||||
load_fixture("connections.json", DOMAIN)
|
||||
await async_load_fixture(hass, "connections.json", DOMAIN)
|
||||
)[6:9]
|
||||
freezer.tick(DEFAULT_UPDATE_TIME)
|
||||
async_fire_time_changed(hass)
|
||||
|
@ -27,7 +27,7 @@ from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||
|
||||
from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -68,9 +68,9 @@ async def test_service_call_fetch_connections_success(
|
||||
"homeassistant.components.swiss_public_transport.OpendataTransport",
|
||||
return_value=AsyncMock(),
|
||||
) as mock:
|
||||
mock().connections = json.loads(load_fixture("connections.json", DOMAIN))[
|
||||
0 : data.get(ATTR_LIMIT, CONNECTIONS_COUNT) + 2
|
||||
]
|
||||
mock().connections = json.loads(
|
||||
await async_load_fixture(hass, "connections.json", DOMAIN)
|
||||
)[0 : data.get(ATTR_LIMIT, CONNECTIONS_COUNT) + 2]
|
||||
|
||||
await setup_integration(hass, config_entry)
|
||||
|
||||
@ -136,7 +136,9 @@ async def test_service_call_fetch_connections_error(
|
||||
"homeassistant.components.swiss_public_transport.OpendataTransport",
|
||||
return_value=AsyncMock(),
|
||||
) as mock:
|
||||
mock().connections = json.loads(load_fixture("connections.json", DOMAIN))
|
||||
mock().connections = json.loads(
|
||||
await async_load_fixture(hass, "connections.json", DOMAIN)
|
||||
)
|
||||
|
||||
await setup_integration(hass, config_entry)
|
||||
|
||||
@ -176,7 +178,9 @@ async def test_service_call_load_unload(
|
||||
"homeassistant.components.swiss_public_transport.OpendataTransport",
|
||||
return_value=AsyncMock(),
|
||||
) as mock:
|
||||
mock().connections = json.loads(load_fixture("connections.json", DOMAIN))
|
||||
mock().connections = json.loads(
|
||||
await async_load_fixture(hass, "connections.json", DOMAIN)
|
||||
)
|
||||
|
||||
await setup_integration(hass, config_entry)
|
||||
|
||||
|
@ -14,14 +14,16 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import MOCK_FAILED_TO_LOGIN_MSG, MOCK_INVALID_TOKEN_MGS
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_cucode_in_coordinator_data", [False, True])
|
||||
async def test_form(hass: HomeAssistant, test_cucode_in_coordinator_data) -> None:
|
||||
"""Test we get the form."""
|
||||
|
||||
coordinator_data = json.loads(load_fixture("switchbee.json", "switchbee"))
|
||||
coordinator_data = json.loads(
|
||||
await async_load_fixture(hass, "switchbee.json", DOMAIN)
|
||||
)
|
||||
|
||||
if test_cucode_in_coordinator_data:
|
||||
coordinator_data["data"]["cuCode"] = "300F123456"
|
||||
@ -138,7 +140,9 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
|
||||
async def test_form_entry_exists(hass: HomeAssistant) -> None:
|
||||
"""Test we handle an already existing entry."""
|
||||
|
||||
coordinator_data = json.loads(load_fixture("switchbee.json", "switchbee"))
|
||||
coordinator_data = json.loads(
|
||||
await async_load_fixture(hass, "switchbee.json", DOMAIN)
|
||||
)
|
||||
MockConfigEntry(
|
||||
unique_id="a8:21:08:e7:67:b6",
|
||||
domain=DOMAIN,
|
||||
|
@ -17,7 +17,7 @@ from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
|
||||
async def test_has_services(
|
||||
@ -38,7 +38,7 @@ async def test_add_meter_readings(
|
||||
await async_init_integration(hass)
|
||||
|
||||
config_entry: MockConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
fixture: str = load_fixture("tado/add_readings_success.json")
|
||||
fixture: str = await async_load_fixture(hass, "add_readings_success.json", DOMAIN)
|
||||
with patch(
|
||||
"PyTado.interface.api.Tado.set_eiq_meter_readings",
|
||||
return_value=json.loads(fixture),
|
||||
@ -91,7 +91,9 @@ async def test_add_meter_readings_invalid(
|
||||
await async_init_integration(hass)
|
||||
|
||||
config_entry: MockConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
fixture: str = load_fixture("tado/add_readings_invalid_meter_reading.json")
|
||||
fixture: str = await async_load_fixture(
|
||||
hass, "add_readings_invalid_meter_reading.json", DOMAIN
|
||||
)
|
||||
with (
|
||||
patch(
|
||||
"PyTado.interface.api.Tado.set_eiq_meter_readings",
|
||||
@ -120,7 +122,9 @@ async def test_add_meter_readings_duplicate(
|
||||
await async_init_integration(hass)
|
||||
|
||||
config_entry: MockConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
fixture: str = load_fixture("tado/add_readings_duplicated_meter_reading.json")
|
||||
fixture: str = await async_load_fixture(
|
||||
hass, "add_readings_duplicated_meter_reading.json", DOMAIN
|
||||
)
|
||||
with (
|
||||
patch(
|
||||
"PyTado.interface.api.Tado.set_eiq_meter_readings",
|
||||
|
@ -5,7 +5,7 @@ import requests_mock
|
||||
from homeassistant.components.tado import CONF_REFRESH_TOKEN, DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
|
||||
async def async_init_integration(
|
||||
@ -14,172 +14,173 @@ async def async_init_integration(
|
||||
):
|
||||
"""Set up the tado integration in Home Assistant."""
|
||||
|
||||
token_fixture = "tado/token.json"
|
||||
devices_fixture = "tado/devices.json"
|
||||
mobile_devices_fixture = "tado/mobile_devices.json"
|
||||
me_fixture = "tado/me.json"
|
||||
weather_fixture = "tado/weather.json"
|
||||
home_fixture = "tado/home.json"
|
||||
home_state_fixture = "tado/home_state.json"
|
||||
zones_fixture = "tado/zones.json"
|
||||
zone_states_fixture = "tado/zone_states.json"
|
||||
token_fixture = "token.json"
|
||||
devices_fixture = "devices.json"
|
||||
mobile_devices_fixture = "mobile_devices.json"
|
||||
me_fixture = "me.json"
|
||||
weather_fixture = "weather.json"
|
||||
home_fixture = "home.json"
|
||||
home_state_fixture = "home_state.json"
|
||||
zones_fixture = "zones.json"
|
||||
zone_states_fixture = "zone_states.json"
|
||||
|
||||
# WR1 Device
|
||||
device_wr1_fixture = "tado/device_wr1.json"
|
||||
device_wr1_fixture = "device_wr1.json"
|
||||
|
||||
# Smart AC with fanLevel, Vertical and Horizontal swings
|
||||
zone_6_state_fixture = "tado/smartac4.with_fanlevel.json"
|
||||
zone_6_capabilities_fixture = (
|
||||
"tado/zone_with_fanlevel_horizontal_vertical_swing.json"
|
||||
)
|
||||
zone_6_state_fixture = "smartac4.with_fanlevel.json"
|
||||
zone_6_capabilities_fixture = "zone_with_fanlevel_horizontal_vertical_swing.json"
|
||||
|
||||
# Smart AC with Swing
|
||||
zone_5_state_fixture = "tado/smartac3.with_swing.json"
|
||||
zone_5_capabilities_fixture = "tado/zone_with_swing_capabilities.json"
|
||||
zone_5_state_fixture = "smartac3.with_swing.json"
|
||||
zone_5_capabilities_fixture = "zone_with_swing_capabilities.json"
|
||||
|
||||
# Water Heater 2
|
||||
zone_4_state_fixture = "tado/tadov2.water_heater.heating.json"
|
||||
zone_4_capabilities_fixture = "tado/water_heater_zone_capabilities.json"
|
||||
zone_4_state_fixture = "tadov2.water_heater.heating.json"
|
||||
zone_4_capabilities_fixture = "water_heater_zone_capabilities.json"
|
||||
|
||||
# Smart AC
|
||||
zone_3_state_fixture = "tado/smartac3.cool_mode.json"
|
||||
zone_3_capabilities_fixture = "tado/zone_capabilities.json"
|
||||
zone_3_state_fixture = "smartac3.cool_mode.json"
|
||||
zone_3_capabilities_fixture = "zone_capabilities.json"
|
||||
|
||||
# Water Heater
|
||||
zone_2_state_fixture = "tado/tadov2.water_heater.auto_mode.json"
|
||||
zone_2_capabilities_fixture = "tado/water_heater_zone_capabilities.json"
|
||||
zone_2_state_fixture = "tadov2.water_heater.auto_mode.json"
|
||||
zone_2_capabilities_fixture = "water_heater_zone_capabilities.json"
|
||||
|
||||
# Tado V2 with manual heating
|
||||
zone_1_state_fixture = "tado/tadov2.heating.manual_mode.json"
|
||||
zone_1_capabilities_fixture = "tado/tadov2.zone_capabilities.json"
|
||||
zone_1_state_fixture = "tadov2.heating.manual_mode.json"
|
||||
zone_1_capabilities_fixture = "tadov2.zone_capabilities.json"
|
||||
|
||||
# Device Temp Offset
|
||||
device_temp_offset = "tado/device_temp_offset.json"
|
||||
device_temp_offset = "device_temp_offset.json"
|
||||
|
||||
# Zone Default Overlay
|
||||
zone_def_overlay = "tado/zone_default_overlay.json"
|
||||
zone_def_overlay = "zone_default_overlay.json"
|
||||
|
||||
with requests_mock.mock() as m:
|
||||
m.post("https://auth.tado.com/oauth/token", text=load_fixture(token_fixture))
|
||||
m.post(
|
||||
"https://auth.tado.com/oauth/token",
|
||||
text=await async_load_fixture(hass, token_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/me",
|
||||
text=load_fixture(me_fixture),
|
||||
text=await async_load_fixture(hass, me_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/",
|
||||
text=load_fixture(home_fixture),
|
||||
text=await async_load_fixture(hass, home_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/weather",
|
||||
text=load_fixture(weather_fixture),
|
||||
text=await async_load_fixture(hass, weather_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/state",
|
||||
text=load_fixture(home_state_fixture),
|
||||
text=await async_load_fixture(hass, home_state_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/devices",
|
||||
text=load_fixture(devices_fixture),
|
||||
text=await async_load_fixture(hass, devices_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/mobileDevices",
|
||||
text=load_fixture(mobile_devices_fixture),
|
||||
text=await async_load_fixture(hass, mobile_devices_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/devices/WR1/",
|
||||
text=load_fixture(device_wr1_fixture),
|
||||
text=await async_load_fixture(hass, device_wr1_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/devices/WR1/temperatureOffset",
|
||||
text=load_fixture(device_temp_offset),
|
||||
text=await async_load_fixture(hass, device_temp_offset, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/devices/WR4/temperatureOffset",
|
||||
text=load_fixture(device_temp_offset),
|
||||
text=await async_load_fixture(hass, device_temp_offset, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones",
|
||||
text=load_fixture(zones_fixture),
|
||||
text=await async_load_fixture(hass, zones_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zoneStates",
|
||||
text=load_fixture(zone_states_fixture),
|
||||
text=await async_load_fixture(hass, zone_states_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/6/capabilities",
|
||||
text=load_fixture(zone_6_capabilities_fixture),
|
||||
text=await async_load_fixture(hass, zone_6_capabilities_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/5/capabilities",
|
||||
text=load_fixture(zone_5_capabilities_fixture),
|
||||
text=await async_load_fixture(hass, zone_5_capabilities_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/4/capabilities",
|
||||
text=load_fixture(zone_4_capabilities_fixture),
|
||||
text=await async_load_fixture(hass, zone_4_capabilities_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/3/capabilities",
|
||||
text=load_fixture(zone_3_capabilities_fixture),
|
||||
text=await async_load_fixture(hass, zone_3_capabilities_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/2/capabilities",
|
||||
text=load_fixture(zone_2_capabilities_fixture),
|
||||
text=await async_load_fixture(hass, zone_2_capabilities_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/1/capabilities",
|
||||
text=load_fixture(zone_1_capabilities_fixture),
|
||||
text=await async_load_fixture(hass, zone_1_capabilities_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/1/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
text=await async_load_fixture(hass, zone_def_overlay, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/2/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
text=await async_load_fixture(hass, zone_def_overlay, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/3/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
text=await async_load_fixture(hass, zone_def_overlay, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/4/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
text=await async_load_fixture(hass, zone_def_overlay, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/5/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
text=await async_load_fixture(hass, zone_def_overlay, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/6/defaultOverlay",
|
||||
text=load_fixture(zone_def_overlay),
|
||||
text=await async_load_fixture(hass, zone_def_overlay, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/6/state",
|
||||
text=load_fixture(zone_6_state_fixture),
|
||||
text=await async_load_fixture(hass, zone_6_state_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/5/state",
|
||||
text=load_fixture(zone_5_state_fixture),
|
||||
text=await async_load_fixture(hass, zone_5_state_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/4/state",
|
||||
text=load_fixture(zone_4_state_fixture),
|
||||
text=await async_load_fixture(hass, zone_4_state_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/3/state",
|
||||
text=load_fixture(zone_3_state_fixture),
|
||||
text=await async_load_fixture(hass, zone_3_state_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/2/state",
|
||||
text=load_fixture(zone_2_state_fixture),
|
||||
text=await async_load_fixture(hass, zone_2_state_fixture, DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
"https://my.tado.com/api/v2/homes/1/zones/1/state",
|
||||
text=load_fixture(zone_1_state_fixture),
|
||||
text=await async_load_fixture(hass, zone_1_state_fixture, DOMAIN),
|
||||
)
|
||||
m.post(
|
||||
"https://login.tado.com/oauth2/token",
|
||||
text=load_fixture(token_fixture),
|
||||
text=await async_load_fixture(hass, token_fixture, DOMAIN),
|
||||
)
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -5,11 +5,12 @@ import json
|
||||
from kasa import Device
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.tplink.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import _mocked_device, initialize_config_entry_for_device
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
@ -40,7 +41,7 @@ async def test_diagnostics(
|
||||
expected_oui: str | None,
|
||||
) -> None:
|
||||
"""Test diagnostics for config entry."""
|
||||
diagnostics_data = json.loads(load_fixture(fixture_file, "tplink"))
|
||||
diagnostics_data = json.loads(await async_load_fixture(hass, fixture_file, DOMAIN))
|
||||
|
||||
mocked_dev.internal_state = diagnostics_data["device_last_response"]
|
||||
|
||||
|
@ -16,7 +16,7 @@ from homeassistant.helpers.typing import UNDEFINED
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.uuid import random_uuid_hex
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
from tests.typing import WebSocketGenerator
|
||||
|
||||
|
||||
@ -449,7 +449,9 @@ async def test_restore_traces(
|
||||
msg_id += 1
|
||||
return msg_id
|
||||
|
||||
saved_traces = json.loads(load_fixture(f"trace/{domain}_saved_traces.json"))
|
||||
saved_traces = json.loads(
|
||||
await async_load_fixture(hass, f"{domain}_saved_traces.json", "trace")
|
||||
)
|
||||
hass_storage["trace.saved_traces"] = saved_traces
|
||||
await _setup_automation_or_script(hass, domain, [])
|
||||
await hass.async_start()
|
||||
@ -628,7 +630,9 @@ async def test_restore_traces_overflow(
|
||||
msg_id += 1
|
||||
return msg_id
|
||||
|
||||
saved_traces = json.loads(load_fixture(f"trace/{domain}_saved_traces.json"))
|
||||
saved_traces = json.loads(
|
||||
await async_load_fixture(hass, f"{domain}_saved_traces.json", "trace")
|
||||
)
|
||||
hass_storage["trace.saved_traces"] = saved_traces
|
||||
sun_config = {
|
||||
"id": "sun",
|
||||
@ -709,7 +713,9 @@ async def test_restore_traces_late_overflow(
|
||||
msg_id += 1
|
||||
return msg_id
|
||||
|
||||
saved_traces = json.loads(load_fixture(f"trace/{domain}_saved_traces.json"))
|
||||
saved_traces = json.loads(
|
||||
await async_load_fixture(hass, f"{domain}_saved_traces.json", "trace")
|
||||
)
|
||||
hass_storage["trace.saved_traces"] = saved_traces
|
||||
sun_config = {
|
||||
"id": "sun",
|
||||
|
@ -22,7 +22,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.dt import now
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
|
||||
BUS_ATCOCODE = "340000368SHE"
|
||||
BUS_DIRECTION = "Wantage"
|
||||
@ -50,7 +50,7 @@ async def test_bus(hass: HomeAssistant) -> None:
|
||||
"""Test for operational uk_transport sensor with proper attributes."""
|
||||
with requests_mock.Mocker() as mock_req:
|
||||
uri = re.compile(UkTransportSensor.TRANSPORT_API_URL_BASE + "*")
|
||||
mock_req.get(uri, text=load_fixture("uk_transport/bus.json"))
|
||||
mock_req.get(uri, text=await async_load_fixture(hass, "uk_transport/bus.json"))
|
||||
assert await async_setup_component(hass, "sensor", VALID_CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@ -75,7 +75,9 @@ async def test_train(hass: HomeAssistant) -> None:
|
||||
patch("homeassistant.util.dt.now", return_value=now().replace(hour=13)),
|
||||
):
|
||||
uri = re.compile(UkTransportSensor.TRANSPORT_API_URL_BASE + "*")
|
||||
mock_req.get(uri, text=load_fixture("uk_transport/train.json"))
|
||||
mock_req.get(
|
||||
uri, text=await async_load_fixture(hass, "uk_transport/train.json")
|
||||
)
|
||||
assert await async_setup_component(hass, "sensor", VALID_CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -3,11 +3,12 @@
|
||||
import requests_mock
|
||||
|
||||
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
|
||||
from homeassistant.components.venstar.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PLATFORM
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
|
||||
TEST_MODELS = ["t2k", "colortouch"]
|
||||
|
||||
@ -23,19 +24,21 @@ def mock_venstar_devices(f):
|
||||
for model in TEST_MODELS:
|
||||
m.get(
|
||||
f"http://venstar-{model}.localdomain/",
|
||||
text=load_fixture(f"venstar/{model}_root.json"),
|
||||
text=await async_load_fixture(hass, f"{model}_root.json", DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
f"http://venstar-{model}.localdomain/query/info",
|
||||
text=load_fixture(f"venstar/{model}_info.json"),
|
||||
text=await async_load_fixture(hass, f"{model}_info.json", DOMAIN),
|
||||
)
|
||||
m.get(
|
||||
f"http://venstar-{model}.localdomain/query/sensors",
|
||||
text=load_fixture(f"venstar/{model}_sensors.json"),
|
||||
text=await async_load_fixture(
|
||||
hass, f"{model}_sensors.json", DOMAIN
|
||||
),
|
||||
)
|
||||
m.get(
|
||||
f"http://venstar-{model}.localdomain/query/alerts",
|
||||
text=load_fixture(f"venstar/{model}_alerts.json"),
|
||||
text=await async_load_fixture(hass, f"{model}_alerts.json", DOMAIN),
|
||||
)
|
||||
await f(hass)
|
||||
|
||||
|
@ -15,13 +15,14 @@ from vulcan import (
|
||||
from vulcan.model import Student
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.vulcan import config_flow, const, register
|
||||
from homeassistant.components.vulcan import config_flow, register
|
||||
from homeassistant.components.vulcan.config_flow import ClientConnectionError, Keystore
|
||||
from homeassistant.components.vulcan.const import DOMAIN
|
||||
from homeassistant.const import CONF_PIN, CONF_REGION, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
fake_keystore = Keystore("", "", "", "", "")
|
||||
fake_account = Account(
|
||||
@ -53,10 +54,10 @@ async def test_config_flow_auth_success(
|
||||
mock_keystore.return_value = fake_keystore
|
||||
mock_account.return_value = fake_account
|
||||
mock_student.return_value = [
|
||||
Student.load(load_fixture("fake_student_1.json", "vulcan"))
|
||||
Student.load(await async_load_fixture(hass, "fake_student_1.json", DOMAIN))
|
||||
]
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -90,12 +91,12 @@ async def test_config_flow_auth_success_with_multiple_students(
|
||||
mock_student.return_value = [
|
||||
Student.load(student)
|
||||
for student in (
|
||||
load_fixture("fake_student_1.json", "vulcan"),
|
||||
load_fixture("fake_student_2.json", "vulcan"),
|
||||
await async_load_fixture(hass, "fake_student_1.json", DOMAIN),
|
||||
await async_load_fixture(hass, "fake_student_2.json", DOMAIN),
|
||||
)
|
||||
]
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -135,10 +136,10 @@ async def test_config_flow_reauth_success(
|
||||
mock_keystore.return_value = fake_keystore
|
||||
mock_account.return_value = fake_account
|
||||
mock_student.return_value = [
|
||||
Student.load(load_fixture("fake_student_1.json", "vulcan"))
|
||||
Student.load(await async_load_fixture(hass, "fake_student_1.json", DOMAIN))
|
||||
]
|
||||
entry = MockConfigEntry(
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="0",
|
||||
data={"student_id": "0"},
|
||||
)
|
||||
@ -173,10 +174,10 @@ async def test_config_flow_reauth_without_matching_entries(
|
||||
mock_keystore.return_value = fake_keystore
|
||||
mock_account.return_value = fake_account
|
||||
mock_student.return_value = [
|
||||
Student.load(load_fixture("fake_student_1.json", "vulcan"))
|
||||
Student.load(await async_load_fixture(hass, "fake_student_1.json", DOMAIN))
|
||||
]
|
||||
entry = MockConfigEntry(
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="0",
|
||||
data={"student_id": "1"},
|
||||
)
|
||||
@ -205,7 +206,7 @@ async def test_config_flow_reauth_with_errors(
|
||||
mock_keystore.return_value = fake_keystore
|
||||
mock_account.return_value = fake_account
|
||||
entry = MockConfigEntry(
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="0",
|
||||
data={"student_id": "0"},
|
||||
)
|
||||
@ -303,16 +304,18 @@ async def test_multiple_config_entries(
|
||||
mock_keystore.return_value = fake_keystore
|
||||
mock_account.return_value = fake_account
|
||||
mock_student.return_value = [
|
||||
Student.load(load_fixture("fake_student_1.json", "vulcan"))
|
||||
Student.load(await async_load_fixture(hass, "fake_student_1.json", DOMAIN))
|
||||
]
|
||||
MockConfigEntry(
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="123456",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan")),
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
),
|
||||
).add_to_hass(hass)
|
||||
await register.register("token", "region", "000000")
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -348,16 +351,18 @@ async def test_multiple_config_entries_using_saved_credentials(
|
||||
) -> None:
|
||||
"""Test a successful config flow for multiple config entries using saved credentials."""
|
||||
mock_student.return_value = [
|
||||
Student.load(load_fixture("fake_student_1.json", "vulcan"))
|
||||
Student.load(await async_load_fixture(hass, "fake_student_1.json", DOMAIN))
|
||||
]
|
||||
MockConfigEntry(
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="123456",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan")),
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
),
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -384,17 +389,19 @@ async def test_multiple_config_entries_using_saved_credentials_2(
|
||||
) -> None:
|
||||
"""Test a successful config flow for multiple config entries using saved credentials (different situation)."""
|
||||
mock_student.return_value = [
|
||||
Student.load(load_fixture("fake_student_1.json", "vulcan")),
|
||||
Student.load(load_fixture("fake_student_2.json", "vulcan")),
|
||||
Student.load(await async_load_fixture(hass, "fake_student_1.json", DOMAIN)),
|
||||
Student.load(await async_load_fixture(hass, "fake_student_2.json", DOMAIN)),
|
||||
]
|
||||
MockConfigEntry(
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="123456",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan")),
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
),
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -430,24 +437,28 @@ async def test_multiple_config_entries_using_saved_credentials_3(
|
||||
) -> None:
|
||||
"""Test a successful config flow for multiple config entries using saved credentials."""
|
||||
mock_student.return_value = [
|
||||
Student.load(load_fixture("fake_student_1.json", "vulcan"))
|
||||
Student.load(await async_load_fixture(hass, "fake_student_1.json", DOMAIN))
|
||||
]
|
||||
MockConfigEntry(
|
||||
entry_id="456",
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="234567",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan"))
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
)
|
||||
| {"student_id": "456"},
|
||||
).add_to_hass(hass)
|
||||
MockConfigEntry(
|
||||
entry_id="123",
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="123456",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan")),
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
),
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -483,25 +494,29 @@ async def test_multiple_config_entries_using_saved_credentials_4(
|
||||
) -> None:
|
||||
"""Test a successful config flow for multiple config entries using saved credentials (different situation)."""
|
||||
mock_student.return_value = [
|
||||
Student.load(load_fixture("fake_student_1.json", "vulcan")),
|
||||
Student.load(load_fixture("fake_student_2.json", "vulcan")),
|
||||
Student.load(await async_load_fixture(hass, "fake_student_1.json", DOMAIN)),
|
||||
Student.load(await async_load_fixture(hass, "fake_student_2.json", DOMAIN)),
|
||||
]
|
||||
MockConfigEntry(
|
||||
entry_id="456",
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="234567",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan"))
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
)
|
||||
| {"student_id": "456"},
|
||||
).add_to_hass(hass)
|
||||
MockConfigEntry(
|
||||
entry_id="123",
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="123456",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan")),
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
),
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -546,20 +561,24 @@ async def test_multiple_config_entries_without_valid_saved_credentials(
|
||||
"""Test a unsuccessful config flow for multiple config entries without valid saved credentials."""
|
||||
MockConfigEntry(
|
||||
entry_id="456",
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="234567",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan"))
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
)
|
||||
| {"student_id": "456"},
|
||||
).add_to_hass(hass)
|
||||
MockConfigEntry(
|
||||
entry_id="123",
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="123456",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan")),
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
),
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -594,20 +613,24 @@ async def test_multiple_config_entries_using_saved_credentials_with_connections_
|
||||
"""Test a unsuccessful config flow for multiple config entries without valid saved credentials."""
|
||||
MockConfigEntry(
|
||||
entry_id="456",
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="234567",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan"))
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
)
|
||||
| {"student_id": "456"},
|
||||
).add_to_hass(hass)
|
||||
MockConfigEntry(
|
||||
entry_id="123",
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="123456",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan")),
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
),
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -642,20 +665,24 @@ async def test_multiple_config_entries_using_saved_credentials_with_unknown_erro
|
||||
"""Test a unsuccessful config flow for multiple config entries without valid saved credentials."""
|
||||
MockConfigEntry(
|
||||
entry_id="456",
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="234567",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan"))
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
)
|
||||
| {"student_id": "456"},
|
||||
).add_to_hass(hass)
|
||||
MockConfigEntry(
|
||||
entry_id="123",
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="123456",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan")),
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
),
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -694,19 +721,21 @@ async def test_student_already_exists(
|
||||
mock_keystore.return_value = fake_keystore
|
||||
mock_account.return_value = fake_account
|
||||
mock_student.return_value = [
|
||||
Student.load(load_fixture("fake_student_1.json", "vulcan"))
|
||||
Student.load(await async_load_fixture(hass, "fake_student_1.json", DOMAIN))
|
||||
]
|
||||
MockConfigEntry(
|
||||
domain=const.DOMAIN,
|
||||
domain=DOMAIN,
|
||||
unique_id="0",
|
||||
data=json.loads(load_fixture("fake_config_entry_data.json", "vulcan"))
|
||||
data=json.loads(
|
||||
await async_load_fixture(hass, "fake_config_entry_data.json", DOMAIN)
|
||||
)
|
||||
| {"student_id": "0"},
|
||||
).add_to_hass(hass)
|
||||
|
||||
await register.register("token", "region", "000000")
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -733,7 +762,7 @@ async def test_config_flow_auth_invalid_token(
|
||||
side_effect=InvalidTokenException,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -761,7 +790,7 @@ async def test_config_flow_auth_invalid_region(
|
||||
side_effect=InvalidSymbolException,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -787,7 +816,7 @@ async def test_config_flow_auth_invalid_pin(mock_keystore, hass: HomeAssistant)
|
||||
side_effect=InvalidPINException,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -815,7 +844,7 @@ async def test_config_flow_auth_expired_token(
|
||||
side_effect=ExpiredTokenException,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -843,7 +872,7 @@ async def test_config_flow_auth_connection_error(
|
||||
side_effect=ClientConnectionError,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -871,7 +900,7 @@ async def test_config_flow_auth_unknown_error(
|
||||
side_effect=Exception,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
@ -20,7 +20,7 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import load_fixture
|
||||
from tests.common import async_load_fixture
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||
|
||||
@ -61,7 +61,9 @@ async def test_full_map_flow(
|
||||
patch(
|
||||
"aiowaqi.WAQIClient.get_by_ip",
|
||||
return_value=WAQIAirQuality.from_dict(
|
||||
json.loads(load_fixture("waqi/air_quality_sensor.json"))
|
||||
json.loads(
|
||||
await async_load_fixture(hass, "air_quality_sensor.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
),
|
||||
):
|
||||
@ -81,13 +83,17 @@ async def test_full_map_flow(
|
||||
patch(
|
||||
"aiowaqi.WAQIClient.get_by_coordinates",
|
||||
return_value=WAQIAirQuality.from_dict(
|
||||
json.loads(load_fixture("waqi/air_quality_sensor.json"))
|
||||
json.loads(
|
||||
await async_load_fixture(hass, "air_quality_sensor.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
),
|
||||
patch(
|
||||
"aiowaqi.WAQIClient.get_by_station_number",
|
||||
return_value=WAQIAirQuality.from_dict(
|
||||
json.loads(load_fixture("waqi/air_quality_sensor.json"))
|
||||
json.loads(
|
||||
await async_load_fixture(hass, "air_quality_sensor.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
),
|
||||
):
|
||||
@ -147,7 +153,9 @@ async def test_flow_errors(
|
||||
patch(
|
||||
"aiowaqi.WAQIClient.get_by_ip",
|
||||
return_value=WAQIAirQuality.from_dict(
|
||||
json.loads(load_fixture("waqi/air_quality_sensor.json"))
|
||||
json.loads(
|
||||
await async_load_fixture(hass, "air_quality_sensor.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
),
|
||||
):
|
||||
@ -167,7 +175,9 @@ async def test_flow_errors(
|
||||
patch(
|
||||
"aiowaqi.WAQIClient.get_by_coordinates",
|
||||
return_value=WAQIAirQuality.from_dict(
|
||||
json.loads(load_fixture("waqi/air_quality_sensor.json"))
|
||||
json.loads(
|
||||
await async_load_fixture(hass, "air_quality_sensor.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
),
|
||||
):
|
||||
@ -240,7 +250,9 @@ async def test_error_in_second_step(
|
||||
patch(
|
||||
"aiowaqi.WAQIClient.get_by_ip",
|
||||
return_value=WAQIAirQuality.from_dict(
|
||||
json.loads(load_fixture("waqi/air_quality_sensor.json"))
|
||||
json.loads(
|
||||
await async_load_fixture(hass, "air_quality_sensor.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
),
|
||||
):
|
||||
@ -276,13 +288,17 @@ async def test_error_in_second_step(
|
||||
patch(
|
||||
"aiowaqi.WAQIClient.get_by_coordinates",
|
||||
return_value=WAQIAirQuality.from_dict(
|
||||
json.loads(load_fixture("waqi/air_quality_sensor.json"))
|
||||
json.loads(
|
||||
await async_load_fixture(hass, "air_quality_sensor.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
),
|
||||
patch(
|
||||
"aiowaqi.WAQIClient.get_by_station_number",
|
||||
return_value=WAQIAirQuality.from_dict(
|
||||
json.loads(load_fixture("waqi/air_quality_sensor.json"))
|
||||
json.loads(
|
||||
await async_load_fixture(hass, "air_quality_sensor.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
),
|
||||
):
|
||||
|
@ -15,7 +15,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, async_load_fixture
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
@ -30,7 +30,9 @@ async def test_sensor(
|
||||
with patch(
|
||||
"aiowaqi.WAQIClient.get_by_station_number",
|
||||
return_value=WAQIAirQuality.from_dict(
|
||||
json.loads(load_fixture("waqi/air_quality_sensor.json"))
|
||||
json.loads(
|
||||
await async_load_fixture(hass, "air_quality_sensor.json", DOMAIN)
|
||||
)
|
||||
),
|
||||
):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
@ -17,7 +17,7 @@ from . import setup_integration
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
async_fire_time_changed,
|
||||
load_fixture,
|
||||
async_load_fixture,
|
||||
snapshot_platform,
|
||||
)
|
||||
|
||||
@ -48,7 +48,7 @@ async def test_all_entities_with_lightning_error(
|
||||
"""Test all entities."""
|
||||
|
||||
get_observation_response_data = ObservationStationREST.from_json(
|
||||
load_fixture("station_observation_error.json", DOMAIN)
|
||||
await async_load_fixture(hass, "station_observation_error.json", DOMAIN)
|
||||
)
|
||||
|
||||
with patch(
|
||||
|
Loading…
x
Reference in New Issue
Block a user