38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import importlib.util
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from launch import LaunchContext
|
|
from launch.actions import DeclareLaunchArgument
|
|
from launch.utilities import perform_substitutions
|
|
|
|
|
|
MODULE_PATH = Path(__file__).parents[1] / "launch" / "arm_debug.launch.py"
|
|
SPEC = importlib.util.spec_from_file_location("arm_debug_launch", MODULE_PATH)
|
|
arm_debug_launch = importlib.util.module_from_spec(SPEC)
|
|
assert SPEC.loader is not None
|
|
SPEC.loader.exec_module(arm_debug_launch)
|
|
|
|
|
|
def test_launch_declares_mujoco_disabled_by_default() -> None:
|
|
description = arm_debug_launch.generate_launch_description()
|
|
arguments = {
|
|
entity.name: entity
|
|
for entity in description.entities
|
|
if isinstance(entity, DeclareLaunchArgument)
|
|
}
|
|
|
|
assert "use_mujoco" in arguments
|
|
assert perform_substitutions(
|
|
LaunchContext(),
|
|
arguments["use_mujoco"].default_value,
|
|
) == "false"
|
|
|
|
|
|
def test_mujoco_mode_requires_both_arms() -> None:
|
|
arm_debug_launch._validate_mujoco_mode("both", True)
|
|
arm_debug_launch._validate_mujoco_mode("left", False)
|
|
|
|
with pytest.raises(ValueError, match="arm:=both"):
|
|
arm_debug_launch._validate_mujoco_mode("left", True)
|