1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
"""Test endpoint for envoy v7 and newer firmware"""
import logging
import aiohttp
import pytest
from aioresponses import aioresponses
from syrupy.assertion import SnapshotAssertion
from pyenphase.models.dry_contacts import DryContactType
from .common import (
get_mock_envoy,
prep_envoy,
start_7_firmware_mock,
)
LOGGER = logging.getLogger(__name__)
@pytest.mark.parametrize(
(
"version",
"dry_contacts",
),
[
(
"8.3.5167_3rd-pv",
{
"NC1": DryContactType.THIRD_PARTY_PV,
"NC2": DryContactType.NONE,
"NO1": DryContactType.NONE,
"NO2": DryContactType.NONE,
},
),
(
"8.2.127_with_generator_running",
{
"NC1": DryContactType.NONE,
"NC2": DryContactType.NONE,
"NO1": DryContactType.LOAD,
"NO2": DryContactType.LOAD,
},
),
],
ids=[
"8.3.5167_3rd-pv",
"8.2.127_with_generator_running",
],
)
@pytest.mark.asyncio
async def test_dry_contact_type(
version: str,
snapshot: SnapshotAssertion,
dry_contacts: dict[str, DryContactType],
caplog: pytest.LogCaptureFixture,
mock_aioresponse: aioresponses,
test_client_session: aiohttp.ClientSession,
) -> None:
"""Verify with 7.x firmware."""
start_7_firmware_mock(mock_aioresponse)
await prep_envoy(mock_aioresponse, "127.0.0.1", version)
caplog.set_level(logging.DEBUG)
envoy = await get_mock_envoy(test_client_session)
data = envoy.data
assert data is not None
for contact, type in dry_contacts.items():
assert data.dry_contact_settings[contact].type == type
|