|
1
|
|
|
from hypothesis import strategies as st |
|
2
|
|
|
from hypothesis import given |
|
3
|
|
|
|
|
4
|
|
|
import tam |
|
5
|
|
|
from tam import Direction, Glue |
|
6
|
|
|
|
|
7
|
|
|
glue_strength_st = st.integers(min_value=0, max_value=2) |
|
8
|
|
|
|
|
9
|
|
|
def test_main(): |
|
10
|
|
|
assert tam # use your library here |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
def test_opposite_directions(): |
|
14
|
|
|
assert Direction.North.opposite() is Direction.South |
|
15
|
|
|
assert Direction.South.opposite() is Direction.North |
|
16
|
|
|
assert Direction.West.opposite() is Direction.East |
|
17
|
|
|
assert Direction.East.opposite() is Direction.West |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
def test_glue_strength_defaults(): |
|
21
|
|
|
test_tile = tam.new_tile("test") |
|
22
|
|
|
|
|
23
|
|
|
assert tam.northbind(test_tile) == 0 |
|
24
|
|
|
assert tam.southbind(test_tile) == 0 |
|
25
|
|
|
assert tam.eastbind(test_tile) == 0 |
|
26
|
|
|
assert tam.westbind(test_tile) == 0 |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
def test_glue_label_defaults(): |
|
30
|
|
|
test_tile = tam.new_tile("test") |
|
31
|
|
|
|
|
32
|
|
|
assert tam.northlabel(test_tile) == "" |
|
33
|
|
|
assert tam.southlabel(test_tile) == "" |
|
34
|
|
|
assert tam.eastlabel(test_tile) == "" |
|
35
|
|
|
assert tam.westlabel(test_tile) == "" |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
@given(st.fixed_dictionaries({ |
|
39
|
|
|
Direction.North: st.builds(Glue, label=st.text(), strength=glue_strength_st), |
|
40
|
|
|
Direction.South: st.builds(Glue, label=st.text(), strength=glue_strength_st), |
|
41
|
|
|
Direction.West: st.builds(Glue, label=st.text(), strength=glue_strength_st), |
|
42
|
|
|
Direction.East: st.builds(Glue, label=st.text(), strength=glue_strength_st) |
|
43
|
|
|
})) |
|
44
|
|
|
def test_glue_properties(g): |
|
45
|
|
|
test_tile = tam.new_tile("test", glues=g) |
|
46
|
|
|
|
|
47
|
|
|
assert tam.northbind(test_tile) == g[Direction.North].strength |
|
48
|
|
|
assert tam.southbind(test_tile) == g[Direction.South].strength |
|
49
|
|
|
assert tam.westbind(test_tile) == g[Direction.West].strength |
|
50
|
|
|
assert tam.eastbind(test_tile) == g[Direction.East].strength |
|
51
|
|
|
|
|
52
|
|
|
assert tam.northlabel(test_tile) == g[Direction.North].label |
|
53
|
|
|
assert tam.southlabel(test_tile) == g[Direction.South].label |
|
54
|
|
|
assert tam.westlabel(test_tile) == g[Direction.West].label |
|
55
|
|
|
assert tam.eastlabel(test_tile) == g[Direction.East].label |
|
56
|
|
|
|