-
-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathdebug_test.py
More file actions
63 lines (48 loc) · 2.09 KB
/
debug_test.py
File metadata and controls
63 lines (48 loc) · 2.09 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
"""Tests for the Debug class."""
from tests.utils.object_assertions import assert_match_object, assert_object_lists_match
from typesense.sync.api_call import ApiCall
from typesense.async_.api_call import AsyncApiCall
from typesense.async_.debug import AsyncDebug
from typesense.sync.debug import Debug
def test_init(fake_api_call: ApiCall) -> None:
"""Test that the Debug object is initialized correctly."""
debug = Debug(
fake_api_call,
)
assert_match_object(debug.api_call, fake_api_call)
assert_object_lists_match(
debug.api_call.node_manager.nodes,
fake_api_call.node_manager.nodes,
)
assert_match_object(
debug.api_call.config.nearest_node,
fake_api_call.config.nearest_node,
)
assert debug.resource_path == "/debug" # noqa: WPS437
def test_init_async(fake_async_api_call: AsyncApiCall) -> None:
"""Test that the AsyncDebug object is initialized correctly."""
debug = AsyncDebug(fake_async_api_call)
assert_match_object(debug.api_call, fake_async_api_call)
assert_object_lists_match(
debug.api_call.node_manager.nodes,
fake_async_api_call.node_manager.nodes,
)
assert_match_object(
debug.api_call.config.nearest_node,
fake_async_api_call.config.nearest_node,
)
assert debug.resource_path == "/debug" # noqa: WPS437
def test_actual_retrieve(actual_debug: Debug) -> None:
"""Test that the Debug object can retrieve a debug on Typesense server and verify response structure."""
response = actual_debug.retrieve()
assert "state" in response
assert "version" in response
assert isinstance(response["state"], int)
assert isinstance(response["version"], str)
async def test_actual_retrieve_async(actual_async_debug: AsyncDebug) -> None:
"""Test that the AsyncDebug object can retrieve a debug on Typesense server and verify response structure."""
response = await actual_async_debug.retrieve()
assert "state" in response
assert "version" in response
assert isinstance(response["state"], int)
assert isinstance(response["version"], str)