Skip to content

Commit 6115b04

Browse files
authored
test: Reset numtracker config before running tests (#1241)
Using a fixture to initialise the numtracker configuration allows the tests to be run repeatedly without restarting the containers.
1 parent 812c427 commit 6115b04

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

tests/system_tests/compose.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ services:
66
image: ghcr.io/diamondlightsource/numtracker:1.0.1
77
ports:
88
- "8406:8000"
9-
post_start:
10-
- command: /app/numtracker client configure adsim --directory '/tmp/' --scan '{instrument}-{scan_number}' --detector '{instrument}-{scan_number}-{detector}' --number 43
11-
9+
1210
rabbitmq:
1311
image: docker.io/rabbitmq:4.0-management
1412
ports:

tests/system_tests/test_blueapi_system.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from blueapi.client.rest import UnknownPlan
1919
from blueapi.config import (
2020
ApplicationConfig,
21+
ConfigLoader,
2122
OIDCConfig,
2223
StompConfig,
2324
)
@@ -155,6 +156,33 @@ def clean_existing_tasks(client: BlueapiClient):
155156
yield
156157

157158

159+
@pytest.fixture(scope="module")
160+
def server_config() -> ApplicationConfig:
161+
loader = ConfigLoader(ApplicationConfig)
162+
loader.use_values_from_yaml(Path("tests", "system_tests", "config.yaml"))
163+
return loader.load()
164+
165+
166+
@pytest.fixture(autouse=True, scope="module")
167+
def reset_numtracker(server_config: ApplicationConfig):
168+
nt_url = server_config.numtracker.url # type: ignore - if numtracker is None we should fail
169+
requests.post(
170+
str(nt_url),
171+
json={
172+
"query": """mutation {
173+
configure(instrument: "adsim",
174+
config: {directory: "/tmp/",
175+
scan: "{instrument}-{scan_number}",
176+
detector: "{instrument}-{scan_number}-{detector}",
177+
scanNumber: 43}) {
178+
scanTemplate
179+
}
180+
}"""
181+
},
182+
).raise_for_status()
183+
yield
184+
185+
158186
@pytest.mark.xfail(reason=_REQUIRES_AUTH_MESSAGE)
159187
def test_cannot_access_endpoints(
160188
client_without_auth: BlueapiClient, blueapi_client_get_methods: list[str]

0 commit comments

Comments
 (0)