Skip to content

Commit

Permalink
add reusable function for checking valid sequence locations
Browse files Browse the repository at this point in the history
  • Loading branch information
katiestahl committed Aug 3, 2024
1 parent be13369 commit 8031f47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions server/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def check_sequence_location():

def check_sequence_location(sequence_location):
assert "ga4gh:SL." in sequence_location.get("id")
assert sequence_location.get("type") == "SequenceLocation"
sequence_reference = sequence_location.get("sequenceReference", {})
assert "refseq:" in sequence_reference.get("id")
assert sequence_reference.get("refgetAccession")
Expand Down
16 changes: 6 additions & 10 deletions server/tests/integration/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def check_tx_element_response(response: dict, expected_response: dict):


@pytest.fixture(scope="session")
def check_reg_element_response():
def check_reg_element_response(check_sequence_location):
"""Provide callback function check correctness of regulatory element constructor."""

def check_re_response(response: dict, expected_response: dict):
Expand All @@ -94,15 +94,15 @@ def check_re_response(response: dict, expected_response: dict):
assert response_re.get("regulatoryClass") == expected_re.get("regulatoryClass")
assert response_re.get("featureId") == expected_re.get("featureId")
assert response_re.get("associatedGene") == expected_re.get("associatedGene")
assert response_re.get("sequenceLocation") == expected_re.get(
"sequenceLocation"
)
sequence_location = response_re.get("sequenceLocation")
if sequence_location:
check_sequence_location(sequence_location)

return check_re_response


@pytest.fixture(scope="session")
def check_templated_sequence_response():
def check_templated_sequence_response(check_sequence_location):
"""Provide callback function to check templated sequence constructor response"""

def check_temp_seq_response(response: dict, expected_response: dict):
Expand All @@ -116,11 +116,7 @@ def check_temp_seq_response(response: dict, expected_response: dict):
assert response_elem["type"] == expected_elem["type"]
assert response_elem["strand"] == expected_elem["strand"]
assert response_elem["region"]["id"] == expected_elem["region"]["id"]
assert response_elem["region"]["type"] == expected_elem["region"]["type"]
assert (
response_elem["region"]["sequenceReference"]["id"]
== expected_elem["region"]["sequenceReference"]["id"]
)
check_sequence_location(response_elem["region"] or {})
assert response_elem["region"]["start"] == expected_elem["region"]["start"]
assert response_elem["region"]["end"] == expected_elem["region"]["end"]

Expand Down

0 comments on commit 8031f47

Please sign in to comment.