Skip to content

Commit

Permalink
fixup basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
ditsuke committed May 19, 2024
1 parent fe071b8 commit e622c42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def schema():
def schema_numeric_fields():
return (
SchemaBuilder()
.add_integer_field("id", stored=True, indexed=True)
.add_float_field("rating", stored=True, indexed=True)
.add_integer_field("id", stored=True, indexed=True, fast=True)
.add_float_field("rating", stored=True, indexed=True, fast=True)
.add_boolean_field("is_good", stored=True, indexed=True)
.add_text_field("body", stored=True)
.add_text_field("body", stored=True, fast=True)
.build()
)

Expand Down
12 changes: 7 additions & 5 deletions tests/tantivy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_and_query(self, ram_index):

assert len(result.hits) == 1

def test_and_agg(self, ram_index_numeric_fields):
def test_and_aggregate(self, ram_index_numeric_fields):
index = ram_index_numeric_fields
query = Query.all_query()
agg_query = """
Expand All @@ -82,13 +82,15 @@ def test_and_agg(self, ram_index_numeric_fields):
}
}
}
"""
"""
searcher = index.searcher()
result = searcher.aggregate(query, agg_query)

print("the result is", result)

assert len(result) == 2
assert isinstance(result, dict)
assert "top_hits_req" in result
assert len(result["top_hits_req"]["hits"]) == 2
for hit in result["top_hits_req"]["hits"]:
assert len(hit["docvalue_fields"]) == 3

def test_and_query_numeric_fields(self, ram_index_numeric_fields):
index = ram_index_numeric_fields
Expand Down

0 comments on commit e622c42

Please sign in to comment.