Skip to content

Commit eaec386

Browse files
committed
fix(curation): fix method signature of upserting curation sets
1 parent 2792b34 commit eaec386

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

src/typesense/curation_set.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99

1010
from typesense.api_call import ApiCall
1111
from typesense.types.curation_set import (
12-
CurationSetSchema,
12+
CurationItemDeleteSchema,
13+
CurationItemSchema,
1314
CurationSetDeleteSchema,
1415
CurationSetListItemResponseSchema,
15-
CurationItemSchema,
16-
CurationItemDeleteSchema,
16+
CurationSetSchema,
17+
CurationSetUpsertSchema,
1718
)
1819

1920

@@ -43,6 +44,17 @@ def delete(self) -> CurationSetDeleteSchema:
4344
)
4445
return response
4546

47+
def upsert(
48+
self,
49+
payload: CurationSetUpsertSchema,
50+
) -> CurationSetSchema:
51+
response: CurationSetSchema = self.api_call.put(
52+
"/".join([self._endpoint_path]),
53+
body=payload,
54+
entity_type=CurationSetSchema,
55+
)
56+
return response
57+
4658
# Items sub-resource
4759
@property
4860
def _items_path(self) -> str:
@@ -92,5 +104,3 @@ def delete_item(self, item_id: str) -> CurationItemDeleteSchema:
92104
entity_type=CurationItemDeleteSchema,
93105
)
94106
return response
95-
96-

src/typesense/curation_sets.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
from typesense.api_call import ApiCall
1111
from typesense.curation_set import CurationSet
1212
from typesense.types.curation_set import (
13-
CurationSetSchema,
1413
CurationSetsListResponseSchema,
15-
CurationSetUpsertSchema,
1614
)
1715

1816

@@ -34,15 +32,3 @@ def __getitem__(self, curation_set_name: str) -> CurationSet:
3432
from typesense.curation_set import CurationSet as PerSet
3533

3634
return PerSet(self.api_call, curation_set_name)
37-
38-
def upsert(
39-
self,
40-
curation_set_name: str,
41-
payload: CurationSetUpsertSchema,
42-
) -> CurationSetSchema:
43-
response: CurationSetSchema = self.api_call.put(
44-
"/".join([CurationSets.resource_path, curation_set_name]),
45-
body=payload,
46-
entity_type=CurationSetSchema,
47-
)
48-
return response

tests/curation_sets_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_upsert(fake_curation_sets: CurationSets) -> None:
9696
}
9797
]
9898
}
99-
response = fake_curation_sets.upsert("products", payload)
99+
response = fake_curation_sets["products"].upsert(payload)
100100

101101
assert response == json_response
102102
assert mock.call_count == 1
@@ -111,8 +111,7 @@ def test_actual_upsert(
111111
delete_all_curation_sets: None,
112112
) -> None:
113113
"""Test that the CurationSets object can upsert a curation set on Typesense Server."""
114-
response = actual_curation_sets.upsert(
115-
"products",
114+
response = actual_curation_sets["products"].upsert(
116115
{
117116
"items": [
118117
{

0 commit comments

Comments
 (0)