def test_position_validation(self): plateau = Plateau(x=10, y=10) position = Position(x=5, y=5, direction=Direction.NORTH) self.assertTrue(plateau.isValidPosition(position))
def test_invalid_position_validation_y_out_of_bounds(self): plateau = Plateau(x=10, y=10) position = Position(x=5, y=99, direction=Direction.NORTH) self.assertFalse(plateau.isValidPosition(position)) position = Position(x=5, y=-1, direction=Direction.NORTH) self.assertFalse(plateau.isValidPosition(position))
def test_instantiation_from_invalid__with_wrong_argnumber(self): str_pos = '1 2' # x, y, and direction position_from_string = Position.from_string(str_pos)
def test_object_instantiation(self): pos = Position(x=1, y=2, direction='n') self.assertIsInstance(pos, Position)
def test_instantiation_from_invalid_string_with_wrong_xy(self): str_pos = 'someRandomInt 2 n' # x, y, and direction position_from_string = Position.from_string(str_pos)
def test_instantiation_from_invalid_string_with_wrong_direction(self): str_pos = '1 2 someInvalidCharacter' # x, y, and direction position_from_string = Position.from_string(str_pos)
def test_invalid_object_instantiation_invalid_direction2(self): pos = Position(x=1, y='notIntValue', direction=1)
def test_instantiation_from_valid_string(self): pos = Position(x=1, y=2, direction='n') str_pos = '1 2 n' # x, y, and direction position_from_string = Position.from_string(str_pos) self.assertEqual(pos, position_from_string)
def test_invalid_object_instantiation_invalid_x(self): pos = Position(x='notIntValue', y=2, direction='n')
def test_object_instantiation(self): plateau = Plateau(x=10, y=10) position = Position(x=10, y=10, direction=Direction.NORTH) rover = Rover(plateau, position) self.assertIsInstance(rover, Rover)
def test_invalid_movement_out_of_boundaries(self): plateau = Plateau(x=10, y=10) position = Position(x=10, y=10, direction=Direction.NORTH) rover = Rover(plateau, position) rover.move_forward()
def test_rotation_right(self): plateau = Plateau(x=10, y=10) position = Position(x=10, y=10, direction=Direction.NORTH) rover = Rover(plateau, position) rover.rotate_right() self.assertEqual(rover.position.direction, Direction.EAST)
def test_invalid_object_instantiation_wrong_plateau_object(self): lateau = (5, 5) position = Position(x=10, y=10, direction=Direction.NORTH) rover = Rover(plateau, position)