Skip to content

Commit 972b9a1

Browse files
committed
test(curation_sets): add integration tests for curation sets
1 parent 7a0dcc2 commit 972b9a1

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

tests/curation_sets_test.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from tests.utils.object_assertions import (
99
assert_match_object,
1010
assert_object_lists_match,
11+
assert_to_contain_object,
1112
)
1213
from tests.utils.version import is_v30_or_above
1314
from typesense.api_call import ApiCall
@@ -110,3 +111,65 @@ def test_upsert(fake_curation_sets: CurationSets) -> None:
110111
assert mock.last_request.json() == payload
111112

112113

114+
def test_actual_upsert(
115+
actual_curation_sets: CurationSets,
116+
delete_all_curation_sets: None,
117+
) -> None:
118+
"""Test that the CurationSets object can upsert a curation set on Typesense Server."""
119+
response = actual_curation_sets.upsert(
120+
"products",
121+
{
122+
"items": [
123+
{
124+
"id": "rule-1",
125+
"rule": {"query": "shoe", "match": "contains"},
126+
"includes": [{"id": "123", "position": 1}],
127+
"excludes": [{"id": "999"}],
128+
}
129+
]
130+
},
131+
)
132+
133+
assert response == {
134+
"items": [
135+
{
136+
"excludes": [
137+
{
138+
"id": "999",
139+
},
140+
],
141+
"filter_curated_hits": False,
142+
"id": "rule-1",
143+
"includes": [
144+
{
145+
"id": "123",
146+
"position": 1,
147+
},
148+
],
149+
"remove_matched_tokens": False,
150+
"rule": {
151+
"match": "contains",
152+
"query": "shoe",
153+
},
154+
"stop_processing": True,
155+
},
156+
],
157+
"name": "products",
158+
}
159+
160+
161+
def test_actual_retrieve(
162+
actual_curation_sets: CurationSets,
163+
delete_all_curation_sets: None,
164+
create_curation_set: None,
165+
) -> None:
166+
"""Test that the CurationSets object can retrieve curation sets from Typesense Server."""
167+
response = actual_curation_sets.retrieve()
168+
169+
assert isinstance(response, list)
170+
assert_to_contain_object(
171+
response[0],
172+
{
173+
"name": "products",
174+
},
175+
)

0 commit comments

Comments
 (0)