diff --git a/src/blueapi/client/client.py b/src/blueapi/client/client.py index 417d7df01c..32d5890898 100644 --- a/src/blueapi/client/client.py +++ b/src/blueapi/client/client.py @@ -299,6 +299,11 @@ def get_plan(self, name: str) -> PlanModel: """ return self._rest.get_plan(name) + def print_plans(self) -> None: + """Print all available plans.""" + for name in self.plans: + print(name) + @start_as_current_span(TRACER) @deprecated("devices property") def get_devices(self) -> DeviceResponse: @@ -338,6 +343,11 @@ def get_device(self, name: str) -> DeviceModel: return self._rest.get_device(name) + def print_devices(self) -> None: + """Print all available devices.""" + for name in self.devices: + print(name) + @property @start_as_current_span(TRACER) def state(self) -> WorkerState: diff --git a/tests/unit_tests/client/test_client.py b/tests/unit_tests/client/test_client.py index 1cff107c1d..a41c22bb1d 100644 --- a/tests/unit_tests/client/test_client.py +++ b/tests/unit_tests/client/test_client.py @@ -146,6 +146,13 @@ def test_get_plan(client: BlueapiClient): assert client.plans["foo"].model == PLAN +def test_print_plans(client: BlueapiClient, capsys: pytest.CaptureFixture): + client.print_plans() + captured = capsys.readouterr() + for dev in PLANS.plans: + assert dev.name in captured.out + + def test_get_nonexistant_plan( client: BlueapiClient, ): @@ -161,6 +168,13 @@ def test_get_device(client: BlueapiClient): assert client.devices.foo.model == DEVICE +def test_print_devices(client: BlueapiClient, capsys: pytest.CaptureFixture): + client.print_devices() + captured = capsys.readouterr() + for dev in DEVICES.devices: + assert dev.name in captured.out + + def test_get_nonexistent_device( client: BlueapiClient, ):