Private
Public Access
Codacy Security Scan / Codacy static analysis (push) Has been cancelled
Codacy Coverage / Tests + coverage (push) Has been cancelled
gitleaks / scan (push) Has been cancelled
Lint / ruff (Python 3.14) (push) Has been cancelled
42 lines
996 B
Python
42 lines
996 B
Python
"""tests/test_devices.py"""
|
|
|
|
import pytest
|
|
|
|
from tuya_re.devices import dp_map_for
|
|
|
|
|
|
def test_mknd4lci_map():
|
|
dps = dp_map_for("mknd4lci")
|
|
assert dps.click == 108
|
|
assert dps.switch == 1
|
|
assert dps.mode == 101
|
|
assert dps.hold_time == 103
|
|
|
|
|
|
def test_fingerbot_plus_szjqr_map():
|
|
dps = dp_map_for("blliqpsj")
|
|
assert dps.click == 2
|
|
assert dps.switch == 2
|
|
assert dps.mode == 8
|
|
|
|
|
|
def test_pearl_zx5816_map():
|
|
dps = dp_map_for("knp8dybt")
|
|
assert dps.click == 1
|
|
assert dps.switch == 1
|
|
assert dps.mode == 2
|
|
assert dps.hold_time == 3
|
|
assert dps.encode_hold_seconds(1) == 10
|
|
assert dps.encode_hold_seconds(10) == 100
|
|
with pytest.raises(ValueError, match="must not exceed 10 seconds"):
|
|
dps.encode_hold_seconds(11)
|
|
|
|
|
|
def test_hold_seconds_are_unscaled_for_other_models():
|
|
assert dp_map_for("blliqpsj").encode_hold_seconds(5) == 5
|
|
|
|
|
|
def test_unknown_product_raises():
|
|
with pytest.raises(ValueError):
|
|
dp_map_for("nope")
|