blob: 35d548a8bf4cf64e8bc4ecdaaae0a1bae2dbb96b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
"""Tests for the audio primitive."""
import pytest
from blc2.functions.audio import Audio
def test_audio(aws):
a = Audio(aws)
a.fade_out = 1000
a.fade_in = 1000
a.filename = "nonexistant"
assert a.audio_scope == {"nonexistant"}
assert not a.scope
assert a.duration == 0
assert a.actual_duration == 0
a.filename = "tests/silence.m4a"
assert a.filename == "tests/silence.m4a"
assert a.audio_scope == {"tests/silence.m4a"}
assert a.duration == 2024
assert a.actual_duration == 3024
a.fade_out = 500
assert a.fade_out == 500
assert a.duration == 2524
assert a.actual_duration == 3024
lc, ac, _ = a.render(0)
assert not lc
assert len(ac) == 1
assert ac[0][1:] == ("tests/silence.m4a", 0, 1000, 2524, 500)
_, ac2, _ = a.render(3000)
assert ac2 == ac
_, ac, _ = a.render(5000)
assert not ac
with pytest.raises(ValueError):
_ = Audio(aws, id_=101, fade_in=-10)
assert 101 not in aws.functions
fout = a.fade_out
with pytest.raises(ValueError):
a.fade_out = -50
assert a.fade_out == fout
fin = a.fade_in
with pytest.raises(ValueError):
a.fade_in = -50
assert a.fade_in == fin
a._set_duration(10000)
assert a.copy_data(a.get_data()) is None
a.filename = None
assert a.duration == 0
assert a.actual_duration == 0
|