예제 #1
0
def test_get_blocked_cards(program_before, program_after):
    """
    Assert the blocked cards (cards which are not None) are extracted
    from robot's program.
    """
    joe = Robot(Direction.N, (0, 0), "bender")
    joe.program = program_before
    assert joe.select_blocked_cards_from_program() == program_after
예제 #2
0
def test_rotate_cards(card, new_direction):
    """
    Give mock robot the RotationCard and check if he's heading to the expected direction.
    """
    robot = Robot(Direction.N, None, "tester")
    robot.program = [card]
    state = get_start_state("maps/test_3.json")
    card.apply_effect(robot, state)
    assert robot.direction == new_direction
예제 #3
0
def test_move_cards(card, new_coordinates):
    """
    Give mock robot the MovementCard and check if he moved to the expected coordinates.
    """
    robot = Robot(Direction.N, None, None, (5, 5))
    robot.program = [card]
    state = get_start_state("maps/test_3.json")
    robot.apply_card_effect(state)
    assert robot.coordinates == new_coordinates
예제 #4
0
def test_move_cards(direction, card, new_coordinates):
    """
    Give mock robot the MovementCard and check if he moved to the expected coordinates.
    Check if the robot's direction remained the same.
    """
    robot = Robot(direction, (4, 7), "tester")
    robot.program = [card]
    state = get_start_state("maps/test_3.json")
    card.apply_effect(robot, state)
    assert robot.coordinates == new_coordinates
    assert robot.direction == direction
예제 #5
0
def test_robot_is_repaired_after_5th_round(damages_before, tile, damages_after):
    """
    When robot is on RepairTile he is supposed to be repaired after the 5th register.
    If he doesn't have any damages, the count remains the same as previous.
    """
    robot = Robot(Direction.N, (0, 0), "tester")
    state = State({(0, 0): [tile]}, [robot])
    robot.damages = damages_before
    robot.program = [MovementCard(100, 0) for x in range(5)]
    apply_all_effects(state)
    assert robot.damages == damages_after
예제 #6
0
def test_robots_dont_change_direction_on_rotating_belts_after_move_card(input_coordinates, input_direction):
    """
    Test robot's direction isn't changed after he is moved by card to
    rotating conveyor belt.
    """
    robot = Robot(input_direction, input_coordinates, "tester")
    robot.program = [MovementCard(100, 1)]
    board = get_board("maps/test_belts.json")
    state = State(board, [robot])
    robot.program[0].apply_effect(robot, state)
    apply_tile_effects(state, 0)
    assert robot.direction == input_direction