-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_code_content_mixed.py
60 lines (48 loc) · 2.15 KB
/
test_code_content_mixed.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
# -*- coding: utf-8 -*-
import pytest
import iscc_core
def test_gen_mixed_code_v0_single_raises():
tc = iscc_core.gen_text_code_v0("Hello World", bits=64)
with pytest.raises(AssertionError):
iscc_core.gen_mixed_code_v0([tc["iscc"]])
def test_gen_mixed_code_v0_non_cc_raises():
tc = iscc_core.gen_text_code_v0("Hello World", bits=64)["iscc"]
mc = iscc_core.gen_meta_code_v0("Meta Code Title", bits=64)["iscc"]
codes = tc, mc
with pytest.raises(AssertionError):
iscc_core.gen_mixed_code_v0(codes, bits=64)
def test_gen_mixed_code_v0_codes_mixed_length():
tc_long = iscc_core.gen_text_code_v0("Hello World", bits=256)["iscc"]
tc_short = iscc_core.gen_text_code_v0("Short Text-Code", bits=64)["iscc"]
codes = tc_long, tc_short
assert iscc_core.gen_mixed_code_v0(codes=codes, bits=64) == {
"iscc": "ISCC:EQASBPL7XH763357",
"parts": [
"ISCC:EADSKDNZNYGUUF5AMFEJLZ5P66CP5YKCOA3X7F36RWE4CIRCBTUWXYY",
"ISCC:EAA3265Q67Q27P7F",
],
}
def test_gen_mixed_code_v0_codes_to_short_raises():
tc_long = iscc_core.gen_text_code_v0("Hello World", bits=256)["iscc"]
tc_short = iscc_core.gen_text_code_v0("Short Text-Code", bits=64)["iscc"]
codes = tc_long, tc_short
with pytest.raises(AssertionError):
iscc_core.gen_mixed_code_v0(codes=codes, bits=128)
def test_gen_mixed_code_codes_to_short_raises():
tc_long = iscc_core.gen_text_code_v0("Hello World", bits=256)["iscc"]
tc_short = iscc_core.gen_text_code_v0("Short Text-Code", bits=64)["iscc"]
codes = tc_long, tc_short
with pytest.raises(AssertionError):
iscc_core.gen_mixed_code(codes=codes, bits=128)
def test_gen_mixed_code_schema_conformance():
tc_long = iscc_core.gen_text_code_v0("Hello World", bits=256)["iscc"]
tc_short = iscc_core.gen_text_code_v0("Short Text-Code", bits=64)["iscc"]
codes = tc_long, tc_short
iscc_obj = iscc_core.gen_mixed_code_v0(codes=codes)
assert iscc_obj == {
"iscc": "ISCC:EQASBPL7XH763357",
"parts": [
"ISCC:EADSKDNZNYGUUF5AMFEJLZ5P66CP5YKCOA3X7F36RWE4CIRCBTUWXYY",
"ISCC:EAA3265Q67Q27P7F",
],
}