summaryrefslogtreecommitdiff
path: root/tests/test_functions_scene.py
blob: 7a5b78b225a97517f84201e2c1df6292347b454d (plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
import pytest

from blc2.functions.scene import Scene
from blc2.constants import INFTY

def test_scene(aws):
    """Test creation and modification of scenes."""
    c1, c2, c3, c4 = aws.fixtures[0].channels

    s1 = Scene(aws)
    assert s1.scope == frozenset()
    assert s1.scope == frozenset()

    values = {c1: 0, c2: 1, c3: 2, c4: 4}
    s1.values = values
    assert s1.values == values
    assert s1.scope == frozenset(values.keys())

    s1.update({c1: 10})
    assert s1.values[c1] == 10
    assert s1.scope == frozenset(values.keys())
    for c, v in values.items():
        if c == c1:
            continue
        assert v == s1.values[c]

    s1.set(values)
    assert s1.values == values
    assert s1.scope == frozenset(values.keys())

    del s1[c1]
    assert s1.scope == {c2, c3, c4}
    assert c1 not in s1.values
    assert s1[c1] is None

    s1[c1] = 10
    assert s1.scope == frozenset(values.keys())
    assert s1[c1] == 10

    assert s1.duration == INFTY
    assert s1.actual_duration == INFTY
    assert s1.fade_in == 0
    assert s1.fade_out == 0
    assert not s1.audio_scope

    with pytest.raises(Exception):
        s1.duration = 0

    with pytest.raises(Exception):
        s1.actual_duration = 0

    with pytest.raises(Exception):
        s1.fade_in = 0

    with pytest.raises(Exception):
        s1.fade_out = 0

    with pytest.raises(Exception):
        s1.scope = frozenset()

    with pytest.raises(Exception):
        s1.audio_scope = frozenset()

    s1.set(values)
    lc, ac, _ = s1.render(0)
    assert ac == ()
    assert dict(lc) == values

    lc, ac, _ = s1.render(1234567890)
    assert ac == ()
    assert dict(lc) == values

    s1[c1] = 10
    lc, ac, _ = s1.render(1)
    assert dict(lc)[c1] == 10
    assert False not in (v == values[c] for c, v in lc if c != c1)