def test_does_not_move_into_obstacle(self): rover = Rover((2, 3), 'E', [(3, 3)]) rover.move(['f']) assert rover.position == (2, 3)
def test_turn_move_n_4(self): '''Test that direction stays the same after and y is increased by 1 after a move north''' rover = Rover([5, 5], [1, 2, 'N']) self.assertEqual(rover.move('M'), '1 3 N')
def test_11(self): '''Test that direction and coordinates are what they should be after a sequence of moves''' rover = Rover([5, 5], [1, 2, 'N']) self.assertEqual(rover.move('LMLMLMLMM'), '1 3 N')
def test_turn_right_4(self): '''Test that direction stays the same after 4 turns to the right''' rover = Rover([5, 5], [1, 2, 'W']) self.assertEqual(rover.move('R' * 4), '1 2 W')
def test_turn_move_e_2(self): '''Test that direction stays the same after and x is decreased by 1 after a move east''' rover = Rover([5, 5], [1, 2, 'E']) self.assertEqual(rover.move('M'), '0 2 E')
def test_turn_left_1(self): '''Test that direction changes from N to E''' rover = Rover([5, 5], [1, 2, 'N']) self.assertEqual(rover.move('L'), '1 2 E')
def test_turn_right_1(self): '''Test that direction changes from N to W''' rover = Rover([5, 5], [1, 2, 'N']) self.assertEqual(rover.move('R'), '1 2 W')
def test_moves_forwards_north(self): rover = Rover((3, 3), 'N') rover.move(['f', 'f']) assert rover.position == (3, 5)
def test_moves_forwards_east(self): rover = Rover((3, 3), 'E') rover.move(['f', 'f']) assert rover.position == (5, 3)
def test_turns_right_twice(self): rover = Rover((3, 3), 'N') rover.move(['r', 'r']) assert rover.direction == 'S'
def test_turns_right_four_times(self): rover = Rover((3, 3), 'N') rover.move(['r', 'r', 'r', 'r']) assert rover.direction == 'N'
def test_reports_the_obstacle(self): rover = Rover((3, 3), 'N', [(1, 1), (3, 4)]) obstacle = rover.move(['f', 'l', 'f']) assert obstacle == (3, 4)
def test_does_not_move_again_after_hitting_obstacle(self): rover = Rover((3, 3), 'N', [(3, 4)]) rover.move(['f', 'l', 'f']) assert rover.position == (3, 3)
def test_does_not_move_backward_into_obstacle(self): rover = Rover((3, 3), 'N', [(3, 2)]) rover.move(['b']) assert rover.position == (3, 3)
def test_ignores_unrecognised_instruction(self): rover = Rover((3, 3), 'N') rover.move(['x']) assert rover.position == (3, 3)
def test_moves_forwards_south(self): rover = Rover((3, 3), 'S') rover.move(['f', 'f']) assert rover.position == (3, 1)
def test_moves_forwards_around_mars_to_east(self): rover = Rover((3, 3), 'E') rover.move(['f', 'f', 'f']) assert rover.position == (1, 3)
def test_moves_forwards_west(self): rover = Rover((3, 3), 'W') rover.move(['f']) assert rover.position == (2, 3)
def test_turn_left_2(self): '''Test that direction changes from W to N''' rover = Rover([5, 5], [1, 2, 'W']) self.assertEqual(rover.move('L'), '1 2 N')
def test_moves_backwards_facing_north(self): rover = Rover((3, 3), 'N') rover.move(['b']) assert rover.position == (3, 2)
def test_turn_right_2(self): '''Test that direction changes from W to S''' rover = Rover([5, 5], [1, 2, 'W']) self.assertEqual(rover.move('R'), '1 2 S')
def test_moves_backwards_facing_east(self): rover = Rover((3, 3), 'E') rover.move(['b', 'b']) assert rover.position == (1, 3)
def test_turn_move_w_1(self): '''Test that direction stays the same after and x is increased by 1 after a move west''' rover = Rover([5, 5], [1, 2, 'W']) self.assertEqual(rover.move('M'), '2 2 W')
def test_moves_backwards_facing_south(self): rover = Rover((2, 2), 'S') rover.move(['b']) assert rover.position == (2, 3)
def test_turn_move_s_3(self): '''Test that direction stays the same after and y is decreased by 1 after a move south''' rover = Rover([5, 5], [1, 2, 'S']) self.assertEqual(rover.move('M'), '1 1 S')
def test_moves_backwards_facing_west(self): rover = Rover((2, 2), 'W') rover.move(['b']) assert rover.position == (3, 2)
def test_turn_move_limits_8(self): '''Test that direction and coordinates stays the same when rover has command to move outside limits''' rover = Rover([5, 5], [5, 5, 'N']) self.assertEqual(rover.move('M'), '5 5 N')
def test_turns_left_twice(self): rover = Rover((3, 3), 'N') rover.move(['l', 'l']) assert rover.direction == 'S'
def test_12(self): '''Test that direction and coordinates are what they should be after a sequence of moves''' rover = Rover([5, 5], [3, 3, 'E']) self.assertEqual(rover.move('MMRMMRMRRM'), '1 5 E')
def test_moves_backwards_over_north_pole(self): rover = Rover((1, 5), 'S') rover.move(['b']) assert rover.position == (5, 5) assert rover.direction == 'N'