Skip to content

Commit

Permalink
:Wait for server to start in system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
callumforrester committed Dec 16, 2024
1 parent 75cb3bb commit fc089eb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/system_tests/test_blueapi_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from bluesky_stomp.models import BasicAuthentication
from pydantic import TypeAdapter
from requests.exceptions import ConnectionError

from blueapi.client.client import (
BlueapiClient,
Expand Down Expand Up @@ -43,7 +44,7 @@


@pytest.fixture
def client_without_auth(tmp_path) -> BlueapiClient:
def client_without_auth(tmp_path: Path) -> BlueapiClient:
return BlueapiClient.from_config(config=ApplicationConfig(auth_token_path=tmp_path))


Expand All @@ -58,6 +59,22 @@ def client_with_stomp() -> BlueapiClient:
)


@pytest.fixture(scope="module", autouse=True)
def wait_for_server():
client = BlueapiClient.from_config(config=ApplicationConfig())

attempts_remaining = 20
while attempts_remaining > 0:
try:
client.get_environment()
return
except ConnectionError:
...
attempts_remaining -= 1
time.sleep(0.5)
raise TimeoutError("No connection to the blueapi server")


# This client will have auth enabled if it finds cached valid token
@pytest.fixture
def client() -> BlueapiClient:
Expand Down

0 comments on commit fc089eb

Please sign in to comment.