def test_robot_has_been_placed(position, want): robot = Robot() robot.position = position got = robot.has_been_placed() assert got == want
def test_turn_left__only_changes_facing_direction(): robot = Robot() robot.position = Position(3, 2, Direction.SOUTH) robot.turn_left() assert robot.position == Position(3, 2, Direction.EAST)
def test_move_forward__moves_the_robot_in_its_facing_direction( current_position, new_position, table): robot = Robot() robot.position = current_position table.move_forward(robot) assert robot.position == new_position
def test_move_forward__raises_exception_when_the_next_position_is_off_the_table( current_position, table): robot = Robot() robot.position = deepcopy(current_position) with pytest.raises(InvalidPositionError): table.move_forward(robot) assert robot.position == current_position
def test_place__sets_the_correct_position_for_the_robot(table): robot = Robot() x, y, facing = 2, 3, Direction.EAST table.place(robot, x, y, facing) assert robot.position.x == x assert robot.position.y == y assert robot.position.facing == facing
def __init__(self): self.table = Table(5, 5) self.robot = Robot()
def test_place__raises_exception_when_position_is_invalid(table): robot = Robot() x, y, facing = -1, 3, Direction.SOUTH with pytest.raises(InvalidPositionError): table.place(robot, x, y, facing)