From bdd837d5572954f33048fe18c410347f1bf7dad7 Mon Sep 17 00:00:00 2001 From: Jordan <21129425+ItIsJordan@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:17:43 +0100 Subject: [PATCH] Update range query result tests Renames test_composite_range_queries to test_range_queries and adds some extra testing for single-range keyword searching. Checks against correct expected sort order. --- tests/search_test.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/search_test.py b/tests/search_test.py index a5f552f4..fcf736a8 100644 --- a/tests/search_test.py +++ b/tests/search_test.py @@ -414,7 +414,7 @@ def test_search_range_ids(app, load_default_data, identifiers): bad_result = os_api.search(range_query % (identifier_id+1, identifier_id-1)) assert not bad_result.get('results') -def test_composite_range_queries(app, load_default_data, identifiers): +def test_range_queries(app, load_default_data, identifiers): """ Tests search functionality to ensure range queries are functional, together and alongside other search types @@ -422,14 +422,30 @@ def test_composite_range_queries(app, load_default_data, identifiers): current_year = datetime.today().year test_data = [ - { # Should cover every ID in the range, and equal the length of identifiers - "test_query": "inspire_id:[0 TO 10000000] AND publication_recid:[0 TO 10000000]", + { # Check all results are returned, and is sorted by inspire_id + "test_query": "inspire_id:[0 TO 10000000]", "expected_result": { "count": len(identifiers), "expected_inspire_ids": [2751932, 1283842, 1245023], "expected_rec_ids": [57, 1, 16] } }, + { # Check all results are returned, and is sorted by recid + "test_query": "publication_recid:[0 TO 10000000]", + "expected_result": { + "count": len(identifiers), + "expected_inspire_ids": [2751932, 1245023, 1283842], + "expected_rec_ids": [57, 16, 1] + } + }, + { # Should cover every ID in the range, and equal the length of identifiers, sorted by recid + "test_query": "inspire_id:[0 TO 10000000] AND publication_recid:[0 TO 10000000]", + "expected_result": { + "count": len(identifiers), + "expected_inspire_ids": [2751932, 1245023, 1283842], + "expected_rec_ids": [57, 16, 1] + } + }, { # Valid search for a specific entry "test_query": "inspire_id:[2751932 TO 2751932] AND publication_recid:[57 TO 57]", "expected_result": {