Skip to content

Commit

Permalink
Update range query result tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ItIsJordan committed Oct 10, 2024
1 parent acdd8b0 commit bdd837d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tests/search_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,22 +414,38 @@ 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
"""
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": {
Expand Down

0 comments on commit bdd837d

Please sign in to comment.