Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add test coverage for hit counts
Browse files Browse the repository at this point in the history
  • Loading branch information
olaughter committed Mar 12, 2024
1 parent f18a10d commit ae0a4a2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tests/test_data/search_responses/empty_search_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"relevance": 1.0,
"continuation": {
"this": ""
},
"fields": {
"count()": 0
}
}
]
Expand Down
33 changes: 33 additions & 0 deletions tests/test_data/search_responses/search_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"continuation": {
"next": "BGAAABECBEBC"
},
"fields": {
"count()": 18
},
"children": [
{
"id": "grouplist:family_import_id",
Expand All @@ -33,6 +36,9 @@
"id": "group:string:UNFCCC.family.1062.0",
"relevance": 9.850756434359045,
"value": "UNFCCC.family.1062.0",
"fields": {
"count()": 451
},
"children": [
{
"id": "hitlist:hits",
Expand Down Expand Up @@ -510,6 +516,9 @@
"id": "group:string:CCLW.family.11127.0",
"relevance": 9.68513590994337,
"value": "CCLW.family.11127.0",
"fields": {
"count()": 251
},
"children": [
{
"id": "hitlist:hits",
Expand Down Expand Up @@ -662,6 +671,9 @@
"id": "group:string:CCLW.family.9095.0",
"relevance": 9.671909754163924,
"value": "CCLW.family.9095.0",
"fields": {
"count()": 151
},
"children": [
{
"id": "hitlist:hits",
Expand Down Expand Up @@ -1139,6 +1151,9 @@
"id": "group:string:UNFCCC.family.1018.0",
"relevance": 9.560969759511618,
"value": "UNFCCC.family.1018.0",
"fields": {
"count()": 71
},
"children": [
{
"id": "hitlist:hits",
Expand Down Expand Up @@ -1475,6 +1490,9 @@
"id": "group:string:UNFCCC.family.1006.0",
"relevance": 9.289557554521354,
"value": "UNFCCC.family.1006.0",
"fields": {
"count()": 47
},
"children": [
{
"id": "hitlist:hits",
Expand Down Expand Up @@ -1952,6 +1970,9 @@
"id": "group:string:UNFCCC.family.1024.0",
"relevance": 9.289557554521354,
"value": "UNFCCC.family.1024.0",
"fields": {
"count()": 44
},
"children": [
{
"id": "hitlist:hits",
Expand Down Expand Up @@ -2429,6 +2450,9 @@
"id": "group:string:UNFCCC.family.1010.0",
"relevance": 9.24455139928541,
"value": "UNFCCC.family.1010.0",
"fields": {
"count()": 38
},
"children": [
{
"id": "hitlist:hits",
Expand Down Expand Up @@ -2906,6 +2930,9 @@
"id": "group:string:CCLW.family.11106.0",
"relevance": 9.2028711390936,
"value": "CCLW.family.11106.0",
"fields": {
"count()": 29
},
"children": [
{
"id": "hitlist:hits",
Expand Down Expand Up @@ -3383,6 +3410,9 @@
"id": "group:string:CCLW.family.9101.0",
"relevance": 9.182188646184347,
"value": "CCLW.family.9101.0",
"fields": {
"count()": 24
},
"children": [
{
"id": "hitlist:hits",
Expand Down Expand Up @@ -3860,6 +3890,9 @@
"id": "group:string:UNFCCC.family.1060.0",
"relevance": 9.07481177458161,
"value": "UNFCCC.family.1060.0",
"fields": {
"count()": 21
},
"children": [
{
"id": "hitlist:hits",
Expand Down
9 changes: 7 additions & 2 deletions tests/test_search_adaptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ def vespa_search(cert_directory: str, request: SearchParameters) -> SearchRespon

@pytest.mark.vespa
def test_vespa_search_adaptor__works(fake_vespa_credentials):
request = SearchParameters(query_string="forest fires")
vespa_search(fake_vespa_credentials, request)
request = SearchParameters(query_string="the")
response = vespa_search(fake_vespa_credentials, request)

assert len(response.families) == response.total_family_hits == 2
assert response.query_time_ms < response.total_time_ms
total_passage_count = sum([f.total_passage_hits for f in response.families])
assert total_passage_count == response.total_hits


@pytest.mark.vespa
Expand Down

0 comments on commit ae0a4a2

Please sign in to comment.