-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_use_case.py
29 lines (26 loc) · 1.17 KB
/
test_use_case.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
from use_case import *
from domain import Direction, initial_input, Map, Material, Position
MAP = Map(materials=[Material.FLOOR, Material.FLOOR, Material.FLOOR,
Material.FLOOR, Material.FLOOR, Material.FLOOR,
Material.FLOOR, Material.FLOOR, Material.FLOOR],
objects=[],
width=3)
PLAYER = Player(name='test',
position=Position(1.5, 1.5),
forward=Direction(0.0, -1.0))
def test_move_forward():
state = initial_state(initial_input, PLAYER, MAP, 3, 5)
state, _ = handle_event(state, 'input', initial_input._replace(forward=True))
state, _ = handle_event(state, 'tick', 0.070)
assert state.player.position.x == 1.5
assert state.player.position.y < 1.5
assert state.player.forward.x == 0.0
assert state.player.forward.y == -1.0
def test_turn_right():
state = initial_state(initial_input, PLAYER, MAP, 3, 5)
state, _ = handle_event(state, 'input', initial_input._replace(turn_right=True))
state, _ = handle_event(state, 'tick', 0.070)
assert state.player.position.x == 1.5
assert state.player.position.y == 1.5
assert state.player.forward.x > 0.0
assert state.player.forward.y > -1.0