Exemplo n.º 1
0
 def test_execute_instructions_raise_invalid_coordinate_exception(self):
     """
     Test for Invalid Coordinate exception if rover is moved out of Plateau grid dimensions
     """
     with self.assertRaises(InvalidCoordinateError):
         rover = Rover(self.plateau_dimensions, self.rover_initial_position,
                       Rover.DIRECTIONS.get('E'))
         rover.execute_instructions('RMMM')
Exemplo n.º 2
0
 def test_rover_position(self):
     """
     Test rover position after performing movements
     """
     rover = Rover(self.plateau_dimensions, self.rover_initial_position,
                   Rover.DIRECTIONS.get('E'))
     rover.execute_instructions("LMLM")
     self.assertEqual(rover._position.x, 1)
     self.assertEqual(rover._position.y, 2)
     self.assertEqual(rover.get_heading, 'W')
Exemplo n.º 3
0
def test_deploy_multiple_rovers(plateau):
    rover_a = Rover(name='RoverA', initial_position=(1, 2, 'N'))
    plateau.deploy_rover(rover_a)
    rover_a.execute_instructions('LMLMLMLMM')
    assert rover_a.current_position == 'RoverA:1 3 N'

    rover_b = Rover(name='RoverB', initial_position=(3, 3, 'E'))
    plateau.deploy_rover(rover_b)
    rover_b.execute_instructions('MMRMMRMRRM')
    assert rover_b.current_position == 'RoverB:5 1 E'

    assert len(plateau.deployed_rovers()) == 2
Exemplo n.º 4
0
def test_should_stop_before_collision(plateau):
    rover_a = Rover(name='RoverA', initial_position=(1, 2, 'N'))
    plateau.deploy_rover(rover_a)
    rover_a.execute_instructions('LMLMLMLMM')  # 1 3 N
    assert rover_a.current_position == 'RoverA:1 3 N'

    rover_b = Rover(name='RoverB', initial_position=(3, 3, 'E'))
    plateau.deploy_rover(rover_b)
    executed_instructions = rover_b.execute_instructions('LLMMMRMLM')
    assert rover_b.current_position == 'RoverB:2 3 W'
    assert executed_instructions == 'LLM'

    assert len(plateau.deployed_rovers()) == 2