mirror of
https://github.com/qdrant/qdrant.git
synced 2026-08-05 01:20:53 -05:00
* Clean up imports * Clean up whitespace * Use drop collection function from helpers * Use parameterized integration tests to test on_disk variations * Promote on_disk_vectors parameter into dedicated fixture * Merge basic retrieve test with parameterization * Flatten functions * Split validation test functions * Don't parameterize on_disk states when testing validation * Parameterize init_from_collection test sequence * Parameterize on_disk_payload in tests with fixture * Parameterize new batch update tests * Fix integration test collection setup distance after incorrect merge
136 lines
4.1 KiB
Python
136 lines
4.1 KiB
Python
import pytest
|
|
|
|
from .helpers.collection_setup import basic_collection_setup, drop_collection
|
|
from .helpers.fixtures import on_disk_vectors
|
|
from .helpers.helpers import request_with_validation
|
|
|
|
collection_name = 'test_collection_payload_indexing'
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def setup(on_disk_vectors):
|
|
basic_collection_setup(collection_name=collection_name, on_disk_vectors=on_disk_vectors)
|
|
yield
|
|
drop_collection(collection_name=collection_name)
|
|
|
|
|
|
def test_payload_indexing_operations():
|
|
# create payload
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/points/payload',
|
|
method="POST",
|
|
path_params={'collection_name': collection_name},
|
|
query_params={'wait': 'true'},
|
|
body={
|
|
"payload": {"test_payload": "keyword"},
|
|
"points": [6]
|
|
}
|
|
)
|
|
assert response.ok
|
|
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="GET",
|
|
path_params={'collection_name': collection_name},
|
|
)
|
|
assert response.ok
|
|
|
|
# Create index
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/index',
|
|
method="PUT",
|
|
path_params={'collection_name': collection_name},
|
|
query_params={'wait': 'true'},
|
|
body={
|
|
"field_name": "test_payload",
|
|
"field_schema": "keyword"
|
|
}
|
|
)
|
|
assert response.ok
|
|
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="GET",
|
|
path_params={'collection_name': collection_name},
|
|
)
|
|
assert response.ok
|
|
assert response.json()['result']['payload_schema']['test_payload']['data_type'] == "keyword"
|
|
|
|
# Delete index
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/index/{field_name}',
|
|
method="DELETE",
|
|
path_params={'collection_name': collection_name, 'field_name': 'test_payload'},
|
|
query_params={'wait': 'true'},
|
|
)
|
|
assert response.ok
|
|
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="GET",
|
|
path_params={'collection_name': collection_name},
|
|
)
|
|
assert response.ok
|
|
assert len(response.json()['result']['payload_schema']) == 0
|
|
|
|
|
|
def set_payload(payload, points):
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/points/payload',
|
|
method="POST",
|
|
path_params={'collection_name': collection_name},
|
|
query_params={'wait': 'true'},
|
|
body={
|
|
"payload": payload,
|
|
"points": points
|
|
}
|
|
)
|
|
assert response.ok
|
|
|
|
|
|
def test_boolean_index():
|
|
bool_key = "boolean_payload"
|
|
# create payload
|
|
set_payload({bool_key: False}, [1, 2, 3, 4])
|
|
set_payload({bool_key: [True, False]}, [5])
|
|
set_payload({bool_key: True}, [6, 7])
|
|
|
|
# Create index
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/index',
|
|
method="PUT",
|
|
path_params={'collection_name': collection_name},
|
|
query_params={'wait': 'true'},
|
|
body={
|
|
"field_name": bool_key,
|
|
"field_schema": "bool"
|
|
}
|
|
)
|
|
assert response.ok
|
|
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="GET",
|
|
path_params={'collection_name': collection_name},
|
|
)
|
|
assert response.ok
|
|
assert response.json()['result']['payload_schema'][bool_key]['data_type'] == "bool"
|
|
assert response.json()['result']['payload_schema'][bool_key]['points'] == 7
|
|
|
|
# Delete index
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/index/{field_name}',
|
|
method="DELETE",
|
|
path_params={'collection_name': collection_name, 'field_name': bool_key},
|
|
query_params={'wait': 'true'},
|
|
)
|
|
assert response.ok
|
|
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="GET",
|
|
path_params={'collection_name': collection_name},
|
|
)
|
|
assert response.ok
|
|
assert len(response.json()['result']['payload_schema']) == 0
|