| blc2 - Python library and frontend for running theatrical lighting and SFX. Written for the English 2041F fall 2019 theatre production of "The Cenci".
git clone https://benconnors.ca/git-repos/blc2 |
test_topology.py (1464B) - raw
1 """Module for testing topology behaviour.""" 2 3 import pytest 4 5 from blc2.topology import Fixture 6 from blc2.workspace import Workspace 7 8 def test_fixture_create(ws): 9 """Test basic fixture creation.""" 10 f = Fixture(ws, id_=0, name="Test 1") 11 assert f.id in ws.fixtures 12 assert f.id == 0 13 assert f.name == "Test 1" 14 assert not f.channels 15 16 with pytest.raises(ValueError): 17 Fixture(ws, id_=0, name="Test 2") 18 19 assert ws.fixtures[0] == f 20 assert len(ws.fixtures) == 1 21 22 f2 = Fixture(ws, name="Test 3") 23 assert f2.id is not None 24 assert ws.fixtures[f2.id] == f2 25 assert len(ws.fixtures) == 2 26 27 f3 = Fixture(ws, channel_count = 3) 28 assert len(f3.channels) == 3 29 30 def test_fixture_channels(ws): 31 """Test fixture channel manipulations.""" 32 f = Fixture(ws, channel_count=3) 33 for i in range(3): 34 f.channels[i].address = (0, i) 35 channels = tuple(f.channels) 36 37 with pytest.raises(ValueError): 38 f.channel_count = -1 39 assert len(f.channels) == 3 40 41 ## Verify that the channels haven't been changed 42 for a, b in zip(f.channels, channels): 43 assert id(a) == id(b) 44 45 f.channel_count = 2 46 assert len(f.channels) == 2 47 for a, b in zip(f.channels, channels[:2]): 48 assert id(a) == id(b) 49 50 f.channel_count = 3 51 assert len(f.channels) == 3 52 for a, b in zip(f.channels, channels[:2]): 53 assert id(a) == id(b) 54 55 assert id(f.channels[2]) != id(channels[2])