-
Notifications
You must be signed in to change notification settings - Fork 17
/
test_tessagon_discovery.py
64 lines (53 loc) · 2.45 KB
/
test_tessagon_discovery.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
import os
import glob
from core_tests_base import CoreTestsBase
from tessagon.core.tessagon_discovery import TessagonDiscovery
from tessagon.types.hex_tessagon import HexTessagon
from tessagon.types.tri_tessagon import TriTessagon
from tessagon.types.square_tessagon import SquareTessagon
class TestTessagonDiscovery(CoreTestsBase):
def test_find_all(self):
# We want to be able to find everything in the types folder
find_all = TessagonDiscovery()
wildcard = os.path.realpath(os.path.dirname(__file__) +
'/../../tessagon/types/*_tessagon.py')
all_type_py = glob.glob(wildcard)
count_all_classes = len(find_all.to_list())
assert count_all_classes > 20
assert count_all_classes == len(all_type_py)
def test_find_regular(self):
find_all = TessagonDiscovery()
regular = find_all.with_classification('regular')
assert set(regular.to_list()) == set([HexTessagon,
TriTessagon,
SquareTessagon])
assert regular.count() == 3
def test_inverse(self):
find_all = TessagonDiscovery()
regular = find_all.with_classification('regular')
inverse = regular.inverse()
find_all_count = find_all.count()
assert find_all_count >= 23
regular_count = regular.count()
assert regular_count == 3
assert inverse.count() + regular_count == find_all_count
assert set(regular.to_list()) | set(inverse.to_list()) == \
set(find_all.to_list())
def test_addition(self):
find_all = TessagonDiscovery()
regular = find_all.with_classification('regular')
inverse = regular.inverse()
assert set((regular + inverse).to_list()) == set(find_all.to_list())
def test_subtraction(self):
find_all = TessagonDiscovery()
regular = find_all.with_classification('regular')
inverse = regular.inverse()
assert set((find_all - regular).to_list()) == set(inverse.to_list())
assert (find_all - find_all).to_list() == []
def test_with_color_pattern(self):
color = TessagonDiscovery().with_color_patterns()
non_color = color.inverse()
for tessagon in color.to_list():
assert tessagon.metadata.num_color_patterns > 0
for tessagon in non_color.to_list():
assert tessagon.metadata.num_color_patterns == 0