def test_delete_datasource(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) data_source_connection = self._create_data_source_connection() result = client.create_data_source_connection(data_source_connection) assert len(client.get_data_source_connections()) == 1 client.delete_data_source_connection("sample-datasource") assert len(client.get_data_source_connections()) == 0
def _clean_up_indexers(endpoint, api_key): from azure.search.documents.indexes import SearchIndexerClient client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) for indexer in client.get_indexers(): client.delete_indexer(indexer) for datasource in client.get_data_source_connection_names(): client.delete_data_source_connection(datasource) for skillset in client.get_skillset_names(): client.delete_skillset(skillset)
def test_delete_datasource_string_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) data_source_connection = self._create_data_source_connection() created = client.create_data_source_connection(data_source_connection) etag = created.e_tag # Now update the data source connection data_source_connection.description = "updated" client.create_or_update_data_source_connection(data_source_connection) # prepare data source connection data_source_connection.e_tag = etag # reset to the original data source connection with pytest.raises(ValueError): client.delete_data_source_connection(data_source_connection.name, match_condition=MatchConditions.IfNotModified)