From 559e8b82dce4c96eacc1be44723090886ecd089b Mon Sep 17 00:00:00 2001 From: Viktor Bozhinov Date: Thu, 10 Feb 2022 16:04:31 +0000 Subject: [PATCH] test: test logic related to setting of Dataset pid #314 --- .../filters/test_search_api_where_filter.py | 12 ++++++++++++ test/search_api/test_models.py | 8 +++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/test/search_api/filters/test_search_api_where_filter.py b/test/search_api/filters/test_search_api_where_filter.py index a6b16c1c..516536db 100644 --- a/test/search_api/filters/test_search_api_where_filter.py +++ b/test/search_api/filters/test_search_api_where_filter.py @@ -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"), diff --git a/test/search_api/test_models.py b/test/search_api/test_models.py index baf34e1a..3c6bd978 100644 --- a/test/search_api/test_models.py +++ b/test/search_api/test_models.py @@ -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 @@ -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] @@ -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}, @@ -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}, ]