mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 01:46:11 -04:00
Use JSON fixture helpers in tests (#180832)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"""Tests for the Dexcom integration."""
|
||||
|
||||
import json
|
||||
from typing import Any
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -10,7 +9,7 @@ from homeassistant.components.dexcom.const import CONF_SERVER, DOMAIN, SERVER_US
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, load_json_object_fixture
|
||||
|
||||
CONFIG = {
|
||||
CONF_USERNAME: "test_username",
|
||||
@@ -18,7 +17,7 @@ CONFIG = {
|
||||
CONF_SERVER: SERVER_US,
|
||||
}
|
||||
|
||||
GLUCOSE_READING = GlucoseReading(json.loads(load_fixture("data.json", "dexcom")))
|
||||
GLUCOSE_READING = GlucoseReading(load_json_object_fixture("data.json", "dexcom"))
|
||||
TEST_ACCOUNT_ID = "99999999-9999-9999-9999-999999999999"
|
||||
TEST_SESSION_ID = "55555555-5555-5555-5555-555555555555"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Common fixtures for the Monarch Money tests."""
|
||||
|
||||
from collections.abc import Generator
|
||||
import json
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock, PropertyMock, patch
|
||||
|
||||
@@ -15,7 +14,7 @@ from typedmonarchmoney.models import (
|
||||
from homeassistant.components.monarch_money.const import DOMAIN
|
||||
from homeassistant.const import CONF_TOKEN
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture, load_json_object_fixture
|
||||
from tests.common import MockConfigEntry, load_json_object_fixture
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -48,12 +47,12 @@ def mock_config_api() -> Generator[AsyncMock]:
|
||||
acc["id"]: MonarchAccount(acc) for acc in account_json["accounts"]
|
||||
}
|
||||
|
||||
cashflow_json: dict[str, Any] = json.loads(
|
||||
load_fixture("get_cashflow_summary.json", DOMAIN)
|
||||
cashflow_json: dict[str, Any] = load_json_object_fixture(
|
||||
"get_cashflow_summary.json", DOMAIN
|
||||
)
|
||||
cashflow_summary = MonarchCashflowSummary(cashflow_json)
|
||||
subscription_details = MonarchSubscription(
|
||||
json.loads(load_fixture("get_subscription_details.json", DOMAIN))
|
||||
load_json_object_fixture("get_subscription_details.json", DOMAIN)
|
||||
)
|
||||
|
||||
with (
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"""Tests for the diagnostics data provided by the TP-Link integration."""
|
||||
|
||||
import json
|
||||
|
||||
from kasa import Device
|
||||
import pytest
|
||||
|
||||
@@ -10,7 +8,7 @@ from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import _mocked_device, initialize_config_entry_for_device
|
||||
|
||||
from tests.common import async_load_fixture
|
||||
from tests.common import async_load_json_object_fixture
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
@@ -41,7 +39,7 @@ async def test_diagnostics(
|
||||
expected_oui: str | None,
|
||||
) -> None:
|
||||
"""Test diagnostics for config entry."""
|
||||
diagnostics_data = json.loads(await async_load_fixture(hass, fixture_file, DOMAIN))
|
||||
diagnostics_data = await async_load_json_object_fixture(hass, fixture_file, DOMAIN)
|
||||
|
||||
mocked_dev.internal_state = diagnostics_data["device_last_response"]
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""Tests for the yandex transport platform."""
|
||||
|
||||
import json
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
@@ -12,11 +11,11 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from tests.common import assert_setup_component, load_fixture
|
||||
from tests.common import assert_setup_component, load_json_object_fixture
|
||||
|
||||
BUS_REPLY = json.loads(load_fixture("bus_reply.json", "yandex_transport"))
|
||||
SUBURBAN_TRAIN_REPLY = json.loads(
|
||||
load_fixture("suburban_reply.json", "yandex_transport")
|
||||
BUS_REPLY = load_json_object_fixture("bus_reply.json", "yandex_transport")
|
||||
SUBURBAN_TRAIN_REPLY = load_json_object_fixture(
|
||||
"suburban_reply.json", "yandex_transport"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user