File: test_parser.py

package info (click to toggle)
python-aioshelly 13.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 732 kB
  • sloc: python: 6,867; makefile: 7; sh: 3
file content (58 lines) | stat: -rw-r--r-- 1,414 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
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
"""Tests for the BLE parser."""

from __future__ import annotations

from aioshelly.ble.parser import parse_ble_scan_result_event


def test_parse_v1() -> None:
    """Test parse v1."""
    assert parse_ble_scan_result_event(
        [
            1,
            "AA:BB:CC:DD:EE:FF",
            -50,
            "AQIDBAUGBwgJCg==",
            "AQIDBAUGBwgJCg==",
        ]
    ) == [
        (
            "AA:BB:CC:DD:EE:FF",
            -50,
            b"\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x01\x02\x03\x04\x05\x06\x07\x08\t\n",
        )
    ]


def test_parse_v2() -> None:
    """Test parse v2."""
    assert parse_ble_scan_result_event(
        [
            2,
            [
                [
                    "AA:BB:CC:DD:EE:FF",
                    -50,
                    "AQIDBAUGBwgJCg==",
                    "AQIDBAUGBwgJCg==",
                ],
                [
                    "AA:BB:CC:DD:EE:FF",
                    -50,
                    "AQIDBAUGBwgJCg==",
                    "AQIDBAUGBwgJCg==",
                ],
            ],
        ]
    ) == [
        (
            "AA:BB:CC:DD:EE:FF",
            -50,
            b"\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x01\x02\x03\x04\x05\x06\x07\x08\t\n",
        ),
        (
            "AA:BB:CC:DD:EE:FF",
            -50,
            b"\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x01\x02\x03\x04\x05\x06\x07\x08\t\n",
        ),
    ]