-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schema4): Filter out comma-delimited ethnicity term IDs from inp…
…ut datastructures (#6126)
- Loading branch information
1 parent
c8a0f86
commit db66f11
Showing
4 changed files
with
518 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""This module tests the helper functions used in `backend.wmg.api.v2.py`. | ||
""" | ||
|
||
import pytest | ||
|
||
from backend.wmg.api.v2 import sanitize_api_query_dict | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input_query,expected_sanitized_query", | ||
[ | ||
( | ||
{ | ||
"organism_ontology_term_id": "NCBITaxon:9606", | ||
"self_reported_ethnicity_ontology_term_ids": ["HANCESTRO:0008"], | ||
}, | ||
{ | ||
"organism_ontology_term_id": "NCBITaxon:9606", | ||
"self_reported_ethnicity_ontology_term_ids": ["HANCESTRO:0008"], | ||
}, | ||
), | ||
( | ||
{ | ||
"organism_ontology_term_id": "NCBITaxon:9606", | ||
"self_reported_ethnicity_ontology_term_ids": ["HANCESTRO:0008", "HANCESTRO:0008,HANCESTOR:0021"], | ||
}, | ||
{ | ||
"organism_ontology_term_id": "NCBITaxon:9606", | ||
"self_reported_ethnicity_ontology_term_ids": ["HANCESTRO:0008"], | ||
}, | ||
), | ||
( | ||
{ | ||
"organism_ontology_term_id": "NCBITaxon:9606", | ||
"self_reported_ethnicity_ontology_term_ids": ["HANCESTRO:0008,HANCESTOR:0021"], | ||
}, | ||
{"organism_ontology_term_id": "NCBITaxon:9606", "self_reported_ethnicity_ontology_term_ids": []}, | ||
), | ||
( | ||
{"organism_ontology_term_id": "NCBITaxon:9606", "self_reported_ethnicity_ontology_term_ids": []}, | ||
{"organism_ontology_term_id": "NCBITaxon:9606", "self_reported_ethnicity_ontology_term_ids": []}, | ||
), | ||
({"organism_ontology_term_id": "NCBITaxon:9606"}, {"organism_ontology_term_id": "NCBITaxon:9606"}), | ||
], | ||
) | ||
def test_sanitize_api_query_dict(input_query, expected_sanitized_query): | ||
# NOTE: `sanitize_api_query_dict()` mutates the function argument | ||
sanitize_api_query_dict(input_query) | ||
|
||
assert input_query == expected_sanitized_query |
Oops, something went wrong.