mirror of
https://github.com/qdrant/qdrant.git
synced 2026-07-26 04:31:02 -05:00
Collection name under test is equal to the test module name, without `.py` suffix. * Helps by debugging/tracing failed tests and find relevant logs lines in qdrant log files * Opens up a possibility to run tests in parallel, given that there are no data sharing between test modules Change details: * defined module scoped `collection_name` fixture in `conftest.py` * removed `collection_name` module variable * each test signature modified to declare the dependency to `collection_name` fixture * `@pytest.mark.parametrize` migrated to `@pytest-cases.parametrize` in cases when `collection_name` was used as the value
73 lines
2.4 KiB
Python
73 lines
2.4 KiB
Python
import pytest
|
|
|
|
from .helpers.collection_setup import basic_collection_setup, drop_collection
|
|
from .helpers.helpers import request_with_validation
|
|
|
|
|
|
@pytest.fixture(autouse=True, scope="module")
|
|
def setup(collection_name):
|
|
basic_collection_setup(collection_name=collection_name)
|
|
yield
|
|
drop_collection(collection_name=collection_name)
|
|
|
|
|
|
def test_validation_collection_name(collection_name):
|
|
# Collection names are limited to 255 chars due to filesystem constraints
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}/points/{id}',
|
|
method="GET",
|
|
path_params={
|
|
'collection_name': '''\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
extremelylongnameextremelylongnameextremelylongname\
|
|
''',
|
|
'id': 1,
|
|
},
|
|
)
|
|
assert not response.ok
|
|
assert 'Validation error' in response.json()["status"]["error"]
|
|
|
|
|
|
def test_validation_body_param(collection_name):
|
|
# Illegal body parameters must trigger a validation error
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="PUT",
|
|
path_params={'collection_name': collection_name},
|
|
body={
|
|
"vectors": {
|
|
"size": 4,
|
|
"distance": "Dot"
|
|
},
|
|
"hnsw_config": {
|
|
"ef_construct": 0,
|
|
}
|
|
}
|
|
)
|
|
assert not response.ok
|
|
assert 'Validation error' in response.json()["status"]["error"]
|
|
assert 'hnsw_config.ef_construct' in response.json()["status"]["error"]
|
|
|
|
|
|
def test_validation_query_param(collection_name):
|
|
# Illegal URL parameters must trigger a validation error
|
|
response = request_with_validation(
|
|
api='/collections/{collection_name}',
|
|
method="PUT",
|
|
path_params={'collection_name': collection_name},
|
|
query_params={'timeout': 0},
|
|
body={
|
|
"vectors": {
|
|
"size": 4,
|
|
"distance": "Dot"
|
|
},
|
|
}
|
|
)
|
|
assert not response.ok
|
|
assert 'Validation error' in response.json()["status"]["error"]
|
|
assert 'timeout: value 0 invalid' in response.json()["status"]["error"]
|