Skip to content
10 changes: 10 additions & 0 deletions src/blueapi/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions tests/unit_tests/client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
):
Expand All @@ -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,
):
Expand Down
Loading