File: test_types.py

package info (click to toggle)
python-bellows 0.40.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 992 kB
  • sloc: python: 13,630; sh: 7; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 684 bytes parent folder | download
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
import pytest
import zigpy.zdo.types as zdo_t

import bellows.types as t


def test_lvbytes32():
    d, r = t.LVBytes32.deserialize(b"\x04\x00\x00\x0012345")
    assert r == b"5"
    assert d == b"1234"

    assert t.LVBytes32.serialize(d) == b"\x04\x00\x00\x001234"


@pytest.mark.parametrize(
    "node_type, logical_type",
    (
        (0, 7),
        (1, 0),
        (2, 1),
        (3, 2),
        (4, 7),
        (0xFF, 7),
    ),
)
def test_ember_node_type_to_zdo_logical_type(node_type, logical_type):
    """Test conversion of node type to logical type."""

    node_type = t.EmberNodeType(node_type)
    assert node_type.zdo_logical_type == zdo_t.LogicalType(logical_type)