mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +00:00
* Create component via script.scaffold * Create sensor definition * Define coordinator * Define config flow * Refine sensor definition and add tests * Refine coordinator after testing end to end * Redefine sensor in a more idiomatic way * Use entity (common-module) * Follow config-flow conventions more closely * Use custom ConfigEntry to conform to strict-typing * Define API object instead of using aio directly * Test before setup in init * Add diagnostics * Make some more quality changes * Move scan interval to const * Commit generated files * Add quality scale * feedback: Apply consistent language to Tilt Pi refs * feedback: Remove empty manifest fields * feedback: Use translations instead of hardcoded name * feedback: Remove diagnostics * feedback: Idiomatic and general improvements * Use tilt-pi library * feedback: Coordinator data returns dict * feedback: Move client creation to coordinator * feedback: Request only Tilt Pi URL from user * Update homeassistant/components/tilt_pi/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/tilt_pi/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/tilt_pi/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * feedback: Avoid redundant keyword arguments in function calls * feedback: Remove unused models and variables * feedback: Use icons.json * feedback: Style best practices * Update homeassistant/components/tilt_pi/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/tilt_pi/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * feedback: Improve config flow unit tests * feedback: Patch TiltPi client mock * feedback: Mark entity-device-class as done * feedback: Align quaity scale with current state * feeback: Create brands file for Tilt brand * feedback: Demonstrate recovery in config flow * feedback: Test coordinator behavior via sensors * Update homeassistant/components/tilt_pi/config_flow.py Co-authored-by: Josef Zweck <josef@zweck.dev> * Update homeassistant/components/tilt_pi/coordinator.py Co-authored-by: Josef Zweck <josef@zweck.dev> * Update homeassistant/components/tilt_pi/quality_scale.yaml Co-authored-by: Josef Zweck <josef@zweck.dev> * Update homeassistant/components/tilt_pi/quality_scale.yaml Co-authored-by: Josef Zweck <josef@zweck.dev> * Update homeassistant/components/tilt_pi/quality_scale.yaml Co-authored-by: Josef Zweck <josef@zweck.dev> * Update homeassistant/components/tilt_pi/config_flow.py Co-authored-by: Josef Zweck <josef@zweck.dev> * feedback: Update tilt_pi quality scale * feedback: Move const to coordinator * feedback: Correct strings.json for incorrect and missing fields * feedback: Use tiltpi package version published via CI * Run ruff format manually * Add missing string for invalid host * Fix * Fix --------- Co-authored-by: Michael Heyman <michaelheyman@users.noreply.github.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Josef Zweck <josef@zweck.dev>
71 lines
1.8 KiB
Python
71 lines
1.8 KiB
Python
"""Common fixtures for the Tilt Pi tests."""
|
|
|
|
from collections.abc import Generator
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
import pytest
|
|
from tiltpi import TiltColor, TiltHydrometerData
|
|
|
|
from homeassistant.components.tilt_pi.const import DOMAIN
|
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
TEST_NAME = "Test Tilt Pi"
|
|
TEST_HOST = "192.168.1.123"
|
|
TEST_PORT = 1880
|
|
TEST_URL = f"http://{TEST_HOST}:{TEST_PORT}"
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
|
"""Override async_setup_entry."""
|
|
with patch(
|
|
"homeassistant.components.tilt_pi.async_setup_entry",
|
|
return_value=True,
|
|
) as mock_setup_entry:
|
|
yield mock_setup_entry
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_config_entry() -> MockConfigEntry:
|
|
"""Return the default mocked config entry."""
|
|
return MockConfigEntry(
|
|
domain=DOMAIN,
|
|
data={
|
|
CONF_HOST: TEST_HOST,
|
|
CONF_PORT: TEST_PORT,
|
|
},
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_tiltpi_client() -> Generator[AsyncMock]:
|
|
"""Mock a TiltPi client."""
|
|
with (
|
|
patch(
|
|
"homeassistant.components.tilt_pi.coordinator.TiltPiClient",
|
|
autospec=True,
|
|
) as mock_client,
|
|
patch(
|
|
"homeassistant.components.tilt_pi.config_flow.TiltPiClient",
|
|
new=mock_client,
|
|
),
|
|
):
|
|
client = mock_client.return_value
|
|
client.get_hydrometers.return_value = [
|
|
TiltHydrometerData(
|
|
mac_id="00:1A:2B:3C:4D:5E",
|
|
color=TiltColor.BLACK,
|
|
temperature=55.0,
|
|
gravity=1.010,
|
|
),
|
|
TiltHydrometerData(
|
|
mac_id="00:1s:99:f1:d2:4f",
|
|
color=TiltColor.YELLOW,
|
|
temperature=68.0,
|
|
gravity=1.015,
|
|
),
|
|
]
|
|
yield client
|