Skip to content

Commit

Permalink
test: test logic related to setting of Document pid #314
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Feb 10, 2022
1 parent 736c6bd commit 07d6a8e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 15 additions & 3 deletions test/search_api/filters/test_search_api_where_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TestSearchAPIWhereFilter:
SearchAPIWhereFilter("pid", "pid:1", "eq"),
"Dataset",
"SELECT o FROM Dataset o WHERE o.id = '1'",
id="Pid dataset value (mapping that maps to multiple ICAT fields)",
id="Id dataset value (mapping that maps to multiple ICAT fields)",
),
pytest.param(
# DataGateway API date format: "2018-05-05 15:00:00"
Expand All @@ -42,6 +42,18 @@ class TestSearchAPIWhereFilter:
" '2018-05-05T15:00:00.000Z'",
id="WHERE filter with date value",
),
pytest.param(
SearchAPIWhereFilter("pid", "1", "eq"),
"Document",
"SELECT o FROM Investigation o WHERE o.doi = '1'",
id="Doi document value (mapping that maps to multiple ICAT fields)",
),
pytest.param(
SearchAPIWhereFilter("pid", "pid:1", "eq"),
"Document",
"SELECT o FROM Investigation o WHERE o.id = '1'",
id="Id document value (mapping that maps to multiple ICAT fields)",
),
pytest.param(
SearchAPIWhereFilter("facility", "ISIS", "like"),
"Instrument",
Expand Down Expand Up @@ -83,13 +95,13 @@ class TestSearchAPIWhereFilter:
SearchAPIWhereFilter("samples.pid", "1", "eq"),
"Dataset",
"SELECT o FROM Dataset o JOIN o.sample AS s1 WHERE s1.pid = '1'",
id="Id sample value (mapping that maps to multiple ICAT fields)",
id="Pid sample value (mapping that maps to multiple ICAT fields)",
),
pytest.param(
SearchAPIWhereFilter("samples.pid", "pid:1", "eq"),
"Dataset",
"SELECT o FROM Dataset o JOIN o.sample AS s1 WHERE s1.id = '1'",
id="Pid sample value (mapping that maps to multiple ICAT fields)",
id="Id sample value (mapping that maps to multiple ICAT fields)",
),
pytest.param(
SearchAPIWhereFilter("parameters.value", "My Parameter", "eq"),
Expand Down
3 changes: 3 additions & 0 deletions test/search_api/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,14 @@ def test_from_icat_document_entity_with_data_for_mandatory_related_entities(self

def test_from_icat_document_entity_with_data_for_all_related_entities(self):
expected_entity_data = DOCUMENT_PANOSC_DATA.copy()
expected_entity_data["pid"] = f"pid:{INVESTIGATION_ICAT_DATA['id']}"
expected_entity_data["doi"] = None
expected_entity_data["datasets"] = [DATASET_PANOSC_DATA, DATASET_PANOSC_DATA]
expected_entity_data["members"] = [MEMBER_PANOSC_DATA]
expected_entity_data["parameters"] = [PARAMETER_PANOSC_DATA]

icat_data = INVESTIGATION_ICAT_DATA.copy()
icat_data["doi"] = None
icat_data["type"] = INVESTIGATION_TYPE_ICAT_DATA
icat_data["keywords"] = [KEYWORD_ICAT_DATA]
icat_data["datasets"] = [DATASET_ICAT_DATA, DATASET_ICAT_DATA]
Expand Down

0 comments on commit 07d6a8e

Please sign in to comment.