mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 00:20:30 +01:00
Simplify tests
This commit is contained in:
@@ -17,11 +17,7 @@ from homeassistant.components.calendar import (
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import (
|
||||
AddConfigEntryEntitiesCallback,
|
||||
AddEntitiesCallback,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from tests.common import (
|
||||
@@ -182,29 +178,6 @@ def mock_setup_config_entry_integration(
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_platform_integration(
|
||||
hass: HomeAssistant,
|
||||
config_flow_fixture: None,
|
||||
test_entities: list[CalendarEntity],
|
||||
) -> None:
|
||||
"""Fixture to set up a mock integration without config entry."""
|
||||
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
pass
|
||||
|
||||
mock_platform(
|
||||
hass,
|
||||
f"{TEST_DOMAIN}.{DOMAIN}",
|
||||
MockPlatform(async_setup_platform=async_setup_platform),
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(name="test_entities")
|
||||
def mock_test_entities() -> list[MockCalendarEntity]:
|
||||
"""Fixture that holdes the fake entities created during the test."""
|
||||
|
||||
@@ -7,6 +7,7 @@ from datetime import timedelta
|
||||
from http import HTTPStatus
|
||||
import re
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from aiohttp.test_utils import TestClient
|
||||
from freezegun import freeze_time
|
||||
@@ -31,6 +32,7 @@ from homeassistant.util import dt as dt_util
|
||||
|
||||
from .conftest import MockCalendarEntity, MockConfigEntry
|
||||
|
||||
from tests.common import MockPlatform, mock_platform
|
||||
from tests.typing import ClientSessionGenerator, WebSocketGenerator
|
||||
|
||||
|
||||
@@ -64,7 +66,6 @@ async def mock_setup_calendar_integration(
|
||||
|
||||
|
||||
@pytest.fixture(name="setup_calendar_config_entry_platform")
|
||||
# @pytest.fixture(name="setup_platform", autouse=True)
|
||||
async def mock_setup_config_entry_platform(
|
||||
hass: HomeAssistant,
|
||||
set_time_zone: None,
|
||||
@@ -802,9 +803,6 @@ async def test_frontend_resources_registered_after_first_config_entry_setup(
|
||||
async def test_frontend_resources_registered_after_first_platform_setup(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
set_time_zone: None,
|
||||
frozen_time: str | None,
|
||||
mock_setup_platform_integration: None,
|
||||
) -> None:
|
||||
"""Test that frontend resources are registered after the first platform is set up."""
|
||||
await async_setup_component(hass, "http", {})
|
||||
@@ -813,6 +811,11 @@ async def test_frontend_resources_registered_after_first_platform_setup(
|
||||
assert "frontend_panels" not in hass.data
|
||||
assert "websocket_api" not in hass.data
|
||||
|
||||
mock_platform(
|
||||
hass,
|
||||
f"test.{DOMAIN}",
|
||||
MockPlatform(async_setup_platform=AsyncMock()),
|
||||
)
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await _assert_http_api_responses(client, HTTPStatus.OK, HTTPStatus.BAD_REQUEST)
|
||||
assert set(hass.data["frontend_panels"]) == {"calendar"}
|
||||
|
||||
Reference in New Issue
Block a user