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 test_create_or_update_datasource(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) assert len(client.get_data_source_connections()) == 1 data_source_connection.description = "updated" client.create_or_update_data_source_connection(data_source_connection) assert len(client.get_data_source_connections()) == 1 result = client.get_data_source_connection("sample-datasource") assert result.name == "sample-datasource" assert result.description == "updated"
def test_list_datasource(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) data_source_connection1 = self._create_data_source_connection() data_source_connection2 = self._create_data_source_connection(name="another-sample") created1 = client.create_data_source_connection(data_source_connection1) created2 = client.create_data_source_connection(data_source_connection2) result = client.get_data_source_connections() assert isinstance(result, list) assert set(x.name for x in result) == {"sample-datasource", "another-sample"}
def test_delete_datasource_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(HttpResponseError): client.delete_data_source_connection(data_source_connection, match_condition=MatchConditions.IfNotModified) assert len(client.get_data_source_connections()) == 1