ha(H2): компонент fglair — manifest, config flow (облако/ручной/импорт), пробная сессия
- custom_components/fglair: manifest (config_flow, local_push, requirements),
const, trial (start -> ONLINE <=10 c -> GET базовых свойств), FglairClient
(сессия pyfglair в executor, колбэки в loop, --runtime_data),
__init__ (setup/unload, рефкаунт глобального лог-пампа)
- config flow: меню cloud/manual/import_json + import-source; discover через
pyfglair.provision; пробное подключение с диагностикой (cannot_connect,
no_slots, key_mismatch, timeout, invalid_auth, invalid_import); unique_id=dsn
- strings.json + translations/{en,ru}.json
- тесты HA (pytest-homeassistant-custom-component): меню/шаги/ошибки/импорт/
облако (discover замокан), setup/unload, занятый порт; trial против
mock_ac.py (online/key_mismatch/unreachable/no_slots)
- pytest.ini (общий), tests/conftest перенесён на уровень tests/,
scripts/py-ci.sh: --setup-ha и прогон tests/components
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""Фикстуры тестов HA-компонента fglair."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from helpers import DSN, KEY_ID, LANIP_KEY
|
||||
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
||||
|
||||
from custom_components.fglair.const import (
|
||||
CONF_DEVICE_PORT,
|
||||
CONF_DSN,
|
||||
CONF_HOST,
|
||||
CONF_LANIP_KEY,
|
||||
CONF_LANIP_KEY_ID,
|
||||
CONF_LISTEN_PORT,
|
||||
CONF_TEMPLATE,
|
||||
DOMAIN,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def auto_enable_custom_integrations(enable_custom_integrations):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def entry_data() -> dict:
|
||||
return {
|
||||
CONF_HOST: "127.0.0.1",
|
||||
CONF_DEVICE_PORT: 9,
|
||||
CONF_DSN: DSN,
|
||||
CONF_LANIP_KEY: LANIP_KEY,
|
||||
CONF_LANIP_KEY_ID: KEY_ID,
|
||||
CONF_TEMPLATE: "A",
|
||||
CONF_LISTEN_PORT: 20000 + (os.getpid() % 20000),
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config_entry(entry_data) -> MockConfigEntry:
|
||||
return MockConfigEntry(domain=DOMAIN, data=entry_data, unique_id=DSN)
|
||||
Reference in New Issue
Block a user