-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_code_content_audio.py
190 lines (164 loc) · 4.02 KB
/
test_code_content_audio.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# -*- coding: utf-8 -*-
import iscc_core.code_content_audio
def test_soft_hash_audio_v0_001_empty():
cv = []
assert (
iscc_core.code_content_audio.soft_hash_audio_v0(cv).hex()
== "0000000000000000000000000000000000000000000000000000000000000000"
)
def test_soft_hash_audio_v0_002_single():
cv = [1]
assert (
iscc_core.code_content_audio.soft_hash_audio_v0(cv, bits=256).hex()
== "0000000100000001000000000000000000000000000000010000000000000000"
)
def test_soft_hash_audio_v0_003_short():
cv = [1, 2]
assert (
iscc_core.code_content_audio.soft_hash_audio_v0(cv, bits=256).hex()
== "0000000300000001000000020000000000000000000000010000000200000000"
)
def test_soft_hash_audio_v0_004_signed():
cv = [-1, 0, 1]
assert (
iscc_core.code_content_audio.soft_hash_audio_v0(cv, bits=256).hex()
== "00000001ffffffff000000000000000100000000ffffffff0000000000000001"
)
def test_soft_hash_audio_v0_005_sample():
assert (
iscc_core.code_content_audio.soft_hash_audio_v0(CHROMA_VECTOR, bits=256).hex()
== "6a24a22672e4e2a33a4e88876a84a0266a24a2263a4ea0836264a22468842a2f"
)
def test_gen_audio_code_v0_default():
assert iscc_core.code_content_audio.gen_audio_code_v0(CHROMA_VECTOR) == {
"iscc": "ISCC:EIAWUJFCEZZOJYVD"
}
def test_gen_audio_code_v0_32bits():
assert iscc_core.code_content_audio.gen_audio_code_v0(CHROMA_VECTOR, bits=32) == {
"iscc": "ISCC:EIAGUJFCEY"
}
def test_gen_audio_code_v0_64bits():
assert iscc_core.code_content_audio.gen_audio_code_v0(CHROMA_VECTOR, bits=64) == {
"iscc": "ISCC:EIAWUJFCEZZOJYVD"
}
def test_gen_audio_code_v0_128bits():
assert iscc_core.code_content_audio.gen_audio_code_v0(CHROMA_VECTOR, bits=128) == {
"iscc": "ISCC:EIBWUJFCEZZOJYVDHJHIRB3KQSQCM"
}
def test_gen_audio_code_v0_256bits():
assert iscc_core.code_content_audio.gen_audio_code_v0(CHROMA_VECTOR, bits=256) == {
"iscc": "ISCC:EIDWUJFCEZZOJYVDHJHIRB3KQSQCM2REUITDUTVAQNRGJIRENCCCULY"
}
def test_gen_audio_code():
assert iscc_core.code_content_audio.gen_audio_code(CHROMA_VECTOR, bits=256) == {
"iscc": "ISCC:EIDWUJFCEZZOJYVDHJHIRB3KQSQCM2REUITDUTVAQNRGJIRENCCCULY"
}
def test_gen_audio_code_schema_conformance():
iscc_obj = iscc_core.gen_audio_code_v0(CHROMA_VECTOR)
assert iscc_obj == {"iscc": "ISCC:EIAWUJFCEZZOJYVD"}
CHROMA_VECTOR = [
684003877,
683946551,
1749295639,
2017796679,
2026256086,
2022066918,
2022001639,
2021968035,
2038741139,
2059709571,
503750851,
369541315,
320225426,
289292450,
830368930,
838789539,
1940835201,
1928186752,
1651297920,
1651283600,
1650959072,
1655022116,
1722069540,
1726259749,
1713694254,
1847914286,
1847912494,
1780832302,
-362410962,
-352973810,
1809196111,
1770397775,
1753686797,
683942429,
943989277,
943989255,
944121430,
952503910,
948374246,
948717799,
1485621411,
462203011,
508470403,
370053251,
303988867,
322879651,
322892963,
862907811,
1928256417,
1928317841,
1651297152,
1647091344,
1650827936,
1659216416,
1722069540,
1726263844,
1717887533,
1713696302,
1847912494,
1847883822,
-366540754,
-345633778,
-336184242,
1771447375,
1753620815,
1757684255,
675553815,
943989255,
944120390,
952508006,
948308582,
948718050,
411879650,
428648578,
516861059,
370057347,
303988865,
306086033,
306086051,
841919649,
846133665,
1919929264,
1647168400,
1647101584,
1650827936,
1659216484,
1671733796,
1738838588,
1717887517,
1713696302,
1847913774,
1847912494,
1780960302,
-362410978,
-336196594,
1775641678,
1770397775,
1753555743,
683942429,
943989271,
944185926,
2026255094,
2022051494,
2021919654,
]