2022-03-25 20:30:28 +01:00
|
|
|
"""Fixtures for Filesize integration tests."""
|
2024-03-08 14:50:04 +01:00
|
|
|
|
2022-03-25 20:30:28 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2024-07-01 11:58:49 +02:00
|
|
|
from collections.abc import Generator
|
2023-04-11 08:57:34 +02:00
|
|
|
from pathlib import Path
|
2022-03-25 20:30:28 +01:00
|
|
|
from unittest.mock import patch
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2024-11-21 08:31:50 +01:00
|
|
|
from homeassistant.components.filesize.const import DOMAIN, PLATFORMS
|
|
|
|
from homeassistant.const import CONF_FILE_PATH, Platform
|
2022-03-25 20:30:28 +01:00
|
|
|
|
2023-04-11 08:57:34 +02:00
|
|
|
from . import TEST_FILE_NAME
|
2022-03-25 20:30:28 +01:00
|
|
|
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
|
|
|
2024-11-21 08:31:50 +01:00
|
|
|
@pytest.fixture(name="load_platforms")
|
|
|
|
async def patch_platform_constant() -> list[Platform]:
|
|
|
|
"""Return list of platforms to load."""
|
|
|
|
return PLATFORMS
|
|
|
|
|
|
|
|
|
2022-03-25 20:30:28 +01:00
|
|
|
@pytest.fixture
|
2024-11-21 08:31:50 +01:00
|
|
|
def mock_config_entry(
|
|
|
|
tmp_path: Path, load_platforms: list[Platform]
|
|
|
|
) -> MockConfigEntry:
|
2022-03-25 20:30:28 +01:00
|
|
|
"""Return the default mocked config entry."""
|
2023-04-11 08:57:34 +02:00
|
|
|
test_file = str(tmp_path.joinpath(TEST_FILE_NAME))
|
2022-03-25 20:30:28 +01:00
|
|
|
return MockConfigEntry(
|
|
|
|
title=TEST_FILE_NAME,
|
|
|
|
domain=DOMAIN,
|
2024-11-21 08:31:50 +01:00
|
|
|
entry_id="01JD5CTQMH9FKEFQKZJ8MMBQ3X",
|
2023-04-11 08:57:34 +02:00
|
|
|
data={CONF_FILE_PATH: test_file},
|
|
|
|
unique_id=test_file,
|
2022-03-25 20:30:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2024-06-06 17:24:22 +02:00
|
|
|
def mock_setup_entry() -> Generator[None]:
|
2022-03-25 20:30:28 +01:00
|
|
|
"""Mock setting up a config entry."""
|
|
|
|
with patch(
|
|
|
|
"homeassistant.components.filesize.async_setup_entry", return_value=True
|
|
|
|
):
|
|
|
|
yield
|