diff --git a/test/search_api/filters/test_where_filter.py b/test/search_api/filters/test_where_filter.py index c8749f9d..c2eea6b5 100644 --- a/test/search_api/filters/test_where_filter.py +++ b/test/search_api/filters/test_where_filter.py @@ -7,7 +7,8 @@ class TestSearchAPIWhereFilter: - # TODO - Add test case for fields we can't map to ICAT + # TODO - Add test case for fields we can't map to ICAT - do we 400/500 or just + # ignore the filter? # TODO - Add test case for isPublic # TODO - Add test case for Dataset.size # TODO - Add test case for Parameter.value (where we map to a list of ICAT fields) @@ -48,6 +49,7 @@ class TestSearchAPIWhereFilter: " '%Keyword%'", id="WHERE filter on ICAT related entity with 0-many relationship", ), + # TODO - add in the rest of the PaNOSC hops pytest.param( SearchAPIWhereFilter("samples.description", "Test description", "like"), "Dataset", @@ -55,6 +57,13 @@ class TestSearchAPIWhereFilter: " JOIN s2.type AS s3 WHERE s3.description like '%Test description%'", id="WHERE filter on ICAT related entity with a PaNOSC hop", ), + pytest.param( + SearchAPIWhereFilter("parameters.value", "My Parameter", "eq"), + "Document", + "SELECT o FROM Investigation o JOIN o.parameters AS p WHERE" + " p.stringValue = 'My Parameter'", + id="WHERE filter using mapping that maps to multiple ICAT fields", + ), ], ) def test_valid_apply_where_filter(self, filter_input, entity_name, expected_query): @@ -77,7 +86,7 @@ def test_valid_apply_where_filter(self, filter_input, entity_name, expected_quer [], [SearchAPIWhereFilter("name", "SANS2D", "like")], "and", ), "Instrument", - "SELECT o FROM Instrument o WHERE (o.name like '%SANS2D%')", + "SELECT o FROM Instrument o WHERE (o.name like '%SANS2D%')", id="Nested input with single filter", ), pytest.param( @@ -114,14 +123,18 @@ def test_valid_apply_where_filter(self, filter_input, entity_name, expected_quer ), pytest.param( NestedWhereFilters( - [SearchAPIWhereFilter("summary", "My Test Summary", "eq")], - [SearchAPIWhereFilter("keywords", "Test keyword", "eq")], + [SearchAPIWhereFilter("title", "Test title", "eq")], + [ + SearchAPIWhereFilter( + "samples.description", "Test description", "like", + ), + ], "and", ), "Dataset", - "SELECT o FROM Dataset o JOIN o.sample AS s1 JOIN s1.paramaters AS s2" - " JOIN s2.type AS s3 WHERE (o.summary = 'My Test Summary' and" - " s3.description like '%Test description%'", + "SELECT o FROM Dataset o JOIN o.sample AS s1 JOIN s1.parameters AS s2" + " JOIN s2.type AS s3 WHERE (o.name = 'Test title' and" + " s3.description like '%Test description%')", id="Nested input with filter on ICAT related entity with multiple hops", ), pytest.param( @@ -144,7 +157,7 @@ def test_valid_apply_where_filter(self, filter_input, entity_name, expected_quer ), "Document", "SELECT o FROM Investigation o WHERE ((o.summary = 'My Test Summary' or" - " o.name = 'Test title') and (o.doi = 'Test pid' or o.doi =" + " o.name like '%Test title%') and (o.doi = 'Test pid' or o.doi =" " 'Test doi'))", id="Nested input - (A or B) and (C or D)", ),