|
8 | 8 | from tests.utils.object_assertions import ( |
9 | 9 | assert_match_object, |
10 | 10 | assert_object_lists_match, |
| 11 | + assert_to_contain_object, |
11 | 12 | ) |
12 | 13 | from tests.utils.version import is_v30_or_above |
13 | 14 | from typesense.api_call import ApiCall |
@@ -110,3 +111,65 @@ def test_upsert(fake_curation_sets: CurationSets) -> None: |
110 | 111 | assert mock.last_request.json() == payload |
111 | 112 |
|
112 | 113 |
|
| 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