Skip to content

Commit

Permalink
Add unit tests for sim_config module
Browse files Browse the repository at this point in the history
  • Loading branch information
ll7 committed Mar 6, 2024
1 parent 6bd3342 commit 43aa423
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/sim_config_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pytest
from robot_sf.sim_config import (
EnvSettings,
SimulationSettings,
LidarScannerSettings,
DifferentialDriveSettings,
BicycleDriveSettings,
MapDefinitionPool,
DifferentialDriveRobot,
BicycleDriveRobot)

def test_env_settings_initialization():
env_settings = EnvSettings()
assert isinstance(env_settings.sim_config, SimulationSettings)
assert isinstance(env_settings.lidar_config, LidarScannerSettings)
assert isinstance(env_settings.robot_config, DifferentialDriveSettings)
assert isinstance(env_settings.map_pool, MapDefinitionPool)

def test_env_settings_post_init():
with pytest.raises(ValueError):
env_settings = EnvSettings(sim_config=None)

def test_robot_factory():
env_settings = EnvSettings()
robot = env_settings.robot_factory()
assert isinstance(robot, DifferentialDriveRobot)

env_settings.robot_config = BicycleDriveSettings()
robot = env_settings.robot_factory()
assert isinstance(robot, BicycleDriveRobot)

with pytest.raises(NotImplementedError):
env_settings.robot_config = "unsupported type"
env_settings.robot_factory()

0 comments on commit 43aa423

Please sign in to comment.