From 0fc3371d48d7e87a5628b16c2bbd09c3fb15cd8e Mon Sep 17 00:00:00 2001 From: Ben Connors Date: Fri, 27 Sep 2019 14:57:46 -0400 Subject: Bugfixes - Add some new tests - Run some basic (interactive) chaser tests, they work-ish now --- tests/test_functions_scene.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'tests/test_functions_scene.py') 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 = """ + + 1 + 2 + 3 + 4 + +""".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) -- cgit v1.2.3