| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| from types import SimpleNamespace |
| from unittest.mock import MagicMock |
|
|
| import pytest |
|
|
| import lerobot.scripts.lerobot_setup_motors as motors_module |
|
|
|
|
| def test_main_registers_plugins_before_parsing(monkeypatch): |
| calls = [] |
| monkeypatch.setattr(motors_module, "register_third_party_plugins", lambda: calls.append("register")) |
| monkeypatch.setattr(motors_module, "setup_motors", lambda: calls.append("setup")) |
|
|
| motors_module.main() |
|
|
| assert calls == ["register", "setup"] |
|
|
|
|
| def test_setup_motors_accepts_third_party_device(monkeypatch): |
| device = MagicMock() |
| monkeypatch.setattr(motors_module, "make_teleoperator_from_config", lambda _: device) |
| cfg = SimpleNamespace(device=SimpleNamespace(type="third_party")) |
|
|
| motors_module.setup_motors.__wrapped__(cfg) |
|
|
| device.setup_motors.assert_called_once_with() |
|
|
|
|
| def test_setup_motors_reports_unsupported_device(monkeypatch): |
| device = object() |
| monkeypatch.setattr(motors_module, "make_teleoperator_from_config", lambda _: device) |
| cfg = SimpleNamespace(device=SimpleNamespace(type="third_party")) |
|
|
| with pytest.raises(NotImplementedError, match="third_party"): |
| motors_module.setup_motors.__wrapped__(cfg) |
|
|