summaryrefslogtreecommitdiff
path: root/tests/test_functions_scene.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_functions_scene.py')
-rw-r--r--tests/test_functions_scene.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/test_functions_scene.py b/tests/test_functions_scene.py
index 7a5b78b..77b2d6f 100644
--- a/tests/test_functions_scene.py
+++ b/tests/test_functions_scene.py
@@ -1,7 +1,9 @@
import pytest
+import xml.etree.ElementTree as et
+
from blc2.functions.scene import Scene
-from blc2.constants import INFTY
+from blc2.constants import INFTY, BXW
def test_scene(aws):
"""Test creation and modification of scenes."""
@@ -74,3 +76,37 @@ def test_scene(aws):
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)
+
+ with pytest.raises(ValueError):
+ s1[c1] = -10
+ assert s1[c1] == 10
+
+ with pytest.raises(ValueError):
+ s1[c1] = -256
+ assert s1[c1] == 10
+
+ del s1[c4]
+ del s1[c4]
+
+def test_scene_serialize(aws, test_xml_eq):
+ return
+ c1, c2, c3, c4 = aws.fixtures[0].channels
+ s = Scene(aws, id_=123, name="Test Scene", values={c1: 1, c2: 2, c3: 3, c4: 4})
+
+ (f1, i1), (f2, i2), (f3, i3), (f4, i4) = ((i.f.id, i.id) for i in (c1, c2, c3, c4))
+
+ e = s.serialize()
+ expected = """
+<function xmlns="{bxw}" type="Scene" id="123" name="Test Scene">
+ <value fixture="{f1}" channel="{i1}">1</value>
+ <value fixture="{f2}" channel="{i2}">2</value>
+ <value fixture="{f3}" channel="{i3}">3</value>
+ <value fixture="{f4}" channel="{i4}">4</value>
+</function>
+""".format(bxw=BXW.strip("{}"), f1=f1, f2=f2, f3=f3, f4=f4, i1=i1,i2=i2,i3=i3,i4=i4)
+
+ et.register_namespace("", BXW)
+ print(et.tostring(e, encoding="utf-8"))
+ print(expected)
+
+ assert test_xml_eq(e, expected)