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
|
"""Tests for the connection module."""
import pytest
from asusrouter.modules.connection import (
ConnectionType,
InternetMode,
get_connection_type,
get_internet_mode,
)
@pytest.mark.parametrize(
("value", "result"),
[
# Existing values of InternetMode
("allow", InternetMode.ALLOW),
("block", InternetMode.BLOCK),
("time", InternetMode.TIME),
# Unknown values of the same type
("unknown", InternetMode.UNKNOWN),
("", InternetMode.UNKNOWN),
# Values of the wrong type
(None, InternetMode.UNKNOWN),
(1, InternetMode.UNKNOWN),
],
)
def test_get_internet_mode(value: str | None, result: InternetMode) -> None:
"""Test get_internet_mode."""
assert get_internet_mode(value) == result
@pytest.mark.parametrize(
("value", "result"),
[
# Existing values of ConnectionType
(0, ConnectionType.WIRED),
(1, ConnectionType.WLAN_2G),
(2, ConnectionType.WLAN_5G),
(3, ConnectionType.WLAN_5G2),
(4, ConnectionType.WLAN_6G),
# Unknown values of the same type
(-1, ConnectionType.WIRED),
(5, ConnectionType.WIRED),
# Values of the wrong type
(None, ConnectionType.WIRED),
("", ConnectionType.WIRED),
# Special cases which would still work
(1.0, ConnectionType.WLAN_2G),
(2.3, ConnectionType.WLAN_5G),
],
)
def test_get_connection_type(
value: int | None, result: ConnectionType
) -> None:
"""Test get_connection_type."""
assert get_connection_type(value) == result
|