Skip to content

Commit

Permalink
test: test logic related to setting of Dataset pid #314
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Feb 10, 2022
1 parent b813f3d commit 559e8b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 12 additions & 0 deletions test/search_api/filters/test_search_api_where_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ class TestSearchAPIWhereFilter:
"SELECT o FROM Dataset o WHERE o.name != 'My Dataset 1'",
id="WHERE filter with non-default operator",
),
pytest.param(
SearchAPIWhereFilter("pid", "1", "eq"),
"Dataset",
"SELECT o FROM Dataset o WHERE o.doi = '1'",
id="Doi dataset value (mapping that maps to multiple ICAT fields)",
),
pytest.param(
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)",
),
pytest.param(
# DataGateway API date format: "2018-05-05 15:00:00"
SearchAPIWhereFilter("startDate", "2018-05-05T15:00:00.000Z", "gt"),
Expand Down
8 changes: 5 additions & 3 deletions test/search_api/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ def test_from_icat_dataset_entity_with_data_for_mandatory_related_entities(self)

def test_from_icat_dataset_entity_with_data_for_all_related_entities(self):
expected_entity_data = DATASET_PANOSC_DATA.copy()
expected_entity_data["pid"] = f"pid:{DATASET_ICAT_DATA['id']}"
expected_entity_data["documents"] = [DOCUMENT_PANOSC_DATA]
expected_entity_data["techniques"] = [TECHNIQUE_PANOSC_DATA]
expected_entity_data["instrument"] = INSTRUMENT_PANOSC_DATA
Expand All @@ -347,10 +348,10 @@ def test_from_icat_dataset_entity_with_data_for_all_related_entities(self):
expected_entity_data["parameters"][0]["value"] = DATASET_PARAMETER_ICAT_DATA[
"stringValue"
]
expected_entity_data["samples"] = [SAMPLE_PANOSC_DATA.copy()]
expected_entity_data["samples"][0]["pid"] = f"pid:{SAMPLE_ICAT_DATA['id']}"
expected_entity_data["samples"] = [SAMPLE_PANOSC_DATA]

icat_data = DATASET_ICAT_DATA.copy()
icat_data["doi"] = None
icat_data["investigation"] = INVESTIGATION_ICAT_DATA.copy()
icat_data["investigation"]["type"] = INVESTIGATION_TYPE_ICAT_DATA
icat_data["investigation"]["keywords"] = [KEYWORD_ICAT_DATA]
Expand All @@ -369,7 +370,6 @@ def test_from_icat_dataset_entity_with_data_for_all_related_entities(self):
icat_data["parameters"] = [DATASET_PARAMETER_ICAT_DATA.copy()]
icat_data["parameters"][0]["type"] = PARAMETER_TYPE_ICAT_DATA
icat_data["sample"] = SAMPLE_ICAT_DATA.copy()
icat_data["sample"]["pid"] = None
icat_data["sample"]["parameters"] = [
{"type": PARAMETER_TYPE_ICAT_DATA},
{"type": PARAMETER_TYPE_ICAT_DATA},
Expand Down Expand Up @@ -562,9 +562,11 @@ def test_from_icat_sample_entity_without_data_for_related_entities(self):

def test_from_icat_sample_entity_with_data_for_all_related_entities(self):
expected_entity_data = SAMPLE_PANOSC_DATA.copy()
expected_entity_data["pid"] = f"pid:{SAMPLE_ICAT_DATA['id']}"
expected_entity_data["datasets"] = [DATASET_PANOSC_DATA, DATASET_PANOSC_DATA]

icat_data = SAMPLE_ICAT_DATA.copy()
icat_data["pid"] = None
icat_data["parameters"] = [
{"type": PARAMETER_TYPE_ICAT_DATA},
]
Expand Down

0 comments on commit 559e8b8

Please sign in to comment.