File: test_cec_command.py

package info (click to toggle)
pycec 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 204 kB
  • sloc: python: 1,335; sh: 48; makefile: 7
file content (63 lines) | stat: -rw-r--r-- 1,665 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
59
60
61
62
63
from pycec.commands import CecCommand
from pycec.const import CMD_POLL


def test_src():
    cc = CecCommand("1f:90:02")
    assert cc.src == 0x1
    cc = CecCommand("52:90:02")
    assert cc.src == 0x5
    cc = CecCommand(0x8F, 0x5, 0x3)
    assert cc.src == 0x3
    cc = CecCommand("52:90:02")
    cc.src = 0x4
    assert ("%s" % cc) == "42:90:02"
    cc = CecCommand(0x8F, 0x5, 0x3, raw="78:a5:89:45")
    assert cc.src == 0x7


def test_dst():
    cc = CecCommand("1f:90:02")
    assert cc.dst == 0xF
    cc = CecCommand("52:90:02")
    assert cc.dst == 0x2
    cc = CecCommand(0x8F, 0x5, 0x3)
    assert cc.dst == 0x5
    cc = CecCommand("52:90:02")
    cc.dst = 0x4
    assert ("%s" % cc) == "54:90:02"
    cc = CecCommand(0x8F, 0x5, 0x3, raw="78:a5:89:45")
    assert cc.dst == 0x8


def test_cmd():
    cc = CecCommand("1f:90:02")
    assert cc.cmd == 0x90
    cc = CecCommand("52:8f:02")
    assert cc.cmd == 0x8F
    cc = CecCommand(0x8F, 0x5, 0x3)
    assert cc.cmd == 0x8F
    cc = CecCommand(0x8F, 0x5, 0x3, raw="78:a5:89:45")
    assert cc.cmd == 0xA5


def test_att():
    cc = CecCommand("1f:90:02")
    assert cc.att == [0x02]
    cc = CecCommand("52:8f:02:56")
    assert cc.att == [0x02, 0x56]
    cc = CecCommand(0x8F, 0x5, 0x3, [0x45, 0x56, 0x98])
    assert cc.att == [0x45, 0x56, 0x98]
    cc = CecCommand(0x8F, 0x5, 0x3, raw="78:a5:89:45")
    assert cc.att == [0x89, 0x45]


def test_raw():
    cc = CecCommand("1f:90:02:05:89")
    assert cc.raw == "1f:90:02:05:89"
    cc = CecCommand("1f:90")
    assert cc.raw == "1f:90"
    cc = CecCommand("2c")
    assert cc.raw == "2c"
    cc = CecCommand(CMD_POLL, dst=3)
    assert cc.raw == "f3"