def testExploringWithMoving(get_plateau, x, y, direction, expected_x, instructions, expected_y, expected_direction): rover = Rover(RoverPosition(RoverCoordinates(x, y), direction)) rover.explorePlateau(instructions) assert (rover.position.coordinates.x == expected_x) and (rover.position.coordinates.y == expected_y) and (rover.position.direction == expected_direction)
#Initialize Plateau plateauDimensions = reader.getPlateauDimensions() Plateau.initializePlateau(plateauDimensions) print( f"Plateau dimensions {plateauDimensions.upper_right_x}, {plateauDimensions.upper_right_y}" ) print("------------------------------------------------------------------") #Iterate on the rovers and their instructions and start explorations in sequential order for p, i in reader.getRoversandInstructions(): marsRover = Rover(p) Plateau.getInstance().addRover(marsRover) print( f"Input: {marsRover.position.coordinates.x} {marsRover.position.coordinates.y} {marsRover.position.direction}" ) marsRover.explorePlateau(i) print( f"Output: {marsRover.position.coordinates.x} {marsRover.position.coordinates.y} {marsRover.position.direction}" ) print( "------------------------------------------------------------------\n" ) print( f"The plateau has {len(Plateau.getInstance().getRovers())} rovers that were able to navigate" )
def testRoversCollision(get_plateau, x, y, direction, instructions): Plateau.getInstance().addRover( Rover(RoverPosition(RoverCoordinates(1, 1), "N"))) with pytest.raises(NextSpotNotEmptyException): rover = Rover(RoverPosition(RoverCoordinates(x, y), direction)) rover.explorePlateau(instructions)
def testMoveOutsidePlateau(get_plateau, x, y, direction, expected_x, instructions, expected_y, expected_direction): with pytest.raises(RoverOutsidePlateauException): rover = Rover(RoverPosition(RoverCoordinates(x, y), direction)) rover.explorePlateau(instructions)