mirror of
https://github.com/home-assistant/core.git
synced 2026-02-15 07:36:16 +00:00
Use load_json_object_fixture in tests for NINA (#160690)
Co-authored-by: Joostlek <joostlek@outlook.com>
This commit is contained in:
@@ -47,7 +47,6 @@ rules:
|
||||
test-coverage:
|
||||
status: todo
|
||||
comment: |
|
||||
Use load_json_object_fixture in tests
|
||||
Patch the library instead of the HTTP requests
|
||||
Create a shared fixture for the mock config entry
|
||||
Use init_integration in tests
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
"""Tests for the Nina integration."""
|
||||
|
||||
import json
|
||||
from typing import Any
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.nina.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
load_json_array_fixture,
|
||||
load_json_object_fixture,
|
||||
)
|
||||
|
||||
|
||||
async def setup_platform(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
|
||||
@@ -24,20 +28,20 @@ async def setup_platform(hass: HomeAssistant, config_entry: MockConfigEntry) ->
|
||||
|
||||
def mocked_request_function(url: str) -> dict[str, Any]:
|
||||
"""Mock of the request function."""
|
||||
dummy_response: dict[str, Any] = json.loads(
|
||||
load_fixture("sample_warnings.json", "nina")
|
||||
dummy_response: list[dict[str, Any]] = load_json_array_fixture(
|
||||
"sample_warnings.json", DOMAIN
|
||||
)
|
||||
|
||||
dummy_response_details: dict[str, Any] = json.loads(
|
||||
load_fixture("sample_warning_details.json", "nina")
|
||||
dummy_response_details: dict[str, Any] = load_json_object_fixture(
|
||||
"sample_warning_details.json", DOMAIN
|
||||
)
|
||||
|
||||
dummy_response_regions: dict[str, Any] = json.loads(
|
||||
load_fixture("sample_regions.json", "nina")
|
||||
dummy_response_regions: dict[str, Any] = load_json_object_fixture(
|
||||
"sample_regions.json", DOMAIN
|
||||
)
|
||||
|
||||
dummy_response_labels: dict[str, Any] = json.loads(
|
||||
load_fixture("sample_labels.json", "nina")
|
||||
dummy_response_labels: dict[str, Any] = load_json_object_fixture(
|
||||
"sample_labels.json", DOMAIN
|
||||
)
|
||||
|
||||
if "https://warnung.bund.de/api31/dashboard/" in url: # codespell:ignore bund
|
||||
|
||||
Reference in New Issue
Block a user