2022-02-11 16:43:47 +01:00
|
|
|
import pytest
|
|
|
|
|
|
2022-05-09 17:32:48 +02:00
|
|
|
from .helpers.collection_setup import basic_collection_setup, drop_collection
|
2023-08-09 12:32:27 +02:00
|
|
|
from .helpers.helpers import request_with_validation
|
2022-02-11 16:43:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
2024-11-06 20:09:31 +01:00
|
|
|
def setup(on_disk_vectors, collection_name):
|
2023-08-09 12:32:27 +02:00
|
|
|
basic_collection_setup(collection_name=collection_name, on_disk_vectors=on_disk_vectors)
|
2022-02-11 16:43:47 +01:00
|
|
|
yield
|
|
|
|
|
drop_collection(collection_name=collection_name)
|
|
|
|
|
|
|
|
|
|
|
2024-11-06 20:09:31 +01:00
|
|
|
def test_delete_points(collection_name):
|
2022-02-11 16:43:47 +01:00
|
|
|
# delete point by filter (has_id)
|
|
|
|
|
response = request_with_validation(
|
2022-03-03 13:27:51 +01:00
|
|
|
api='/collections/{collection_name}/points/delete',
|
2022-02-11 16:43:47 +01:00
|
|
|
method="POST",
|
2022-03-03 13:27:51 +01:00
|
|
|
path_params={'collection_name': collection_name},
|
2022-02-11 16:43:47 +01:00
|
|
|
query_params={'wait': 'true'},
|
|
|
|
|
body={
|
|
|
|
|
"filter": {
|
|
|
|
|
"must": [
|
|
|
|
|
{"has_id": [5]}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
assert response.ok
|
|
|
|
|
|
|
|
|
|
# quantity check if the above point id was deleted
|
|
|
|
|
response = request_with_validation(
|
2022-03-03 13:27:51 +01:00
|
|
|
api='/collections/{collection_name}',
|
2022-02-11 16:43:47 +01:00
|
|
|
method="GET",
|
2022-03-03 13:27:51 +01:00
|
|
|
path_params={'collection_name': collection_name},
|
2022-02-11 16:43:47 +01:00
|
|
|
)
|
|
|
|
|
assert response.ok
|
2023-12-03 18:58:19 +01:00
|
|
|
assert response.json()['result']['points_count'] == 9
|
2022-02-11 16:43:47 +01:00
|
|
|
|
|
|
|
|
response = request_with_validation(
|
2022-03-03 13:27:51 +01:00
|
|
|
api='/collections/{collection_name}/points/delete',
|
2022-02-11 16:43:47 +01:00
|
|
|
method="POST",
|
2022-03-03 13:27:51 +01:00
|
|
|
path_params={'collection_name': collection_name},
|
2022-02-11 16:43:47 +01:00
|
|
|
query_params={'wait': 'true'},
|
|
|
|
|
body={
|
|
|
|
|
"points": [1, 2, 3, 4]
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
assert response.ok
|
|
|
|
|
|
|
|
|
|
# quantity check if the above point id was deleted
|
|
|
|
|
response = request_with_validation(
|
2022-03-03 13:27:51 +01:00
|
|
|
api='/collections/{collection_name}',
|
2022-02-11 16:43:47 +01:00
|
|
|
method="GET",
|
2022-03-03 13:27:51 +01:00
|
|
|
path_params={'collection_name': collection_name},
|
2022-02-11 16:43:47 +01:00
|
|
|
)
|
|
|
|
|
assert response.ok
|
2023-12-03 18:58:19 +01:00
|
|
|
assert response.json()['result']['points_count'] == 5
|