Example #1
0
 def test_delete_synonym_map(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",
         "Washington, Wash. => WA",
     ])
     assert len(client.get_synonym_maps()) == 1
     client.delete_synonym_map("test-syn-map")
     assert len(client.get_synonym_maps()) == 0
Example #2
0
def _clean_up_indexes(endpoint, api_key):
    from azure.search.documents.indexes import SearchIndexClient
    client = SearchIndexClient(endpoint, AzureKeyCredential(api_key))

    # wipe the synonym maps which seem to survive the index
    for map in client.get_synonym_maps():
        client.delete_synonym_map(map.name)

    # wipe any existing indexes
    for index in client.list_indexes():
        client.delete_index(index)
Example #3
0
    def test_delete_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",
            "Washington, Wash. => WA",
        ])
        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.delete_synonym_map(
                result, match_condition=MatchConditions.IfNotModified)
            assert len(client.get_synonym_maps()) == 1