def test_robot_place(self): subject = Robot() subject.place('4,2,EAST') self.assertEqual(subject.x, 4) self.assertEqual(subject.y, 2) self.assertEqual(subject.facing, 'EAST')
def test_move_on_robot_placed(input_params, x, y, direction): robot = Robot() robot.place(input_params) robot.move() assert robot.x_coordinate == x assert robot.y_coordinate == y assert robot.facing == direction
def test_robot_move_east_from_place_2_2_east(self): subject = Robot() subject.place('2,2,EAST') subject.move() self.assertEqual(subject.x, 3) self.assertEqual(subject.y, 2) self.assertEqual(subject.facing, 'EAST')
def test_robot_move_south_from_place_2_2_south(self): subject = Robot() subject.place('2,2,SOUTH') subject.move() self.assertEqual(subject.x, 2) self.assertEqual(subject.y, 1) self.assertEqual(subject.facing, 'SOUTH')
def test_robot_move_north_from_place_2_2_north(self): subject = Robot() subject.place('2,2,NORTH') subject.move() self.assertEqual(subject.x, 2) self.assertEqual(subject.y, 3) self.assertEqual(subject.facing, 'NORTH')
def test_robot_move_west_from_place_2_2_west(self): subject = Robot() subject.place('2,2,WEST') subject.move() self.assertEqual(subject.x, 1) self.assertEqual(subject.y, 2) self.assertEqual(subject.facing, 'WEST')
def test_move_for_robot_out_of_bounds(input_params, x, y, direction): with pytest.raises(MoveOutOfBoundsException) as e: robot = Robot() robot.place(input_params) robot.move() assert str(e.value) == 'Cannot move robot. Coordinates out of bound.' assert robot.x_coordinate == x assert robot.y_coordinate == y assert robot.facing == direction
def test_report_on_robot_placed(capsys): robot = Robot() robot.place([0, 0, 'NORTH']) robot.report() assert robot.x_coordinate == 0 assert robot.y_coordinate == 0 assert robot.facing == 'NORTH' captured = capsys.readouterr() assert captured.out.replace('\n', '') == 'Output: 0, 0, NORTH'
def test_place_with_valid_params(): robot = Robot() robot.place([0, 0, 'NORTH']) assert robot.x_coordinate == 0 assert robot.y_coordinate == 0 assert robot.facing == 'NORTH'
def test_turn_left_on_robot_placed(input_params, expected_direction): robot = Robot() robot.place(input_params) robot.turn_left() assert robot.facing == expected_direction