def test_parameters(self): # Create asteroid x, y = 15, 25 asteroid = Asteroid(x, y) # Create obstacles x_a, y_a = 10, 10 obstacle = Obstacle(x_a, y_a) # Add obstacle to Asteroid asteroid.add_obstacle(obstacle) assert asteroid.get_obstacle_count() == 1 # Create robot direction = "E" robot = Robot(x, y, asteroid, direction) # Check robot/asteroid/obstacle creation assert robot.x == 15 assert robot.y == 25 assert robot.direction == direction assert robot.asteroid == asteroid robot.set_direction("N") assert robot.direction == "N" assert obstacle.x == 10 assert obstacle.y == 10
def test_check_if_robot_on_asteroid(self, asteroid_size, robot_obstacle_coordinates): obstacle = Obstacle(*robot_obstacle_coordinates) asteroid = Asteroid(*asteroid_size) robot = Robot(*robot_obstacle_coordinates, asteroid, "W") with pytest.raises(MissAsteroidError): asteroid.check_obstacle_position(obstacle) robot.check_position_on_asteroid() with pytest.raises(ObstacleCrashError): asteroid.add_obstacle(obstacle) robot.check_for_block()