Files
qdrant/openapi/tests/openapi_integration/test_count.py
Andrey Vasnetsov 098bc4c751 Count api (#777)
* count api

* test for approx counting

* fmt + clippy

* unit test

* add warning
2022-07-05 09:33:38 +02:00

73 lines
2.0 KiB
Python

import pytest
from .helpers.collection_setup import basic_collection_setup, drop_collection
from .helpers.helpers import request_with_validation
collection_name = 'test_collection_threshold'
@pytest.fixture(autouse=True)
def setup():
basic_collection_setup(collection_name=collection_name)
yield
drop_collection(collection_name=collection_name)
def test_exact_count_search():
response = request_with_validation(
api='/collections/{collection_name}/points/count',
method="POST",
path_params={'collection_name': collection_name},
body={
"filter": {
"should": [
{
"key": "city",
"match": {
"value": "London"
}
},
{
"key": "city",
"match": {
"value": "Berlin"
}
}
]
}
}
)
assert response.ok
assert response.json()['result']['count'] == 4
def test_approx_count_search():
response = request_with_validation(
api='/collections/{collection_name}/points/count',
method="POST",
path_params={'collection_name': collection_name},
body={
"filter": {
"should": [
{
"key": "city",
"match": {
"value": "London"
}
},
{
"key": "city",
"match": {
"value": "Berlin"
}
}
]
},
"exact": False
}
)
assert response.ok
print(response.json())
assert response.json()['result']['count'] < 6
assert response.json()['result']['count'] > 0