From 08605afe7e0aba134a6e7d5fe1af50393091b370 Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Mon, 20 Dec 2021 17:17:00 +0000 Subject: [PATCH] test: add test cases to cover ICAT parameter values #260 --- .../filters/test_search_api_where_filter.py | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 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 c2eea6b5..06a762fe 100644 --- a/test/search_api/filters/test_search_api_where_filter.py +++ b/test/search_api/filters/test_search_api_where_filter.py @@ -7,11 +7,6 @@ class TestSearchAPIWhereFilter: - # 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) @pytest.mark.parametrize( "filter_input, entity_name, expected_query", [ @@ -62,7 +57,33 @@ class TestSearchAPIWhereFilter: "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", + id="String parameter value (mapping that maps to multiple ICAT fields)", + ), + pytest.param( + SearchAPIWhereFilter( + "parameters.value", "2018-05-05T15:00:00.000Z", "eq", + ), + "Document", + "SELECT o FROM Investigation o JOIN o.parameters AS p WHERE" + " p.dateTimeValue = '2018-05-05T15:00:00.000Z'", + id="Datetime parameter value (mapping that maps to multiple ICAT" + " fields)", + ), + pytest.param( + SearchAPIWhereFilter("parameters.value", 20, "eq"), + "Document", + "SELECT o FROM Investigation o JOIN o.parameters AS p WHERE" + " p.numericValue = '20'", + id="Numeric (int) parameter value (mapping that maps to multiple ICAT" + " fields)", + ), + pytest.param( + SearchAPIWhereFilter("parameters.value", 20.0, "eq"), + "Document", + "SELECT o FROM Investigation o JOIN o.parameters AS p WHERE" + " p.numericValue = '20.0'", + id="Numeric (float) parameter value (mapping that maps to multiple ICAT" + "fields)", ), ], )