summaryrefslogtreecommitdiff
path: root/tests/test_functions_chaserstep.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_functions_chaserstep.py')
-rw-r--r--tests/test_functions_chaserstep.py55
1 files changed, 54 insertions, 1 deletions
diff --git a/tests/test_functions_chaserstep.py b/tests/test_functions_chaserstep.py
index 134b893..6185f46 100644
--- a/tests/test_functions_chaserstep.py
+++ b/tests/test_functions_chaserstep.py
@@ -11,10 +11,17 @@ from blc2.constants import INHERIT, MANUAL, EXTERNAL, INTERNAL, INFTY
class DummyChaser:
def register_step(self, *args, **kwargs):
- return
+ if self.throw:
+ raise Exception("blah")
+ self.count += 1
+
+ def delete_step(self, *args, **kwargs):
+ self.count -= 1
def __init__(self, w):
self.w = w
+ self.count = 0
+ self.throw = False
@pytest.fixture
def cw():
@@ -35,10 +42,24 @@ def test_chaserstep(cw):
a = cw.functions[2]
c0, = cw.fixtures[0].channels
+ ## Try adding a negative index
+ with pytest.raises(Exception):
+ ChaserStep(c, id_=42069, function=s0, duration_mode=INHERIT, index=-10)
+ assert c.count == 0
+ assert 42069 not in cw.functions
+
+ ## Test a failed add
+ with pytest.raises(Exception):
+ c.throw = True
+ ChaserStep(c, id_=42069, function=s0, duration_mode=INHERIT)
+ assert 42069 not in cw.functions
+ c.throw = False
+
## Test how it handles inherit
cs1 = ChaserStep(c, function=s0, duration_mode=INHERIT)
assert cs1.duration == INFTY
assert cs1.actual_duration == INFTY
+ assert cs1.duration_mode == INHERIT
assert cs1.fade_out_mode == s0.fade_out_mode
assert cs1.scope == s0.scope
assert cs1.audio_scope == s0.audio_scope
@@ -122,3 +143,35 @@ def test_chaserstep(cw):
lc, ac, data = cs1.render(3025, data)
assert not lc
assert not ac
+
+ cs1.function = None
+ assert cs1.duration == 0
+ assert cs1.actual_duration == 0
+
+ cs1.fade_in = 100
+ with pytest.raises(ValueError):
+ cs1.fade_in = -100
+ assert cs1.fade_in == 100
+
+ cs1.fade_out = 100
+ with pytest.raises(ValueError):
+ cs1.fade_out = -100
+ assert cs1.fade_out == 100
+
+ cs1.function = s0
+ s0.delete()
+ assert cs1.function is None
+ assert cs1.audio_scope == frozenset()
+ assert cs1.scope == frozenset()
+ cs1.duration_mode = INHERIT
+ with pytest.raises(AttributeError):
+ cs1.duration = 50
+ assert cs1.render(10000, data)[:2] == ((), ())
+
+ cs1.duration_mode = MANUAL
+ cs1.duration = 500
+ with pytest.raises(ValueError):
+ cs1.duration = -100
+ assert cs1.duration == 500
+
+