Completed
Push — master ( a7407f...64c77b )
by Luiz
01:12
created

tests.test_glue_properties()   C

Complexity

Conditions 9

Size

Total Lines 18

Duplication

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