Skip to content

Commit

Permalink
test: test logic related to setting of Instrument pid #314
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Feb 10, 2022
1 parent ae7e57a commit 29583b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 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 @@ -16,6 +16,18 @@ class TestSearchAPIWhereFilter:
"SELECT o FROM Instrument o WHERE o.name = 'WISH'",
id="Regular WHERE filter",
),
pytest.param(
SearchAPIWhereFilter("pid", "1", "eq"),
"Instrument",
"SELECT o FROM Instrument o WHERE o.pid = '1'",
id="Pid instrument value (mapping that maps to multiple ICAT fields)",
),
pytest.param(
SearchAPIWhereFilter("pid", "pid:1", "eq"),
"Instrument",
"SELECT o FROM Instrument o WHERE o.id = '1'",
id="Id instrument value (mapping that maps to multiple ICAT fields)",
),
pytest.param(
SearchAPIWhereFilter("title", "My Dataset 1", "ne"),
"Dataset",
Expand Down
6 changes: 4 additions & 2 deletions test/search_api/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

INSTRUMENT_ICAT_DATA = {
"type": "Test type",
"pid": None,
"pid": "Test pid",
"name": "Test name",
"id": 1,
"modTime": "2000-12-31 00:00:00+00:00",
Expand Down Expand Up @@ -243,7 +243,7 @@
}

INSTRUMENT_PANOSC_DATA = {
"pid": str(INSTRUMENT_ICAT_DATA["id"]),
"pid": INSTRUMENT_ICAT_DATA["pid"],
"name": INSTRUMENT_ICAT_DATA["name"],
"facility": FACILITY_ICAT_DATA["name"],
"datasets": [],
Expand Down Expand Up @@ -451,9 +451,11 @@ def test_from_icat_instrument_entity_without_data_for_related_entities(self):

def test_from_icat_instrument_entity_with_data_for_all_related_entities(self):
expected_entity_data = INSTRUMENT_PANOSC_DATA.copy()
expected_entity_data["pid"] = f"pid:{INSTRUMENT_ICAT_DATA['id']}"
expected_entity_data["datasets"] = [DATASET_PANOSC_DATA]

icat_data = INSTRUMENT_ICAT_DATA.copy()
icat_data["pid"] = None
icat_data["facility"] = FACILITY_ICAT_DATA
icat_data["datasetInstruments"] = [{"dataset": DATASET_ICAT_DATA.copy()}]

Expand Down

0 comments on commit 29583b1

Please sign in to comment.