Skip to content

Commit 0fa0571

Browse files
fix tests
1 parent 37fb5e5 commit 0fa0571

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

tests/unit/test_schemas.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Test schema validation functionality"""
22

3+
import os
34
import re
45

56
import pytest
67

78
from anyvlm.schemas.vlm import (
9+
BeaconHandover,
810
HandoverType,
911
ResponseField,
1012
ResponseSummary,
@@ -16,7 +18,22 @@
1618

1719
@pytest.fixture(scope="module")
1820
def valid_handover_id() -> str:
19-
return HandoverType().id
21+
return os.environ.get("HANDOVER_TYPE_ID") # type: ignore
22+
23+
24+
@pytest.fixture(scope="module")
25+
def beacon_handovers(valid_handover_id: str) -> list[BeaconHandover]:
26+
handover_type = HandoverType(
27+
id=valid_handover_id,
28+
label=os.environ.get("HANDOVER_TYPE_LABEL"), # type: ignore
29+
)
30+
31+
return [
32+
BeaconHandover(
33+
handoverType=handover_type,
34+
url=os.environ.get("BEACON_HANDOVER_URL"), # type: ignore
35+
)
36+
]
2037

2138

2239
@pytest.fixture(scope="module")
@@ -25,7 +42,7 @@ def response_summary() -> ResponseSummary:
2542

2643

2744
@pytest.fixture(scope="module")
28-
def responses_with_invalid_resultset_ids(valid_handover_id) -> list[ResponseField]:
45+
def responses_with_invalid_resultset_ids(valid_handover_id: str) -> list[ResponseField]:
2946
return [
3047
ResponseField(
3148
resultSets=[
@@ -54,7 +71,11 @@ def responses_with_invalid_resultset_ids(valid_handover_id) -> list[ResponseFiel
5471
]
5572

5673

57-
def test_valid_resultset_id(response_summary, valid_handover_id):
74+
def test_valid_resultset_id(
75+
valid_handover_id: str,
76+
beacon_handovers: list[BeaconHandover],
77+
response_summary: ResponseSummary,
78+
):
5879
response = ResponseField(
5980
resultSets=[
6081
ResultSet(
@@ -65,18 +86,30 @@ def test_valid_resultset_id(response_summary, valid_handover_id):
6586
)
6687

6788
# Should NOT raise an error
68-
vlm_response = VlmResponse(responseSummary=response_summary, response=response)
89+
vlm_response = VlmResponse(
90+
beaconHandovers=beacon_handovers,
91+
responseSummary=response_summary,
92+
response=response,
93+
)
6994

7095
assert (
7196
vlm_response.response.resultSets[0].id
7297
== f"{valid_handover_id} {Zygosity.HOMOZYGOUS}"
7398
)
7499

75100

76-
def test_invalid_resultset_ids(response_summary, responses_with_invalid_resultset_ids):
101+
def test_invalid_resultset_ids(
102+
response_summary: ResponseSummary,
103+
responses_with_invalid_resultset_ids: list[ResponseField],
104+
beacon_handovers: list[BeaconHandover],
105+
):
77106
for response in responses_with_invalid_resultset_ids:
78107
with pytest.raises(
79108
ValueError,
80109
match=re.escape(VlmResponse.resultset_id_error_message_base),
81110
):
82-
VlmResponse(responseSummary=response_summary, response=response)
111+
VlmResponse(
112+
beaconHandovers=beacon_handovers,
113+
responseSummary=response_summary,
114+
response=response,
115+
)

0 commit comments

Comments
 (0)