Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/analytics_rules_v1_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_get_missing_analytics_rule(fake_analytics_rules: AnalyticsRulesV1) -> N
"""Test that the AnalyticsRulesV1 object can get a missing analytics_rule."""
analytics_rule = fake_analytics_rules["company_analytics_rule"]

assert analytics_rule.rule_id == "company_analytics_rule"
assert analytics_rule.rule_name == "company_analytics_rule"
assert_match_object(analytics_rule.api_call, fake_analytics_rules.api_call)
assert_object_lists_match(
analytics_rule.api_call.node_manager.nodes,
Expand Down
6 changes: 1 addition & 5 deletions tests/collection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def test_actual_retrieve(
"infix": False,
"stem": False,
"stem_dictionary": "",
"truncate_len": 100,
"store": True,
},
{
Expand All @@ -66,16 +65,13 @@ def test_actual_retrieve(
"infix": False,
"stem": False,
"stem_dictionary": "",
"truncate_len": 100,
"store": True,
},
],
"name": "companies",
"num_documents": 0,
"symbols_to_index": [],
"token_separators": [],
"synonym_sets": [],
"curation_sets": [],
}

response.pop("created_at")
Expand All @@ -95,7 +91,7 @@ def test_actual_update(

expected: CollectionSchema = {
"fields": [
{"name": "num_locations", "truncate_len": 100, "type": "int32"},
{"name": "num_locations", "type": "int32"},
],
}

Expand Down
17 changes: 0 additions & 17 deletions tests/collections_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Tests for the Collections class."""


import sys

from typesense.async_.api_call import AsyncApiCall
Expand Down Expand Up @@ -113,7 +112,6 @@ def test_actual_create(actual_collections: Collections, delete_all: None) -> Non
"infix": False,
"stem": False,
"stem_dictionary": "",
"truncate_len": 100,
"store": True,
},
{
Expand All @@ -127,16 +125,13 @@ def test_actual_create(actual_collections: Collections, delete_all: None) -> Non
"infix": False,
"stem": False,
"stem_dictionary": "",
"truncate_len": 100,
"store": True,
},
],
"name": "companies",
"num_documents": 0,
"symbols_to_index": [],
"token_separators": [],
"synonym_sets": [],
"curation_sets": [],
}

response = actual_collections.create(
Expand Down Expand Up @@ -185,7 +180,6 @@ def test_actual_retrieve(
"infix": False,
"stem": False,
"stem_dictionary": "",
"truncate_len": 100,
"store": True,
},
{
Expand All @@ -199,16 +193,13 @@ def test_actual_retrieve(
"infix": False,
"stem": False,
"stem_dictionary": "",
"truncate_len": 100,
"store": True,
},
],
"name": "companies",
"num_documents": 0,
"symbols_to_index": [],
"token_separators": [],
"synonym_sets": [],
"curation_sets": [],
},
]

Expand Down Expand Up @@ -250,7 +241,6 @@ async def test_actual_create_async(
"infix": False,
"stem": False,
"stem_dictionary": "",
"truncate_len": 100,
"store": True,
},
{
Expand All @@ -264,16 +254,13 @@ async def test_actual_create_async(
"infix": False,
"stem": False,
"stem_dictionary": "",
"truncate_len": 100,
"store": True,
},
],
"name": "companies",
"num_documents": 0,
"symbols_to_index": [],
"token_separators": [],
"synonym_sets": [],
"curation_sets": [],
}

response = await actual_async_collections.create(
Expand Down Expand Up @@ -322,7 +309,6 @@ async def test_actual_retrieve_async(
"infix": False,
"stem": False,
"stem_dictionary": "",
"truncate_len": 100,
"store": True,
},
{
Expand All @@ -336,16 +322,13 @@ async def test_actual_retrieve_async(
"infix": False,
"stem": False,
"stem_dictionary": "",
"truncate_len": 100,
"store": True,
},
],
"name": "companies",
"num_documents": 0,
"symbols_to_index": [],
"token_separators": [],
"synonym_sets": [],
"curation_sets": [],
},
]

Expand Down
12 changes: 12 additions & 0 deletions tests/curation_set_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def test_actual_retrieve(
"rule": {
"match": "contains",
"query": "shoe",
"stem": False,
"synonyms": False,
},
"stop_processing": True,
},
Expand Down Expand Up @@ -108,6 +110,8 @@ def test_actual_list_items(
"rule": {
"match": "contains",
"query": "shoe",
"stem": False,
"synonyms": False,
},
"stop_processing": True,
},
Expand Down Expand Up @@ -140,6 +144,8 @@ def test_actual_get_item(
"rule": {
"match": "contains",
"query": "shoe",
"stem": False,
"synonyms": False,
},
"stop_processing": True,
}
Expand Down Expand Up @@ -218,6 +224,8 @@ async def test_actual_retrieve_async(
"rule": {
"match": "contains",
"query": "shoe",
"stem": False,
"synonyms": False,
},
"stop_processing": True,
},
Expand Down Expand Up @@ -263,6 +271,8 @@ async def test_actual_list_items_async(
"rule": {
"match": "contains",
"query": "shoe",
"stem": False,
"synonyms": False,
},
"stop_processing": True,
},
Expand Down Expand Up @@ -295,6 +305,8 @@ async def test_actual_get_item_async(
"rule": {
"match": "contains",
"query": "shoe",
"stem": False,
"synonyms": False,
},
"stop_processing": True,
}
Expand Down
4 changes: 4 additions & 0 deletions tests/curation_sets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def test_actual_upsert(
"rule": {
"match": "contains",
"query": "shoe",
"stem": False,
"synonyms": False,
},
"stop_processing": True,
},
Expand Down Expand Up @@ -150,6 +152,8 @@ async def test_actual_upsert_async(
"rule": {
"match": "contains",
"query": "shoe",
"stem": False,
"synonyms": False,
},
"stop_processing": True,
},
Expand Down
18 changes: 12 additions & 6 deletions tests/metrics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,22 @@ def test_init_async(fake_async_api_call: AsyncApiCall) -> None:
)
assert metrics.resource_path == "/metrics.json" # noqa: WPS437

import platform


def test_actual_retrieve(actual_metrics: Metrics) -> None:
"""Test that the Metrics object can retrieve metrics on Typesense server and verify response structure."""
response = actual_metrics.retrieve()

assert "system_cpu_active_percentage" in response
if platform.system() == "Linux":
assert "system_cpu_active_percentage" in response
assert "system_network_received_bytes" in response
assert "system_network_sent_bytes" in response

assert "system_disk_total_bytes" in response
assert "system_disk_used_bytes" in response
assert "system_memory_total_bytes" in response
assert "system_memory_used_bytes" in response
assert "system_network_received_bytes" in response
assert "system_network_sent_bytes" in response
assert "typesense_memory_active_bytes" in response
assert "typesense_memory_allocated_bytes" in response
assert "typesense_memory_fragmentation_ratio" in response
Expand All @@ -68,13 +72,15 @@ async def test_actual_retrieve_async(actual_async_metrics: AsyncMetrics) -> None
"""Test that the AsyncMetrics object can retrieve metrics on Typesense server and verify response structure."""
response = await actual_async_metrics.retrieve()

assert "system_cpu_active_percentage" in response
if platform.system() == "Linux":
assert "system_cpu_active_percentage" in response
assert "system_network_received_bytes" in response
assert "system_network_sent_bytes" in response

assert "system_disk_total_bytes" in response
assert "system_disk_used_bytes" in response
assert "system_memory_total_bytes" in response
assert "system_memory_used_bytes" in response
assert "system_network_received_bytes" in response
assert "system_network_sent_bytes" in response
assert "typesense_memory_active_bytes" in response
assert "typesense_memory_allocated_bytes" in response
assert "typesense_memory_fragmentation_ratio" in response
Expand Down
4 changes: 2 additions & 2 deletions tests/operations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ def test_cache_clear(actual_operations: Operations) -> None:
assert response["success"]


def test_snapshot(actual_operations: Operations) -> None:
def test_snapshot(actual_operations: Operations, tmp_path) -> None:
"""Test that the Operations object can perform the snapshot operation."""
response = actual_operations.perform(
"snapshot",
{"snapshot_path": "/tmp"}, # noqa: S108
{"snapshot_path": str(tmp_path)}, # noqa: S108
)

assert response["success"]
Expand Down
4 changes: 2 additions & 2 deletions tests/override_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_init(fake_api_call: ApiCall) -> None:
fake_api_call.config.nearest_node,
)
assert (
override._endpoint_path() # noqa: WPS437
override._endpoint_path # noqa: WPS437
== "/collections/companies/overrides/company_override"
)

Expand Down Expand Up @@ -104,7 +104,7 @@ def test_init_async(fake_async_api_call: AsyncApiCall) -> None:
fake_async_api_call.config.nearest_node,
)
assert (
override._endpoint_path() # noqa: WPS437
override._endpoint_path # noqa: WPS437
== "/collections/companies/overrides/company_override"
)

Expand Down
4 changes: 2 additions & 2 deletions tests/overrides_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_get_missing_override(fake_overrides: Overrides) -> None:
)
assert override.collection_name == "companies"
assert (
override._endpoint_path() # noqa: WPS437
override._endpoint_path # noqa: WPS437
== "/collections/companies/overrides/company_override"
)

Expand Down Expand Up @@ -186,7 +186,7 @@ def test_get_missing_override_async(fake_async_overrides) -> None:
)
assert override.collection_name == "companies"
assert (
override._endpoint_path() # noqa: WPS437
override._endpoint_path # noqa: WPS437
== "/collections/companies/overrides/company_override"
)

Expand Down
4 changes: 2 additions & 2 deletions tests/synonym_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_init(fake_api_call: ApiCall) -> None:
fake_api_call.config.nearest_node,
)
assert (
synonym._endpoint_path() # noqa: WPS437
synonym._endpoint_path # noqa: WPS437
== "/collections/companies/synonyms/company_synonym"
)

Expand Down Expand Up @@ -99,7 +99,7 @@ def test_init_async(fake_async_api_call: AsyncApiCall) -> None:
fake_async_api_call.config.nearest_node,
)
assert (
synonym._endpoint_path() # noqa: WPS437
synonym._endpoint_path # noqa: WPS437
== "/collections/companies/synonyms/company_synonym"
)

Expand Down
4 changes: 2 additions & 2 deletions tests/synonyms_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_get_missing_synonym(fake_synonyms: Synonyms) -> None:
)
assert synonym.collection_name == "companies"
assert (
synonym._endpoint_path() # noqa: WPS437
synonym._endpoint_path # noqa: WPS437
== "/collections/companies/synonyms/company_synonym"
)

Expand Down Expand Up @@ -174,7 +174,7 @@ def test_get_missing_synonym_async(fake_async_synonyms) -> None:
)
assert synonym.collection_name == "companies"
assert (
synonym._endpoint_path() # noqa: WPS437
synonym._endpoint_path # noqa: WPS437
== "/collections/companies/synonyms/company_synonym"
)

Expand Down