def test_create_or_update_synonym_map_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexClient(endpoint, AzureKeyCredential(api_key)) result = client.create_synonym_map("test-syn-map", [ "USA, United States, United States of America", ]) etag = result.e_tag client.create_or_update_synonym_map("test-syn-map", [ "Washington, Wash. => WA", ]) result.e_tag = etag with pytest.raises(HttpResponseError): client.create_or_update_synonym_map( result, match_condition=MatchConditions.IfNotModified)
def test_create_or_update_synonym_map(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexClient(endpoint, AzureKeyCredential(api_key)) client.create_synonym_map("test-syn-map", [ "USA, United States, United States of America", ]) assert len(client.get_synonym_maps()) == 1 client.create_or_update_synonym_map("test-syn-map", [ "Washington, Wash. => WA", ]) assert len(client.get_synonym_maps()) == 1 result = client.get_synonym_map("test-syn-map") assert isinstance(result, SynonymMap) assert result.name == "test-syn-map" assert result.synonyms == [ "Washington, Wash. => WA", ]
def test_delete_synonym_map_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexClient(endpoint, AzureKeyCredential(api_key)) synonyms = [ "USA, United States, United States of America", "Washington, Wash. => WA", ] synonym_map = SynonymMap(name="test-syn-map", synonyms=synonyms) result = client.create_synonym_map(synonym_map) etag = result.e_tag synonym_map.synonyms = "\n".join([ "Washington, Wash. => WA", ]) client.create_or_update_synonym_map(synonym_map) result.e_tag = etag with pytest.raises(HttpResponseError): client.delete_synonym_map( result, match_condition=MatchConditions.IfNotModified) assert len(client.get_synonym_maps()) == 1