Skip to content

Commit 3ad951e

Browse files
committed
Update system tests
1 parent 9e2b30e commit 3ad951e

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

tests/system_tests/test_blueapi_system.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
BlueskyRemoteControlError,
1818
)
1919
from blueapi.client.event_bus import AnyEvent, BlueskyStreamingError
20-
from blueapi.client.rest import BlueskyRequestError
21-
from blueapi.client.rest import BlueapiRestClient, UnknownPlanError
20+
from blueapi.client.rest import BlueapiRestClient, BlueskyRequestError
2221
from blueapi.config import (
2322
ApplicationConfig,
2423
ConfigLoader,
@@ -170,18 +169,15 @@ def expected_devices() -> DeviceResponse:
170169

171170

172171
@pytest.fixture
173-
def blueapi_client_get_methods() -> list[str]:
172+
def blueapi_rest_client_get_methods() -> list[str]:
174173
# Get a list of methods that take only one argument (self)
175-
# This will currently return
176-
# ['get_plans', 'get_devices', 'get_state', 'get_all_tasks',
177-
# 'get_active_task','get_environment','resume', 'stop','get_oidc_config']
178174
return [
179-
method
180-
for method in BlueapiClient.__dict__
181-
if callable(getattr(BlueapiClient, method))
182-
and not method.startswith("__")
183-
and len(inspect.signature(getattr(BlueapiClient, method)).parameters) == 1
184-
and "self" in inspect.signature(getattr(BlueapiClient, method)).parameters
175+
name
176+
for name, method in BlueapiRestClient.__dict__.items()
177+
if not name.startswith("__")
178+
and callable(method)
179+
and len(params := inspect.signature(method).parameters) == 1
180+
and "self" in params
185181
]
186182

187183

@@ -220,14 +216,14 @@ def reset_numtracker(server_config: ApplicationConfig):
220216

221217

222218
def test_cannot_access_endpoints(
223-
client_without_auth: BlueapiClient, blueapi_client_get_methods: list[str]
219+
client_without_auth: BlueapiClient, blueapi_rest_client_get_methods: list[str]
224220
):
225-
blueapi_client_get_methods.remove(
221+
blueapi_rest_client_get_methods.remove(
226222
"get_oidc_config"
227223
) # get_oidc_config can be accessed without auth
228-
for get_method in blueapi_client_get_methods:
224+
for get_method in blueapi_rest_client_get_methods:
229225
with pytest.raises(BlueskyRemoteControlError, match=r"<Response \[401\]>"):
230-
getattr(client_without_auth, get_method)()
226+
getattr(client_without_auth._rest, get_method)()
231227

232228

233229
def test_can_get_oidc_config_without_auth(client_without_auth: BlueapiClient):
@@ -248,7 +244,7 @@ def test_get_plans(rest_client: BlueapiRestClient, expected_plans: PlanResponse)
248244

249245
def test_get_plans_by_name(client: BlueapiClient, expected_plans: PlanResponse):
250246
for plan in expected_plans.plans:
251-
assert getattr(client.plans, plan.name).model == plan
247+
assert client.plans[plan.name].model == plan
252248

253249

254250
def test_get_non_existent_plan(rest_client: BlueapiRestClient):

0 commit comments

Comments
 (0)