mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00

* Add iskra integration * iskra non resettable counters naming fix * added iskra config_flow test * fixed iskra integration according to code review * changed iskra config flow test * iskra integration, fixed codeowners * Removed counters code & minor fixes * added comment * Update homeassistant/components/iskra/__init__.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Updated Iskra integration according to review * Update homeassistant/components/iskra/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Updated iskra integration according to review * minor iskra integration change * iskra integration changes according to review * iskra integration changes according to review * Changed iskra integration according to review * added iskra config_flow range validation * Fixed tests for iskra integration * Update homeassistant/components/iskra/coordinator.py * Update homeassistant/components/iskra/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Fixed iskra integration according to review * Changed voluptuous schema for iskra integration and added data_descriptions * Iskra integration tests lint error fix --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
"""Fixtures for mocking pyiskra's different protocols.
|
|
|
|
Fixtures:
|
|
- `mock_pyiskra_rest`: Mock pyiskra Rest API protocol.
|
|
- `mock_pyiskra_modbus`: Mock pyiskra Modbus protocol.
|
|
"""
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from .const import PQ_MODEL, SERIAL, SG_MODEL
|
|
|
|
|
|
class MockBasicInfo:
|
|
"""Mock BasicInfo class."""
|
|
|
|
def __init__(self, model) -> None:
|
|
"""Initialize the mock class."""
|
|
self.serial = SERIAL
|
|
self.model = model
|
|
self.description = "Iskra mock device"
|
|
self.location = "imagination"
|
|
self.sw_ver = "1.0.0"
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_pyiskra_rest():
|
|
"""Mock Iskra API authenticate with Rest API protocol."""
|
|
|
|
with patch(
|
|
"pyiskra.adapters.RestAPI.RestAPI.get_basic_info",
|
|
return_value=MockBasicInfo(model=SG_MODEL),
|
|
) as basic_info_mock:
|
|
yield basic_info_mock
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_pyiskra_modbus():
|
|
"""Mock Iskra API authenticate with Rest API protocol."""
|
|
|
|
with patch(
|
|
"pyiskra.adapters.Modbus.Modbus.get_basic_info",
|
|
return_value=MockBasicInfo(model=PQ_MODEL),
|
|
) as basic_info_mock:
|
|
yield basic_info_mock
|