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)