def test_delete_datasource(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) data_source = self._create_datasource() result = client.create_datasource(data_source) assert len(client.get_datasources()) == 1 client.delete_datasource("sample-datasource") assert len(client.get_datasources()) == 0
def test_delete_datasource_string_if_unchanged(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) data_source = self._create_datasource() created = client.create_datasource(data_source) etag = created.e_tag # Now update the data source data_source.description = "updated" client.create_or_update_datasource(data_source) # prepare data source data_source.e_tag = etag # reset to the original datasource with pytest.raises(ValueError): client.delete_datasource( data_source.name, match_condition=MatchConditions.IfNotModified)