コード例 #1
0
 def test_check_if_robot_falls_from_asteroid(self, robot_direction,
                                             asteroid_size,
                                             robot_coordinates):
     with pytest.raises(RobotHasFallFromAsteroidError):
         asteroid = Asteroid(*asteroid_size)
         robot = Robot(*robot_coordinates, asteroid, *robot_direction)
         robot.move_forward()
コード例 #2
0
 def test_if_robot_fell(self):
     x, y = 10, 15
     asteroid = Asteroid(x + 1, y + 1)
     robot = Robot(x, y, asteroid, "E")
     with pytest.raises(ValueError):
         robot.move_forward(100)
     with pytest.raises(ValueError):
         robot.move_backward(100)
コード例 #3
0
 def test_move_forward(self, current_direction, current_x, current_y,
                       expected_x, expected_y):
     asteroid = Asteroid(5, 5)
     robot = Robot(current_x, current_y, asteroid, current_direction)
     assert robot.x == current_x and robot.y == current_y
     robot.move_forward()
     assert robot.x == expected_x and robot.y == expected_y
     with pytest.raises(MovementError):
         robot.check_robot_location()
コード例 #4
0
    def test_move_forward(self, current_direction, robot_coordinates,
                          expected_coordinates):
        robot = Robot(*robot_coordinates, self.asteroid, current_direction)
        robot.move_forward()
        assert (robot.x, robot.y) == expected_coordinates

        # check if robot falls from asteroid during movement
        with pytest.raises(RobotFallsFromAsteroidError):
            robot.check_robot_falls_from_asteroid()
            assert robot_coordinates == (robot.x, robot.y)
コード例 #5
0
 def test_move_forward(self, current_direction, current_x, current_y,
                       expected_x, expected_y):
     obstacle = Obstacle(expected_x, expected_y)
     self.asteroid.add_obstacle(obstacle)
     robot = Robot(current_x, current_y, self.asteroid, current_direction)
     robot.move_forward()
     assert robot.x == expected_x and robot.y == expected_y
     # Check if it try to falls from asteroid during movement or get obstacle
     with pytest.raises(MissAsteroidError):
         robot.check_position_on_asteroid()
     with pytest.raises(ObstacleCrashError):
         robot.check_for_block()
コード例 #6
0
 def test_move_forward(self, current_direction, expected_x, expected_y):
     robot = Robot(self.x, self.y, self.asteroid, current_direction)
     assert robot.move_forward() == expected_x + expected_y
コード例 #7
0
 def test_move_forward(self, direction, current_position,
                       expected_position):
     robot = Robot(self.x, self.y, self.direction, self.asteroid)
     robot.move_forward()
     assert robot.x, robot.y == expected_position
コード例 #8
0
 def test_check_if_robot_can_move_forward(self, direction,
                                          robot_coordinates):
     with pytest.raises(EndAsteroidError):
         robot = Robot(*robot_coordinates, self.asteroid, direction)
         robot.move_forward()
コード例 #9
0
 def test_move_forward(self, direction, stop_point):
     robot = Robot(self.x, self.y, self.asteroid, direction)
     robot.move_forward()
     assert robot.x == stop_point[0]
     assert robot.y == stop_point[1]
コード例 #10
0
 def test_check_for_obstacles_when_move_forward(self, direction,
                                                robot_coordinates):
     with pytest.raises(ObstaclesOnAsteroidError):
         robot = Robot(*robot_coordinates, self.asteroid, direction)
         robot.move_forward()
コード例 #11
0
 def test_move_forward(self, current_direction, steps, expect_pos):
     robot = Robot(self.x, self.y, self.asteroid, current_direction)
     robot.move_forward(steps)
     assert robot.x, robot.y == expect_pos
コード例 #12
0
 def test_move_forward(self, current_direction, current_position, expected_position):
     robot = Robot(*current_position, self.asteroid, current_direction)
     robot.move_forward()
     assert (robot.x, robot.y) == expected_position
コード例 #13
0
 def test_check_robot_fall_move_forward(self, asteroid_size, robot_coordinates, current_direction):
     with pytest.raises(RobotFallFromAsteroidError):
         asteroid = Asteroid(*asteroid_size)
         robot = Robot(*robot_coordinates, asteroid, *current_direction)
         robot.move_forward()
コード例 #14
0
 def test_move_forward(self, direction, distance, expected_position):
     robot = Robot(self.x, self.y, self.asteroid, direction)
     robot.move_forward(distance)
     assert robot.x == expected_position or robot.y == expected_position
コード例 #15
0
 def test_robot_fall_forward(self, direction, distance, expected_x, expected_y):
     with pytest.raises(RobotFallError):
         robot = Robot(self.x, self.y, self.asteroid, direction)
         robot.move_forward(distance)