-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathtest_delete_points.py
More file actions
96 lines (76 loc) · 2.78 KB
/
test_delete_points.py
File metadata and controls
96 lines (76 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from tests.congruence_tests.test_common import (
COLLECTION_NAME,
compare_client_results,
compare_collections,
generate_fixtures,
generate_sparse_fixtures,
init_client,
init_local,
init_remote,
sparse_vectors_config,
)
def test_delete_points(local_client, remote_client):
points = generate_fixtures(100)
vector = points[0].vector["image"]
local_client.upload_points(COLLECTION_NAME, points)
remote_client.upload_points(COLLECTION_NAME, points, wait=True)
compare_client_results(
local_client,
remote_client,
lambda c: c.query_points(COLLECTION_NAME, query=vector, using="image").points,
)
found_ids = [
scored_point.id
for scored_point in local_client.query_points(
COLLECTION_NAME, query=vector, using="image"
).points
]
local_client.delete(COLLECTION_NAME, found_ids)
remote_client.delete(COLLECTION_NAME, found_ids)
compare_collections(local_client, remote_client, 100, attrs=("points_count",))
compare_client_results(
local_client,
remote_client,
lambda c: c.query_points(COLLECTION_NAME, query=vector, using="image").points,
)
# delete non-existent points
local_client.delete(COLLECTION_NAME, found_ids)
remote_client.delete(COLLECTION_NAME, found_ids)
compare_collections(local_client, remote_client, 100, attrs=("points_count",))
compare_client_results(
local_client,
remote_client,
lambda c: c.query_points(COLLECTION_NAME, query=vector, using="image").points,
)
def test_delete_sparse_points():
points = generate_sparse_fixtures(100)
vector = points[0].vector["sparse-image"]
local_client = init_local()
init_client(local_client, [], sparse_vectors_config=sparse_vectors_config)
remote_client = init_remote()
init_client(remote_client, [], sparse_vectors_config=sparse_vectors_config)
local_client.upload_points(COLLECTION_NAME, points)
remote_client.upload_points(COLLECTION_NAME, points, wait=True)
compare_client_results(
local_client,
remote_client,
lambda c: c.query_points(
COLLECTION_NAME,
query=vector,
using="sparse-image",
).points,
)
found_ids = [
scored_point.id
for scored_point in local_client.query_points(
COLLECTION_NAME, query=vector, using="sparse-image"
).points
]
local_client.delete(COLLECTION_NAME, found_ids)
remote_client.delete(COLLECTION_NAME, found_ids)
compare_collections(local_client, remote_client, 100, attrs=("points_count",))
compare_client_results(
local_client,
remote_client,
lambda c: c.query_points(COLLECTION_NAME, query=vector, using="sparse-image").points,
)