|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | 5 | import pytest |
6 | | -import requests_mock |
7 | 6 |
|
8 | 7 | from tests.utils.version import is_v30_or_above |
9 | 8 | from typesense.client import Client |
10 | | -from typesense.synonym_set import SynonymSet |
| 9 | +from typesense.synonym_sets import SynonymSets |
11 | 10 | from typesense.types.synonym_set import ( |
12 | | - SynonymItemDeleteSchema, |
13 | 11 | SynonymItemSchema, |
14 | 12 | ) |
15 | 13 |
|
|
26 | 24 | ) |
27 | 25 |
|
28 | 26 |
|
| 27 | +def test_actual_list_items( |
| 28 | + actual_synonym_sets: SynonymSets, |
| 29 | + delete_all_synonym_sets: None, |
| 30 | + create_synonym_set: None, |
| 31 | +) -> None: |
| 32 | + """Test that the SynonymSet object can list items from Typesense Server.""" |
| 33 | + response = actual_synonym_sets["test-set"].list_items() |
| 34 | + |
| 35 | + assert response == [ |
| 36 | + { |
| 37 | + "id": "company_synonym", |
| 38 | + "root": "", |
| 39 | + "synonyms": ["companies", "corporations", "firms"], |
| 40 | + }, |
29 | 41 | ] |
30 | 42 |
|
31 | 43 |
|
| 44 | +def test_actual_get_item( |
| 45 | + actual_synonym_sets: SynonymSets, |
| 46 | + delete_all_synonym_sets: None, |
| 47 | + create_synonym_set: None, |
| 48 | +) -> None: |
| 49 | + """Test that the SynonymSet object can get a specific item from Typesense Server.""" |
| 50 | + response = actual_synonym_sets["test-set"].get_item("company_synonym") |
| 51 | + |
| 52 | + assert response == { |
| 53 | + "id": "company_synonym", |
| 54 | + "root": "", |
| 55 | + "synonyms": ["companies", "corporations", "firms"], |
32 | 56 | } |
33 | 57 |
|
34 | 58 |
|
| 59 | +def test_actual_upsert_item( |
| 60 | + actual_synonym_sets: SynonymSets, |
| 61 | + delete_all_synonym_sets: None, |
| 62 | + create_synonym_set: None, |
| 63 | +) -> None: |
| 64 | + """Test that the SynonymSet object can upsert an item in Typesense Server.""" |
35 | 65 | payload: SynonymItemSchema = { |
| 66 | + "id": "brand_synonym", |
| 67 | + "synonyms": ["brand", "brands", "label"], |
36 | 68 | } |
| 69 | + response = actual_synonym_sets["test-set"].upsert_item("brand_synonym", payload) |
| 70 | + |
| 71 | + assert response == { |
| 72 | + "id": "brand_synonym", |
| 73 | + "synonyms": ["brand", "brands", "label"], |
| 74 | + } |
| 75 | + |
37 | 76 |
|
| 77 | +def test_actual_delete_item( |
| 78 | + actual_synonym_sets: SynonymSets, |
| 79 | + delete_all_synonym_sets: None, |
| 80 | + create_synonym_set: None, |
| 81 | +) -> None: |
| 82 | + """Test that the SynonymSet object can delete an item from Typesense Server.""" |
| 83 | + response = actual_synonym_sets["test-set"].delete_item("company_synonym") |
38 | 84 |
|
| 85 | + assert response == {"id": "company_synonym"} |
0 commit comments