Exemple #1
0
    def test_it_stops_before_reaching_distant_obstacle(self):
        marsrover = MarsRover(rocks=[(0, 2)])
        try:
            marsrover.execute('f')
            marsrover.execute('f')
        except ReachedObstacleError:
            pass

        self.assertEqual(marsrover.position, (0, 1))
Exemple #2
0
    def test_it_rotate_to_west_when_order_is_l_and_orientation_is_n(self):
        marsrover = MarsRover(orientation='N')

        marsrover.execute('l')

        self.assertEqual(marsrover.orientation, 'W')
Exemple #3
0
    def test_it_rotate_to_north_when_order_is_r_and_orientation_is_w(self):
        marsrover = MarsRover(orientation='W')

        marsrover.execute('r')

        self.assertEqual(marsrover.orientation, 'N')
Exemple #4
0
    def test_it_moves_back_when_order_is_b_and_orientation_is_e(self):
        marsrover = MarsRover(orientation='E', x=1)

        marsrover.execute('b')

        self.assertEquals(marsrover.position, (0, 0))
Exemple #5
0
    def test_it_moves_front_when_order_is_f_and_orientation_is_w(self):
        marsrover = MarsRover(orientation='W', x=1)

        marsrover.execute('f')

        self.assertEquals(marsrover.position, (0, 0))
Exemple #6
0
    def test_it_turns_left_when_order_is_l(self):
        marsrover = MarsRover()

        marsrover.execute('l')

        self.assertEquals(marsrover.orientation, 'W')
Exemple #7
0
    def test_it_turns_right_when_order_is_r(self):
        marsrover = MarsRover()

        marsrover.execute('r')

        self.assertEquals(marsrover.orientation, 'E')
Exemple #8
0
    def test_it_moves_back_when_order_is_b(self):
        marsrover = MarsRover(y=1)

        marsrover.execute('b')

        self.assertEquals(marsrover.position, (0, 0))
Exemple #9
0
    def test_it_moves_front_when_order_is_f(self):
        marsrover = MarsRover()

        marsrover.execute('f')

        self.assertEquals(marsrover.position, (0, 1))
def test_rover_can_wrap_around_different_sized_grids():
    grid = Grid(5, 8)
    curiosity = MarsRover(grid)
    curiosity.execute("LMLM")
    assert curiosity.get_location() == "4:7:S"
def test_rover_can_move_around_obstacle():
    grid = Grid(10, 10, Position(0, 4))
    curiosity = MarsRover(grid)
    curiosity.execute("MMMMMMRMLMMLMRM")
    assert curiosity.get_location() == "0:6:N"
def test_rover_cannot_move_through_obstacle():
    grid = Grid(10, 10, Position(0, 4))
    curiosity = MarsRover(grid)
    curiosity.execute("MMMMMM")
    assert curiosity.get_location() == "O:0:3:N"