コード例 #1
0
ファイル: test_backend.py プロジェクト: encukou/roboprojekt
def test_robot_walk(input_coordinates, input_direction, distance, output_coordinates):
    """
    Take robot's coordinates, direction and distance and assert robot walked
    to correct coordinates.
    """
    state = get_start_state("maps/test_3.json")
    robot = Robot(input_direction, input_coordinates, "tester")
    robot.walk(distance, state, input_direction)
    assert robot.coordinates == output_coordinates
コード例 #2
0
def test_robot_died(lives_before, lives_after):
    """
    When robot comes to a HoleTile (or goes / is pushed out of the game board),
    he gets killed.
    Check that his lives were lowered, he got inactive till the next game round
    and his coordinates changed to the None.
    """
    robot = Robot(Direction.N, (0, 0), "tester")
    state = State({(0, 1): [HoleTile(None, None, None)]}, [robot])
    robot.lives = lives_before
    robot.walk(1, state)
    assert robot.lives == lives_after
    assert robot.inactive is True
    assert robot.coordinates is None