-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathtest_client_debug.py
More file actions
65 lines (50 loc) · 2.26 KB
/
test_client_debug.py
File metadata and controls
65 lines (50 loc) · 2.26 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
import pytest
from integration.conftest import (
AsyncClientFactory,
AsyncCollectionFactory,
ClientFactory,
CollectionFactory,
)
from weaviate.classes.config import DataType, Property
from weaviate.classes.debug import DebugRESTObject
def test_get_object_single_node(
client_factory: ClientFactory, collection_factory: CollectionFactory
) -> None:
client = client_factory()
collection = collection_factory(properties=[Property(name="name", data_type=DataType.TEXT)])
uuid = collection.data.insert({"name": "John Doe"})
debug_obj = client.debug.get_object_over_rest(collection.name, uuid)
assert debug_obj is not None
assert isinstance(debug_obj, DebugRESTObject)
assert str(debug_obj.uuid) == str(uuid)
non_existant_uuid = "00000000-0000-0000-0000-000000000000"
debug_obj = client.debug.get_object_over_rest(collection.name, non_existant_uuid)
assert debug_obj is None
@pytest.mark.asyncio
async def test_get_object_single_node_async(
async_client_factory: AsyncClientFactory, async_collection_factory: AsyncCollectionFactory
) -> None:
client = await async_client_factory()
collection = await async_collection_factory(
properties=[Property(name="name", data_type=DataType.TEXT)]
)
uuid = await collection.data.insert({"name": "John Doe"})
debug_obj = await client.debug.get_object_over_rest(collection.name, uuid)
assert debug_obj is not None
assert isinstance(debug_obj, DebugRESTObject)
assert str(debug_obj.uuid) == str(uuid)
non_existant_uuid = "00000000-0000-0000-0000-000000000000"
debug_obj = await client.debug.get_object_over_rest(collection.name, non_existant_uuid)
assert debug_obj is None
def test_get_object_multi_node(
client_factory: ClientFactory, collection_factory: CollectionFactory
) -> None:
client = client_factory(ports=(8087, 50058))
collection = collection_factory(
ports=(8087, 50058), properties=[Property(name="name", data_type=DataType.TEXT)]
)
uuid = collection.data.insert({"name": "John Doe"})
for node_name in ["node1", "node2", "node3"]:
debug_obj = client.debug.get_object_over_rest(collection.name, uuid, node_name=node_name)
assert debug_obj is not None
assert str(debug_obj.uuid) == str(uuid)