File: test_models.py

package info (click to toggle)
python-homewizard-energy 10.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,104 kB
  • sloc: python: 3,523; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 1,253 bytes parent folder | download | duplicates (2)
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
"""Test the helper functions."""

import pytest

from homewizard_energy.models import get_verification_hostname

pytestmark = [pytest.mark.asyncio]


@pytest.mark.parametrize(
    ("model", "expected"),
    [
        ("HWE-P1", "appliance/p1dongle/1234567890"),
        ("HWE-SKT", "appliance/energysocket/1234567890"),
        ("HWE-WTR", "appliance/watermeter/1234567890"),
        ("HWE-DSP", "appliance/display/1234567890"),
        ("HWE-KWH1", "appliance/energymeter/1234567890"),
        ("SDM230-wifi", "appliance/energymeter/1234567890"),
        ("HWE-KWH3", "appliance/energymeter/1234567890"),
        ("SDM630-wifi", "appliance/energymeter/1234567890"),
        ("HWE-BAT", "appliance/battery/1234567890"),
    ],
)
async def test_get_verification_hostname_returns_expected_identifier(
    model: str, expected: str
):
    """Test if get_verification_hostname returns the expected identifier."""
    result = get_verification_hostname(model, "1234567890")
    assert result == expected


async def test_get_verification_hostname_raises_value_error():
    """Test if get_verification_hostname raises a ValueError for an unsupported model."""
    with pytest.raises(ValueError):
        get_verification_hostname("unsupported", "1234567890")