From 5da8d817a6cfab35480240027862c2f34fe4cc41 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 30 Apr 2021 11:05:48 -0400 Subject: [PATCH 01/15] working for sync and async, new preparer, changed tests --- .../azure/data/tables/_authentication.py | 21 +-- .../azure/data/tables/_base_client.py | 24 +-- .../data/tables/_shared_access_signature.py | 4 +- .../data/tables/aio/_base_client_async.py | 6 +- .../azure-data-tables/tests/preparers.py | 57 ++++++- .../azure-data-tables/tests/test_retry.py | 14 +- .../tests/test_retry_async.py | 14 +- .../azure-data-tables/tests/test_table.py | 53 +++--- .../tests/test_table_async.py | 32 ++-- .../tests/test_table_batch.py | 46 +++--- .../tests/test_table_batch_async.py | 40 ++--- .../tests/test_table_batch_cosmos.py | 30 ++-- .../tests/test_table_batch_cosmos_async.py | 34 ++-- .../tests/test_table_client.py | 12 +- .../tests/test_table_client_async.py | 8 +- .../tests/test_table_client_cosmos.py | 8 +- .../tests/test_table_client_cosmos_async.py | 8 +- .../tests/test_table_cosmos.py | 20 +-- .../tests/test_table_cosmos_async.py | 20 +-- .../tests/test_table_entity.py | 156 +++++++++--------- .../tests/test_table_entity_async.py | 152 ++++++++--------- .../tests/test_table_entity_cosmos.py | 134 +++++++-------- .../tests/test_table_entity_cosmos_async.py | 132 +++++++-------- .../tests/test_table_service_properties.py | 16 +- .../test_table_service_properties_async.py | 16 +- .../test_table_service_properties_cosmos.py | 6 +- ...t_table_service_properties_cosmos_async.py | 6 +- .../tests/test_table_service_stats.py | 6 +- .../tests/test_table_service_stats_async.py | 6 +- .../tests/test_table_service_stats_cosmos.py | 6 +- .../test_table_service_stats_cosmos_async.py | 6 +- 31 files changed, 567 insertions(+), 526 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py b/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py index b0dfbd5d56e0..e15a41a78a26 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- import logging +from typing import Union, Awaitable try: from urllib.parse import urlparse @@ -45,11 +46,8 @@ class AzureSigningError(ClientAuthenticationError): # pylint: disable=no-self-use class SharedKeyCredentialPolicy(SansIOHTTPPolicy): - def __init__( - self, account_name, account_key, is_emulated=False - ): - self.account_name = account_name - self.account_key = account_key + def __init__(self, credential, is_emulated=False): + self._credential = credential self.is_emulated = is_emulated def _get_headers(self, request, headers_to_sign): @@ -82,10 +80,10 @@ def _get_canonicalized_resource(self, request): ) ): uri_path = URL(uri_path) - return "/" + self.account_name + str(uri_path) + return "/" + self._credential.name + str(uri_path) except TypeError: pass - return "/" + self.account_name + uri_path + return "/" + self._credential.named_key.name + uri_path def _get_canonicalized_headers(self, request): string_to_sign = "" @@ -101,17 +99,16 @@ def _get_canonicalized_headers(self, request): def _add_authorization_header(self, request, string_to_sign): try: - signature = _sign_string(self.account_key, string_to_sign) - auth_string = "SharedKey " + self.account_name + ":" + signature + signature = _sign_string(self._credential.named_key.key, string_to_sign) + auth_string = "SharedKey " + self._credential.named_key.name + ":" + signature request.headers["Authorization"] = auth_string except Exception as ex: # Wrap any error that occurred as signing error # Doing so will clarify/locate the source of problem raise _wrap_exception(ex, AzureSigningError) - def on_request( - self, request - ): # type: (PipelineRequest) -> Union[None, Awaitable[None]] + def on_request(self, request): + # type: (PipelineRequest) -> Union[None, Awaitable[None]] self.sign_request(request) def sign_request(self, request): diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py index ed64fb1fe34b..cf357d689331 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py @@ -13,7 +13,7 @@ from urllib2 import quote # type: ignore import six -from azure.core.credentials import AzureSasCredential +from azure.core.credentials import AzureSasCredential, AzureNamedKeyCredential from azure.core.utils import parse_connection_string from azure.core.pipeline.transport import ( HttpTransport, @@ -30,7 +30,7 @@ AzureSasCredentialPolicy, NetworkTraceLoggingPolicy, CustomHookPolicy, - RequestIdPolicy + RequestIdPolicy, ) from ._generated import AzureTable @@ -111,7 +111,7 @@ def __init__( self.account_name = account[0] if len(account) > 1 else None secondary_hostname = None - self.credential = format_shared_key_credential(account, credential) + self.credential = credential if self.scheme.lower() != "https" and hasattr(self.credential, "get_token"): raise ValueError("Token credential is only supported with HTTPS.") if hasattr(self.credential, "account_name"): @@ -259,6 +259,8 @@ def _configure_credential(self, credential): self._credential_policy = credential elif isinstance(credential, AzureSasCredential): self._credential_policy = AzureSasCredentialPolicy(credential) + elif isinstance(credential, AzureNamedKeyCredential): + self._credential_policy = SharedKeyCredentialPolicy(credential) elif credential is not None: raise TypeError("Unsupported credential: {}".format(credential)) @@ -344,22 +346,6 @@ def __exit__(self, *args): # pylint: disable=arguments-differ pass -def format_shared_key_credential(account, credential): - if isinstance(credential, six.string_types): - if len(account) < 2: - raise ValueError( - "Unable to determine account name for shared key credential." - ) - credential = {"account_name": account[0], "account_key": credential} - if isinstance(credential, dict): - if "account_name" not in credential: - raise ValueError("Shared key credential missing 'account_name") - if "account_key" not in credential: - raise ValueError("Shared key credential missing 'account_key") - return SharedKeyCredentialPolicy(**credential) - return credential - - def parse_connection_str(conn_str, credential, keyword_args): conn_settings = parse_connection_string(conn_str) primary = None diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_shared_access_signature.py b/sdk/tables/azure-data-tables/azure/data/tables/_shared_access_signature.py index 55e0f3a41075..71d8fb6b83fb 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_shared_access_signature.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_shared_access_signature.py @@ -32,13 +32,13 @@ def __init__(self, account_name, account_key, x_ms_version=DEFAULT_X_MS_VERSION) """ :param str account_name: The storage account name used to generate the shared access signatures. - :param str account_key: + :param AzureNamedKeyCredential account_key: The access key to generate the shares access signatures. :param str x_ms_version: The service version used to generate the shared access signatures. """ self.account_name = account_name - self.account_key = account_key + self.account_key = account_key.named_key.key self.x_ms_version = x_ms_version def generate_account( diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py index 800d46aeba5d..9555c20ce4a3 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py @@ -7,7 +7,7 @@ from typing import Any, List, Mapping from uuid import uuid4 -from azure.core.credentials import AzureSasCredential +from azure.core.credentials import AzureSasCredential, AzureNamedKeyCredential from azure.core.pipeline.policies import ( ContentDecodePolicy, AsyncBearerTokenCredentialPolicy, @@ -19,7 +19,7 @@ AzureSasCredentialPolicy, RequestIdPolicy, CustomHookPolicy, - NetworkTraceLoggingPolicy + NetworkTraceLoggingPolicy, ) from azure.core.pipeline.transport import ( AsyncHttpTransport, @@ -77,6 +77,8 @@ def _configure_credential(self, credential): self._credential_policy = credential elif isinstance(credential, AzureSasCredential): self._credential_policy = AzureSasCredentialPolicy(credential) + elif isinstance(credential, AzureNamedKeyCredential): + self._credential_policy = SharedKeyCredentialPolicy(credential) elif credential is not None: raise TypeError("Unsupported credential: {}".format(credential)) diff --git a/sdk/tables/azure-data-tables/tests/preparers.py b/sdk/tables/azure-data-tables/tests/preparers.py index ff6142f0c785..8293be3408c1 100644 --- a/sdk/tables/azure-data-tables/tests/preparers.py +++ b/sdk/tables/azure-data-tables/tests/preparers.py @@ -1,4 +1,7 @@ import functools +import inspect + +from azure.core.credentials import AzureNamedKeyCredential from devtools_testutils import PowerShellPreparer CosmosPreparer = functools.partial( @@ -11,4 +14,56 @@ PowerShellPreparer, "tables", tables_storage_account_name="fake_table_account", tables_primary_storage_account_key="faketablesaccountkey" -) \ No newline at end of file +) + + +def trim_kwargs_from_test_function(fn, kwargs): + # the next function is the actual test function. the kwargs need to be trimmed so + # that parameters which are not required will not be passed to it. + if not getattr(fn, '__is_preparer', False): + try: + args, _, kw, _, _, _, _ = inspect.getfullargspec(fn) + except AttributeError: + args, _, kw, _ = inspect.getargspec(fn) # pylint: disable=deprecated-method + if kw is None: + args = set(args) + for key in [k for k in kwargs if k not in args]: + del kwargs[key] + + +def tables_decorator(func, **kwargs): + + @TablesPreparer() + def wrapper(*args, **kwargs): + key = kwargs.pop("tables_primary_storage_account_key") + name = kwargs.pop("tables_storage_account_name") + key = AzureNamedKeyCredential(key=key, name=name) + + kwargs["tables_primary_storage_account_key"] = key + kwargs["tables_storage_account_name"] = name + + trimmed_kwargs = {k:v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + func(*args, **trimmed_kwargs) + + return wrapper + + +def cosmos_decorator(func, **kwargs): + + @CosmosPreparer() + def wrapper(*args, **kwargs): + key = kwargs.pop("tables_primary_cosmos_account_key") + name = kwargs.pop("tables_cosmos_account_name") + key = AzureNamedKeyCredential(key=key, name=name) + + kwargs["tables_primary_cosmos_account_key"] = key + kwargs["tables_cosmos_account_name"] = name + + trimmed_kwargs = {k:v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + func(*args, **trimmed_kwargs) + + return wrapper diff --git a/sdk/tables/azure-data-tables/tests/test_retry.py b/sdk/tables/azure-data-tables/tests/test_retry.py index 1ca1388c49b4..a0b17ae09979 100644 --- a/sdk/tables/azure-data-tables/tests/test_retry.py +++ b/sdk/tables/azure-data-tables/tests/test_retry.py @@ -31,7 +31,7 @@ RetryCounter ) -from preparers import TablesPreparer +from preparers import tables_decorator class RetryRequestTransport(RequestsTransport): @@ -39,7 +39,7 @@ class RetryRequestTransport(RequestsTransport): def __init__(self, *args, **kwargs): super(RetryRequestTransport, self).__init__(*args, **kwargs) self.count = 0 - + def send(self, request, **kwargs): self.count += 1 response = super(RetryRequestTransport, self).send(request, **kwargs) @@ -81,7 +81,7 @@ def _tear_down(self, **kwargs): pass # --Test Cases -------------------------------------------- - @TablesPreparer() + @tables_decorator def test_retry_on_server_error(self, tables_storage_account_name, tables_primary_storage_account_key): self._set_up(tables_storage_account_name, tables_primary_storage_account_key, default_table=False) try: @@ -96,7 +96,7 @@ def test_retry_on_server_error(self, tables_storage_account_name, tables_primary self.ts.delete_table(new_table_name) self._tear_down() - @TablesPreparer() + @tables_decorator def test_retry_on_timeout(self, tables_storage_account_name, tables_primary_storage_account_key): self._set_up( tables_storage_account_name, @@ -115,7 +115,7 @@ def test_retry_on_timeout(self, tables_storage_account_name, tables_primary_stor self._tear_down() @pytest.mark.live_test_only - @TablesPreparer() + @tables_decorator def test_retry_on_socket_timeout(self, tables_storage_account_name, tables_primary_storage_account_key): retry_transport = RetryRequestTransport(connection_timeout=11, read_timeout=0.000000000001) self._set_up( @@ -125,7 +125,7 @@ def test_retry_on_socket_timeout(self, tables_storage_account_name, tables_prima default_table=False, retry_mode=RetryMode.Fixed, retry_backoff_factor=1) - + new_table_name = self.get_resource_name('uttable') try: with pytest.raises(AzureError) as error: @@ -139,7 +139,7 @@ def test_retry_on_socket_timeout(self, tables_storage_account_name, tables_prima finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_no_retry(self, tables_storage_account_name, tables_primary_storage_account_key): self._set_up(tables_storage_account_name, tables_primary_storage_account_key, retry_total=0, default_table=False) diff --git a/sdk/tables/azure-data-tables/tests/test_retry_async.py b/sdk/tables/azure-data-tables/tests/test_retry_async.py index bc396831de61..bbe8367fabee 100644 --- a/sdk/tables/azure-data-tables/tests/test_retry_async.py +++ b/sdk/tables/azure-data-tables/tests/test_retry_async.py @@ -29,7 +29,7 @@ RetryCounter ) -from preparers import TablesPreparer +from preparers import tables_decorator class RetryAioHttpTransport(AioHttpTransport): @@ -37,7 +37,7 @@ class RetryAioHttpTransport(AioHttpTransport): def __init__(self, *args, **kwargs): super(RetryAioHttpTransport, self).__init__(*args, **kwargs) self.count = 0 - + async def send(self, request, **kwargs): self.count += 1 response = await super(RetryAioHttpTransport, self).send(request, **kwargs) @@ -80,7 +80,7 @@ async def _tear_down(self, **kwargs): pass # --Test Cases -------------------------------------------- - @TablesPreparer() + @tables_decorator async def test_retry_on_server_error_async(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up(tables_storage_account_name, tables_primary_storage_account_key, default_table=False) try: @@ -95,7 +95,7 @@ async def test_retry_on_server_error_async(self, tables_storage_account_name, ta await self.ts.delete_table(new_table_name) await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_retry_on_timeout_async(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up( tables_storage_account_name, @@ -114,7 +114,7 @@ async def test_retry_on_timeout_async(self, tables_storage_account_name, tables_ await self._tear_down() @pytest.mark.live_test_only - @TablesPreparer() + @tables_decorator async def test_retry_on_socket_timeout_async(self, tables_storage_account_name, tables_primary_storage_account_key): retry_transport = RetryAioHttpTransport(connection_timeout=11, read_timeout=0.000000000001) await self._set_up( @@ -124,7 +124,7 @@ async def test_retry_on_socket_timeout_async(self, tables_storage_account_name, retry_backoff_factor=1, transport=retry_transport, default_table=False) - + new_table_name = self.get_resource_name('uttable') try: with pytest.raises(AzureError) as error: @@ -138,7 +138,7 @@ async def test_retry_on_socket_timeout_async(self, tables_storage_account_name, finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_no_retry_async(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up(tables_storage_account_name, tables_primary_storage_account_key, retry_total=0, default_table=False) diff --git a/sdk/tables/azure-data-tables/tests/test_table.py b/sdk/tables/azure-data-tables/tests/test_table.py index 90cce3deb7ba..3bc428095a85 100644 --- a/sdk/tables/azure-data-tables/tests/test_table.py +++ b/sdk/tables/azure-data-tables/tests/test_table.py @@ -29,7 +29,7 @@ generate_account_sas, ResourceTypes ) -from azure.core.credentials import AzureSasCredential +from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential from azure.core.pipeline import Pipeline from azure.core.pipeline.policies import ( HeadersPolicy, @@ -42,7 +42,7 @@ ) from _shared.testcase import TableTestCase -from preparers import TablesPreparer +from preparers import tables_decorator, tables_decorator # ------------------------------------------------------------------------------ TEST_TABLE_PREFIX = 'pytablesync' @@ -83,7 +83,7 @@ def _delete_all_tables(self, ts): # --Test cases for tables -------------------------------------------------- - @TablesPreparer() + @tables_decorator def test_create_properties(self, tables_storage_account_name, tables_primary_storage_account_key): # # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -106,7 +106,7 @@ def test_create_properties(self, tables_storage_account_name, tables_primary_sto ps = ts.get_service_properties() ts.delete_table(table_name) - @TablesPreparer() + @tables_decorator def test_create_table(self, tables_storage_account_name, tables_primary_storage_account_key): # # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -121,7 +121,7 @@ def test_create_table(self, tables_storage_account_name, tables_primary_storage_ assert created.table_name == table_name ts.delete_table(table_name) - @TablesPreparer() + @tables_decorator def test_create_table_fail_on_exist(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -140,7 +140,7 @@ def test_create_table_fail_on_exist(self, tables_storage_account_name, tables_pr assert created is not None ts.delete_table(table_name) - @TablesPreparer() + @tables_decorator def test_query_tables_per_page(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -172,7 +172,7 @@ def test_query_tables_per_page(self, tables_storage_account_name, tables_primary if self.is_live: self.sleep(10) # wait for tables to be deleted before proceeding - @TablesPreparer() + @tables_decorator def test_create_table_if_exists(self, tables_storage_account_name, tables_primary_storage_account_key): account_url = self.account_url(tables_storage_account_name, "table") ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) @@ -186,7 +186,7 @@ def test_create_table_if_exists(self, tables_storage_account_name, tables_primar assert t0.table_name == t1.table_name ts.delete_table(table_name) - @TablesPreparer() + @tables_decorator def test_create_table_if_exists_new_table(self, tables_storage_account_name, tables_primary_storage_account_key): account_url = self.account_url(tables_storage_account_name, "table") ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) @@ -198,7 +198,7 @@ def test_create_table_if_exists_new_table(self, tables_storage_account_name, tab assert t.table_name == table_name ts.delete_table(table_name) - @TablesPreparer() + @tables_decorator def test_query_tables(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -220,7 +220,7 @@ def test_query_tables(self, tables_storage_account_name, tables_primary_storage_ if self.is_live: self.sleep(10) # wait for tables to be deleted before proceeding - @TablesPreparer() + @tables_decorator def test_query_tables_with_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -244,7 +244,7 @@ def test_query_tables_with_filter(self, tables_storage_account_name, tables_prim if self.is_live: self.sleep(10) # wait for tables to be deleted before proceeding - @TablesPreparer() + @tables_decorator def test_query_tables_with_num_results(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange prefix = 'listtable' @@ -273,7 +273,7 @@ def test_query_tables_with_num_results(self, tables_storage_account_name, tables if self.is_live: self.sleep(10) # wait for tables to be deleted before proceeding - @TablesPreparer() + @tables_decorator def test_query_tables_with_marker(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -303,7 +303,7 @@ def test_query_tables_with_marker(self, tables_storage_account_name, tables_prim if self.is_live: self.sleep(10) # wait for tables to be deleted before proceeding - @TablesPreparer() + @tables_decorator def test_delete_table_with_existing_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -318,7 +318,7 @@ def test_delete_table_with_existing_table(self, tables_storage_account_name, tab assert deleted is None assert len(existing) == 0 - @TablesPreparer() + @tables_decorator def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -329,7 +329,7 @@ def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_storag with pytest.raises(HttpResponseError): ts.delete_table(table_name) - @TablesPreparer() + @tables_decorator def test_get_table_acl(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -346,7 +346,7 @@ def test_get_table_acl(self, tables_storage_account_name, tables_primary_storage finally: ts.delete_table(table.table_name) - @TablesPreparer() + @tables_decorator def test_set_table_acl_with_empty_signed_identifiers(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -365,7 +365,7 @@ def test_set_table_acl_with_empty_signed_identifiers(self, tables_storage_accoun finally: ts.delete_table(table.table_name) - @TablesPreparer() + @tables_decorator def test_set_table_acl_with_empty_signed_identifier(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -387,7 +387,7 @@ def test_set_table_acl_with_empty_signed_identifier(self, tables_storage_account finally: ts.delete_table(table.table_name) - @TablesPreparer() + @tables_decorator def test_set_table_acl_with_signed_identifiers(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -412,7 +412,7 @@ def test_set_table_acl_with_signed_identifiers(self, tables_storage_account_name finally: ts.delete_table(table.table_name) - @TablesPreparer() + @tables_decorator def test_set_table_acl_too_many_ids(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -433,7 +433,7 @@ def test_set_table_acl_too_many_ids(self, tables_storage_account_name, tables_pr ts.delete_table(table.table_name) @pytest.mark.live_test_only - @TablesPreparer() + @tables_decorator def test_account_sas(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only @@ -482,11 +482,12 @@ def test_account_sas(self, tables_storage_account_name, tables_primary_storage_a class TestTablesUnitTest(TableTestCase): tables_storage_account_name = "fake_storage_account" tables_primary_storage_account_key = "fakeXMZjnGsZGvd4bVr3Il5SeHA" + credential = AzureNamedKeyCredential(name=tables_storage_account_name, key=tables_primary_storage_account_key) def test_unicode_create_table_unicode_name(self): # Arrange account_url = self.account_url(self.tables_storage_account_name, "table") - tsc = TableServiceClient(account_url, credential=self.tables_primary_storage_account_key) + tsc = TableServiceClient(account_url, credential=self.credential) table_name = u'啊齄丂狛狜' @@ -500,7 +501,7 @@ def test_unicode_create_table_unicode_name(self): def test_create_table_invalid_name(self): # Arrange account_url = self.account_url(self.tables_storage_account_name, "table") - tsc = TableServiceClient(account_url, credential=self.tables_primary_storage_account_key) + tsc = TableServiceClient(account_url, credential=self.credential) invalid_table_name = "my_table" with pytest.raises(ValueError) as excinfo: @@ -512,7 +513,7 @@ def test_create_table_invalid_name(self): def test_delete_table_invalid_name(self): # Arrange account_url = self.account_url(self.tables_storage_account_name, "table") - tsc = TableServiceClient(account_url, credential=self.tables_primary_storage_account_key) + tsc = TableServiceClient(account_url, credential=self.credential) invalid_table_name = "my_table" with pytest.raises(ValueError) as excinfo: @@ -523,10 +524,10 @@ def test_delete_table_invalid_name(self): def test_azurite_url(self): account_url = "https://127.0.0.1:10002/my_account" - tsc = TableServiceClient(account_url, credential=self.tables_primary_storage_account_key) + tsc = TableServiceClient(account_url, credential=self.credential) assert tsc.account_name == "my_account" assert tsc.url == "https://127.0.0.1:10002/my_account" assert tsc.location_mode == "primary" - assert tsc.credential.account_key == self.tables_primary_storage_account_key - assert tsc.credential.account_name == "my_account" \ No newline at end of file + assert tsc.credential.named_key.key == self.credential.named_key.key + assert tsc.credential.named_key.name == self.credential.named_key.name \ No newline at end of file diff --git a/sdk/tables/azure-data-tables/tests/test_table_async.py b/sdk/tables/azure-data-tables/tests/test_table_async.py index 8003b1b57c74..e925bcc3c3f2 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_async.py @@ -20,7 +20,7 @@ from azure.data.tables.aio import TableServiceClient, TableClient from _shared.asynctestcase import AsyncTableTestCase -from preparers import TablesPreparer +from preparers import tables_decorator TEST_TABLE_PREFIX = 'pytableasync' @@ -52,7 +52,7 @@ async def _delete_table(self, ts, table): pass # --Test cases for tables -------------------------------------------------- - @TablesPreparer() + @tables_decorator async def test_create_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -67,7 +67,7 @@ async def test_create_table(self, tables_storage_account_name, tables_primary_st assert created.table_name == table_name await ts.delete_table(table_name=table_name) - @TablesPreparer() + @tables_decorator async def test_create_table_fail_on_exist(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -86,7 +86,7 @@ async def test_create_table_fail_on_exist(self, tables_storage_account_name, tab assert isinstance(created, TableClient) await ts.delete_table(table_name=table_name) - @TablesPreparer() + @tables_decorator async def test_query_tables_per_page(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -115,7 +115,7 @@ async def test_query_tables_per_page(self, tables_storage_account_name, tables_p for i in range(5): await ts.delete_table(table_name + str(i)) - @TablesPreparer() + @tables_decorator async def test_list_tables(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -136,7 +136,7 @@ async def test_list_tables(self, tables_storage_account_name, tables_primary_sto assert tables[0] is not None await ts.delete_table(table.table_name) - @TablesPreparer() + @tables_decorator async def test_query_tables_with_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -158,7 +158,7 @@ async def test_query_tables_with_filter(self, tables_storage_account_name, table assert table_item.name is not None await ts.delete_table(table.table_name) - @TablesPreparer() + @tables_decorator async def test_list_tables_with_num_results(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange prefix = 'listtable' @@ -185,7 +185,7 @@ async def test_list_tables_with_num_results(self, tables_storage_account_name, t assert len(small_page) == 2 assert len(big_page) >= 4 - @TablesPreparer() + @tables_decorator async def test_list_tables_with_marker(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -218,7 +218,7 @@ async def test_list_tables_with_marker(self, tables_storage_account_name, tables assert tables2_len == 2 assert tables1 != tables2 - @TablesPreparer() + @tables_decorator async def test_delete_table_with_existing_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -234,7 +234,7 @@ async def test_delete_table_with_existing_table(self, tables_storage_account_nam tables.append(e) assert tables == [] - @TablesPreparer() + @tables_decorator async def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -248,7 +248,7 @@ async def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_ # Assert - @TablesPreparer() + @tables_decorator async def test_get_table_acl(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -265,7 +265,7 @@ async def test_get_table_acl(self, tables_storage_account_name, tables_primary_s finally: await ts.delete_table(table.table_name) - @TablesPreparer() + @tables_decorator async def test_set_table_acl_with_empty_signed_identifiers(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -283,7 +283,7 @@ async def test_set_table_acl_with_empty_signed_identifiers(self, tables_storage_ finally: await ts.delete_table(table.table_name) - @TablesPreparer() + @tables_decorator async def test_set_table_acl_with_empty_signed_identifier(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -304,7 +304,7 @@ async def test_set_table_acl_with_empty_signed_identifier(self, tables_storage_a # self._delete_table(table) await ts.delete_table(table.table_name) - @TablesPreparer() + @tables_decorator async def test_set_table_acl_with_signed_identifiers(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -328,7 +328,7 @@ async def test_set_table_acl_with_signed_identifiers(self, tables_storage_accoun finally: await ts.delete_table(table.table_name) - @TablesPreparer() + @tables_decorator async def test_set_table_acl_too_many_ids(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -347,7 +347,7 @@ async def test_set_table_acl_too_many_ids(self, tables_storage_account_name, tab await ts.delete_table(table.table_name) @pytest.mark.live_test_only - @TablesPreparer() + @tables_decorator async def test_account_sas(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch.py b/sdk/tables/azure-data-tables/tests/test_table_batch.py index 79e84e4a8f6a..8adf5ed1057f 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch.py @@ -39,7 +39,7 @@ ) from _shared.testcase import TableTestCase -from preparers import TablesPreparer +from preparers import tables_decorator #------------------------------------------------------------------------------ TEST_TABLE_PREFIX = 'table' @@ -174,7 +174,7 @@ def _assert_valid_batch_transaction(self, transaction, length): @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_single_insert(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -205,7 +205,7 @@ def test_batch_single_insert(self, tables_storage_account_name, tables_primary_s self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_single_update(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -240,7 +240,7 @@ def test_batch_single_update(self, tables_storage_account_name, tables_primary_s self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_update(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -276,7 +276,7 @@ def test_batch_update(self, tables_storage_account_name, tables_primary_storage_ self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_merge(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -315,7 +315,7 @@ def test_batch_merge(self, tables_storage_account_name, tables_primary_storage_a self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_update_if_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -343,7 +343,7 @@ def test_batch_update_if_match(self, tables_storage_account_name, tables_primary self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_update_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -369,7 +369,7 @@ def test_batch_update_if_doesnt_match(self, tables_storage_account_name, tables_ self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_single_op_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -411,7 +411,7 @@ def test_batch_single_op_if_doesnt_match(self, tables_storage_account_name, tabl self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_insert_replace(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -441,7 +441,7 @@ def test_batch_insert_replace(self, tables_storage_account_name, tables_primary_ self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_insert_merge(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -471,7 +471,7 @@ def test_batch_insert_merge(self, tables_storage_account_name, tables_primary_st self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_delete(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -503,7 +503,7 @@ def test_batch_delete(self, tables_storage_account_name, tables_primary_storage_ self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_inserts(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -538,7 +538,7 @@ def test_batch_inserts(self, tables_storage_account_name, tables_primary_storage self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_all_operations_together(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -607,7 +607,7 @@ def test_batch_all_operations_together(self, tables_storage_account_name, tables self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_reuse(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -645,7 +645,7 @@ def test_batch_reuse(self, tables_storage_account_name, tables_primary_storage_a self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_same_row_operations_fail(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -673,7 +673,7 @@ def test_batch_same_row_operations_fail(self, tables_storage_account_name, table self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_different_partition_operations_fail(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -698,7 +698,7 @@ def test_batch_different_partition_operations_fail(self, tables_storage_account_ self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_too_many_ops(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -721,7 +721,7 @@ def test_batch_too_many_ops(self, tables_storage_account_name, tables_primary_st self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_batch_different_partition_keys(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -738,7 +738,7 @@ def test_batch_different_partition_keys(self, tables_storage_account_name, table self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_new_non_existent_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -756,7 +756,7 @@ def test_new_non_existent_table(self, tables_storage_account_name, tables_primar self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_new_invalid_key(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange invalid_key = tables_primary_storage_account_key[0:-6] + "==" # cut off a bit from the end to invalidate @@ -772,7 +772,7 @@ def test_new_invalid_key(self, tables_storage_account_name, tables_primary_stora resp = self.table.submit_transaction(batch) @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @TablesPreparer() + @tables_decorator def test_new_delete_nonexistent_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -789,7 +789,7 @@ def test_new_delete_nonexistent_entity(self, tables_storage_account_name, tables @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") @pytest.mark.live_test_only - @TablesPreparer() + @tables_decorator def test_batch_sas_auth(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -839,7 +839,7 @@ def test_batch_sas_auth(self, tables_storage_account_name, tables_primary_storag @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") @pytest.mark.live_test_only # Request bodies are very large - @TablesPreparer() + @tables_decorator def test_batch_request_too_large(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch_async.py b/sdk/tables/azure-data-tables/tests/test_table_batch_async.py index c60070d4b77c..c8f5d33fdd17 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch_async.py @@ -38,7 +38,7 @@ ) from _shared.asynctestcase import AsyncTableTestCase -from preparers import TablesPreparer +from preparers import tables_decorator #------------------------------------------------------------------------------ TEST_TABLE_PREFIX = 'table' @@ -173,7 +173,7 @@ def _assert_valid_batch_transaction(self, transaction, length): assert length == len(transaction) #--Test cases for batch --------------------------------------------- - @TablesPreparer() + @tables_decorator async def test_batch_single_insert(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -203,7 +203,7 @@ async def test_batch_single_insert(self, tables_storage_account_name, tables_pri finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_single_update(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -238,7 +238,7 @@ async def test_batch_single_update(self, tables_storage_account_name, tables_pri finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_update(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -272,7 +272,7 @@ async def test_batch_update(self, tables_storage_account_name, tables_primary_st finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_merge(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -310,7 +310,7 @@ async def test_batch_merge(self, tables_storage_account_name, tables_primary_sto finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_update_if_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -337,7 +337,7 @@ async def test_batch_update_if_match(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_update_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -363,7 +363,7 @@ async def test_batch_update_if_doesnt_match(self, tables_storage_account_name, t finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_insert_replace(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -392,7 +392,7 @@ async def test_batch_insert_replace(self, tables_storage_account_name, tables_pr finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_insert_merge(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -421,7 +421,7 @@ async def test_batch_insert_merge(self, tables_storage_account_name, tables_prim finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_delete(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -452,7 +452,7 @@ async def test_batch_delete(self, tables_storage_account_name, tables_primary_st finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_inserts(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -489,7 +489,7 @@ async def test_batch_inserts(self, tables_storage_account_name, tables_primary_s finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_all_operations_together(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -560,7 +560,7 @@ async def test_batch_all_operations_together(self, tables_storage_account_name, finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_same_row_operations_fail(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -585,7 +585,7 @@ async def test_batch_same_row_operations_fail(self, tables_storage_account_name, finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_different_partition_operations_fail(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -610,7 +610,7 @@ async def test_batch_different_partition_operations_fail(self, tables_storage_ac finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_batch_too_many_ops(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -632,7 +632,7 @@ async def test_batch_too_many_ops(self, tables_storage_account_name, tables_prim finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_new_non_existent_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -649,7 +649,7 @@ async def test_new_non_existent_table(self, tables_storage_account_name, tables_ finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_new_invalid_key(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange invalid_key = tables_primary_storage_account_key[0:-6] + "==" # cut off a bit from the end to invalidate @@ -668,7 +668,7 @@ async def test_new_invalid_key(self, tables_storage_account_name, tables_primary with pytest.raises(ClientAuthenticationError): resp = await self.table.submit_transaction(batch) - @TablesPreparer() + @tables_decorator async def test_new_delete_nonexistent_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -683,7 +683,7 @@ async def test_new_delete_nonexistent_entity(self, tables_storage_account_name, await self._tear_down() @pytest.mark.live_test_only - @TablesPreparer() + @tables_decorator async def test_batch_sas_auth(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -732,7 +732,7 @@ async def test_batch_sas_auth(self, tables_storage_account_name, tables_primary_ await self._tear_down() @pytest.mark.live_test_only # Request bodies are very large - @TablesPreparer() + @tables_decorator async def test_batch_request_too_large(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos.py index 7a709515ac29..7bda0d30be25 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos.py @@ -34,7 +34,7 @@ ) from _shared.testcase import TableTestCase, SLEEP_DELAY -from preparers import CosmosPreparer +from preparers import cosmos_decorator #------------------------------------------------------------------------------ TEST_TABLE_PREFIX = 'table' @@ -169,7 +169,7 @@ def _assert_valid_batch_transaction(self, transaction, length): assert length == len(transaction) @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_insert(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -199,7 +199,7 @@ def test_batch_insert(self, tables_cosmos_account_name, tables_primary_cosmos_ac self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_update(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -234,7 +234,7 @@ def test_batch_update(self, tables_cosmos_account_name, tables_primary_cosmos_ac self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_merge(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -273,7 +273,7 @@ def test_batch_merge(self, tables_cosmos_account_name, tables_primary_cosmos_acc self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_update_if_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -301,7 +301,7 @@ def test_batch_update_if_match(self, tables_cosmos_account_name, tables_primary_ self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_update_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -327,7 +327,7 @@ def test_batch_update_if_doesnt_match(self, tables_cosmos_account_name, tables_p self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_insert_replace(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -357,7 +357,7 @@ def test_batch_insert_replace(self, tables_cosmos_account_name, tables_primary_c self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_insert_merge(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -387,7 +387,7 @@ def test_batch_insert_merge(self, tables_cosmos_account_name, tables_primary_cos self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_delete(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -419,7 +419,7 @@ def test_batch_delete(self, tables_cosmos_account_name, tables_primary_cosmos_ac self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_inserts(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -454,7 +454,7 @@ def test_batch_inserts(self, tables_cosmos_account_name, tables_primary_cosmos_a self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_all_operations_together(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -523,7 +523,7 @@ def test_batch_all_operations_together(self, tables_cosmos_account_name, tables_ self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_batch_different_partition_operations_fail(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -548,7 +548,7 @@ def test_batch_different_partition_operations_fail(self, tables_cosmos_account_n self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_new_non_existent_table(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -566,7 +566,7 @@ def test_new_non_existent_table(self, tables_cosmos_account_name, tables_primary self._tear_down() @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_new_delete_nonexistent_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -582,7 +582,7 @@ def test_new_delete_nonexistent_entity(self, tables_cosmos_account_name, tables_ @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") @pytest.mark.live_test_only # Request bodies are very large - @CosmosPreparer() + @cosmos_decorator def test_batch_request_too_large(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py index 3b4e726865c6..7265202670da 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py @@ -36,7 +36,7 @@ from _shared.testcase import SLEEP_DELAY from _shared.asynctestcase import AsyncTableTestCase -from preparers import CosmosPreparer +from preparers import cosmos_decorator #------------------------------------------------------------------------------ TEST_TABLE_PREFIX = 'table' @@ -172,7 +172,7 @@ def _assert_valid_batch_transaction(self, transaction, length): assert length == len(transaction) #--Test cases for batch --------------------------------------------- - @CosmosPreparer() + @cosmos_decorator async def test_batch_single_insert(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -203,7 +203,7 @@ async def test_batch_single_insert(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_single_update(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -238,7 +238,7 @@ async def test_batch_single_update(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_update(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -272,7 +272,7 @@ async def test_batch_update(self, tables_cosmos_account_name, tables_primary_cos finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_merge(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -310,7 +310,7 @@ async def test_batch_merge(self, tables_cosmos_account_name, tables_primary_cosm finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_update_if_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -337,7 +337,7 @@ async def test_batch_update_if_match(self, tables_cosmos_account_name, tables_pr finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_update_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -364,7 +364,7 @@ async def test_batch_update_if_doesnt_match(self, tables_cosmos_account_name, ta finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_insert_replace(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -393,7 +393,7 @@ async def test_batch_insert_replace(self, tables_cosmos_account_name, tables_pri finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_insert_merge(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -422,7 +422,7 @@ async def test_batch_insert_merge(self, tables_cosmos_account_name, tables_prima finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_delete(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -453,7 +453,7 @@ async def test_batch_delete(self, tables_cosmos_account_name, tables_primary_cos finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_inserts(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -490,7 +490,7 @@ async def test_batch_inserts(self, tables_cosmos_account_name, tables_primary_co finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_all_operations_together(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -561,7 +561,7 @@ async def test_batch_all_operations_together(self, tables_cosmos_account_name, t finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_batch_different_partition_operations_fail(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -586,7 +586,7 @@ async def test_batch_different_partition_operations_fail(self, tables_cosmos_acc finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_new_non_existent_table(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -604,7 +604,7 @@ async def test_new_non_existent_table(self, tables_cosmos_account_name, tables_p await self._tear_down() @pytest.mark.live_test_only - @CosmosPreparer() + @cosmos_decorator async def test_new_invalid_key(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange invalid_key = tables_primary_cosmos_account_key[0:-6] + "==" # cut off a bit from the end to invalidate @@ -624,7 +624,7 @@ async def test_new_invalid_key(self, tables_cosmos_account_name, tables_primary_ with pytest.raises(ClientAuthenticationError): resp = await self.table.submit_transaction(batch) - @CosmosPreparer() + @cosmos_decorator async def test_new_delete_nonexistent_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -639,7 +639,7 @@ async def test_new_delete_nonexistent_entity(self, tables_cosmos_account_name, t await self._tear_down() @pytest.mark.live_test_only # Request bodies are very large - @CosmosPreparer() + @cosmos_decorator async def test_batch_request_too_large(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_client.py b/sdk/tables/azure-data-tables/tests/test_table_client.py index af993338e060..6f34dad0a672 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client.py @@ -16,7 +16,7 @@ TableTestCase ) -from preparers import TablesPreparer +from preparers import tables_decorator # ------------------------------------------------------------------------------ @@ -31,7 +31,7 @@ class TestTableClient(AzureTestCase, TableTestCase): - @TablesPreparer() + @tables_decorator def test_user_agent_custom(self, tables_storage_account_name, tables_primary_storage_account_key): custom_app = "TestApp/v1.0" service = TableServiceClient( @@ -67,7 +67,7 @@ def callback(response): for table in tables: count += 1 - @TablesPreparer() + @tables_decorator def test_user_agent_append(self, tables_storage_account_name, tables_primary_storage_account_key): service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) @@ -83,7 +83,7 @@ def callback(response): for table in tables: count += 1 - @TablesPreparer() + @tables_decorator def test_user_agent_default(self, tables_storage_account_name, tables_primary_storage_account_key): service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) @@ -214,7 +214,7 @@ def test_create_service_with_socket_timeout(self): self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) assert service._client._client._pipeline._transport.connection_config.timeout == 22 assert default_service._client._client._pipeline._transport.connection_config.timeout == 300 - + # Assert Parent transport is shared with child client service = TableServiceClient( self.account_url(self.tables_storage_account_name, "table"), @@ -223,7 +223,7 @@ def test_create_service_with_socket_timeout(self): assert service._client._client._pipeline._transport.connection_config.timeout == 22 table = service.get_table_client('tablename') assert table._client._client._pipeline._transport._transport.connection_config.timeout == 22 - + # --Connection String Test Cases -------------------------------------------- diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_async.py index f989d2df8a27..b17211d6b9ad 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_async.py @@ -12,7 +12,7 @@ from azure.data.tables._version import VERSION from _shared.asynctestcase import AsyncTableTestCase -from preparers import TablesPreparer +from preparers import tables_decorator from devtools_testutils import AzureTestCase # ------------------------------------------------------------------------------ SERVICES = { @@ -27,7 +27,7 @@ class TestTableClient(AzureTestCase, AsyncTableTestCase): - @TablesPreparer() + @tables_decorator async def test_user_agent_default_async(self, tables_storage_account_name, tables_primary_storage_account_key): service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) @@ -46,7 +46,7 @@ def callback(response): async for table in tables: count += 1 - @TablesPreparer() + @tables_decorator async def test_user_agent_custom_async(self, tables_storage_account_name, tables_primary_storage_account_key): custom_app = "TestApp/v1.0" service = TableServiceClient( @@ -82,7 +82,7 @@ def callback(response): async for table in tables: count += 1 - @TablesPreparer() + @tables_decorator async def test_user_agent_append(self, tables_storage_account_name, tables_primary_storage_account_key): service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py index 8d8da85ef85c..a2cc5aad0a1f 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py @@ -17,7 +17,7 @@ TableTestCase, SLEEP_DELAY ) -from preparers import CosmosPreparer +from preparers import cosmos_decorator # ------------------------------------------------------------------------------ SERVICES = { @@ -32,7 +32,7 @@ class TestTableClient(AzureTestCase, TableTestCase): @pytest.mark.skipif(sys.version_info < (3, 0), reason="Malformed string") - @CosmosPreparer() + @cosmos_decorator def test_user_agent_default(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): service = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), credential=tables_primary_cosmos_account_key) @@ -54,7 +54,7 @@ def callback(response): sleep(SLEEP_DELAY) @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_user_agent_custom(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): custom_app = "TestApp/v1.0" service = TableServiceClient( @@ -94,7 +94,7 @@ def callback(response): sleep(SLEEP_DELAY) @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") - @CosmosPreparer() + @cosmos_decorator def test_user_agent_append(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): service = self.create_client_from_credential( TableServiceClient, diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py index 8952b69490f7..fb712a252b29 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py @@ -14,7 +14,7 @@ from _shared.asynctestcase import AsyncTableTestCase from _shared.testcase import SLEEP_DELAY -from preparers import CosmosPreparer +from preparers import cosmos_decorator from devtools_testutils import AzureTestCase # ------------------------------------------------------------------------------ @@ -30,7 +30,7 @@ class TestTableClient(AzureTestCase, AsyncTableTestCase): - @CosmosPreparer() + @cosmos_decorator async def test_user_agent_default_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): service = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), credential=tables_primary_cosmos_account_key) @@ -52,7 +52,7 @@ def callback(response): if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_user_agent_custom_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): custom_app = "TestApp/v1.0" service = TableServiceClient( @@ -88,7 +88,7 @@ def callback(response): if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_user_agent_append(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): service = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), credential=tables_primary_cosmos_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_cosmos.py index ff8abed741c2..e715badd20b8 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_cosmos.py @@ -44,7 +44,7 @@ ) from _shared.testcase import TableTestCase, SLEEP_DELAY -from preparers import CosmosPreparer +from preparers import cosmos_decorator # ------------------------------------------------------------------------------ TEST_TABLE_PREFIX = 'pytablesync' @@ -84,7 +84,7 @@ def _delete_all_tables(self, ts): pass # --Test cases for tables -------------------------------------------------- - @CosmosPreparer() + @cosmos_decorator def test_create_table(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -101,7 +101,7 @@ def test_create_table(self, tables_cosmos_account_name, tables_primary_cosmos_ac if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_create_table_fail_on_exist(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -119,7 +119,7 @@ def test_create_table_fail_on_exist(self, tables_cosmos_account_name, tables_pri if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_tables_per_page(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -150,7 +150,7 @@ def test_query_tables_per_page(self, tables_cosmos_account_name, tables_primary_ sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_tables(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -168,7 +168,7 @@ def test_query_tables(self, tables_cosmos_account_name, tables_primary_cosmos_ac if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_tables_with_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -188,7 +188,7 @@ def test_query_tables_with_filter(self, tables_cosmos_account_name, tables_prima if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_tables_with_num_results(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange prefix = 'listtable' @@ -216,7 +216,7 @@ def test_query_tables_with_num_results(self, tables_cosmos_account_name, tables_ if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_tables_with_marker(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -247,7 +247,7 @@ def test_query_tables_with_marker(self, tables_cosmos_account_name, tables_prima if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_delete_table_with_existing_table(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -263,7 +263,7 @@ def test_delete_table_with_existing_table(self, tables_cosmos_account_name, tabl if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange diff --git a/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py index 72f53706d89d..ce8f8e873aea 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py @@ -21,7 +21,7 @@ from _shared.asynctestcase import AsyncTableTestCase from _shared.testcase import SLEEP_DELAY -from preparers import CosmosPreparer +from preparers import cosmos_decorator TEST_TABLE_PREFIX = 'pytableasync' @@ -60,7 +60,7 @@ async def _delete_table(self, ts, table): pass # --Test cases for tables -------------------------------------------------- - @CosmosPreparer() + @cosmos_decorator async def test_create_table(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -77,7 +77,7 @@ async def test_create_table(self, tables_cosmos_account_name, tables_primary_cos if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_create_table_fail_on_exist(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -95,7 +95,7 @@ async def test_create_table_fail_on_exist(self, tables_cosmos_account_name, tabl if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_query_tables_per_page(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange # account_url = self.account_url(tables_cosmos_account_name, "table") @@ -128,7 +128,7 @@ async def test_query_tables_per_page(self, tables_cosmos_account_name, tables_pr if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_list_tables(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -147,7 +147,7 @@ async def test_list_tables(self, tables_cosmos_account_name, tables_primary_cosm if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_query_tables_with_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -167,7 +167,7 @@ async def test_query_tables_with_filter(self, tables_cosmos_account_name, tables if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_list_tables_with_num_results(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._delete_all_tables(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -196,7 +196,7 @@ async def test_list_tables_with_num_results(self, tables_cosmos_account_name, ta # if self.is_live: # sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_list_tables_with_marker(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -231,7 +231,7 @@ async def test_list_tables_with_marker(self, tables_cosmos_account_name, tables_ if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_delete_table_with_existing_table(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -248,7 +248,7 @@ async def test_delete_table_with_existing_table(self, tables_cosmos_account_name if self.is_live: sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity.py b/sdk/tables/azure-data-tables/tests/test_table_entity.py index 3c1cf70af42b..3cdca2a7f231 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity.py @@ -38,7 +38,7 @@ ) from _shared.testcase import TableTestCase -from preparers import TablesPreparer +from preparers import tables_decorator # ------------------------------------------------------------------------------ @@ -289,7 +289,7 @@ def _assert_valid_metadata(self, metadata): assert len(keys) == 3 # --Test cases for entities ------------------------------------------ - @TablesPreparer() + @tables_decorator def test_url_encoding_at_symbol(self, tables_storage_account_name, tables_primary_storage_account_key): self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -324,7 +324,7 @@ def test_url_encoding_at_symbol(self, tables_storage_account_name, tables_primar finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_etag(self, tables_storage_account_name, tables_primary_storage_account_key): self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -341,7 +341,7 @@ def test_insert_etag(self, tables_storage_account_name, tables_primary_storage_a finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_user_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -364,7 +364,7 @@ def test_query_user_filter(self, tables_storage_account_name, tables_primary_sto finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_user_filter_multiple_params(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -388,7 +388,7 @@ def test_query_user_filter_multiple_params(self, tables_storage_account_name, ta finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_user_filter_integers(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -411,7 +411,7 @@ def test_query_user_filter_integers(self, tables_storage_account_name, tables_pr finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_user_filter_floats(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -434,7 +434,7 @@ def test_query_user_filter_floats(self, tables_storage_account_name, tables_prim finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_user_filter_datetimes(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -457,7 +457,7 @@ def test_query_user_filter_datetimes(self, tables_storage_account_name, tables_p finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_user_filter_guids(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -480,7 +480,7 @@ def test_query_user_filter_guids(self, tables_storage_account_name, tables_prima finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_user_filter_binary(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -503,7 +503,7 @@ def test_query_user_filter_binary(self, tables_storage_account_name, tables_prim finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_user_filter_int64(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -533,7 +533,7 @@ def test_query_user_filter_int64(self, tables_storage_account_name, tables_prima finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_invalid_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -557,7 +557,7 @@ def test_query_invalid_filter(self, tables_storage_account_name, tables_primary_ finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_dictionary(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -572,7 +572,7 @@ def test_insert_entity_dictionary(self, tables_storage_account_name, tables_prim finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_with_hook(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -592,7 +592,7 @@ def test_insert_entity_with_hook(self, tables_storage_account_name, tables_prima finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_with_no_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -617,7 +617,7 @@ def test_insert_entity_with_no_metadata(self, tables_storage_account_name, table finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_with_full_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -642,7 +642,7 @@ def test_insert_entity_with_full_metadata(self, tables_storage_account_name, tab finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_conflict(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -657,7 +657,7 @@ def test_insert_entity_conflict(self, tables_storage_account_name, tables_primar finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_with_large_int32_value_throws(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -677,7 +677,7 @@ def test_insert_entity_with_large_int32_value_throws(self, tables_storage_accoun finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_with_large_int64_value_throws(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -697,7 +697,7 @@ def test_insert_entity_with_large_int64_value_throws(self, tables_storage_accoun finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_with_large_int_success(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -723,7 +723,7 @@ def test_insert_entity_with_large_int_success(self, tables_storage_account_name, finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_missing_pk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -737,7 +737,7 @@ def test_insert_entity_missing_pk(self, tables_storage_account_name, tables_prim finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_empty_string_pk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -751,7 +751,7 @@ def test_insert_entity_empty_string_pk(self, tables_storage_account_name, tables finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_missing_rk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -765,7 +765,7 @@ def test_insert_entity_missing_rk(self, tables_storage_account_name, tables_prim finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_empty_string_rk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -779,7 +779,7 @@ def test_insert_entity_empty_string_rk(self, tables_storage_account_name, tables finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_too_many_properties(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -796,7 +796,7 @@ def test_insert_entity_too_many_properties(self, tables_storage_account_name, ta finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_property_name_too_long(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -812,7 +812,7 @@ def test_insert_entity_property_name_too_long(self, tables_storage_account_name, finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_entity_with_enums(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -842,7 +842,7 @@ class Color(Enum): finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_get_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -860,7 +860,7 @@ def test_get_entity(self, tables_storage_account_name, tables_primary_storage_ac finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_get_entity_with_hook(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -882,7 +882,7 @@ def test_get_entity_with_hook(self, tables_storage_account_name, tables_primary_ finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_get_entity_if_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -910,7 +910,7 @@ def test_get_entity_if_match(self, tables_storage_account_name, tables_primary_s finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_get_entity_full_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -930,7 +930,7 @@ def test_get_entity_full_metadata(self, tables_storage_account_name, tables_prim finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_get_entity_no_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -950,7 +950,7 @@ def test_get_entity_no_metadata(self, tables_storage_account_name, tables_primar finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_get_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -966,7 +966,7 @@ def test_get_entity_not_existing(self, tables_storage_account_name, tables_prima finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_get_entity_with_special_doubles(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -990,7 +990,7 @@ def test_get_entity_with_special_doubles(self, tables_storage_account_name, tabl finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_update_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1014,7 +1014,7 @@ def test_update_entity(self, tables_storage_account_name, tables_primary_storage finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_update_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1030,7 +1030,7 @@ def test_update_entity_not_existing(self, tables_storage_account_name, tables_pr finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_update_entity_with_if_matches(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1051,7 +1051,7 @@ def test_update_entity_with_if_matches(self, tables_storage_account_name, tables finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_update_entity_with_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1069,7 +1069,7 @@ def test_update_entity_with_if_doesnt_match(self, tables_storage_account_name, t finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_or_merge_entity_with_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -1088,7 +1088,7 @@ def test_insert_or_merge_entity_with_existing_entity(self, tables_storage_accoun finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_or_merge_entity_with_non_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -1108,7 +1108,7 @@ def test_insert_or_merge_entity_with_non_existing_entity(self, tables_storage_ac finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_or_replace_entity_with_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -1127,7 +1127,7 @@ def test_insert_or_replace_entity_with_existing_entity(self, tables_storage_acco finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_insert_or_replace_entity_with_non_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -1147,7 +1147,7 @@ def test_insert_or_replace_entity_with_non_existing_entity(self, tables_storage_ finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_merge_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1165,7 +1165,7 @@ def test_merge_entity(self, tables_storage_account_name, tables_primary_storage_ finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_merge_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1181,7 +1181,7 @@ def test_merge_entity_not_existing(self, tables_storage_account_name, tables_pri finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_merge_entity_with_if_matches(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1203,7 +1203,7 @@ def test_merge_entity_with_if_matches(self, tables_storage_account_name, tables_ finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_merge_entity_with_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1222,7 +1222,7 @@ def test_merge_entity_with_if_doesnt_match(self, tables_storage_account_name, ta finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_delete_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1239,7 +1239,7 @@ def test_delete_entity(self, tables_storage_account_name, tables_primary_storage finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_delete_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1254,7 +1254,7 @@ def test_delete_entity_not_existing(self, tables_storage_account_name, tables_pr finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_delete_entity_with_if_matches(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1272,7 +1272,7 @@ def test_delete_entity_with_if_matches(self, tables_storage_account_name, tables finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_delete_entity_with_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1290,7 +1290,7 @@ def test_delete_entity_with_if_doesnt_match(self, tables_storage_account_name, t finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_unicode_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1314,7 +1314,7 @@ def test_unicode_property_value(self, tables_storage_account_name, tables_primar finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_unicode_property_name(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1338,7 +1338,7 @@ def test_unicode_property_name(self, tables_storage_account_name, tables_primary finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_operations_on_entity_with_partition_key_having_single_quote(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange partition_key_with_single_quote = u"a''''b" @@ -1375,7 +1375,7 @@ def test_operations_on_entity_with_partition_key_having_single_quote(self, table finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_empty_and_spaces_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1413,7 +1413,7 @@ def test_empty_and_spaces_property_value(self, tables_storage_account_name, tabl finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_none_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1431,7 +1431,7 @@ def test_none_property_value(self, tables_storage_account_name, tables_primary_s finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_binary_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1450,7 +1450,7 @@ def test_binary_property_value(self, tables_storage_account_name, tables_primary finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_timezone(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1472,7 +1472,7 @@ def test_timezone(self, tables_storage_account_name, tables_primary_storage_acco finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_entities(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1489,7 +1489,7 @@ def test_query_entities(self, tables_storage_account_name, tables_primary_storag finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_entities_each_page(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1529,7 +1529,7 @@ def test_query_entities_each_page(self, tables_storage_account_name, tables_prim finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_zero_entities(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1544,7 +1544,7 @@ def test_query_zero_entities(self, tables_storage_account_name, tables_primary_s finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_entities_full_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1561,7 +1561,7 @@ def test_query_entities_full_metadata(self, tables_storage_account_name, tables_ finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_entities_no_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1578,7 +1578,7 @@ def test_query_entities_no_metadata(self, tables_storage_account_name, tables_pr finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_entities_with_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1599,7 +1599,7 @@ def test_query_entities_with_filter(self, tables_storage_account_name, tables_pr finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_injection(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1626,7 +1626,7 @@ def test_query_injection(self, tables_storage_account_name, tables_primary_stora self.ts.delete_table(table_name) self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_special_chars(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1667,7 +1667,7 @@ def test_query_special_chars(self, tables_storage_account_name, tables_primary_s self.ts.delete_table(table_name) self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_entities_with_select(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1687,7 +1687,7 @@ def test_query_entities_with_select(self, tables_storage_account_name, tables_pr finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_entities_with_top(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1702,7 +1702,7 @@ def test_query_entities_with_top(self, tables_storage_account_name, tables_prima finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_query_entities_with_top_and_next(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1735,7 +1735,7 @@ def test_query_entities_with_top_and_next(self, tables_storage_account_name, tab finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_sas_query(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1769,7 +1769,7 @@ def test_sas_query(self, tables_storage_account_name, tables_primary_storage_acc finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_sas_add(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1803,7 +1803,7 @@ def test_sas_add(self, tables_storage_account_name, tables_primary_storage_accou finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_sas_add_inside_range(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1836,7 +1836,7 @@ def test_sas_add_inside_range(self, tables_storage_account_name, tables_primary_ finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_sas_add_outside_range(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1868,7 +1868,7 @@ def test_sas_add_outside_range(self, tables_storage_account_name, tables_primary finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_sas_update(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1908,7 +1908,7 @@ def test_sas_update(self, tables_storage_account_name, tables_primary_storage_ac finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_sas_delete(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1939,7 +1939,7 @@ def test_sas_delete(self, tables_storage_account_name, tables_primary_storage_ac finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_sas_upper_case_table_name(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1981,7 +1981,7 @@ def test_sas_upper_case_table_name(self, tables_storage_account_name, tables_pri finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_sas_signed_identifier(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -2021,7 +2021,7 @@ def test_sas_signed_identifier(self, tables_storage_account_name, tables_primary finally: self._tear_down() - @TablesPreparer() + @tables_decorator def test_datetime_milliseconds(self, tables_storage_account_name, tables_primary_storage_account_key): self._set_up(tables_storage_account_name, tables_primary_storage_account_key) try: @@ -2042,7 +2042,7 @@ def test_datetime_milliseconds(self, tables_storage_account_name, tables_primary self._tear_down() - @TablesPreparer() + @tables_decorator def test_datetime_str_passthrough(self, tables_storage_account_name, tables_primary_storage_account_key): self._set_up(tables_storage_account_name, tables_primary_storage_account_key) partition, row = self._create_pk_rk(None, None) diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py index a95ffe8d3d40..53a743865df6 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py @@ -35,7 +35,7 @@ from azure.data.tables.aio import TableServiceClient from _shared.asynctestcase import AsyncTableTestCase -from preparers import TablesPreparer +from preparers import tables_decorator class StorageTableEntityTest(AzureTestCase, AsyncTableTestCase): @@ -281,7 +281,7 @@ def _assert_valid_metadata(self, metadata): # --Test cases for entities ------------------------------------------ - @TablesPreparer() + @tables_decorator async def test_url_encoding_at_symbol(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -316,7 +316,7 @@ async def test_url_encoding_at_symbol(self, tables_storage_account_name, tables_ finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_dictionary(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -331,7 +331,7 @@ async def test_insert_entity_dictionary(self, tables_storage_account_name, table finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_with_hook(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -350,7 +350,7 @@ async def test_insert_entity_with_hook(self, tables_storage_account_name, tables finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_with_no_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -375,7 +375,7 @@ async def test_insert_entity_with_no_metadata(self, tables_storage_account_name, finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_with_full_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -402,7 +402,7 @@ async def test_insert_entity_with_full_metadata(self, tables_storage_account_nam finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_conflict(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -418,7 +418,7 @@ async def test_insert_entity_conflict(self, tables_storage_account_name, tables_ finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_with_large_int32_value_throws(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -438,7 +438,7 @@ async def test_insert_entity_with_large_int32_value_throws(self, tables_storage_ finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_with_large_int64_value_throws(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -458,7 +458,7 @@ async def test_insert_entity_with_large_int64_value_throws(self, tables_storage_ finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_with_large_int_success(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -484,7 +484,7 @@ async def test_insert_entity_with_large_int_success(self, tables_storage_account finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_missing_pk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -497,7 +497,7 @@ async def test_insert_entity_missing_pk(self, tables_storage_account_name, table finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_empty_string_pk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -510,7 +510,7 @@ async def test_insert_entity_empty_string_pk(self, tables_storage_account_name, finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_missing_rk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -525,7 +525,7 @@ async def test_insert_entity_missing_rk(self, tables_storage_account_name, table finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_empty_string_rk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -539,7 +539,7 @@ async def test_insert_entity_empty_string_rk(self, tables_storage_account_name, finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_too_many_properties(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -556,7 +556,7 @@ async def test_insert_entity_too_many_properties(self, tables_storage_account_na finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_entity_property_name_too_long(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -573,7 +573,7 @@ async def test_insert_entity_property_name_too_long(self, tables_storage_account finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_get_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -591,7 +591,7 @@ async def test_get_entity(self, tables_storage_account_name, tables_primary_stor finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_get_entity_with_hook(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -613,7 +613,7 @@ async def test_get_entity_with_hook(self, tables_storage_account_name, tables_pr finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_get_entity_if_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -637,7 +637,7 @@ async def test_get_entity_if_match(self, tables_storage_account_name, tables_pri finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_get_entity_full_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -657,7 +657,7 @@ async def test_get_entity_full_metadata(self, tables_storage_account_name, table finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_get_entity_no_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -677,7 +677,7 @@ async def test_get_entity_no_metadata(self, tables_storage_account_name, tables_ finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_get_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -693,7 +693,7 @@ async def test_get_entity_not_existing(self, tables_storage_account_name, tables finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_get_entity_with_special_doubles(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -718,7 +718,7 @@ async def test_get_entity_with_special_doubles(self, tables_storage_account_name finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_update_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -740,7 +740,7 @@ async def test_update_entity(self, tables_storage_account_name, tables_primary_s finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_update_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -756,7 +756,7 @@ async def test_update_entity_not_existing(self, tables_storage_account_name, tab finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_update_entity_with_if_matches(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -778,7 +778,7 @@ async def test_update_entity_with_if_matches(self, tables_storage_account_name, finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_update_entity_with_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -799,7 +799,7 @@ async def test_update_entity_with_if_doesnt_match(self, tables_storage_account_n finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_or_merge_entity_with_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -819,7 +819,7 @@ async def test_insert_or_merge_entity_with_existing_entity(self, tables_storage_ finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_or_merge_entity_with_non_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -839,7 +839,7 @@ async def test_insert_or_merge_entity_with_non_existing_entity(self, tables_stor finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_or_replace_entity_with_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -859,7 +859,7 @@ async def test_insert_or_replace_entity_with_existing_entity(self, tables_storag finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_insert_or_replace_entity_with_non_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -879,7 +879,7 @@ async def test_insert_or_replace_entity_with_non_existing_entity(self, tables_st finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_merge_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -898,7 +898,7 @@ async def test_merge_entity(self, tables_storage_account_name, tables_primary_st finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_merge_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -914,7 +914,7 @@ async def test_merge_entity_not_existing(self, tables_storage_account_name, tabl finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_merge_entity_with_if_matches(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -935,7 +935,7 @@ async def test_merge_entity_with_if_matches(self, tables_storage_account_name, t finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_merge_entity_with_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -955,7 +955,7 @@ async def test_merge_entity_with_if_doesnt_match(self, tables_storage_account_na finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_delete_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -972,7 +972,7 @@ async def test_delete_entity(self, tables_storage_account_name, tables_primary_s finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_delete_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -987,7 +987,7 @@ async def test_delete_entity_not_existing(self, tables_storage_account_name, tab finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_delete_entity_with_if_matches(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1005,7 +1005,7 @@ async def test_delete_entity_with_if_matches(self, tables_storage_account_name, finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_delete_entity_with_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -1024,7 +1024,7 @@ async def test_delete_entity_with_if_doesnt_match(self, tables_storage_account_n finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_unicode_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): ''' regression test for github issue #57''' # Arrange @@ -1051,7 +1051,7 @@ async def test_unicode_property_value(self, tables_storage_account_name, tables_ finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_unicode_property_name(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1077,7 +1077,7 @@ async def test_unicode_property_name(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_operations_on_entity_with_partition_key_having_single_quote(self, tables_storage_account_name, tables_primary_storage_account_key): partition_key_with_single_quote = u"a''''b" row_key_with_single_quote = u"a''''b" @@ -1103,7 +1103,7 @@ async def test_operations_on_entity_with_partition_key_having_single_quote(self, finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_empty_and_spaces_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -1142,7 +1142,7 @@ async def test_empty_and_spaces_property_value(self, tables_storage_account_name finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_none_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1160,7 +1160,7 @@ async def test_none_property_value(self, tables_storage_account_name, tables_pri finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_binary_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1179,7 +1179,7 @@ async def test_binary_property_value(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_timezone(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1201,7 +1201,7 @@ async def test_timezone(self, tables_storage_account_name, tables_primary_storag finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_entities(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1220,7 +1220,7 @@ async def test_query_entities(self, tables_storage_account_name, tables_primary_ finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_entities_each_page(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1260,7 +1260,7 @@ async def test_query_entities_each_page(self, tables_storage_account_name, table finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_injection_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1296,7 +1296,7 @@ async def test_query_injection_async(self, tables_storage_account_name, tables_p await self.ts.delete_table(table_name) await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_special_chars(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1355,7 +1355,7 @@ async def test_query_special_chars(self, tables_storage_account_name, tables_pri await self.ts.delete_table(table_name) await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_user_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1375,7 +1375,7 @@ async def test_query_user_filter(self, tables_storage_account_name, tables_prima finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_user_filter_multiple_params(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1399,7 +1399,7 @@ async def test_query_user_filter_multiple_params(self, tables_storage_account_na finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_user_filter_integers(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1422,7 +1422,7 @@ async def test_query_user_filter_integers(self, tables_storage_account_name, tab finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_user_filter_floats(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1445,7 +1445,7 @@ async def test_query_user_filter_floats(self, tables_storage_account_name, table finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_user_filter_datetimes(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1468,7 +1468,7 @@ async def test_query_user_filter_datetimes(self, tables_storage_account_name, ta finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_user_filter_guids(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1491,7 +1491,7 @@ async def test_query_user_filter_guids(self, tables_storage_account_name, tables finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_user_filter_binary(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1514,7 +1514,7 @@ async def test_query_user_filter_binary(self, tables_storage_account_name, table finally: self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_user_filter_int64(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1544,7 +1544,7 @@ async def test_query_user_filter_int64(self, tables_storage_account_name, tables finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_zero_entities(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1561,7 +1561,7 @@ async def test_query_zero_entities(self, tables_storage_account_name, tables_pri finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_entities_full_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1580,7 +1580,7 @@ async def test_query_entities_full_metadata(self, tables_storage_account_name, t finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_entities_no_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1599,7 +1599,7 @@ async def test_query_entities_no_metadata(self, tables_storage_account_name, tab finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_entities_with_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1621,7 +1621,7 @@ async def test_query_entities_with_filter(self, tables_storage_account_name, tab finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_invalid_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1643,7 +1643,7 @@ async def test_query_invalid_filter(self, tables_storage_account_name, tables_pr finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_entities_with_select(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1665,7 +1665,7 @@ async def test_query_entities_with_select(self, tables_storage_account_name, tab finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_entities_with_top(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1682,7 +1682,7 @@ async def test_query_entities_with_top(self, tables_storage_account_name, tables finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_query_entities_with_top_and_next(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -1718,7 +1718,7 @@ async def test_query_entities_with_top_and_next(self, tables_storage_account_nam finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_sas_query(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1754,7 +1754,7 @@ async def test_sas_query(self, tables_storage_account_name, tables_primary_stora finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_sas_add(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1788,7 +1788,7 @@ async def test_sas_add(self, tables_storage_account_name, tables_primary_storage finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_sas_add_inside_range(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1821,7 +1821,7 @@ async def test_sas_add_inside_range(self, tables_storage_account_name, tables_pr finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_sas_add_outside_range(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1853,7 +1853,7 @@ async def test_sas_add_outside_range(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_sas_update(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1888,7 +1888,7 @@ async def test_sas_update(self, tables_storage_account_name, tables_primary_stor finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_sas_delete(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1919,7 +1919,7 @@ async def test_sas_delete(self, tables_storage_account_name, tables_primary_stor finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_sas_upper_case_table_name(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1956,7 +1956,7 @@ async def test_sas_upper_case_table_name(self, tables_storage_account_name, tabl finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_sas_signed_identifier(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1998,7 +1998,7 @@ async def test_sas_signed_identifier(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_datetime_milliseconds(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) try: @@ -2018,7 +2018,7 @@ async def test_datetime_milliseconds(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @TablesPreparer() + @tables_decorator async def test_datetime_str_passthrough(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) partition, row = self._create_pk_rk(None, None) diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py index a5542c363a35..ff284e76f8fd 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py @@ -36,7 +36,7 @@ ) from _shared.testcase import TableTestCase, SLEEP_DELAY -from preparers import CosmosPreparer +from preparers import cosmos_decorator # ------------------------------------------------------------------------------ @@ -289,7 +289,7 @@ def _assert_valid_metadata(self, metadata): assert len(keys) == 3 # --Test cases for entities ------------------------------------------ - @CosmosPreparer() + @cosmos_decorator def test_url_encoding_at_symbol(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -325,7 +325,7 @@ def test_url_encoding_at_symbol(self, tables_cosmos_account_name, tables_primary self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_etag(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -342,7 +342,7 @@ def test_insert_etag(self, tables_cosmos_account_name, tables_primary_cosmos_acc self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_user_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -363,7 +363,7 @@ def test_query_user_filter(self, tables_cosmos_account_name, tables_primary_cosm self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_user_filter_multiple_params(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -388,7 +388,7 @@ def test_query_user_filter_multiple_params(self, tables_cosmos_account_name, tab self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_user_filter_integers(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -412,7 +412,7 @@ def test_query_user_filter_integers(self, tables_cosmos_account_name, tables_pri self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_user_filter_floats(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -436,7 +436,7 @@ def test_query_user_filter_floats(self, tables_cosmos_account_name, tables_prima self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_user_filter_datetimes(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -460,7 +460,7 @@ def test_query_user_filter_datetimes(self, tables_cosmos_account_name, tables_pr self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_user_filter_guids(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -484,7 +484,7 @@ def test_query_user_filter_guids(self, tables_cosmos_account_name, tables_primar self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_user_filter_binary(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -507,7 +507,7 @@ def test_query_user_filter_binary(self, tables_cosmos_account_name, tables_prima finally: self._tear_down() - @CosmosPreparer() + @cosmos_decorator def test_query_user_filter_int64(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -536,7 +536,7 @@ def test_query_user_filter_int64(self, tables_cosmos_account_name, tables_primar finally: self._tear_down() - @CosmosPreparer() + @cosmos_decorator def test_query_invalid_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -561,7 +561,7 @@ def test_query_invalid_filter(self, tables_cosmos_account_name, tables_primary_c self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_dictionary(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -577,7 +577,7 @@ def test_insert_entity_dictionary(self, tables_cosmos_account_name, tables_prima self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_with_hook(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -598,7 +598,7 @@ def test_insert_entity_with_hook(self, tables_cosmos_account_name, tables_primar self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_with_no_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -624,7 +624,7 @@ def test_insert_entity_with_no_metadata(self, tables_cosmos_account_name, tables self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_with_full_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -650,7 +650,7 @@ def test_insert_entity_with_full_metadata(self, tables_cosmos_account_name, tabl self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_conflict(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -668,7 +668,7 @@ def test_insert_entity_conflict(self, tables_cosmos_account_name, tables_primary self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_with_large_int32_value_throws(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -689,7 +689,7 @@ def test_insert_entity_with_large_int32_value_throws(self, tables_cosmos_account self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_with_large_int64_value_throws(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -710,7 +710,7 @@ def test_insert_entity_with_large_int64_value_throws(self, tables_cosmos_account self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_with_large_int_success(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -737,7 +737,7 @@ def test_insert_entity_with_large_int_success(self, tables_cosmos_account_name, self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_missing_pk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -752,7 +752,7 @@ def test_insert_entity_missing_pk(self, tables_cosmos_account_name, tables_prima self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_empty_string_pk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -769,7 +769,7 @@ def test_insert_entity_empty_string_pk(self, tables_cosmos_account_name, tables_ self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_missing_rk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -785,7 +785,7 @@ def test_insert_entity_missing_rk(self, tables_cosmos_account_name, tables_prima self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_entity_empty_string_rk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -800,7 +800,7 @@ def test_insert_entity_empty_string_rk(self, tables_cosmos_account_name, tables_ self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_get_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -819,7 +819,7 @@ def test_get_entity(self, tables_cosmos_account_name, tables_primary_cosmos_acco self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_get_entity_with_hook(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -842,7 +842,7 @@ def test_get_entity_with_hook(self, tables_cosmos_account_name, tables_primary_c self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_get_entity_if_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -867,7 +867,7 @@ def test_get_entity_if_match(self, tables_cosmos_account_name, tables_primary_co self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_get_entity_full_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -888,7 +888,7 @@ def test_get_entity_full_metadata(self, tables_cosmos_account_name, tables_prima self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_get_entity_no_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -909,7 +909,7 @@ def test_get_entity_no_metadata(self, tables_cosmos_account_name, tables_primary self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_get_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -926,7 +926,7 @@ def test_get_entity_not_existing(self, tables_cosmos_account_name, tables_primar self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_get_entity_with_special_doubles(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -951,7 +951,7 @@ def test_get_entity_with_special_doubles(self, tables_cosmos_account_name, table self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_update_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -973,7 +973,7 @@ def test_update_entity(self, tables_cosmos_account_name, tables_primary_cosmos_a self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_update_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -990,7 +990,7 @@ def test_update_entity_not_existing(self, tables_cosmos_account_name, tables_pri self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_update_entity_with_if_matches(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1012,7 +1012,7 @@ def test_update_entity_with_if_matches(self, tables_cosmos_account_name, tables_ self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_update_entity_with_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1033,7 +1033,7 @@ def test_update_entity_with_if_doesnt_match(self, tables_cosmos_account_name, ta self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_or_merge_entity_with_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -1053,7 +1053,7 @@ def test_insert_or_merge_entity_with_existing_entity(self, tables_cosmos_account self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_or_merge_entity_with_non_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -1074,7 +1074,7 @@ def test_insert_or_merge_entity_with_non_existing_entity(self, tables_cosmos_acc self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_or_replace_entity_with_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -1094,7 +1094,7 @@ def test_insert_or_replace_entity_with_existing_entity(self, tables_cosmos_accou self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_insert_or_replace_entity_with_non_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -1115,7 +1115,7 @@ def test_insert_or_replace_entity_with_non_existing_entity(self, tables_cosmos_a self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_merge_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1134,7 +1134,7 @@ def test_merge_entity(self, tables_cosmos_account_name, tables_primary_cosmos_ac self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_merge_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1151,7 +1151,7 @@ def test_merge_entity_not_existing(self, tables_cosmos_account_name, tables_prim self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_merge_entity_with_if_matches(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1174,7 +1174,7 @@ def test_merge_entity_with_if_matches(self, tables_cosmos_account_name, tables_p self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_merge_entity_with_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1194,7 +1194,7 @@ def test_merge_entity_with_if_doesnt_match(self, tables_cosmos_account_name, tab self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_delete_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1211,7 +1211,7 @@ def test_delete_entity(self, tables_cosmos_account_name, tables_primary_cosmos_a self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_delete_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1227,7 +1227,7 @@ def test_delete_entity_not_existing(self, tables_cosmos_account_name, tables_pri self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_delete_entity_with_if_matches(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1249,7 +1249,7 @@ def test_delete_entity_with_if_matches(self, tables_cosmos_account_name, tables_ self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_delete_entity_with_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1268,7 +1268,7 @@ def test_delete_entity_with_if_doesnt_match(self, tables_cosmos_account_name, ta self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_unicode_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1293,7 +1293,7 @@ def test_unicode_property_value(self, tables_cosmos_account_name, tables_primary self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_unicode_property_name(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1319,7 +1319,7 @@ def test_unicode_property_name(self, tables_cosmos_account_name, tables_primary_ self.sleep(SLEEP_DELAY) @pytest.mark.skip("Bad Request: Cosmos cannot handle single quotes in a PK/RK (confirm)") - @CosmosPreparer() + @cosmos_decorator def test_operations_on_entity_with_partition_key_having_single_quote(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -1358,7 +1358,7 @@ def test_operations_on_entity_with_partition_key_having_single_quote(self, table self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_empty_and_spaces_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1397,7 +1397,7 @@ def test_empty_and_spaces_property_value(self, tables_cosmos_account_name, table self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_none_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1416,7 +1416,7 @@ def test_none_property_value(self, tables_cosmos_account_name, tables_primary_co self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_binary_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1436,7 +1436,7 @@ def test_binary_property_value(self, tables_cosmos_account_name, tables_primary_ self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_timezone(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1459,7 +1459,7 @@ def test_timezone(self, tables_cosmos_account_name, tables_primary_cosmos_accoun self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_entities(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1477,7 +1477,7 @@ def test_query_entities(self, tables_cosmos_account_name, tables_primary_cosmos_ self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_entities_each_page(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1518,7 +1518,7 @@ def test_query_entities_each_page(self, tables_cosmos_account_name, tables_prima self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_zero_entities(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1534,7 +1534,7 @@ def test_query_zero_entities(self, tables_cosmos_account_name, tables_primary_co self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_entities_full_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1552,7 +1552,7 @@ def test_query_entities_full_metadata(self, tables_cosmos_account_name, tables_p self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_entities_no_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1570,7 +1570,7 @@ def test_query_entities_no_metadata(self, tables_cosmos_account_name, tables_pri self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_entities_with_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1591,7 +1591,7 @@ def test_query_entities_with_filter(self, tables_cosmos_account_name, tables_pri self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_injection(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1619,7 +1619,7 @@ def test_query_injection(self, tables_cosmos_account_name, tables_primary_cosmos self._tear_down() @pytest.mark.live_test_only - @CosmosPreparer() + @cosmos_decorator def test_query_special_chars(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1660,7 +1660,7 @@ def test_query_special_chars(self, tables_cosmos_account_name, tables_primary_co self.ts.delete_table(table_name) self._tear_down() - @CosmosPreparer() + @cosmos_decorator def test_query_entities_with_select(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1683,7 +1683,7 @@ def test_query_entities_with_select(self, tables_cosmos_account_name, tables_pri self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_entities_with_top(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1699,7 +1699,7 @@ def test_query_entities_with_top(self, tables_cosmos_account_name, tables_primar self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_query_entities_with_top_and_next(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1733,7 +1733,7 @@ def test_query_entities_with_top_and_next(self, tables_cosmos_account_name, tabl self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_datetime_milliseconds(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) try: @@ -1754,7 +1754,7 @@ def test_datetime_milliseconds(self, tables_cosmos_account_name, tables_primary_ self._tear_down() self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_datetime_str_passthrough(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) partition, row = self._create_pk_rk(None, None) diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py index d07f496d5e6e..7bbf9e0f2308 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py @@ -37,7 +37,7 @@ from _shared.asynctestcase import AsyncTableTestCase from _shared.testcase import SLEEP_DELAY -from preparers import CosmosPreparer +from preparers import cosmos_decorator # ------------------------------------------------------------------------------ # TODO: change to `with table_client as client:` to close sessions # ------------------------------------------------------------------------------ @@ -286,7 +286,7 @@ def _assert_valid_metadata(self, metadata): assert len(keys) == 3 # --Test cases for entities ------------------------------------------ - @CosmosPreparer() + @cosmos_decorator async def test_url_encoding_at_symbol(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -321,7 +321,7 @@ async def test_url_encoding_at_symbol(self, tables_cosmos_account_name, tables_p finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_dictionary(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -336,7 +336,7 @@ async def test_insert_entity_dictionary(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_with_hook(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -355,7 +355,7 @@ async def test_insert_entity_with_hook(self, tables_cosmos_account_name, tables_ finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_with_no_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -380,7 +380,7 @@ async def test_insert_entity_with_no_metadata(self, tables_cosmos_account_name, finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_with_full_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -406,7 +406,7 @@ async def test_insert_entity_with_full_metadata(self, tables_cosmos_account_name finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_conflict(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -421,7 +421,7 @@ async def test_insert_entity_conflict(self, tables_cosmos_account_name, tables_p finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_with_large_int32_value_throws(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -441,7 +441,7 @@ async def test_insert_entity_with_large_int32_value_throws(self, tables_cosmos_a finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_with_large_int64_value_throws(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -461,7 +461,7 @@ async def test_insert_entity_with_large_int64_value_throws(self, tables_cosmos_a finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_with_large_int_success(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -487,7 +487,7 @@ async def test_insert_entity_with_large_int_success(self, tables_cosmos_account_ finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_missing_pk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -501,7 +501,7 @@ async def test_insert_entity_missing_pk(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_empty_string_pk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -514,7 +514,7 @@ async def test_insert_entity_empty_string_pk(self, tables_cosmos_account_name, t finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_missing_rk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -529,7 +529,7 @@ async def test_insert_entity_missing_rk(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_entity_empty_string_rk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -543,7 +543,7 @@ async def test_insert_entity_empty_string_rk(self, tables_cosmos_account_name, t finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_get_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -561,7 +561,7 @@ async def test_get_entity(self, tables_cosmos_account_name, tables_primary_cosmo finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_get_entity_with_hook(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -581,7 +581,7 @@ async def test_get_entity_with_hook(self, tables_cosmos_account_name, tables_pri finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_get_entity_if_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -603,7 +603,7 @@ async def test_get_entity_if_match(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_get_entity_full_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -623,7 +623,7 @@ async def test_get_entity_full_metadata(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_get_entity_no_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -643,7 +643,7 @@ async def test_get_entity_no_metadata(self, tables_cosmos_account_name, tables_p finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_get_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -659,7 +659,7 @@ async def test_get_entity_not_existing(self, tables_cosmos_account_name, tables_ finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_get_entity_with_special_doubles(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -684,7 +684,7 @@ async def test_get_entity_with_special_doubles(self, tables_cosmos_account_name, finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_update_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -706,7 +706,7 @@ async def test_update_entity(self, tables_cosmos_account_name, tables_primary_co finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_update_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -722,7 +722,7 @@ async def test_update_entity_not_existing(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_update_entity_with_if_matches(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -744,7 +744,7 @@ async def test_update_entity_with_if_matches(self, tables_cosmos_account_name, t finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_update_entity_with_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -765,7 +765,7 @@ async def test_update_entity_with_if_doesnt_match(self, tables_cosmos_account_na finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_or_merge_entity_with_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -784,7 +784,7 @@ async def test_insert_or_merge_entity_with_existing_entity(self, tables_cosmos_a finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_or_merge_entity_with_non_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -802,7 +802,7 @@ async def test_insert_or_merge_entity_with_non_existing_entity(self, tables_cosm finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_or_replace_entity_with_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -821,7 +821,7 @@ async def test_insert_or_replace_entity_with_existing_entity(self, tables_cosmos finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_insert_or_replace_entity_with_non_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -838,7 +838,7 @@ async def test_insert_or_replace_entity_with_non_existing_entity(self, tables_co finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_merge_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -855,7 +855,7 @@ async def test_merge_entity(self, tables_cosmos_account_name, tables_primary_cos finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_merge_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -871,7 +871,7 @@ async def test_merge_entity_not_existing(self, tables_cosmos_account_name, table finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_merge_entity_with_if_matches(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -890,7 +890,7 @@ async def test_merge_entity_with_if_matches(self, tables_cosmos_account_name, ta finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_merge_entity_with_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -910,7 +910,7 @@ async def test_merge_entity_with_if_doesnt_match(self, tables_cosmos_account_nam finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_delete_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -925,7 +925,7 @@ async def test_delete_entity(self, tables_cosmos_account_name, tables_primary_co finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_delete_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -940,7 +940,7 @@ async def test_delete_entity_not_existing(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_delete_entity_with_if_matches(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -956,7 +956,7 @@ async def test_delete_entity_with_if_matches(self, tables_cosmos_account_name, t finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_delete_entity_with_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -975,7 +975,7 @@ async def test_delete_entity_with_if_doesnt_match(self, tables_cosmos_account_na finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_unicode_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): ''' regression test for github issue #57''' # Arrange @@ -1002,7 +1002,7 @@ async def test_unicode_property_value(self, tables_cosmos_account_name, tables_p finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_unicode_property_name(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1029,7 +1029,7 @@ async def test_unicode_property_name(self, tables_cosmos_account_name, tables_pr await self._tear_down() @pytest.mark.skip("Bad Request: Cosmos cannot handle single quotes in a PK/RK (confirm)") - @CosmosPreparer() + @cosmos_decorator async def test_operations_on_entity_with_partition_key_having_single_quote(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange partition_key_with_single_quote = "a''''b" @@ -1059,7 +1059,7 @@ async def test_operations_on_entity_with_partition_key_having_single_quote(self, finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_empty_and_spaces_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -1098,7 +1098,7 @@ async def test_empty_and_spaces_property_value(self, tables_cosmos_account_name, finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_none_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1116,7 +1116,7 @@ async def test_none_property_value(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_binary_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1135,7 +1135,7 @@ async def test_binary_property_value(self, tables_cosmos_account_name, tables_pr finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_timezone(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1157,7 +1157,7 @@ async def test_timezone(self, tables_cosmos_account_name, tables_primary_cosmos_ finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_entities(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1176,7 +1176,7 @@ async def test_query_entities(self, tables_cosmos_account_name, tables_primary_c finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_entities_each_page(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1216,7 +1216,7 @@ async def test_query_entities_each_page(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_user_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1237,7 +1237,7 @@ async def test_query_user_filter(self, tables_cosmos_account_name, tables_primar finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_user_filter_multiple_params(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1261,7 +1261,7 @@ async def test_query_user_filter_multiple_params(self, tables_cosmos_account_nam finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_user_filter_integers(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1284,7 +1284,7 @@ async def test_query_user_filter_integers(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_user_filter_floats(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1307,7 +1307,7 @@ async def test_query_user_filter_floats(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_user_filter_datetimes(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1330,7 +1330,7 @@ async def test_query_user_filter_datetimes(self, tables_cosmos_account_name, tab finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_user_filter_guids(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1353,7 +1353,7 @@ async def test_query_user_filter_guids(self, tables_cosmos_account_name, tables_ finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_user_filter_binary(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1376,7 +1376,7 @@ async def test_query_user_filter_binary(self, tables_cosmos_account_name, tables finally: self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_user_filter_int64(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1406,7 +1406,7 @@ async def test_query_user_filter_int64(self, tables_cosmos_account_name, tables_ finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_zero_entities(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1423,7 +1423,7 @@ async def test_query_zero_entities(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_entities_full_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1442,7 +1442,7 @@ async def test_query_entities_full_metadata(self, tables_cosmos_account_name, ta finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_entities_no_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1461,7 +1461,7 @@ async def test_query_entities_no_metadata(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_entities_with_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1483,7 +1483,7 @@ async def test_query_entities_with_filter(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_injection_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1518,7 +1518,7 @@ async def test_query_injection_async(self, tables_cosmos_account_name, tables_pr finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_special_chars(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1576,7 +1576,7 @@ async def test_query_special_chars(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_invalid_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1598,7 +1598,7 @@ async def test_query_invalid_filter(self, tables_cosmos_account_name, tables_pri finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_entities_with_select(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) try: @@ -1619,7 +1619,7 @@ async def test_query_entities_with_select(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_entities_with_top(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1634,7 +1634,7 @@ async def test_query_entities_with_top(self, tables_cosmos_account_name, tables_ finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_query_entities_with_top_and_next(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -1670,7 +1670,7 @@ async def test_query_entities_with_top_and_next(self, tables_cosmos_account_name finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_datetime_milliseconds(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) try: @@ -1690,7 +1690,7 @@ async def test_datetime_milliseconds(self, tables_cosmos_account_name, tables_pr finally: await self._tear_down() - @CosmosPreparer() + @cosmos_decorator async def test_datetime_str_passthrough(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) partition, row = self._create_pk_rk(None, None) diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_properties.py b/sdk/tables/azure-data-tables/tests/test_table_service_properties.py index 69cf89874978..961b573d39a6 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_properties.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_properties.py @@ -20,7 +20,7 @@ from azure.core.exceptions import HttpResponseError from _shared.testcase import TableTestCase -from preparers import TablesPreparer +from preparers import tables_decorator # ------------------------------------------------------------------------------ @@ -101,7 +101,7 @@ def _assert_retention_equal(self, ret1, ret2): assert ret1.days == ret2.days # --Test cases per service --------------------------------------- - @TablesPreparer() + @tables_decorator def test_table_service_properties(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -120,7 +120,7 @@ def test_table_service_properties(self, tables_storage_account_name, tables_prim self._assert_properties_default(tsc.get_service_properties()) # --Test cases per feature --------------------------------------- - @TablesPreparer() + @tables_decorator def test_set_logging(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -136,7 +136,7 @@ def test_set_logging(self, tables_storage_account_name, tables_primary_storage_a received_props = tsc.get_service_properties() self._assert_logging_equal(received_props['analytics_logging'], logging) - @TablesPreparer() + @tables_decorator def test_set_hour_metrics(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -152,7 +152,7 @@ def test_set_hour_metrics(self, tables_storage_account_name, tables_primary_stor received_props = tsc.get_service_properties() self._assert_metrics_equal(received_props['hour_metrics'], hour_metrics) - @TablesPreparer() + @tables_decorator def test_set_minute_metrics(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -169,7 +169,7 @@ def test_set_minute_metrics(self, tables_storage_account_name, tables_primary_st received_props = tsc.get_service_properties() self._assert_metrics_equal(received_props['minute_metrics'], minute_metrics) - @TablesPreparer() + @tables_decorator def test_set_cors(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -200,7 +200,7 @@ def test_set_cors(self, tables_storage_account_name, tables_primary_storage_acco self._assert_cors_equal(received_props['cors'], cors) # --Test cases for errors --------------------------------------- - @TablesPreparer() + @tables_decorator def test_too_many_cors_rules(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange tsc = TableServiceClient(self.account_url(tables_storage_account_name, "table"), tables_primary_storage_account_key) @@ -212,7 +212,7 @@ def test_too_many_cors_rules(self, tables_storage_account_name, tables_primary_s pytest.raises(HttpResponseError, tsc.set_service_properties, None, None, None, cors) - @TablesPreparer() + @tables_decorator def test_retention_too_long(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange tsc = TableServiceClient(self.account_url(tables_storage_account_name, "table"), tables_primary_storage_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py b/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py index 6faf66eb1999..ee19c63b41d9 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py @@ -16,7 +16,7 @@ from azure.data.tables.aio import TableServiceClient from _shared.testcase import TableTestCase -from preparers import TablesPreparer +from preparers import tables_decorator # ------------------------------------------------------------------------------ @@ -97,7 +97,7 @@ def _assert_retention_equal(self, ret1, ret2): assert ret1.days == ret2.days # --Test cases per service --------------------------------------- - @TablesPreparer() + @tables_decorator async def test_table_service_properties_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -116,7 +116,7 @@ async def test_table_service_properties_async(self, tables_storage_account_name, self._assert_properties_default(await tsc.get_service_properties()) # --Test cases per feature --------------------------------------- - @TablesPreparer() + @tables_decorator async def test_set_logging_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -132,7 +132,7 @@ async def test_set_logging_async(self, tables_storage_account_name, tables_prima received_props = await tsc.get_service_properties() self._assert_logging_equal(received_props['analytics_logging'], logging) - @TablesPreparer() + @tables_decorator async def test_set_hour_metrics_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -148,7 +148,7 @@ async def test_set_hour_metrics_async(self, tables_storage_account_name, tables_ received_props = await tsc.get_service_properties() self._assert_metrics_equal(received_props['hour_metrics'], hour_metrics) - @TablesPreparer() + @tables_decorator async def test_set_minute_metrics_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -165,7 +165,7 @@ async def test_set_minute_metrics_async(self, tables_storage_account_name, table received_props = await tsc.get_service_properties() self._assert_metrics_equal(received_props['minute_metrics'], minute_metrics) - @TablesPreparer() + @tables_decorator async def test_set_cors_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -196,7 +196,7 @@ async def test_set_cors_async(self, tables_storage_account_name, tables_primary_ self._assert_cors_equal(received_props['cors'], cors) # --Test cases for errors --------------------------------------- - @TablesPreparer() + @tables_decorator async def test_too_many_cors_rules_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange tsc = TableServiceClient(self.account_url(tables_storage_account_name, "table"), tables_primary_storage_account_key) @@ -208,7 +208,7 @@ async def test_too_many_cors_rules_async(self, tables_storage_account_name, tabl with pytest.raises(HttpResponseError): await tsc.set_service_properties(None, None, None, cors) - @TablesPreparer() + @tables_decorator async def test_retention_too_long_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange tsc = TableServiceClient(self.account_url(tables_storage_account_name, "table"), tables_primary_storage_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos.py index cb10940789f9..418f7e26d910 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos.py @@ -21,7 +21,7 @@ ) from _shared.testcase import TableTestCase, SLEEP_DELAY -from preparers import CosmosPreparer +from preparers import cosmos_decorator # ------------------------------------------------------------------------------ class TableServicePropertiesTest(AzureTestCase, TableTestCase): @@ -100,7 +100,7 @@ def _assert_retention_equal(self, ret1, ret2): assert ret1.days == ret2.days # --Test cases for errors --------------------------------------- - @CosmosPreparer() + @cosmos_decorator def test_too_many_cors_rules(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): tsc = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) cors = [] @@ -111,7 +111,7 @@ def test_too_many_cors_rules(self, tables_cosmos_account_name, tables_primary_co tsc.set_service_properties(None, None, None, cors) self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator def test_retention_too_long(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): tsc = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) minute_metrics = Metrics(enabled=True, include_apis=True, retention_policy=RetentionPolicy(enabled=True, days=366)) diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py index f3ff9bac0127..bf59b5f3d311 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py @@ -16,7 +16,7 @@ from _shared.testcase import SLEEP_DELAY from _shared.asynctestcase import AsyncTableTestCase -from preparers import CosmosPreparer +from preparers import cosmos_decorator # ------------------------------------------------------------------------------ class TableServicePropertiesTest(AzureTestCase, AsyncTableTestCase): @@ -95,7 +95,7 @@ def _assert_retention_equal(self, ret1, ret2): assert ret1.days == ret2.days # --Test cases for errors --------------------------------------- - @CosmosPreparer() + @cosmos_decorator async def test_too_many_cors_rules_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange tsc = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -108,7 +108,7 @@ async def test_too_many_cors_rules_async(self, tables_cosmos_account_name, table await tsc.set_service_properties(None, None, None, cors) self.sleep(SLEEP_DELAY) - @CosmosPreparer() + @cosmos_decorator async def test_retention_too_long_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange tsc = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_stats.py b/sdk/tables/azure-data-tables/tests/test_table_service_stats.py index 765d9ad6ff10..9995c4627a1c 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_stats.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_stats.py @@ -9,7 +9,7 @@ from azure.data.tables import TableServiceClient from _shared.testcase import TableTestCase -from preparers import TablesPreparer +from preparers import tables_decorator SERVICE_UNAVAILABLE_RESP_BODY = 'unavailableunavailableunavailableunavailable Date: Fri, 30 Apr 2021 11:23:56 -0400 Subject: [PATCH 02/15] added async preparers --- .../azure-data-tables/tests/preparers.py | 44 +++++ .../tests/test_table_async.py | 47 +++--- .../tests/test_table_batch.py | 7 +- .../tests/test_table_batch_async.py | 40 ++--- .../tests/test_table_batch_cosmos_async.py | 34 ++-- .../tests/test_table_client.py | 81 +++++----- .../tests/test_table_client_async.py | 86 +++++----- .../tests/test_table_client_cosmos.py | 2 + .../tests/test_table_client_cosmos_async.py | 8 +- .../tests/test_table_cosmos.py | 9 +- .../tests/test_table_cosmos_async.py | 29 ++-- .../tests/test_table_entity_async.py | 152 +++++++++--------- .../tests/test_table_entity_cosmos_async.py | 132 +++++++-------- .../test_table_service_properties_async.py | 16 +- ...t_table_service_properties_cosmos_async.py | 6 +- .../tests/test_table_service_stats_async.py | 6 +- .../test_table_service_stats_cosmos_async.py | 6 +- 17 files changed, 379 insertions(+), 326 deletions(-) diff --git a/sdk/tables/azure-data-tables/tests/preparers.py b/sdk/tables/azure-data-tables/tests/preparers.py index 8293be3408c1..d76ce6fd738d 100644 --- a/sdk/tables/azure-data-tables/tests/preparers.py +++ b/sdk/tables/azure-data-tables/tests/preparers.py @@ -67,3 +67,47 @@ def wrapper(*args, **kwargs): func(*args, **trimmed_kwargs) return wrapper + + +def cosmos_decorator_async(func, **kwargs): + + @CosmosPreparer() + def wrapper(*args, **kwargs): + key = kwargs.pop("tables_primary_cosmos_account_key") + name = kwargs.pop("tables_cosmos_account_name") + key = AzureNamedKeyCredential(key=key, name=name) + + kwargs["tables_primary_cosmos_account_key"] = key + kwargs["tables_cosmos_account_name"] = name + + trimmed_kwargs = {k:v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + @functools.wraps(func) + async def wrapped(*args, **kwargs): + return await func(*args, **trimmed_kwargs) + return wrapped + + return wrapper + + +def tables_decorator_async(func, **kwargs): + + @TablesPreparer() + def wrapper(*args, **kwargs): + key = kwargs.pop("tables_primary_storage_account_key") + name = kwargs.pop("tables_storage_account_name") + key = AzureNamedKeyCredential(key=key, name=name) + + kwargs["tables_primary_storage_account_key"] = key + kwargs["tables_storage_account_name"] = name + + trimmed_kwargs = {k:v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + @functools.wraps(func) + async def wrapped(*args, **kwargs): + return await func(*args, **trimmed_kwargs) + return wrapped + + return wrapper diff --git a/sdk/tables/azure-data-tables/tests/test_table_async.py b/sdk/tables/azure-data-tables/tests/test_table_async.py index e925bcc3c3f2..d715286928d3 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_async.py @@ -7,7 +7,7 @@ from devtools_testutils import AzureTestCase -from azure.core.credentials import AzureSasCredential +from azure.core.credentials import AzureSasCredential, AzureNamedKeyCredential from azure.core.exceptions import ResourceNotFoundError, ResourceExistsError from azure.data.tables import ( AccessPolicy, @@ -20,7 +20,7 @@ from azure.data.tables.aio import TableServiceClient, TableClient from _shared.asynctestcase import AsyncTableTestCase -from preparers import tables_decorator +from preparers import tables_decorator_async TEST_TABLE_PREFIX = 'pytableasync' @@ -52,7 +52,7 @@ async def _delete_table(self, ts, table): pass # --Test cases for tables -------------------------------------------------- - @tables_decorator + @tables_decorator_async async def test_create_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -67,7 +67,7 @@ async def test_create_table(self, tables_storage_account_name, tables_primary_st assert created.table_name == table_name await ts.delete_table(table_name=table_name) - @tables_decorator + @tables_decorator_async async def test_create_table_fail_on_exist(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -86,7 +86,7 @@ async def test_create_table_fail_on_exist(self, tables_storage_account_name, tab assert isinstance(created, TableClient) await ts.delete_table(table_name=table_name) - @tables_decorator + @tables_decorator_async async def test_query_tables_per_page(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -115,7 +115,7 @@ async def test_query_tables_per_page(self, tables_storage_account_name, tables_p for i in range(5): await ts.delete_table(table_name + str(i)) - @tables_decorator + @tables_decorator_async async def test_list_tables(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -136,7 +136,7 @@ async def test_list_tables(self, tables_storage_account_name, tables_primary_sto assert tables[0] is not None await ts.delete_table(table.table_name) - @tables_decorator + @tables_decorator_async async def test_query_tables_with_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -158,7 +158,7 @@ async def test_query_tables_with_filter(self, tables_storage_account_name, table assert table_item.name is not None await ts.delete_table(table.table_name) - @tables_decorator + @tables_decorator_async async def test_list_tables_with_num_results(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange prefix = 'listtable' @@ -185,7 +185,7 @@ async def test_list_tables_with_num_results(self, tables_storage_account_name, t assert len(small_page) == 2 assert len(big_page) >= 4 - @tables_decorator + @tables_decorator_async async def test_list_tables_with_marker(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -218,7 +218,7 @@ async def test_list_tables_with_marker(self, tables_storage_account_name, tables assert tables2_len == 2 assert tables1 != tables2 - @tables_decorator + @tables_decorator_async async def test_delete_table_with_existing_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -234,7 +234,7 @@ async def test_delete_table_with_existing_table(self, tables_storage_account_nam tables.append(e) assert tables == [] - @tables_decorator + @tables_decorator_async async def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -248,7 +248,7 @@ async def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_ # Assert - @tables_decorator + @tables_decorator_async async def test_get_table_acl(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -265,7 +265,7 @@ async def test_get_table_acl(self, tables_storage_account_name, tables_primary_s finally: await ts.delete_table(table.table_name) - @tables_decorator + @tables_decorator_async async def test_set_table_acl_with_empty_signed_identifiers(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") @@ -283,7 +283,7 @@ async def test_set_table_acl_with_empty_signed_identifiers(self, tables_storage_ finally: await ts.delete_table(table.table_name) - @tables_decorator + @tables_decorator_async async def test_set_table_acl_with_empty_signed_identifier(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -304,7 +304,7 @@ async def test_set_table_acl_with_empty_signed_identifier(self, tables_storage_a # self._delete_table(table) await ts.delete_table(table.table_name) - @tables_decorator + @tables_decorator_async async def test_set_table_acl_with_signed_identifiers(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -328,7 +328,7 @@ async def test_set_table_acl_with_signed_identifiers(self, tables_storage_accoun finally: await ts.delete_table(table.table_name) - @tables_decorator + @tables_decorator_async async def test_set_table_acl_too_many_ids(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -347,7 +347,7 @@ async def test_set_table_acl_too_many_ids(self, tables_storage_account_name, tab await ts.delete_table(table.table_name) @pytest.mark.live_test_only - @tables_decorator + @tables_decorator_async async def test_account_sas(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only @@ -397,12 +397,13 @@ async def test_account_sas(self, tables_storage_account_name, tables_primary_sto class TestTablesUnitTest(AsyncTableTestCase): tables_storage_account_name = "fake_storage_account" tables_primary_storage_account_key = "fakeXMZjnGsZGvd4bVr3Il5SeHA" + credential = AzureNamedKeyCredential(name=tables_storage_account_name, key=tables_primary_storage_account_key) @pytest.mark.asyncio async def test_unicode_create_table_unicode_name(self): # Arrange account_url = self.account_url(self.tables_storage_account_name, "table") - tsc = TableServiceClient(account_url, credential=self.tables_primary_storage_account_key) + tsc = TableServiceClient(account_url, credential=self.credential) table_name = u'啊齄丂狛狜' @@ -417,7 +418,7 @@ async def test_unicode_create_table_unicode_name(self): async def test_create_table_invalid_name(self): # Arrange account_url = self.account_url(self.tables_storage_account_name, "table") - tsc = TableServiceClient(account_url, credential=self.tables_primary_storage_account_key) + tsc = TableServiceClient(account_url, credential=self.credential) invalid_table_name = "my_table" with pytest.raises(ValueError) as excinfo: @@ -430,7 +431,7 @@ async def test_create_table_invalid_name(self): async def test_delete_table_invalid_name(self): # Arrange account_url = self.account_url(self.tables_storage_account_name, "table") - tsc = TableServiceClient(account_url, credential=self.tables_primary_storage_account_key) + tsc = TableServiceClient(account_url, credential=self.credential) invalid_table_name = "my_table" with pytest.raises(ValueError) as excinfo: @@ -441,10 +442,10 @@ async def test_delete_table_invalid_name(self): def test_azurite_url(self): account_url = "https://127.0.0.1:10002/my_account" - tsc = TableServiceClient(account_url, credential=self.tables_primary_storage_account_key) + tsc = TableServiceClient(account_url, credential=self.credential) assert tsc.account_name == "my_account" assert tsc.url == "https://127.0.0.1:10002/my_account" assert tsc.location_mode == "primary" - assert tsc.credential.account_key == self.tables_primary_storage_account_key - assert tsc.credential.account_name == "my_account" + assert tsc.credential.named_key.key == self.credential.named_key.key + assert tsc.credential.named_key.name == self.credential.named_key.name diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch.py b/sdk/tables/azure-data-tables/tests/test_table_batch.py index 8adf5ed1057f..edc3ad000010 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch.py @@ -17,7 +17,7 @@ from devtools_testutils import AzureTestCase from azure.core import MatchConditions -from azure.core.credentials import AzureSasCredential +from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential from azure.core.exceptions import ( ResourceExistsError, ResourceNotFoundError, @@ -759,8 +759,9 @@ def test_new_non_existent_table(self, tables_storage_account_name, tables_primar @tables_decorator def test_new_invalid_key(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange - invalid_key = tables_primary_storage_account_key[0:-6] + "==" # cut off a bit from the end to invalidate - self.ts = TableServiceClient(self.account_url(tables_storage_account_name, "table"), invalid_key) + invalid_key = tables_primary_storage_account_key.named_key.key[0:-6] + "==" # cut off a bit from the end to invalidate + credential = AzureNamedKeyCredential(name=tables_storage_account_name, key=tables_primary_storage_account_key.named_key.key) + self.ts = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential) self.table_name = self.get_resource_name('uttable') self.table = self.ts.get_table_client(self.table_name) diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch_async.py b/sdk/tables/azure-data-tables/tests/test_table_batch_async.py index c8f5d33fdd17..c4aafce665bd 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch_async.py @@ -38,7 +38,7 @@ ) from _shared.asynctestcase import AsyncTableTestCase -from preparers import tables_decorator +from preparers import tables_decorator_async #------------------------------------------------------------------------------ TEST_TABLE_PREFIX = 'table' @@ -173,7 +173,7 @@ def _assert_valid_batch_transaction(self, transaction, length): assert length == len(transaction) #--Test cases for batch --------------------------------------------- - @tables_decorator + @tables_decorator_async async def test_batch_single_insert(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -203,7 +203,7 @@ async def test_batch_single_insert(self, tables_storage_account_name, tables_pri finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_single_update(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -238,7 +238,7 @@ async def test_batch_single_update(self, tables_storage_account_name, tables_pri finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_update(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -272,7 +272,7 @@ async def test_batch_update(self, tables_storage_account_name, tables_primary_st finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_merge(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -310,7 +310,7 @@ async def test_batch_merge(self, tables_storage_account_name, tables_primary_sto finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_update_if_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -337,7 +337,7 @@ async def test_batch_update_if_match(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_update_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -363,7 +363,7 @@ async def test_batch_update_if_doesnt_match(self, tables_storage_account_name, t finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_insert_replace(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -392,7 +392,7 @@ async def test_batch_insert_replace(self, tables_storage_account_name, tables_pr finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_insert_merge(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -421,7 +421,7 @@ async def test_batch_insert_merge(self, tables_storage_account_name, tables_prim finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_delete(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -452,7 +452,7 @@ async def test_batch_delete(self, tables_storage_account_name, tables_primary_st finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_inserts(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -489,7 +489,7 @@ async def test_batch_inserts(self, tables_storage_account_name, tables_primary_s finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_all_operations_together(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -560,7 +560,7 @@ async def test_batch_all_operations_together(self, tables_storage_account_name, finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_same_row_operations_fail(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -585,7 +585,7 @@ async def test_batch_same_row_operations_fail(self, tables_storage_account_name, finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_different_partition_operations_fail(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -610,7 +610,7 @@ async def test_batch_different_partition_operations_fail(self, tables_storage_ac finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_batch_too_many_ops(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -632,7 +632,7 @@ async def test_batch_too_many_ops(self, tables_storage_account_name, tables_prim finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_new_non_existent_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -649,7 +649,7 @@ async def test_new_non_existent_table(self, tables_storage_account_name, tables_ finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_new_invalid_key(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange invalid_key = tables_primary_storage_account_key[0:-6] + "==" # cut off a bit from the end to invalidate @@ -668,7 +668,7 @@ async def test_new_invalid_key(self, tables_storage_account_name, tables_primary with pytest.raises(ClientAuthenticationError): resp = await self.table.submit_transaction(batch) - @tables_decorator + @tables_decorator_async async def test_new_delete_nonexistent_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -683,7 +683,7 @@ async def test_new_delete_nonexistent_entity(self, tables_storage_account_name, await self._tear_down() @pytest.mark.live_test_only - @tables_decorator + @tables_decorator_async async def test_batch_sas_auth(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -732,7 +732,7 @@ async def test_batch_sas_auth(self, tables_storage_account_name, tables_primary_ await self._tear_down() @pytest.mark.live_test_only # Request bodies are very large - @tables_decorator + @tables_decorator_async async def test_batch_request_too_large(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py index 7265202670da..6b400261770b 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py @@ -36,7 +36,7 @@ from _shared.testcase import SLEEP_DELAY from _shared.asynctestcase import AsyncTableTestCase -from preparers import cosmos_decorator +from preparers import cosmos_decorator_async #------------------------------------------------------------------------------ TEST_TABLE_PREFIX = 'table' @@ -172,7 +172,7 @@ def _assert_valid_batch_transaction(self, transaction, length): assert length == len(transaction) #--Test cases for batch --------------------------------------------- - @cosmos_decorator + @cosmos_decorator_async async def test_batch_single_insert(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -203,7 +203,7 @@ async def test_batch_single_insert(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_single_update(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -238,7 +238,7 @@ async def test_batch_single_update(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_update(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -272,7 +272,7 @@ async def test_batch_update(self, tables_cosmos_account_name, tables_primary_cos finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_merge(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -310,7 +310,7 @@ async def test_batch_merge(self, tables_cosmos_account_name, tables_primary_cosm finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_update_if_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -337,7 +337,7 @@ async def test_batch_update_if_match(self, tables_cosmos_account_name, tables_pr finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_update_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -364,7 +364,7 @@ async def test_batch_update_if_doesnt_match(self, tables_cosmos_account_name, ta finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_insert_replace(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -393,7 +393,7 @@ async def test_batch_insert_replace(self, tables_cosmos_account_name, tables_pri finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_insert_merge(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -422,7 +422,7 @@ async def test_batch_insert_merge(self, tables_cosmos_account_name, tables_prima finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_delete(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -453,7 +453,7 @@ async def test_batch_delete(self, tables_cosmos_account_name, tables_primary_cos finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_inserts(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -490,7 +490,7 @@ async def test_batch_inserts(self, tables_cosmos_account_name, tables_primary_co finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_all_operations_together(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -561,7 +561,7 @@ async def test_batch_all_operations_together(self, tables_cosmos_account_name, t finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_batch_different_partition_operations_fail(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -586,7 +586,7 @@ async def test_batch_different_partition_operations_fail(self, tables_cosmos_acc finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_new_non_existent_table(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -604,7 +604,7 @@ async def test_new_non_existent_table(self, tables_cosmos_account_name, tables_p await self._tear_down() @pytest.mark.live_test_only - @cosmos_decorator + @cosmos_decorator_async async def test_new_invalid_key(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange invalid_key = tables_primary_cosmos_account_key[0:-6] + "==" # cut off a bit from the end to invalidate @@ -624,7 +624,7 @@ async def test_new_invalid_key(self, tables_cosmos_account_name, tables_primary_ with pytest.raises(ClientAuthenticationError): resp = await self.table.submit_transaction(batch) - @cosmos_decorator + @cosmos_decorator_async async def test_new_delete_nonexistent_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -639,7 +639,7 @@ async def test_new_delete_nonexistent_entity(self, tables_cosmos_account_name, t await self._tear_down() @pytest.mark.live_test_only # Request bodies are very large - @cosmos_decorator + @cosmos_decorator_async async def test_batch_request_too_large(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_client.py b/sdk/tables/azure-data-tables/tests/test_table_client.py index 6f34dad0a672..e2d919b56b93 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client.py @@ -10,7 +10,7 @@ from azure.data.tables import TableServiceClient, TableClient from azure.data.tables import __version__ as VERSION -from azure.core.exceptions import HttpResponseError +from azure.core.credentials import AzureNamedKeyCredential from _shared.testcase import ( TableTestCase @@ -106,6 +106,7 @@ def callback(response): class TestTableUnitTests(TableTestCase): tables_storage_account_name = "fake_storage_account" tables_primary_storage_account_key = "fakeXMZjnGsZGvd4bVr3Il5SeHA" + credential = AzureNamedKeyCredential(name=tables_storage_account_name, key=tables_primary_storage_account_key) # --Helpers----------------------------------------------------------------- def validate_standard_account_endpoints(self, service, account_name, account_key): @@ -122,10 +123,10 @@ def test_create_service_with_key(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, url), credential=self.tables_primary_storage_account_key, table_name='foo') + self.account_url(self.tables_storage_account_name, url), credential=self.credential, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) assert service.scheme == 'https' def test_create_service_with_connection_string(self): @@ -133,10 +134,10 @@ def test_create_service_with_connection_string(self): for service_type in SERVICES.items(): # Act service = service_type[0].from_connection_string( - self.connection_string(self.tables_storage_account_name, self.tables_primary_storage_account_key), table_name="test") + self.connection_string(self.tables_storage_account_name, self.credential), table_name="test") # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) assert service.scheme == 'https' def test_create_service_with_sas(self): @@ -162,13 +163,13 @@ def test_create_service_china(self): # Act url = self.account_url(self.tables_storage_account_name, "table").replace('core.windows.net', 'core.chinacloudapi.cn') service = service_type[0]( - url, credential=self.tables_primary_storage_account_key, table_name='foo') + url, credential=self.credential, table_name='foo') # Assert assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) def test_create_service_protocol(self): @@ -178,10 +179,10 @@ def test_create_service_protocol(self): # Act url = self.account_url(self.tables_storage_account_name, "table").replace('https', 'http') service = service_type[0]( - url, credential=self.tables_primary_storage_account_key, table_name='foo') + url, credential=self.credential, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) assert service.scheme == 'http' def test_create_service_empty_key(self): @@ -195,7 +196,7 @@ def test_create_service_empty_key(self): # test non-string account URL with pytest.raises(ValueError): - test_service = service_type(account_url=123456, credential=self.tables_primary_storage_account_key, table_name='foo') + test_service = service_type(account_url=123456, credential=self.credential, table_name='foo') assert str(e.value) == "You need to provide either a SAS token or an account shared key to authenticate." @@ -205,20 +206,20 @@ def test_create_service_with_socket_timeout(self): for service_type in SERVICES.items(): # Act default_service = service_type[0]( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='foo') + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='foo') service = service_type[0]( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='foo', connection_timeout=22) # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) assert service._client._client._pipeline._transport.connection_config.timeout == 22 assert default_service._client._client._pipeline._transport.connection_config.timeout == 300 # Assert Parent transport is shared with child client service = TableServiceClient( self.account_url(self.tables_storage_account_name, "table"), - credential=self.tables_primary_storage_account_key, + credential=self.credential, connection_timeout=22) assert service._client._client._pipeline._transport.connection_config.timeout == 22 table = service.get_table_client('tablename') @@ -229,14 +230,14 @@ def test_create_service_with_socket_timeout(self): # --Connection String Test Cases -------------------------------------------- def test_create_service_with_connection_string_key(self): # Arrange - conn_string = 'AccountName={};AccountKey={};'.format(self.tables_storage_account_name, self.tables_primary_storage_account_key) + conn_string = 'AccountName={};AccountKey={};'.format(self.tables_storage_account_name, self.credential) for service_type in SERVICES.items(): # Act service = service_type[0].from_connection_string(conn_string, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) assert service.scheme == 'https' def test_create_service_with_connection_string_sas(self): @@ -260,7 +261,7 @@ def test_create_service_with_connection_string_sas(self): def test_create_service_with_connection_string_cosmos(self): # Arrange conn_string = 'DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};TableEndpoint=https://{0}.table.cosmos.azure.com:443/;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.tables_storage_account_name, self.credential) for service_type in SERVICES: # Act @@ -271,14 +272,14 @@ def test_create_service_with_connection_string_cosmos(self): assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') assert service.scheme == 'https' def test_create_service_with_connection_string_endpoint_protocol(self): # Arrange conn_string = 'AccountName={};AccountKey={};DefaultEndpointsProtocol=http;EndpointSuffix=core.chinacloudapi.cn;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.tables_storage_account_name, self.credential) for service_type in SERVICES.items(): # Act @@ -288,14 +289,14 @@ def test_create_service_with_connection_string_endpoint_protocol(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('http://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) assert service.scheme == 'http' def test_create_service_with_connection_string_emulated(self): # Arrange for service_type in SERVICES.items(): - conn_string = 'UseDevelopmentStorage=true;'.format(self.tables_storage_account_name, self.tables_primary_storage_account_key) + conn_string = 'UseDevelopmentStorage=true;'.format(self.tables_storage_account_name, self.credential) # Act with pytest.raises(ValueError): @@ -305,7 +306,7 @@ def test_create_service_with_connection_string_custom_domain(self): # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.tables_storage_account_name, self.credential) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") @@ -314,14 +315,14 @@ def test_create_service_with_connection_string_custom_domain(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_custom_domain_trailing_slash(self): # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com/;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.tables_storage_account_name, self.credential) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") @@ -330,14 +331,14 @@ def test_create_service_with_conn_str_custom_domain_trailing_slash(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_custom_domain_sec_override(self): # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com/;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.tables_storage_account_name, self.credential) # Act service = service_type[0].from_connection_string( @@ -347,14 +348,14 @@ def test_create_service_with_conn_str_custom_domain_sec_override(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_fails_if_sec_without_primary(self): for service_type in SERVICES.items(): # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key, + self.tables_storage_account_name, self.credential, _CONNECTION_ENDPOINTS_SECONDARY.get(service_type[1])) # Act @@ -368,7 +369,7 @@ def test_create_service_with_conn_str_succeeds_if_sec_with_primary(self): # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;{}=www-sec.mydomain.com;'.format( self.tables_storage_account_name, - self.tables_primary_storage_account_key, + self.credential, _CONNECTION_ENDPOINTS.get(service_type[1]), _CONNECTION_ENDPOINTS_SECONDARY.get(service_type[1])) @@ -379,7 +380,7 @@ def test_create_service_with_conn_str_succeeds_if_sec_with_primary(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_custom_account_endpoint_path(self): @@ -387,7 +388,7 @@ def test_create_service_with_custom_account_endpoint_path(self): custom_account_url = "http://local-machine:11002/custom/account/path/" + token for service_type in SERVICES.items(): conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};TableEndpoint={};'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key, custom_account_url) + self.tables_storage_account_name, self.credential, custom_account_url) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") @@ -395,7 +396,7 @@ def test_create_service_with_custom_account_endpoint_path(self): # Assert assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_hostname == 'local-machine:11002/custom/account/path' service = TableServiceClient(account_url=custom_account_url) @@ -421,7 +422,7 @@ def test_create_service_with_custom_account_endpoint_path(self): def test_create_table_client_with_complete_table_url(self): # Arrange table_url = self.account_url(self.tables_storage_account_name, "table") + "/foo" - service = TableClient(table_url, table_name='bar', credential=self.tables_primary_storage_account_key) + service = TableClient(table_url, table_name='bar', credential=self.credential) # Assert assert service.scheme == 'https' @@ -431,7 +432,7 @@ def test_create_table_client_with_complete_table_url(self): def test_create_table_client_with_complete_url(self): # Arrange table_url = "https://{}.table.core.windows.net:443/foo".format(self.tables_storage_account_name) - service = TableClient(account_url=table_url, table_name='bar', credential=self.tables_primary_storage_account_key) + service = TableClient(account_url=table_url, table_name='bar', credential=self.credential) # Assert assert service.scheme == 'https' @@ -445,7 +446,7 @@ def test_create_table_client_with_invalid_name(self): # Assert with pytest.raises(ValueError) as excinfo: - service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.tables_primary_storage_account_key") + service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.credential") assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long." in str(excinfo) @@ -468,7 +469,7 @@ def test_closing_pipeline_client(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='table') + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='table') # Assert with service: @@ -480,7 +481,7 @@ def test_closing_pipeline_client_simple(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='table') + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='table') service.close() def test_create_service_with_token_and_http(self): @@ -517,15 +518,15 @@ def test_create_service_with_token(self): def test_create_client_with_api_version(self): url = self.account_url(self.tables_storage_account_name, "table") - client = TableServiceClient(url, credential=self.tables_primary_storage_account_key) + client = TableServiceClient(url, credential=self.credential) assert client._client._config.version == "2019-02-02" table = client.get_table_client('tablename') assert table._client._config.version == "2019-02-02" - client = TableServiceClient(url, credential=self.tables_primary_storage_account_key, api_version="2019-07-07") + client = TableServiceClient(url, credential=self.credential, api_version="2019-07-07") assert client._client._config.version == "2019-07-07" table = client.get_table_client('tablename') assert table._client._config.version == "2019-07-07" with pytest.raises(ValueError): - TableServiceClient(url, credential=self.tables_primary_storage_account_key, api_version="foo") + TableServiceClient(url, credential=self.credential, api_version="foo") diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_async.py index b17211d6b9ad..e48bde9a8700 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_async.py @@ -10,9 +10,10 @@ from azure.data.tables.aio import TableServiceClient, TableClient from azure.data.tables._version import VERSION +from azure.core.credentials import AzureNamedKeyCredential from _shared.asynctestcase import AsyncTableTestCase -from preparers import tables_decorator +from preparers import tables_decorator_async from devtools_testutils import AzureTestCase # ------------------------------------------------------------------------------ SERVICES = { @@ -27,7 +28,7 @@ class TestTableClient(AzureTestCase, AsyncTableTestCase): - @tables_decorator + @tables_decorator_async async def test_user_agent_default_async(self, tables_storage_account_name, tables_primary_storage_account_key): service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) @@ -46,7 +47,7 @@ def callback(response): async for table in tables: count += 1 - @tables_decorator + @tables_decorator_async async def test_user_agent_custom_async(self, tables_storage_account_name, tables_primary_storage_account_key): custom_app = "TestApp/v1.0" service = TableServiceClient( @@ -82,7 +83,7 @@ def callback(response): async for table in tables: count += 1 - @tables_decorator + @tables_decorator_async async def test_user_agent_append(self, tables_storage_account_name, tables_primary_storage_account_key): service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) @@ -102,6 +103,7 @@ def callback(response): class TestTableClientUnit(AsyncTableTestCase): tables_storage_account_name = "fake_storage_account" tables_primary_storage_account_key = "fakeXMZjnGsZGvd4bVr3Il5SeHA" + credential = AzureNamedKeyCredential(name=tables_storage_account_name, key=tables_primary_storage_account_key) # --Helpers----------------------------------------------------------------- def validate_standard_account_endpoints(self, service, account_name, account_key): @@ -119,10 +121,10 @@ async def test_create_service_with_key_async(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, url), credential=self.tables_primary_storage_account_key, table_name='foo') + self.account_url(self.tables_storage_account_name, url), credential=self.credential, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) assert service.scheme == 'https' @pytest.mark.asyncio @@ -131,10 +133,10 @@ async def test_create_service_with_connection_string_async(self): for service_type in SERVICES.items(): # Act service = service_type[0].from_connection_string( - self.connection_string(self.tables_storage_account_name, self.tables_primary_storage_account_key), table_name="test") + self.connection_string(self.tables_storage_account_name, self.credential), table_name="test") # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) assert service.scheme == 'https' @pytest.mark.asyncio @@ -187,13 +189,13 @@ async def test_create_service_china_async(self): # Act url = self.account_url(self.tables_storage_account_name, "table").replace('core.windows.net', 'core.chinacloudapi.cn') service = service_type[0]( - url, credential=self.tables_primary_storage_account_key, table_name='foo') + url, credential=self.credential, table_name='foo') # Assert assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) @pytest.mark.asyncio @@ -204,10 +206,10 @@ async def test_create_service_protocol_async(self): # Act url = self.account_url(self.tables_storage_account_name, "table").replace('https', 'http') service = service_type[0]( - url, credential=self.tables_primary_storage_account_key, table_name='foo') + url, credential=self.credential, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) assert service.scheme == 'http' @pytest.mark.asyncio @@ -229,20 +231,20 @@ async def test_create_service_with_socket_timeout_async(self): for service_type in SERVICES.items(): # Act default_service = service_type[0]( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='foo') + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='foo') service = service_type[0]( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='foo', connection_timeout=22) # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) assert service._client._client._pipeline._transport.connection_config.timeout == 22 assert default_service._client._client._pipeline._transport.connection_config.timeout == 300 # Assert Parent transport is shared with child client service = TableServiceClient( self.account_url(self.tables_storage_account_name, "table"), - credential=self.tables_primary_storage_account_key, + credential=self.credential, connection_timeout=22) assert service._client._client._pipeline._transport.connection_config.timeout == 22 table = service.get_table_client('tablename') @@ -252,14 +254,14 @@ async def test_create_service_with_socket_timeout_async(self): @pytest.mark.asyncio async def test_create_service_with_connection_string_key_async(self): # Arrange - conn_string = 'AccountName={};AccountKey={};'.format(self.tables_storage_account_name, self.tables_primary_storage_account_key) + conn_string = 'AccountName={};AccountKey={};'.format(self.tables_storage_account_name, self.credential) for service_type in SERVICES.items(): # Act service = service_type[0].from_connection_string(conn_string, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) assert service.scheme == 'https' @pytest.mark.asyncio @@ -283,7 +285,7 @@ async def test_create_service_with_connection_string_sas_async(self): async def test_create_service_with_connection_string_cosmos_async(self): # Arrange conn_string = 'DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};TableEndpoint=https://{0}.table.cosmos.azure.com:443/;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.tables_storage_account_name, self.credential) for service_type in SERVICES: # Act @@ -294,7 +296,7 @@ async def test_create_service_with_connection_string_cosmos_async(self): assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') assert service.scheme == 'https' @@ -302,7 +304,7 @@ async def test_create_service_with_connection_string_cosmos_async(self): async def test_create_service_with_connection_string_endpoint_protocol_async(self): # Arrange conn_string = 'AccountName={};AccountKey={};DefaultEndpointsProtocol=http;EndpointSuffix=core.chinacloudapi.cn;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.tables_storage_account_name, self.credential) for service_type in SERVICES.items(): # Act @@ -312,7 +314,7 @@ async def test_create_service_with_connection_string_endpoint_protocol_async(sel assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('http://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) assert service.scheme == 'http' @@ -320,7 +322,7 @@ async def test_create_service_with_connection_string_endpoint_protocol_async(sel async def test_create_service_with_connection_string_emulated_async(self): # Arrange for service_type in SERVICES.items(): - conn_string = 'UseDevelopmentStorage=true;'.format(self.tables_storage_account_name, self.tables_primary_storage_account_key) + conn_string = 'UseDevelopmentStorage=true;'.format(self.tables_storage_account_name, self.credential) # Act with pytest.raises(ValueError): @@ -331,7 +333,7 @@ async def test_create_service_with_connection_string_custom_domain_async(self): # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.tables_storage_account_name, self.credential) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") @@ -340,7 +342,7 @@ async def test_create_service_with_connection_string_custom_domain_async(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -348,7 +350,7 @@ async def test_create_service_with_conn_str_custom_domain_trailing_slash_async(s # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com/;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.tables_storage_account_name, self.credential) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") @@ -357,7 +359,7 @@ async def test_create_service_with_conn_str_custom_domain_trailing_slash_async(s assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -365,7 +367,7 @@ async def test_create_service_with_conn_str_custom_domain_sec_override_async(sel # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com/;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key) + self.tables_storage_account_name, self.credential) # Act service = service_type[0].from_connection_string( @@ -375,7 +377,7 @@ async def test_create_service_with_conn_str_custom_domain_sec_override_async(sel assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -383,7 +385,7 @@ async def test_create_service_with_conn_str_fails_if_sec_without_primary_async(s for service_type in SERVICES.items(): # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key, + self.tables_storage_account_name, self.credential, _CONNECTION_ENDPOINTS_SECONDARY.get(service_type[1])) # Fails if primary excluded @@ -396,7 +398,7 @@ async def test_create_service_with_conn_str_succeeds_if_sec_with_primary_async(s # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;{}=www-sec.mydomain.com;'.format( self.tables_storage_account_name, - self.tables_primary_storage_account_key, + self.credential, _CONNECTION_ENDPOINTS.get(service_type[1]), _CONNECTION_ENDPOINTS_SECONDARY.get(service_type[1])) @@ -407,7 +409,7 @@ async def test_create_service_with_conn_str_succeeds_if_sec_with_primary_async(s assert service is not None assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -416,7 +418,7 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): custom_account_url = "http://local-machine:11002/custom/account/path/" + token for service_type in SERVICES.items(): conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};TableEndpoint={};'.format( - self.tables_storage_account_name, self.tables_primary_storage_account_key, custom_account_url) + self.tables_storage_account_name, self.credential, custom_account_url) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") @@ -424,7 +426,7 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): # Assert assert service.account_name == self.tables_storage_account_name assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.account_key == self.credential assert service._primary_hostname == 'local-machine:11002/custom/account/path' service = TableServiceClient(account_url=custom_account_url) @@ -451,7 +453,7 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): async def test_create_table_client_with_complete_table_url_async(self): # Arrange table_url = self.account_url(self.tables_storage_account_name, "table") + "/foo" - service = TableClient(table_url, table_name='bar', credential=self.tables_primary_storage_account_key) + service = TableClient(table_url, table_name='bar', credential=self.credential) # Assert assert service.scheme == 'https' @@ -462,7 +464,7 @@ async def test_create_table_client_with_complete_table_url_async(self): async def test_create_table_client_with_complete_url_async(self): # Arrange table_url = "https://{}.table.core.windows.net:443/foo".format(self.tables_storage_account_name) - service = TableClient(account_url=table_url, table_name='bar', credential=self.tables_primary_storage_account_key) + service = TableClient(account_url=table_url, table_name='bar', credential=self.credential) # Assert assert service.scheme == 'https' @@ -477,7 +479,7 @@ async def test_create_table_client_with_invalid_name_async(self): # Assert with pytest.raises(ValueError) as excinfo: - service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.tables_primary_storage_account_key") + service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.credential") assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long."in str(excinfo) @@ -502,7 +504,7 @@ async def test_closing_pipeline_client_async(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='table') + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='table') # Assert async with service: @@ -515,21 +517,21 @@ async def test_closing_pipeline_client_simple_async(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='table') + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='table') await service.close() @pytest.mark.asyncio async def test_create_client_with_api_version(self): url = self.account_url(self.tables_storage_account_name, "table") - client = TableServiceClient(url, credential=self.tables_primary_storage_account_key) + client = TableServiceClient(url, credential=self.credential) assert client._client._config.version == "2019-02-02" table = client.get_table_client('tablename') assert table._client._config.version == "2019-02-02" - client = TableServiceClient(url, credential=self.tables_primary_storage_account_key, api_version="2019-07-07") + client = TableServiceClient(url, credential=self.credential, api_version="2019-07-07") assert client._client._config.version == "2019-07-07" table = client.get_table_client('tablename') assert table._client._config.version == "2019-07-07" with pytest.raises(ValueError): - TableServiceClient(url, credential=self.tables_primary_storage_account_key, api_version="foo") \ No newline at end of file + TableServiceClient(url, credential=self.credential, api_version="foo") \ No newline at end of file diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py index a2cc5aad0a1f..61956db021e6 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py @@ -12,6 +12,7 @@ from azure.data.tables import TableServiceClient, TableClient from azure.data.tables import __version__ as VERSION +from azure.core.credentials import AzureNamedKeyCredential from _shared.testcase import ( TableTestCase, @@ -120,6 +121,7 @@ def callback(response): class TestTableClientUnit(TableTestCase): tables_cosmos_account_name = "fake_storage_account" tables_primary_cosmos_account_key = "fakeXMZjnGsZGvd4bVr3Il5SeHA" + credential = AzureNamedKeyCredential(name=tables_cosmos_account_name, key=tables_primary_cosmos_account_key) # --Helpers----------------------------------------------------------------- def validate_standard_account_endpoints(self, service, account_name, account_key): diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py index fb712a252b29..a1336e1d29b4 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py @@ -14,7 +14,7 @@ from _shared.asynctestcase import AsyncTableTestCase from _shared.testcase import SLEEP_DELAY -from preparers import cosmos_decorator +from preparers import cosmos_decorator_async from devtools_testutils import AzureTestCase # ------------------------------------------------------------------------------ @@ -30,7 +30,7 @@ class TestTableClient(AzureTestCase, AsyncTableTestCase): - @cosmos_decorator + @cosmos_decorator_async async def test_user_agent_default_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): service = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), credential=tables_primary_cosmos_account_key) @@ -52,7 +52,7 @@ def callback(response): if self.is_live: sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_user_agent_custom_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): custom_app = "TestApp/v1.0" service = TableServiceClient( @@ -88,7 +88,7 @@ def callback(response): if self.is_live: sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_user_agent_append(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): service = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), credential=tables_primary_cosmos_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_cosmos.py index e715badd20b8..66a73027d1d0 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_cosmos.py @@ -17,7 +17,7 @@ from devtools_testutils import AzureTestCase -from azure.core.credentials import AzureSasCredential +from azure.core.credentials import AzureNamedKeyCredential from azure.core.exceptions import ( HttpResponseError, ResourceNotFoundError, @@ -281,10 +281,11 @@ def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_cosmos class TestTableUnitTest(TableTestCase): tables_cosmos_account_name = "fake_storage_account" tables_primary_cosmos_account_key = "fakeXMZjnGsZGvd4bVr3Il5SeHA" + credential = AzureNamedKeyCredential(name=tables_cosmos_account_name, key=tables_primary_cosmos_account_key) def test_create_table_invalid_name(self): # Arrange - ts = TableServiceClient(self.account_url(self.tables_cosmos_account_name, "cosmos"), self.tables_primary_cosmos_account_key) + ts = TableServiceClient(self.account_url(self.tables_cosmos_account_name, "cosmos"), self.credential) invalid_table_name = "my_table" with pytest.raises(ValueError) as excinfo: @@ -295,7 +296,7 @@ def test_create_table_invalid_name(self): def test_delete_table_invalid_name(self): # Arrange - ts = TableServiceClient(self.account_url(self.tables_cosmos_account_name, "cosmos"), self.tables_primary_cosmos_account_key) + ts = TableServiceClient(self.account_url(self.tables_cosmos_account_name, "cosmos"), self.credential) invalid_table_name = "my_table" with pytest.raises(ValueError) as excinfo: @@ -307,7 +308,7 @@ def test_delete_table_invalid_name(self): def test_unicode_create_table_unicode_name(self): # Arrange url = self.account_url(self.tables_cosmos_account_name, "cosmos") - ts = TableServiceClient(url, self.tables_primary_cosmos_account_key) + ts = TableServiceClient(url, self.credential) table_name = u'啊齄丂狛狜' # Act diff --git a/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py index ce8f8e873aea..68faf37a36cb 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py @@ -8,7 +8,7 @@ from devtools_testutils import AzureTestCase -from azure.core.credentials import AzureSasCredential +from azure.core.credentials import AzureNamedKeyCredential from azure.core.exceptions import ResourceNotFoundError, ResourceExistsError, HttpResponseError from azure.data.tables import ( AccessPolicy, @@ -21,7 +21,7 @@ from _shared.asynctestcase import AsyncTableTestCase from _shared.testcase import SLEEP_DELAY -from preparers import cosmos_decorator +from preparers import cosmos_decorator_async TEST_TABLE_PREFIX = 'pytableasync' @@ -60,7 +60,7 @@ async def _delete_table(self, ts, table): pass # --Test cases for tables -------------------------------------------------- - @cosmos_decorator + @cosmos_decorator_async async def test_create_table(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -77,7 +77,7 @@ async def test_create_table(self, tables_cosmos_account_name, tables_primary_cos if self.is_live: sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_create_table_fail_on_exist(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -95,7 +95,7 @@ async def test_create_table_fail_on_exist(self, tables_cosmos_account_name, tabl if self.is_live: sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_query_tables_per_page(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange # account_url = self.account_url(tables_cosmos_account_name, "table") @@ -128,7 +128,7 @@ async def test_query_tables_per_page(self, tables_cosmos_account_name, tables_pr if self.is_live: sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_list_tables(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -147,7 +147,7 @@ async def test_list_tables(self, tables_cosmos_account_name, tables_primary_cosm if self.is_live: sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_query_tables_with_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -167,7 +167,7 @@ async def test_query_tables_with_filter(self, tables_cosmos_account_name, tables if self.is_live: sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_list_tables_with_num_results(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._delete_all_tables(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -196,7 +196,7 @@ async def test_list_tables_with_num_results(self, tables_cosmos_account_name, ta # if self.is_live: # sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_list_tables_with_marker(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -231,7 +231,7 @@ async def test_list_tables_with_marker(self, tables_cosmos_account_name, tables_ if self.is_live: sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_delete_table_with_existing_table(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -248,7 +248,7 @@ async def test_delete_table_with_existing_table(self, tables_cosmos_account_name if self.is_live: sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -266,12 +266,13 @@ async def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_ class TestTableUnitTest(AsyncTableTestCase): tables_cosmos_account_name = "fake_storage_account" tables_primary_cosmos_account_key = "fakeXMZjnGsZGvd4bVr3Il5SeHA" + credential = AzureNamedKeyCredential(name=tables_cosmos_account_name, key=tables_primary_cosmos_account_key) @pytest.mark.asyncio async def test_unicode_create_table_unicode_name(self): # Arrange url = self.account_url(self.tables_cosmos_account_name, "cosmos") - ts = TableServiceClient(url, self.tables_primary_cosmos_account_key) + ts = TableServiceClient(url, self.credential) table_name = u'啊齄丂狛狜' with pytest.raises(ValueError) as excinfo: @@ -283,7 +284,7 @@ async def test_unicode_create_table_unicode_name(self): @pytest.mark.asyncio async def test_create_table_invalid_name(self): # Arrange - ts = TableServiceClient(self.account_url(self.tables_cosmos_account_name, "cosmos"), self.tables_primary_cosmos_account_key) + ts = TableServiceClient(self.account_url(self.tables_cosmos_account_name, "cosmos"), self.credential) invalid_table_name = "my_table" with pytest.raises(ValueError) as excinfo: @@ -295,7 +296,7 @@ async def test_create_table_invalid_name(self): @pytest.mark.asyncio async def test_delete_table_invalid_name(self): # Arrange - ts = TableServiceClient(self.account_url(self.tables_cosmos_account_name, "cosmos"), self.tables_primary_cosmos_account_key) + ts = TableServiceClient(self.account_url(self.tables_cosmos_account_name, "cosmos"), self.credential) invalid_table_name = "my_table" with pytest.raises(ValueError) as excinfo: diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py index 53a743865df6..a32de1c1c452 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py @@ -35,7 +35,7 @@ from azure.data.tables.aio import TableServiceClient from _shared.asynctestcase import AsyncTableTestCase -from preparers import tables_decorator +from preparers import tables_decorator_async class StorageTableEntityTest(AzureTestCase, AsyncTableTestCase): @@ -281,7 +281,7 @@ def _assert_valid_metadata(self, metadata): # --Test cases for entities ------------------------------------------ - @tables_decorator + @tables_decorator_async async def test_url_encoding_at_symbol(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -316,7 +316,7 @@ async def test_url_encoding_at_symbol(self, tables_storage_account_name, tables_ finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_dictionary(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -331,7 +331,7 @@ async def test_insert_entity_dictionary(self, tables_storage_account_name, table finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_with_hook(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -350,7 +350,7 @@ async def test_insert_entity_with_hook(self, tables_storage_account_name, tables finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_with_no_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -375,7 +375,7 @@ async def test_insert_entity_with_no_metadata(self, tables_storage_account_name, finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_with_full_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -402,7 +402,7 @@ async def test_insert_entity_with_full_metadata(self, tables_storage_account_nam finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_conflict(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -418,7 +418,7 @@ async def test_insert_entity_conflict(self, tables_storage_account_name, tables_ finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_with_large_int32_value_throws(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -438,7 +438,7 @@ async def test_insert_entity_with_large_int32_value_throws(self, tables_storage_ finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_with_large_int64_value_throws(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -458,7 +458,7 @@ async def test_insert_entity_with_large_int64_value_throws(self, tables_storage_ finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_with_large_int_success(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -484,7 +484,7 @@ async def test_insert_entity_with_large_int_success(self, tables_storage_account finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_missing_pk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -497,7 +497,7 @@ async def test_insert_entity_missing_pk(self, tables_storage_account_name, table finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_empty_string_pk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -510,7 +510,7 @@ async def test_insert_entity_empty_string_pk(self, tables_storage_account_name, finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_missing_rk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -525,7 +525,7 @@ async def test_insert_entity_missing_rk(self, tables_storage_account_name, table finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_empty_string_rk(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -539,7 +539,7 @@ async def test_insert_entity_empty_string_rk(self, tables_storage_account_name, finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_too_many_properties(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -556,7 +556,7 @@ async def test_insert_entity_too_many_properties(self, tables_storage_account_na finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_entity_property_name_too_long(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -573,7 +573,7 @@ async def test_insert_entity_property_name_too_long(self, tables_storage_account finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_get_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -591,7 +591,7 @@ async def test_get_entity(self, tables_storage_account_name, tables_primary_stor finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_get_entity_with_hook(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -613,7 +613,7 @@ async def test_get_entity_with_hook(self, tables_storage_account_name, tables_pr finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_get_entity_if_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -637,7 +637,7 @@ async def test_get_entity_if_match(self, tables_storage_account_name, tables_pri finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_get_entity_full_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -657,7 +657,7 @@ async def test_get_entity_full_metadata(self, tables_storage_account_name, table finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_get_entity_no_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -677,7 +677,7 @@ async def test_get_entity_no_metadata(self, tables_storage_account_name, tables_ finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_get_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -693,7 +693,7 @@ async def test_get_entity_not_existing(self, tables_storage_account_name, tables finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_get_entity_with_special_doubles(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -718,7 +718,7 @@ async def test_get_entity_with_special_doubles(self, tables_storage_account_name finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_update_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -740,7 +740,7 @@ async def test_update_entity(self, tables_storage_account_name, tables_primary_s finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_update_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -756,7 +756,7 @@ async def test_update_entity_not_existing(self, tables_storage_account_name, tab finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_update_entity_with_if_matches(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -778,7 +778,7 @@ async def test_update_entity_with_if_matches(self, tables_storage_account_name, finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_update_entity_with_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -799,7 +799,7 @@ async def test_update_entity_with_if_doesnt_match(self, tables_storage_account_n finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_or_merge_entity_with_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -819,7 +819,7 @@ async def test_insert_or_merge_entity_with_existing_entity(self, tables_storage_ finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_or_merge_entity_with_non_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -839,7 +839,7 @@ async def test_insert_or_merge_entity_with_non_existing_entity(self, tables_stor finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_or_replace_entity_with_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -859,7 +859,7 @@ async def test_insert_or_replace_entity_with_existing_entity(self, tables_storag finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_insert_or_replace_entity_with_non_existing_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -879,7 +879,7 @@ async def test_insert_or_replace_entity_with_non_existing_entity(self, tables_st finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_merge_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -898,7 +898,7 @@ async def test_merge_entity(self, tables_storage_account_name, tables_primary_st finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_merge_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -914,7 +914,7 @@ async def test_merge_entity_not_existing(self, tables_storage_account_name, tabl finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_merge_entity_with_if_matches(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -935,7 +935,7 @@ async def test_merge_entity_with_if_matches(self, tables_storage_account_name, t finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_merge_entity_with_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -955,7 +955,7 @@ async def test_merge_entity_with_if_doesnt_match(self, tables_storage_account_na finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_delete_entity(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -972,7 +972,7 @@ async def test_delete_entity(self, tables_storage_account_name, tables_primary_s finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_delete_entity_not_existing(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -987,7 +987,7 @@ async def test_delete_entity_not_existing(self, tables_storage_account_name, tab finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_delete_entity_with_if_matches(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1005,7 +1005,7 @@ async def test_delete_entity_with_if_matches(self, tables_storage_account_name, finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_delete_entity_with_if_doesnt_match(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -1024,7 +1024,7 @@ async def test_delete_entity_with_if_doesnt_match(self, tables_storage_account_n finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_unicode_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): ''' regression test for github issue #57''' # Arrange @@ -1051,7 +1051,7 @@ async def test_unicode_property_value(self, tables_storage_account_name, tables_ finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_unicode_property_name(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1077,7 +1077,7 @@ async def test_unicode_property_name(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_operations_on_entity_with_partition_key_having_single_quote(self, tables_storage_account_name, tables_primary_storage_account_key): partition_key_with_single_quote = u"a''''b" row_key_with_single_quote = u"a''''b" @@ -1103,7 +1103,7 @@ async def test_operations_on_entity_with_partition_key_having_single_quote(self, finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_empty_and_spaces_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -1142,7 +1142,7 @@ async def test_empty_and_spaces_property_value(self, tables_storage_account_name finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_none_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1160,7 +1160,7 @@ async def test_none_property_value(self, tables_storage_account_name, tables_pri finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_binary_property_value(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1179,7 +1179,7 @@ async def test_binary_property_value(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_timezone(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1201,7 +1201,7 @@ async def test_timezone(self, tables_storage_account_name, tables_primary_storag finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_entities(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1220,7 +1220,7 @@ async def test_query_entities(self, tables_storage_account_name, tables_primary_ finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_entities_each_page(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1260,7 +1260,7 @@ async def test_query_entities_each_page(self, tables_storage_account_name, table finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_injection_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1296,7 +1296,7 @@ async def test_query_injection_async(self, tables_storage_account_name, tables_p await self.ts.delete_table(table_name) await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_special_chars(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1355,7 +1355,7 @@ async def test_query_special_chars(self, tables_storage_account_name, tables_pri await self.ts.delete_table(table_name) await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_user_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1375,7 +1375,7 @@ async def test_query_user_filter(self, tables_storage_account_name, tables_prima finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_user_filter_multiple_params(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1399,7 +1399,7 @@ async def test_query_user_filter_multiple_params(self, tables_storage_account_na finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_user_filter_integers(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1422,7 +1422,7 @@ async def test_query_user_filter_integers(self, tables_storage_account_name, tab finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_user_filter_floats(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1445,7 +1445,7 @@ async def test_query_user_filter_floats(self, tables_storage_account_name, table finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_user_filter_datetimes(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1468,7 +1468,7 @@ async def test_query_user_filter_datetimes(self, tables_storage_account_name, ta finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_user_filter_guids(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1491,7 +1491,7 @@ async def test_query_user_filter_guids(self, tables_storage_account_name, tables finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_user_filter_binary(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1514,7 +1514,7 @@ async def test_query_user_filter_binary(self, tables_storage_account_name, table finally: self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_user_filter_int64(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1544,7 +1544,7 @@ async def test_query_user_filter_int64(self, tables_storage_account_name, tables finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_zero_entities(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1561,7 +1561,7 @@ async def test_query_zero_entities(self, tables_storage_account_name, tables_pri finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_entities_full_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1580,7 +1580,7 @@ async def test_query_entities_full_metadata(self, tables_storage_account_name, t finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_entities_no_metadata(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1599,7 +1599,7 @@ async def test_query_entities_no_metadata(self, tables_storage_account_name, tab finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_entities_with_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1621,7 +1621,7 @@ async def test_query_entities_with_filter(self, tables_storage_account_name, tab finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_invalid_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1643,7 +1643,7 @@ async def test_query_invalid_filter(self, tables_storage_account_name, tables_pr finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_entities_with_select(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1665,7 +1665,7 @@ async def test_query_entities_with_select(self, tables_storage_account_name, tab finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_entities_with_top(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) @@ -1682,7 +1682,7 @@ async def test_query_entities_with_top(self, tables_storage_account_name, tables finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_query_entities_with_top_and_next(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange @@ -1718,7 +1718,7 @@ async def test_query_entities_with_top_and_next(self, tables_storage_account_nam finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_sas_query(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1754,7 +1754,7 @@ async def test_sas_query(self, tables_storage_account_name, tables_primary_stora finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_sas_add(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1788,7 +1788,7 @@ async def test_sas_add(self, tables_storage_account_name, tables_primary_storage finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_sas_add_inside_range(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1821,7 +1821,7 @@ async def test_sas_add_inside_range(self, tables_storage_account_name, tables_pr finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_sas_add_outside_range(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1853,7 +1853,7 @@ async def test_sas_add_outside_range(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_sas_update(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1888,7 +1888,7 @@ async def test_sas_update(self, tables_storage_account_name, tables_primary_stor finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_sas_delete(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1919,7 +1919,7 @@ async def test_sas_delete(self, tables_storage_account_name, tables_primary_stor finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_sas_upper_case_table_name(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1956,7 +1956,7 @@ async def test_sas_upper_case_table_name(self, tables_storage_account_name, tabl finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_sas_signed_identifier(self, tables_storage_account_name, tables_primary_storage_account_key): # SAS URL is calculated from storage key, so this test runs live only url = self.account_url(tables_storage_account_name, "table") @@ -1998,7 +1998,7 @@ async def test_sas_signed_identifier(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_datetime_milliseconds(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) try: @@ -2018,7 +2018,7 @@ async def test_datetime_milliseconds(self, tables_storage_account_name, tables_p finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_datetime_str_passthrough(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) partition, row = self._create_pk_rk(None, None) diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py index 7bbf9e0f2308..bd027bdecb7f 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py @@ -37,7 +37,7 @@ from _shared.asynctestcase import AsyncTableTestCase from _shared.testcase import SLEEP_DELAY -from preparers import cosmos_decorator +from preparers import cosmos_decorator_async # ------------------------------------------------------------------------------ # TODO: change to `with table_client as client:` to close sessions # ------------------------------------------------------------------------------ @@ -286,7 +286,7 @@ def _assert_valid_metadata(self, metadata): assert len(keys) == 3 # --Test cases for entities ------------------------------------------ - @cosmos_decorator + @cosmos_decorator_async async def test_url_encoding_at_symbol(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -321,7 +321,7 @@ async def test_url_encoding_at_symbol(self, tables_cosmos_account_name, tables_p finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_dictionary(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -336,7 +336,7 @@ async def test_insert_entity_dictionary(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_with_hook(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -355,7 +355,7 @@ async def test_insert_entity_with_hook(self, tables_cosmos_account_name, tables_ finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_with_no_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -380,7 +380,7 @@ async def test_insert_entity_with_no_metadata(self, tables_cosmos_account_name, finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_with_full_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -406,7 +406,7 @@ async def test_insert_entity_with_full_metadata(self, tables_cosmos_account_name finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_conflict(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -421,7 +421,7 @@ async def test_insert_entity_conflict(self, tables_cosmos_account_name, tables_p finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_with_large_int32_value_throws(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -441,7 +441,7 @@ async def test_insert_entity_with_large_int32_value_throws(self, tables_cosmos_a finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_with_large_int64_value_throws(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -461,7 +461,7 @@ async def test_insert_entity_with_large_int64_value_throws(self, tables_cosmos_a finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_with_large_int_success(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -487,7 +487,7 @@ async def test_insert_entity_with_large_int_success(self, tables_cosmos_account_ finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_missing_pk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -501,7 +501,7 @@ async def test_insert_entity_missing_pk(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_empty_string_pk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -514,7 +514,7 @@ async def test_insert_entity_empty_string_pk(self, tables_cosmos_account_name, t finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_missing_rk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -529,7 +529,7 @@ async def test_insert_entity_missing_rk(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_entity_empty_string_rk(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -543,7 +543,7 @@ async def test_insert_entity_empty_string_rk(self, tables_cosmos_account_name, t finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_get_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -561,7 +561,7 @@ async def test_get_entity(self, tables_cosmos_account_name, tables_primary_cosmo finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_get_entity_with_hook(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -581,7 +581,7 @@ async def test_get_entity_with_hook(self, tables_cosmos_account_name, tables_pri finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_get_entity_if_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -603,7 +603,7 @@ async def test_get_entity_if_match(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_get_entity_full_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -623,7 +623,7 @@ async def test_get_entity_full_metadata(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_get_entity_no_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -643,7 +643,7 @@ async def test_get_entity_no_metadata(self, tables_cosmos_account_name, tables_p finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_get_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -659,7 +659,7 @@ async def test_get_entity_not_existing(self, tables_cosmos_account_name, tables_ finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_get_entity_with_special_doubles(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -684,7 +684,7 @@ async def test_get_entity_with_special_doubles(self, tables_cosmos_account_name, finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_update_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -706,7 +706,7 @@ async def test_update_entity(self, tables_cosmos_account_name, tables_primary_co finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_update_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -722,7 +722,7 @@ async def test_update_entity_not_existing(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_update_entity_with_if_matches(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -744,7 +744,7 @@ async def test_update_entity_with_if_matches(self, tables_cosmos_account_name, t finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_update_entity_with_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -765,7 +765,7 @@ async def test_update_entity_with_if_doesnt_match(self, tables_cosmos_account_na finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_or_merge_entity_with_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -784,7 +784,7 @@ async def test_insert_or_merge_entity_with_existing_entity(self, tables_cosmos_a finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_or_merge_entity_with_non_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -802,7 +802,7 @@ async def test_insert_or_merge_entity_with_non_existing_entity(self, tables_cosm finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_or_replace_entity_with_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -821,7 +821,7 @@ async def test_insert_or_replace_entity_with_existing_entity(self, tables_cosmos finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_insert_or_replace_entity_with_non_existing_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -838,7 +838,7 @@ async def test_insert_or_replace_entity_with_non_existing_entity(self, tables_co finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_merge_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -855,7 +855,7 @@ async def test_merge_entity(self, tables_cosmos_account_name, tables_primary_cos finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_merge_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -871,7 +871,7 @@ async def test_merge_entity_not_existing(self, tables_cosmos_account_name, table finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_merge_entity_with_if_matches(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -890,7 +890,7 @@ async def test_merge_entity_with_if_matches(self, tables_cosmos_account_name, ta finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_merge_entity_with_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -910,7 +910,7 @@ async def test_merge_entity_with_if_doesnt_match(self, tables_cosmos_account_nam finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_delete_entity(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -925,7 +925,7 @@ async def test_delete_entity(self, tables_cosmos_account_name, tables_primary_co finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_delete_entity_not_existing(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -940,7 +940,7 @@ async def test_delete_entity_not_existing(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_delete_entity_with_if_matches(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -956,7 +956,7 @@ async def test_delete_entity_with_if_matches(self, tables_cosmos_account_name, t finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_delete_entity_with_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -975,7 +975,7 @@ async def test_delete_entity_with_if_doesnt_match(self, tables_cosmos_account_na finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_unicode_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): ''' regression test for github issue #57''' # Arrange @@ -1002,7 +1002,7 @@ async def test_unicode_property_value(self, tables_cosmos_account_name, tables_p finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_unicode_property_name(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1029,7 +1029,7 @@ async def test_unicode_property_name(self, tables_cosmos_account_name, tables_pr await self._tear_down() @pytest.mark.skip("Bad Request: Cosmos cannot handle single quotes in a PK/RK (confirm)") - @cosmos_decorator + @cosmos_decorator_async async def test_operations_on_entity_with_partition_key_having_single_quote(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange partition_key_with_single_quote = "a''''b" @@ -1059,7 +1059,7 @@ async def test_operations_on_entity_with_partition_key_having_single_quote(self, finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_empty_and_spaces_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -1098,7 +1098,7 @@ async def test_empty_and_spaces_property_value(self, tables_cosmos_account_name, finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_none_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1116,7 +1116,7 @@ async def test_none_property_value(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_binary_property_value(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1135,7 +1135,7 @@ async def test_binary_property_value(self, tables_cosmos_account_name, tables_pr finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_timezone(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1157,7 +1157,7 @@ async def test_timezone(self, tables_cosmos_account_name, tables_primary_cosmos_ finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_entities(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1176,7 +1176,7 @@ async def test_query_entities(self, tables_cosmos_account_name, tables_primary_c finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_entities_each_page(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1216,7 +1216,7 @@ async def test_query_entities_each_page(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_user_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1237,7 +1237,7 @@ async def test_query_user_filter(self, tables_cosmos_account_name, tables_primar finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_user_filter_multiple_params(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1261,7 +1261,7 @@ async def test_query_user_filter_multiple_params(self, tables_cosmos_account_nam finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_user_filter_integers(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1284,7 +1284,7 @@ async def test_query_user_filter_integers(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_user_filter_floats(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1307,7 +1307,7 @@ async def test_query_user_filter_floats(self, tables_cosmos_account_name, tables finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_user_filter_datetimes(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1330,7 +1330,7 @@ async def test_query_user_filter_datetimes(self, tables_cosmos_account_name, tab finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_user_filter_guids(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1353,7 +1353,7 @@ async def test_query_user_filter_guids(self, tables_cosmos_account_name, tables_ finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_user_filter_binary(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1376,7 +1376,7 @@ async def test_query_user_filter_binary(self, tables_cosmos_account_name, tables finally: self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_user_filter_int64(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1406,7 +1406,7 @@ async def test_query_user_filter_int64(self, tables_cosmos_account_name, tables_ finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_zero_entities(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1423,7 +1423,7 @@ async def test_query_zero_entities(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_entities_full_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1442,7 +1442,7 @@ async def test_query_entities_full_metadata(self, tables_cosmos_account_name, ta finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_entities_no_metadata(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1461,7 +1461,7 @@ async def test_query_entities_no_metadata(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_entities_with_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1483,7 +1483,7 @@ async def test_query_entities_with_filter(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_injection_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1518,7 +1518,7 @@ async def test_query_injection_async(self, tables_cosmos_account_name, tables_pr finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_special_chars(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1576,7 +1576,7 @@ async def test_query_special_chars(self, tables_cosmos_account_name, tables_prim finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_invalid_filter(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1598,7 +1598,7 @@ async def test_query_invalid_filter(self, tables_cosmos_account_name, tables_pri finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_entities_with_select(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) try: @@ -1619,7 +1619,7 @@ async def test_query_entities_with_select(self, tables_cosmos_account_name, tabl finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_entities_with_top(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) @@ -1634,7 +1634,7 @@ async def test_query_entities_with_top(self, tables_cosmos_account_name, tables_ finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_query_entities_with_top_and_next(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange @@ -1670,7 +1670,7 @@ async def test_query_entities_with_top_and_next(self, tables_cosmos_account_name finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_datetime_milliseconds(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) try: @@ -1690,7 +1690,7 @@ async def test_datetime_milliseconds(self, tables_cosmos_account_name, tables_pr finally: await self._tear_down() - @cosmos_decorator + @cosmos_decorator_async async def test_datetime_str_passthrough(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) partition, row = self._create_pk_rk(None, None) diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py b/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py index ee19c63b41d9..f87ee3843bbd 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py @@ -16,7 +16,7 @@ from azure.data.tables.aio import TableServiceClient from _shared.testcase import TableTestCase -from preparers import tables_decorator +from preparers import tables_decorator_async # ------------------------------------------------------------------------------ @@ -97,7 +97,7 @@ def _assert_retention_equal(self, ret1, ret2): assert ret1.days == ret2.days # --Test cases per service --------------------------------------- - @tables_decorator + @tables_decorator_async async def test_table_service_properties_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -116,7 +116,7 @@ async def test_table_service_properties_async(self, tables_storage_account_name, self._assert_properties_default(await tsc.get_service_properties()) # --Test cases per feature --------------------------------------- - @tables_decorator + @tables_decorator_async async def test_set_logging_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -132,7 +132,7 @@ async def test_set_logging_async(self, tables_storage_account_name, tables_prima received_props = await tsc.get_service_properties() self._assert_logging_equal(received_props['analytics_logging'], logging) - @tables_decorator + @tables_decorator_async async def test_set_hour_metrics_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -148,7 +148,7 @@ async def test_set_hour_metrics_async(self, tables_storage_account_name, tables_ received_props = await tsc.get_service_properties() self._assert_metrics_equal(received_props['hour_metrics'], hour_metrics) - @tables_decorator + @tables_decorator_async async def test_set_minute_metrics_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -165,7 +165,7 @@ async def test_set_minute_metrics_async(self, tables_storage_account_name, table received_props = await tsc.get_service_properties() self._assert_metrics_equal(received_props['minute_metrics'], minute_metrics) - @tables_decorator + @tables_decorator_async async def test_set_cors_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange url = self.account_url(tables_storage_account_name, "table") @@ -196,7 +196,7 @@ async def test_set_cors_async(self, tables_storage_account_name, tables_primary_ self._assert_cors_equal(received_props['cors'], cors) # --Test cases for errors --------------------------------------- - @tables_decorator + @tables_decorator_async async def test_too_many_cors_rules_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange tsc = TableServiceClient(self.account_url(tables_storage_account_name, "table"), tables_primary_storage_account_key) @@ -208,7 +208,7 @@ async def test_too_many_cors_rules_async(self, tables_storage_account_name, tabl with pytest.raises(HttpResponseError): await tsc.set_service_properties(None, None, None, cors) - @tables_decorator + @tables_decorator_async async def test_retention_too_long_async(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange tsc = TableServiceClient(self.account_url(tables_storage_account_name, "table"), tables_primary_storage_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py index bf59b5f3d311..7f1f3bd905ed 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py @@ -16,7 +16,7 @@ from _shared.testcase import SLEEP_DELAY from _shared.asynctestcase import AsyncTableTestCase -from preparers import cosmos_decorator +from preparers import cosmos_decorator_async # ------------------------------------------------------------------------------ class TableServicePropertiesTest(AzureTestCase, AsyncTableTestCase): @@ -95,7 +95,7 @@ def _assert_retention_equal(self, ret1, ret2): assert ret1.days == ret2.days # --Test cases for errors --------------------------------------- - @cosmos_decorator + @cosmos_decorator_async async def test_too_many_cors_rules_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange tsc = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) @@ -108,7 +108,7 @@ async def test_too_many_cors_rules_async(self, tables_cosmos_account_name, table await tsc.set_service_properties(None, None, None, cors) self.sleep(SLEEP_DELAY) - @cosmos_decorator + @cosmos_decorator_async async def test_retention_too_long_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange tsc = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_stats_async.py b/sdk/tables/azure-data-tables/tests/test_table_service_stats_async.py index 9014c082a45b..1decb7b6da95 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_stats_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_stats_async.py @@ -10,7 +10,7 @@ from azure.data.tables.aio import TableServiceClient from _shared.asynctestcase import AsyncTableTestCase -from preparers import tables_decorator +from preparers import tables_decorator_async SERVICE_UNAVAILABLE_RESP_BODY = 'unavailableunavailable Date: Fri, 30 Apr 2021 11:49:35 -0400 Subject: [PATCH 03/15] more test fixes --- .../azure/data/tables/_base_client.py | 5 +- .../tests/_shared/testcase.py | 4 +- .../tests/test_table_client.py | 40 +++++------- .../tests/test_table_client_async.py | 48 ++++++-------- .../tests/test_table_client_cosmos.py | 65 +++++++++---------- .../tests/test_table_client_cosmos_async.py | 63 +++++++++--------- 6 files changed, 102 insertions(+), 123 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py index cf357d689331..c94163de91ff 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py @@ -352,10 +352,7 @@ def parse_connection_str(conn_str, credential, keyword_args): secondary = None if not credential: try: - credential = { - "account_name": conn_settings["accountname"], - "account_key": conn_settings["accountkey"], - } + credential = AzureNamedKeyCredential(name=conn_settings["accountname"], key=conn_settings["accountkey"]) except KeyError: credential = conn_settings.get("sharedaccesssignature") diff --git a/sdk/tables/azure-data-tables/tests/_shared/testcase.py b/sdk/tables/azure-data-tables/tests/_shared/testcase.py index 518aead71473..59c066af2335 100644 --- a/sdk/tables/azure-data-tables/tests/_shared/testcase.py +++ b/sdk/tables/azure-data-tables/tests/_shared/testcase.py @@ -14,7 +14,7 @@ import pytest from devtools_testutils import AzureTestCase -from azure.core.credentials import AccessToken +from azure.core.credentials import AccessToken, AzureNamedKeyCredential from azure.data.tables import generate_account_sas, AccountSasPermissions, ResourceTypes LOGGING_FORMAT = '%(asctime)s %(name)-20s %(levelname)-5s %(message)s' @@ -62,7 +62,7 @@ def generate_sas_token(self): return '?' + generate_account_sas( account_name = 'test', # name of the storage account - account_key = fake_key, # key for the storage account + account_key = AzureNamedKeyCredential(name="fakename", key=fake_key), # key for the storage account resource_types = ResourceTypes(object=True), permission = AccountSasPermissions(read=True,list=True), start = datetime.now() - timedelta(hours = 24), diff --git a/sdk/tables/azure-data-tables/tests/test_table_client.py b/sdk/tables/azure-data-tables/tests/test_table_client.py index e2d919b56b93..a61b41337dcc 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client.py @@ -112,8 +112,8 @@ class TestTableUnitTests(TableTestCase): def validate_standard_account_endpoints(self, service, account_name, account_key): assert service is not None assert service.account_name == account_name - assert service.credential.account_name == account_name - assert service.credential.account_key == account_key + assert service.credential.named_key.name == account_name + assert service.credential.named_key.key == account_key assert ('{}.{}'.format(account_name, 'table.core.windows.net') in service.url) or ('{}.{}'.format(account_name, 'table.cosmos.azure.com') in service.url) # --Direct Parameters Test Cases -------------------------------------------- @@ -168,8 +168,8 @@ def test_create_service_china(self): # Assert assert service is not None assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) def test_create_service_protocol(self): @@ -271,8 +271,8 @@ def test_create_service_with_connection_string_cosmos(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') assert service.scheme == 'https' @@ -288,8 +288,8 @@ def test_create_service_with_connection_string_endpoint_protocol(self): # Assert assert service is not None assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('http://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) assert service.scheme == 'http' @@ -313,9 +313,8 @@ def test_create_service_with_connection_string_custom_domain(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_custom_domain_trailing_slash(self): @@ -329,9 +328,8 @@ def test_create_service_with_conn_str_custom_domain_trailing_slash(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_custom_domain_sec_override(self): @@ -346,9 +344,8 @@ def test_create_service_with_conn_str_custom_domain_sec_override(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_fails_if_sec_without_primary(self): @@ -378,9 +375,8 @@ def test_create_service_with_conn_str_succeeds_if_sec_with_primary(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_custom_account_endpoint_path(self): @@ -395,8 +391,8 @@ def test_create_service_with_custom_account_endpoint_path(self): # Assert assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_hostname == 'local-machine:11002/custom/account/path' service = TableServiceClient(account_url=custom_account_url) diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_async.py index e48bde9a8700..8925edccfce5 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_async.py @@ -109,8 +109,8 @@ class TestTableClientUnit(AsyncTableTestCase): def validate_standard_account_endpoints(self, service, account_name, account_key): assert service is not None assert service.account_name == account_name - assert service.credential.account_name == account_name - assert service.credential.account_key == account_key + assert service.credential.named_key.name == account_name + assert service.credential.named_key.key == account_key assert ('{}.{}'.format(account_name, 'table.core.windows.net') in service.url) or ('{}.{}'.format(account_name, 'table.cosmos.azure.com') in service.url) # --Direct Parameters Test Cases -------------------------------------------- @@ -161,18 +161,16 @@ async def test_create_service_with_sas_async(self): async def test_create_service_with_token_async(self): url = self.account_url(self.tables_storage_account_name, "table") suffix = '.table.core.windows.net' - self.token_credential = self.generate_fake_token() + # self.credential = self.generate_fake_token() for service_type in SERVICES: # Act - service = service_type(url, credential=self.token_credential, table_name='foo') + service = service_type(url, credential=self.credential, table_name='foo') # Assert assert service is not None assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + suffix) - assert service.credential == self.token_credential - assert not hasattr(service.credential, 'account_key') - assert hasattr(service.credential, 'get_token') + assert service.credential == self.credential @pytest.mark.asyncio async def test_create_service_with_token_and_http_async(self): @@ -194,8 +192,8 @@ async def test_create_service_china_async(self): # Assert assert service is not None assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) @pytest.mark.asyncio @@ -295,8 +293,8 @@ async def test_create_service_with_connection_string_cosmos_async(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') assert service.scheme == 'https' @@ -313,8 +311,8 @@ async def test_create_service_with_connection_string_endpoint_protocol_async(sel # Assert assert service is not None assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('http://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) assert service.scheme == 'http' @@ -340,9 +338,8 @@ async def test_create_service_with_connection_string_custom_domain_async(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -357,9 +354,8 @@ async def test_create_service_with_conn_str_custom_domain_trailing_slash_async(s # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -375,9 +371,8 @@ async def test_create_service_with_conn_str_custom_domain_sec_override_async(sel # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -407,9 +402,8 @@ async def test_create_service_with_conn_str_succeeds_if_sec_with_primary_async(s # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.credential assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -425,8 +419,8 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): # Assert assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.credential + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_hostname == 'local-machine:11002/custom/account/path' service = TableServiceClient(account_url=custom_account_url) diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py index 61956db021e6..2cb2787da0c3 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py @@ -127,8 +127,8 @@ class TestTableClientUnit(TableTestCase): def validate_standard_account_endpoints(self, service, account_name, account_key): assert service is not None assert service.account_name == account_name - assert service.credential.account_name == account_name - assert service.credential.account_key == account_key + assert service.credential.named_key.name == account_name + assert service.credential.named_key.key == account_key assert ('{}.{}'.format(account_name, 'table.core.windows.net') in service.url) or ('{}.{}'.format(account_name, 'table.cosmos.azure.com') in service.url) def _account_url(self, account_name): @@ -142,21 +142,20 @@ def test_create_service_with_key(self): # Act service = client( account_url=self._account_url(self.tables_cosmos_account_name), - credential=self.tables_primary_cosmos_account_key, + credential=self.credential, table_name='foo') # Assert self.validate_standard_account_endpoints(service, self.tables_cosmos_account_name, self.tables_primary_cosmos_account_key) assert service.scheme == 'https' - def test_create_service_with_connection_string(self): for client, url in SERVICES.items(): # Act service = client( account_url=self._account_url(self.tables_cosmos_account_name), - credential=self.tables_primary_cosmos_account_key, + credential=self.credential, table_name="test") # Assert @@ -189,7 +188,7 @@ def test_create_service_with_token(self): # Act service = service_type( account_url=self._account_url(self.tables_cosmos_account_name), - credential=self.tables_primary_cosmos_account_key, + credential=self.credential, table_name="foo") # Assert @@ -214,12 +213,12 @@ def test_create_service_china(self): for service_type in SERVICES.items(): url = self.account_url(self.tables_cosmos_account_name, "cosmos").replace('cosmos.azure.com', 'core.chinacloudapi.cn') service = service_type[0]( - url, credential=self.tables_primary_cosmos_account_key, table_name='foo') + url, credential=self.credential, table_name='foo') assert service is not None assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://{}.{}.core.chinacloudapi.cn'.format(self.tables_cosmos_account_name, "table")) def test_create_service_protocol(self): @@ -230,7 +229,7 @@ def test_create_service_protocol(self): # Act service = service_type( account_url=url, - credential=self.tables_primary_cosmos_account_key, + credential=self.credential, table_name="foo") # Assert @@ -255,11 +254,11 @@ def test_create_service_with_socket_timeout(self): # Act default_service = service_type[0]( account_url=self._account_url(self.tables_cosmos_account_name), - credential=self.tables_primary_cosmos_account_key, + credential=self.credential, table_name="foo") service = service_type[0]( account_url=self._account_url(self.tables_cosmos_account_name), - credential=self.tables_primary_cosmos_account_key, + credential=self.credential, table_name="foo", connection_timeout=22) # Assert @@ -311,8 +310,8 @@ def test_create_service_with_connection_string_cosmos(self): assert service is not None assert service.account_name == self.tables_cosmos_account_name assert service.url.startswith('https://' + self.tables_cosmos_account_name + '.table.cosmos.azure.com') - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://' + self.tables_cosmos_account_name + '.table.cosmos.azure.com') assert service.scheme == 'https' @@ -325,8 +324,8 @@ def test_create_service_with_connection_string_endpoint_protocol(self): assert service is not None assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('http://{}.{}.core.chinacloudapi.cn'.format(self.tables_cosmos_account_name, "table")) assert service.scheme == 'http' @@ -352,9 +351,8 @@ def test_create_service_with_connection_string_custom_domain(self): # Assert assert service is not None - assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') @@ -369,9 +367,8 @@ def test_create_service_with_conn_str_custom_domain_trailing_slash(self): # Assert assert service is not None - assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_custom_domain_sec_override(self): @@ -386,9 +383,8 @@ def test_create_service_with_conn_str_custom_domain_sec_override(self): # Assert assert service is not None - assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_fails_if_sec_without_primary(self): @@ -419,9 +415,8 @@ def test_create_service_with_conn_str_succeeds_if_sec_with_primary(self): # Assert assert service is not None - assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_custom_account_endpoint_path(self): @@ -435,9 +430,9 @@ def test_create_service_with_custom_account_endpoint_path(self): service = service_type[0].from_connection_string(conn_string, table_name="foo") # Assert - assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.account_name == "custom" + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_hostname == 'local-machine:11002/custom/account/path' service = TableServiceClient(account_url=custom_account_url) @@ -466,7 +461,7 @@ def test_create_table_client_with_complete_table_url(self): table_url = self._account_url(self.tables_cosmos_account_name) + "/foo" service = TableClient( account_url=table_url, - credential=self.tables_primary_cosmos_account_key, + credential=self.credential, table_name="bar") # Assert @@ -480,7 +475,7 @@ def test_create_table_client_with_complete_url(self): table_url = "https://{}.table.cosmos.azure.com:443/foo".format(self.tables_cosmos_account_name) service = TableClient( account_url=table_url, - credential=self.tables_primary_cosmos_account_key, + credential=self.credential, table_name="bar") # Assert @@ -519,7 +514,7 @@ def test_closing_pipeline_client(self): # Act service = client( account_url=self._account_url(self.tables_cosmos_account_name), - credential=self.tables_primary_cosmos_account_key, + credential=self.credential, table_name='table') # Assert @@ -534,7 +529,7 @@ def test_closing_pipeline_client_simple(self): # Act service = client( account_url=self._account_url(self.tables_cosmos_account_name), - credential=self.tables_primary_cosmos_account_key, + credential=self.credential, table_name='table') service.close() diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py index a1336e1d29b4..d8d34c34f7e3 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +from azure.core.credentials import AzureNamedKeyCredential import pytest import platform from time import sleep @@ -111,13 +112,14 @@ def callback(response): class TestTableClientUnit(AsyncTableTestCase): tables_cosmos_account_name = "fake_storage_account" tables_primary_cosmos_account_key = "fakeXMZjnGsZGvd4bVr3Il5SeHA" + credential = AzureNamedKeyCredential(name=tables_cosmos_account_name, key=tables_primary_cosmos_account_key) # --Helpers----------------------------------------------------------------- def validate_standard_account_endpoints(self, service, account_name, account_key): assert service is not None assert service.account_name == account_name - assert service.credential.account_name == account_name - assert service.credential.account_key == account_key + assert service.credential.named_key.name == account_name + assert service.credential.named_key.key == account_key assert '{}.{}'.format(account_name, 'table.core.windows.net') in service.url or '{}.{}'.format(account_name, 'table.cosmos.azure.com') in service.url # --Direct Parameters Test Cases -------------------------------------------- @@ -128,7 +130,7 @@ async def test_create_service_with_key_async(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_cosmos_account_name, url), credential=self.tables_primary_cosmos_account_key, table_name='foo') + self.account_url(self.tables_cosmos_account_name, url), credential=self.credential, table_name='foo') # Assert self.validate_standard_account_endpoints(service, self.tables_cosmos_account_name, self.tables_primary_cosmos_account_key) @@ -197,14 +199,13 @@ async def test_create_service_china_async(self): for service_type in SERVICES.items(): # Act url = self.account_url(self.tables_cosmos_account_name, "cosmos").replace('cosmos.azure.com', 'core.chinacloudapi.cn') - service = service_type[0]( - url, credential=self.tables_primary_cosmos_account_key, table_name='foo') + service = service_type[0](url, credential=self.credential, table_name='foo') # Assert assert service is not None assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://{}.{}.core.chinacloudapi.cn'.format(self.tables_cosmos_account_name, "table")) @pytest.mark.asyncio @@ -215,7 +216,7 @@ async def test_create_service_protocol_async(self): # Act url = self.account_url(self.tables_cosmos_account_name, "cosmos").replace('https', 'http') service = service_type[0]( - url, credential=self.tables_primary_cosmos_account_key, table_name='foo') + url, credential=self.credential, table_name='foo') # Assert self.validate_standard_account_endpoints(service, self.tables_cosmos_account_name, self.tables_primary_cosmos_account_key) @@ -240,9 +241,9 @@ async def test_create_service_with_socket_timeout_async(self): for service_type in SERVICES.items(): # Act default_service = service_type[0]( - self.account_url(self.tables_cosmos_account_name, "cosmos"), credential=self.tables_primary_cosmos_account_key, table_name='foo') + self.account_url(self.tables_cosmos_account_name, "cosmos"), credential=self.credential, table_name='foo') service = service_type[0]( - self.account_url(self.tables_cosmos_account_name, "cosmos"), credential=self.tables_primary_cosmos_account_key, + self.account_url(self.tables_cosmos_account_name, "cosmos"), credential=self.credential, table_name='foo', connection_timeout=22) # Assert @@ -295,8 +296,8 @@ async def test_create_service_with_connection_string_cosmos_async(self): assert service is not None assert service.account_name == self.tables_cosmos_account_name assert service.url.startswith('https://' + self.tables_cosmos_account_name + '.table.cosmos.azure.com') - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://' + self.tables_cosmos_account_name + '.table.cosmos.azure.com') assert service.scheme == 'https' @@ -313,8 +314,8 @@ async def test_create_service_with_connection_string_endpoint_protocol_async(sel # Assert assert service is not None assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('http://{}.{}.core.chinacloudapi.cn'.format(self.tables_cosmos_account_name, "table")) assert service.scheme == 'http' @@ -340,9 +341,8 @@ async def test_create_service_with_connection_string_custom_domain_async(self): # Assert assert service is not None - assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -357,9 +357,8 @@ async def test_create_service_with_conn_str_custom_domain_trailing_slash_async(s # Assert assert service is not None - assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -375,9 +374,8 @@ async def test_create_service_with_conn_str_custom_domain_sec_override_async(sel # Assert assert service is not None - assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -407,9 +405,8 @@ async def test_create_service_with_conn_str_succeeds_if_sec_with_primary_async(s # Assert assert service is not None - assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -424,9 +421,9 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): service = service_type[0].from_connection_string(conn_string, table_name="foo") # Assert - assert service.account_name == self.tables_cosmos_account_name - assert service.credential.account_name == self.tables_cosmos_account_name - assert service.credential.account_key == self.tables_primary_cosmos_account_key + assert service.account_name == "custom" + assert service.credential.named_key.name == self.tables_cosmos_account_name + assert service.credential.named_key.key == self.tables_primary_cosmos_account_key assert service._primary_hostname == 'local-machine:11002/custom/account/path' service = TableServiceClient(account_url=custom_account_url) @@ -454,7 +451,7 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): async def test_create_table_client_with_complete_table_url_async(self): # Arrange table_url = self.account_url(self.tables_cosmos_account_name, "cosmos") + "/foo" - service = TableClient(table_url, table_name='bar', credential=self.tables_primary_cosmos_account_key) + service = TableClient(table_url, table_name='bar', credential=self.credential) # Assert assert service.scheme == 'https' @@ -465,7 +462,7 @@ async def test_create_table_client_with_complete_table_url_async(self): async def test_create_table_client_with_complete_url_async(self): # Arrange table_url = "https://{}.table.cosmos.azure.com:443/foo".format(self.tables_cosmos_account_name) - service = TableClient(table_url, table_name='bar', credential=self.tables_primary_cosmos_account_key) + service = TableClient(table_url, table_name='bar', credential=self.credential) # Assert assert service.scheme == 'https' @@ -505,7 +502,7 @@ async def test_closing_pipeline_client_async(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_cosmos_account_name, "cosmos"), credential=self.tables_primary_cosmos_account_key, table_name='table') + self.account_url(self.tables_cosmos_account_name, "cosmos"), credential=self.credential, table_name='table') # Assert async with service: @@ -518,5 +515,5 @@ async def test_closing_pipeline_client_simple_async(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_cosmos_account_name, "cosmos"), credential=self.tables_primary_cosmos_account_key, table_name='table') + self.account_url(self.tables_cosmos_account_name, "cosmos"), credential=self.credential, table_name='table') await service.close() From 62382a3652c2b08ce4b1380a781215ac0bb715b4 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 30 Apr 2021 12:01:12 -0400 Subject: [PATCH 04/15] one file to go --- .../tests/test_table_client.py | 117 ++++++++--------- .../tests/test_table_client_async.py | 121 +++++++++--------- 2 files changed, 121 insertions(+), 117 deletions(-) diff --git a/sdk/tables/azure-data-tables/tests/test_table_client.py b/sdk/tables/azure-data-tables/tests/test_table_client.py index a61b41337dcc..af993338e060 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client.py @@ -10,13 +10,13 @@ from azure.data.tables import TableServiceClient, TableClient from azure.data.tables import __version__ as VERSION -from azure.core.credentials import AzureNamedKeyCredential +from azure.core.exceptions import HttpResponseError from _shared.testcase import ( TableTestCase ) -from preparers import tables_decorator +from preparers import TablesPreparer # ------------------------------------------------------------------------------ @@ -31,7 +31,7 @@ class TestTableClient(AzureTestCase, TableTestCase): - @tables_decorator + @TablesPreparer() def test_user_agent_custom(self, tables_storage_account_name, tables_primary_storage_account_key): custom_app = "TestApp/v1.0" service = TableServiceClient( @@ -67,7 +67,7 @@ def callback(response): for table in tables: count += 1 - @tables_decorator + @TablesPreparer() def test_user_agent_append(self, tables_storage_account_name, tables_primary_storage_account_key): service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) @@ -83,7 +83,7 @@ def callback(response): for table in tables: count += 1 - @tables_decorator + @TablesPreparer() def test_user_agent_default(self, tables_storage_account_name, tables_primary_storage_account_key): service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) @@ -106,14 +106,13 @@ def callback(response): class TestTableUnitTests(TableTestCase): tables_storage_account_name = "fake_storage_account" tables_primary_storage_account_key = "fakeXMZjnGsZGvd4bVr3Il5SeHA" - credential = AzureNamedKeyCredential(name=tables_storage_account_name, key=tables_primary_storage_account_key) # --Helpers----------------------------------------------------------------- def validate_standard_account_endpoints(self, service, account_name, account_key): assert service is not None assert service.account_name == account_name - assert service.credential.named_key.name == account_name - assert service.credential.named_key.key == account_key + assert service.credential.account_name == account_name + assert service.credential.account_key == account_key assert ('{}.{}'.format(account_name, 'table.core.windows.net') in service.url) or ('{}.{}'.format(account_name, 'table.cosmos.azure.com') in service.url) # --Direct Parameters Test Cases -------------------------------------------- @@ -123,10 +122,10 @@ def test_create_service_with_key(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, url), credential=self.credential, table_name='foo') + self.account_url(self.tables_storage_account_name, url), credential=self.tables_primary_storage_account_key, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) assert service.scheme == 'https' def test_create_service_with_connection_string(self): @@ -134,10 +133,10 @@ def test_create_service_with_connection_string(self): for service_type in SERVICES.items(): # Act service = service_type[0].from_connection_string( - self.connection_string(self.tables_storage_account_name, self.credential), table_name="test") + self.connection_string(self.tables_storage_account_name, self.tables_primary_storage_account_key), table_name="test") # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) assert service.scheme == 'https' def test_create_service_with_sas(self): @@ -163,13 +162,13 @@ def test_create_service_china(self): # Act url = self.account_url(self.tables_storage_account_name, "table").replace('core.windows.net', 'core.chinacloudapi.cn') service = service_type[0]( - url, credential=self.credential, table_name='foo') + url, credential=self.tables_primary_storage_account_key, table_name='foo') # Assert assert service is not None assert service.account_name == self.tables_storage_account_name - assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.tables_primary_storage_account_key + assert service.credential.account_name == self.tables_storage_account_name + assert service.credential.account_key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) def test_create_service_protocol(self): @@ -179,10 +178,10 @@ def test_create_service_protocol(self): # Act url = self.account_url(self.tables_storage_account_name, "table").replace('https', 'http') service = service_type[0]( - url, credential=self.credential, table_name='foo') + url, credential=self.tables_primary_storage_account_key, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) assert service.scheme == 'http' def test_create_service_empty_key(self): @@ -196,7 +195,7 @@ def test_create_service_empty_key(self): # test non-string account URL with pytest.raises(ValueError): - test_service = service_type(account_url=123456, credential=self.credential, table_name='foo') + test_service = service_type(account_url=123456, credential=self.tables_primary_storage_account_key, table_name='foo') assert str(e.value) == "You need to provide either a SAS token or an account shared key to authenticate." @@ -206,38 +205,38 @@ def test_create_service_with_socket_timeout(self): for service_type in SERVICES.items(): # Act default_service = service_type[0]( - self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='foo') + self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='foo') service = service_type[0]( - self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, + self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='foo', connection_timeout=22) # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) assert service._client._client._pipeline._transport.connection_config.timeout == 22 assert default_service._client._client._pipeline._transport.connection_config.timeout == 300 - + # Assert Parent transport is shared with child client service = TableServiceClient( self.account_url(self.tables_storage_account_name, "table"), - credential=self.credential, + credential=self.tables_primary_storage_account_key, connection_timeout=22) assert service._client._client._pipeline._transport.connection_config.timeout == 22 table = service.get_table_client('tablename') assert table._client._client._pipeline._transport._transport.connection_config.timeout == 22 - + # --Connection String Test Cases -------------------------------------------- def test_create_service_with_connection_string_key(self): # Arrange - conn_string = 'AccountName={};AccountKey={};'.format(self.tables_storage_account_name, self.credential) + conn_string = 'AccountName={};AccountKey={};'.format(self.tables_storage_account_name, self.tables_primary_storage_account_key) for service_type in SERVICES.items(): # Act service = service_type[0].from_connection_string(conn_string, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) assert service.scheme == 'https' def test_create_service_with_connection_string_sas(self): @@ -261,7 +260,7 @@ def test_create_service_with_connection_string_sas(self): def test_create_service_with_connection_string_cosmos(self): # Arrange conn_string = 'DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};TableEndpoint=https://{0}.table.cosmos.azure.com:443/;'.format( - self.tables_storage_account_name, self.credential) + self.tables_storage_account_name, self.tables_primary_storage_account_key) for service_type in SERVICES: # Act @@ -271,15 +270,15 @@ def test_create_service_with_connection_string_cosmos(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') - assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.tables_primary_storage_account_key + assert service.credential.account_name == self.tables_storage_account_name + assert service.credential.account_key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') assert service.scheme == 'https' def test_create_service_with_connection_string_endpoint_protocol(self): # Arrange conn_string = 'AccountName={};AccountKey={};DefaultEndpointsProtocol=http;EndpointSuffix=core.chinacloudapi.cn;'.format( - self.tables_storage_account_name, self.credential) + self.tables_storage_account_name, self.tables_primary_storage_account_key) for service_type in SERVICES.items(): # Act @@ -288,15 +287,15 @@ def test_create_service_with_connection_string_endpoint_protocol(self): # Assert assert service is not None assert service.account_name == self.tables_storage_account_name - assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.tables_primary_storage_account_key + assert service.credential.account_name == self.tables_storage_account_name + assert service.credential.account_key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('http://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) assert service.scheme == 'http' def test_create_service_with_connection_string_emulated(self): # Arrange for service_type in SERVICES.items(): - conn_string = 'UseDevelopmentStorage=true;'.format(self.tables_storage_account_name, self.credential) + conn_string = 'UseDevelopmentStorage=true;'.format(self.tables_storage_account_name, self.tables_primary_storage_account_key) # Act with pytest.raises(ValueError): @@ -306,37 +305,39 @@ def test_create_service_with_connection_string_custom_domain(self): # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com;'.format( - self.tables_storage_account_name, self.credential) + self.tables_storage_account_name, self.tables_primary_storage_account_key) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") # Assert assert service is not None - assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.tables_primary_storage_account_key + assert service.account_name == self.tables_storage_account_name + assert service.credential.account_name == self.tables_storage_account_name + assert service.credential.account_key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_custom_domain_trailing_slash(self): # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com/;'.format( - self.tables_storage_account_name, self.credential) + self.tables_storage_account_name, self.tables_primary_storage_account_key) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") # Assert assert service is not None - assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.tables_primary_storage_account_key + assert service.account_name == self.tables_storage_account_name + assert service.credential.account_name == self.tables_storage_account_name + assert service.credential.account_key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_custom_domain_sec_override(self): # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com/;'.format( - self.tables_storage_account_name, self.credential) + self.tables_storage_account_name, self.tables_primary_storage_account_key) # Act service = service_type[0].from_connection_string( @@ -344,15 +345,16 @@ def test_create_service_with_conn_str_custom_domain_sec_override(self): # Assert assert service is not None - assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.tables_primary_storage_account_key + assert service.account_name == self.tables_storage_account_name + assert service.credential.account_name == self.tables_storage_account_name + assert service.credential.account_key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_fails_if_sec_without_primary(self): for service_type in SERVICES.items(): # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;'.format( - self.tables_storage_account_name, self.credential, + self.tables_storage_account_name, self.tables_primary_storage_account_key, _CONNECTION_ENDPOINTS_SECONDARY.get(service_type[1])) # Act @@ -366,7 +368,7 @@ def test_create_service_with_conn_str_succeeds_if_sec_with_primary(self): # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;{}=www-sec.mydomain.com;'.format( self.tables_storage_account_name, - self.credential, + self.tables_primary_storage_account_key, _CONNECTION_ENDPOINTS.get(service_type[1]), _CONNECTION_ENDPOINTS_SECONDARY.get(service_type[1])) @@ -375,8 +377,9 @@ def test_create_service_with_conn_str_succeeds_if_sec_with_primary(self): # Assert assert service is not None - assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.tables_primary_storage_account_key + assert service.account_name == self.tables_storage_account_name + assert service.credential.account_name == self.tables_storage_account_name + assert service.credential.account_key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_custom_account_endpoint_path(self): @@ -384,15 +387,15 @@ def test_create_service_with_custom_account_endpoint_path(self): custom_account_url = "http://local-machine:11002/custom/account/path/" + token for service_type in SERVICES.items(): conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};TableEndpoint={};'.format( - self.tables_storage_account_name, self.credential, custom_account_url) + self.tables_storage_account_name, self.tables_primary_storage_account_key, custom_account_url) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") # Assert assert service.account_name == self.tables_storage_account_name - assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.tables_primary_storage_account_key + assert service.credential.account_name == self.tables_storage_account_name + assert service.credential.account_key == self.tables_primary_storage_account_key assert service._primary_hostname == 'local-machine:11002/custom/account/path' service = TableServiceClient(account_url=custom_account_url) @@ -418,7 +421,7 @@ def test_create_service_with_custom_account_endpoint_path(self): def test_create_table_client_with_complete_table_url(self): # Arrange table_url = self.account_url(self.tables_storage_account_name, "table") + "/foo" - service = TableClient(table_url, table_name='bar', credential=self.credential) + service = TableClient(table_url, table_name='bar', credential=self.tables_primary_storage_account_key) # Assert assert service.scheme == 'https' @@ -428,7 +431,7 @@ def test_create_table_client_with_complete_table_url(self): def test_create_table_client_with_complete_url(self): # Arrange table_url = "https://{}.table.core.windows.net:443/foo".format(self.tables_storage_account_name) - service = TableClient(account_url=table_url, table_name='bar', credential=self.credential) + service = TableClient(account_url=table_url, table_name='bar', credential=self.tables_primary_storage_account_key) # Assert assert service.scheme == 'https' @@ -442,7 +445,7 @@ def test_create_table_client_with_invalid_name(self): # Assert with pytest.raises(ValueError) as excinfo: - service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.credential") + service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.tables_primary_storage_account_key") assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long." in str(excinfo) @@ -465,7 +468,7 @@ def test_closing_pipeline_client(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='table') + self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='table') # Assert with service: @@ -477,7 +480,7 @@ def test_closing_pipeline_client_simple(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='table') + self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='table') service.close() def test_create_service_with_token_and_http(self): @@ -514,15 +517,15 @@ def test_create_service_with_token(self): def test_create_client_with_api_version(self): url = self.account_url(self.tables_storage_account_name, "table") - client = TableServiceClient(url, credential=self.credential) + client = TableServiceClient(url, credential=self.tables_primary_storage_account_key) assert client._client._config.version == "2019-02-02" table = client.get_table_client('tablename') assert table._client._config.version == "2019-02-02" - client = TableServiceClient(url, credential=self.credential, api_version="2019-07-07") + client = TableServiceClient(url, credential=self.tables_primary_storage_account_key, api_version="2019-07-07") assert client._client._config.version == "2019-07-07" table = client.get_table_client('tablename') assert table._client._config.version == "2019-07-07" with pytest.raises(ValueError): - TableServiceClient(url, credential=self.credential, api_version="foo") + TableServiceClient(url, credential=self.tables_primary_storage_account_key, api_version="foo") diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_async.py index 8925edccfce5..834838bff91c 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_async.py @@ -3,14 +3,15 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +from azure.core.credentials import AzureNamedKeyCredential import pytest import platform from devtools_testutils import AzureTestCase +from azure.core.credentials import AzureNamedKeyCredential from azure.data.tables.aio import TableServiceClient, TableClient from azure.data.tables._version import VERSION -from azure.core.credentials import AzureNamedKeyCredential from _shared.asynctestcase import AsyncTableTestCase from preparers import tables_decorator_async @@ -108,9 +109,9 @@ class TestTableClientUnit(AsyncTableTestCase): # --Helpers----------------------------------------------------------------- def validate_standard_account_endpoints(self, service, account_name, account_key): assert service is not None - assert service.account_name == account_name - assert service.credential.named_key.name == account_name - assert service.credential.named_key.key == account_key + assert service.account_name == account_name + assert service.credential.named_key.name == account_name + assert service.credential.named_key.key == account_key assert ('{}.{}'.format(account_name, 'table.core.windows.net') in service.url) or ('{}.{}'.format(account_name, 'table.cosmos.azure.com') in service.url) # --Direct Parameters Test Cases -------------------------------------------- @@ -124,8 +125,8 @@ async def test_create_service_with_key_async(self): self.account_url(self.tables_storage_account_name, url), credential=self.credential, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) - assert service.scheme == 'https' + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + assert service.scheme == 'https' @pytest.mark.asyncio async def test_create_service_with_connection_string_async(self): @@ -133,11 +134,11 @@ async def test_create_service_with_connection_string_async(self): for service_type in SERVICES.items(): # Act service = service_type[0].from_connection_string( - self.connection_string(self.tables_storage_account_name, self.credential), table_name="test") + self.connection_string(self.tables_storage_account_name, self.tables_primary_storage_account_key), table_name="test") # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) - assert service.scheme == 'https' + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + assert service.scheme == 'https' @pytest.mark.asyncio async def test_create_service_with_sas_async(self): @@ -152,7 +153,7 @@ async def test_create_service_with_sas_async(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name + assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + suffix) assert service.url.endswith(token) assert service.credential is None @@ -161,16 +162,18 @@ async def test_create_service_with_sas_async(self): async def test_create_service_with_token_async(self): url = self.account_url(self.tables_storage_account_name, "table") suffix = '.table.core.windows.net' - # self.credential = self.generate_fake_token() + self.token_credential = self.generate_fake_token() for service_type in SERVICES: # Act - service = service_type(url, credential=self.credential, table_name='foo') + service = service_type(url, credential=self.token_credential, table_name='foo') # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name + assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + suffix) - assert service.credential == self.credential + assert service.credential == self.token_credential + assert not hasattr(service.credential, 'account_key') + assert hasattr(service.credential, 'get_token') @pytest.mark.asyncio async def test_create_service_with_token_and_http_async(self): @@ -191,8 +194,8 @@ async def test_create_service_china_async(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.named_key.name == self.tables_storage_account_name + assert service.account_name == self.tables_storage_account_name + assert service.credential.named_key.name == self.tables_storage_account_name assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) @@ -207,8 +210,8 @@ async def test_create_service_protocol_async(self): url, credential=self.credential, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) - assert service.scheme == 'http' + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + assert service.scheme == 'http' @pytest.mark.asyncio async def test_create_service_empty_key_async(self): @@ -235,7 +238,7 @@ async def test_create_service_with_socket_timeout_async(self): table_name='foo', connection_timeout=22) # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) assert service._client._client._pipeline._transport.connection_config.timeout == 22 assert default_service._client._client._pipeline._transport.connection_config.timeout == 300 @@ -252,15 +255,15 @@ async def test_create_service_with_socket_timeout_async(self): @pytest.mark.asyncio async def test_create_service_with_connection_string_key_async(self): # Arrange - conn_string = 'AccountName={};AccountKey={};'.format(self.tables_storage_account_name, self.credential) + conn_string = 'AccountName={};AccountKey={};'.format(self.tables_storage_account_name, self.tables_primary_storage_account_key) for service_type in SERVICES.items(): # Act service = service_type[0].from_connection_string(conn_string, table_name='foo') # Assert - self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.credential) - assert service.scheme == 'https' + self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) + assert service.scheme == 'https' @pytest.mark.asyncio async def test_create_service_with_connection_string_sas_async(self): @@ -274,7 +277,7 @@ async def test_create_service_with_connection_string_sas_async(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name + assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + '.table.core.windows.net') assert service.url.endswith(token) assert service.credential is None @@ -283,7 +286,7 @@ async def test_create_service_with_connection_string_sas_async(self): async def test_create_service_with_connection_string_cosmos_async(self): # Arrange conn_string = 'DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};TableEndpoint=https://{0}.table.cosmos.azure.com:443/;'.format( - self.tables_storage_account_name, self.credential) + self.tables_storage_account_name, self.tables_primary_storage_account_key) for service_type in SERVICES: # Act @@ -291,18 +294,17 @@ async def test_create_service_with_connection_string_cosmos_async(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') - assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.name == self.tables_storage_account_name assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') - assert service.scheme == 'https' + assert service.scheme == 'https' @pytest.mark.asyncio async def test_create_service_with_connection_string_endpoint_protocol_async(self): # Arrange conn_string = 'AccountName={};AccountKey={};DefaultEndpointsProtocol=http;EndpointSuffix=core.chinacloudapi.cn;'.format( - self.tables_storage_account_name, self.credential) + self.tables_storage_account_name, self.tables_primary_storage_account_key) for service_type in SERVICES.items(): # Act @@ -310,17 +312,16 @@ async def test_create_service_with_connection_string_endpoint_protocol_async(sel # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.name == self.tables_storage_account_name assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('http://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) - assert service.scheme == 'http' + assert service.scheme == 'http' @pytest.mark.asyncio async def test_create_service_with_connection_string_emulated_async(self): # Arrange for service_type in SERVICES.items(): - conn_string = 'UseDevelopmentStorage=true;'.format(self.tables_storage_account_name, self.credential) + conn_string = 'UseDevelopmentStorage=true;'.format(self.tables_storage_account_name, self.tables_primary_storage_account_key) # Act with pytest.raises(ValueError): @@ -331,14 +332,14 @@ async def test_create_service_with_connection_string_custom_domain_async(self): # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com;'.format( - self.tables_storage_account_name, self.credential) + self.tables_storage_account_name, self.tables_primary_storage_account_key) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") # Assert assert service is not None - assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.name == self.tables_storage_account_name assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') @@ -347,7 +348,7 @@ async def test_create_service_with_conn_str_custom_domain_trailing_slash_async(s # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com/;'.format( - self.tables_storage_account_name, self.credential) + self.tables_storage_account_name, self.tables_primary_storage_account_key) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") @@ -355,7 +356,7 @@ async def test_create_service_with_conn_str_custom_domain_trailing_slash_async(s # Assert assert service is not None assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.credential + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -363,7 +364,7 @@ async def test_create_service_with_conn_str_custom_domain_sec_override_async(sel # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};TableEndpoint=www.mydomain.com/;'.format( - self.tables_storage_account_name, self.credential) + self.tables_storage_account_name, self.tables_primary_storage_account_key) # Act service = service_type[0].from_connection_string( @@ -372,7 +373,7 @@ async def test_create_service_with_conn_str_custom_domain_sec_override_async(sel # Assert assert service is not None assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.credential + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -380,7 +381,7 @@ async def test_create_service_with_conn_str_fails_if_sec_without_primary_async(s for service_type in SERVICES.items(): # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;'.format( - self.tables_storage_account_name, self.credential, + self.tables_storage_account_name, self.tables_primary_storage_account_key, _CONNECTION_ENDPOINTS_SECONDARY.get(service_type[1])) # Fails if primary excluded @@ -393,7 +394,7 @@ async def test_create_service_with_conn_str_succeeds_if_sec_with_primary_async(s # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;{}=www-sec.mydomain.com;'.format( self.tables_storage_account_name, - self.credential, + self.tables_primary_storage_account_key, _CONNECTION_ENDPOINTS.get(service_type[1]), _CONNECTION_ENDPOINTS_SECONDARY.get(service_type[1])) @@ -403,7 +404,7 @@ async def test_create_service_with_conn_str_succeeds_if_sec_with_primary_async(s # Assert assert service is not None assert service.credential.named_key.name == self.tables_storage_account_name - assert service.credential.named_key.key == self.credential + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') @pytest.mark.asyncio @@ -412,35 +413,35 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): custom_account_url = "http://local-machine:11002/custom/account/path/" + token for service_type in SERVICES.items(): conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};TableEndpoint={};'.format( - self.tables_storage_account_name, self.credential, custom_account_url) + self.tables_storage_account_name, self.tables_primary_storage_account_key, custom_account_url) # Act service = service_type[0].from_connection_string(conn_string, table_name="foo") # Assert - assert service.account_name == self.tables_storage_account_name - assert service.credential.named_key.name == self.tables_storage_account_name + assert service.account_name == "custom" + assert service.credential.named_key.name == self.tables_storage_account_name assert service.credential.named_key.key == self.tables_primary_storage_account_key - assert service._primary_hostname == 'local-machine:11002/custom/account/path' + assert service._primary_hostname == 'local-machine:11002/custom/account/path' service = TableServiceClient(account_url=custom_account_url) assert service.account_name == "custom" - assert service.credential == None - assert service._primary_hostname == 'local-machine:11002/custom/account/path' + assert service.credential == None + assert service._primary_hostname == 'local-machine:11002/custom/account/path' assert service.url.startswith('http://local-machine:11002/custom/account/path') service = TableClient(account_url=custom_account_url, table_name="foo") assert service.account_name == "custom" - assert service.table_name == "foo" - assert service.credential == None - assert service._primary_hostname == 'local-machine:11002/custom/account/path' + assert service.table_name == "foo" + assert service.credential == None + assert service._primary_hostname == 'local-machine:11002/custom/account/path' assert service.url.startswith('http://local-machine:11002/custom/account/path') service = TableClient.from_table_url("http://local-machine:11002/custom/account/path/foo" + token) assert service.account_name == "custom" - assert service.table_name == "foo" - assert service.credential == None - assert service._primary_hostname == 'local-machine:11002/custom/account/path' + assert service.table_name == "foo" + assert service.credential == None + assert service._primary_hostname == 'local-machine:11002/custom/account/path' assert service.url.startswith('http://local-machine:11002/custom/account/path') @pytest.mark.asyncio @@ -450,9 +451,9 @@ async def test_create_table_client_with_complete_table_url_async(self): service = TableClient(table_url, table_name='bar', credential=self.credential) # Assert - assert service.scheme == 'https' - assert service.table_name == 'bar' - assert service.account_name == self.tables_storage_account_name + assert service.scheme == 'https' + assert service.table_name == 'bar' + assert service.account_name == self.tables_storage_account_name @pytest.mark.asyncio async def test_create_table_client_with_complete_url_async(self): @@ -461,9 +462,9 @@ async def test_create_table_client_with_complete_url_async(self): service = TableClient(account_url=table_url, table_name='bar', credential=self.credential) # Assert - assert service.scheme == 'https' - assert service.table_name == 'bar' - assert service.account_name == self.tables_storage_account_name + assert service.scheme == 'https' + assert service.table_name == 'bar' + assert service.account_name == self.tables_storage_account_name @pytest.mark.asyncio async def test_create_table_client_with_invalid_name_async(self): @@ -473,7 +474,7 @@ async def test_create_table_client_with_invalid_name_async(self): # Assert with pytest.raises(ValueError) as excinfo: - service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.credential") + service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.tables_primary_storage_account_key") assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long."in str(excinfo) From e2fc8fafc824465d34259b583d709f07fcd19fdb Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 30 Apr 2021 12:18:25 -0400 Subject: [PATCH 05/15] doc hints --- .../azure/data/tables/_table_client.py | 5 +- .../data/tables/_table_service_client.py | 2 +- .../data/tables/aio/_base_client_async.py | 8 +- .../data/tables/aio/_table_client_async.py | 10 +- .../tests/test_retry_async.py | 10 +- .../tests/test_table_client.py | 143 +++++++++--------- 6 files changed, 87 insertions(+), 91 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py index d88ea7e2357b..82885b14ac10 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py @@ -50,7 +50,7 @@ def __init__( self, account_url, # type: str table_name, # type: str - credential=None, # type: str + credential=None, # type: Union[AzureNamedKeyCredential, AzureSasCredential] **kwargs # type: Any ): # type: (...) -> None @@ -66,8 +66,7 @@ def __init__( account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string or an account shared access key. - :type credential: str - + :type credential: :class:`~azure.core.credentials.AzureNamedKeyCredential` or :class:`~azure.core.credentials.AzureSasCredential` :returns: None """ if not table_name: diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py index c80e1c54d238..133754b6c4a7 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py @@ -36,7 +36,7 @@ class TableServiceClient(TablesBaseClient): account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string or an account shared access key. - :type credential: str + :type credential: :class:`~azure.core.credentials.AzureNamedKeyCredential` or :class:`~azure.core.credentials.AzureSasCredential` :returns: None .. admonition:: Example: diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py index 9555c20ce4a3..4f87d4ba5567 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- -from typing import Any, List, Mapping +from typing import Any, List, Mapping, Optional, Union from uuid import uuid4 from azure.core.credentials import AzureSasCredential, AzureNamedKeyCredential @@ -40,9 +40,9 @@ class AsyncTablesBaseClient(AccountHostsMixin): def __init__( self, - account_url, # type: str - credential=None, # type: str - **kwargs # type: Any + account_url: str, + credential: Optional[Union[AzureSasCredential, AzureNamedKeyCredential]] = None, + **kwargs: Any ): # type: (...) -> None super(AsyncTablesBaseClient, self).__init__(account_url, credential=credential, **kwargs) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py index a771860a508e..1eb66e465482 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py @@ -11,7 +11,7 @@ from urlparse import urlparse # type: ignore from urllib2 import unquote # type: ignore -from azure.core.credentials import AzureSasCredential +from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential from azure.core.async_paging import AsyncItemPaged from azure.core.exceptions import ResourceNotFoundError, HttpResponseError from azure.core.tracing.decorator import distributed_trace @@ -43,7 +43,7 @@ def __init__( self, account_url: str, table_name: str, - credential: Optional[Union[AzureSasCredential]] = None, + credential: Optional[Union[AzureSasCredential, AzureNamedKeyCredential]] = None, **kwargs ) -> None: """Create TableClient from a Credential. @@ -58,7 +58,7 @@ def __init__( account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string or an account shared access key. - :type credential: str + :type credential: :class:`~azure.core.credentials.AzureNamedKeyCredential` or :class:`~azure.core.credentials.AzureSasCredential` :returns: None """ @@ -109,7 +109,7 @@ def from_connection_string( def from_table_url( cls, table_url: str, - credential: Optional[Union[AzureSasCredential]] = None, + credential: Optional[Union[AzureSasCredential, AzureNamedKeyCredential]] = None, **kwargs ) -> 'TableClient': """A client to interact with a specific Table. @@ -120,7 +120,7 @@ def from_table_url( The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, an account shared access key. - :type credential: str + :type credential: :class:`~azure.core.credentials.AzureNamedKeyCredential` or :class:`~azure.core.credentials.AzureSasCredential` :returns: A table client. :rtype: :class:`~azure.data.tables.TableClient` """ diff --git a/sdk/tables/azure-data-tables/tests/test_retry_async.py b/sdk/tables/azure-data-tables/tests/test_retry_async.py index bbe8367fabee..827ce5f7cbd6 100644 --- a/sdk/tables/azure-data-tables/tests/test_retry_async.py +++ b/sdk/tables/azure-data-tables/tests/test_retry_async.py @@ -29,7 +29,7 @@ RetryCounter ) -from preparers import tables_decorator +from preparers import tables_decorator_async class RetryAioHttpTransport(AioHttpTransport): @@ -80,7 +80,7 @@ async def _tear_down(self, **kwargs): pass # --Test Cases -------------------------------------------- - @tables_decorator + @tables_decorator_async async def test_retry_on_server_error_async(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up(tables_storage_account_name, tables_primary_storage_account_key, default_table=False) try: @@ -95,7 +95,7 @@ async def test_retry_on_server_error_async(self, tables_storage_account_name, ta await self.ts.delete_table(new_table_name) await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_retry_on_timeout_async(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up( tables_storage_account_name, @@ -114,7 +114,7 @@ async def test_retry_on_timeout_async(self, tables_storage_account_name, tables_ await self._tear_down() @pytest.mark.live_test_only - @tables_decorator + @tables_decorator_async async def test_retry_on_socket_timeout_async(self, tables_storage_account_name, tables_primary_storage_account_key): retry_transport = RetryAioHttpTransport(connection_timeout=11, read_timeout=0.000000000001) await self._set_up( @@ -138,7 +138,7 @@ async def test_retry_on_socket_timeout_async(self, tables_storage_account_name, finally: await self._tear_down() - @tables_decorator + @tables_decorator_async async def test_no_retry_async(self, tables_storage_account_name, tables_primary_storage_account_key): await self._set_up(tables_storage_account_name, tables_primary_storage_account_key, retry_total=0, default_table=False) diff --git a/sdk/tables/azure-data-tables/tests/test_table_client.py b/sdk/tables/azure-data-tables/tests/test_table_client.py index af993338e060..8afa69f4b13a 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client.py @@ -10,13 +10,13 @@ from azure.data.tables import TableServiceClient, TableClient from azure.data.tables import __version__ as VERSION -from azure.core.exceptions import HttpResponseError +from azure.core.credentials import AzureNamedKeyCredential from _shared.testcase import ( TableTestCase ) -from preparers import TablesPreparer +from preparers import tables_decorator # ------------------------------------------------------------------------------ @@ -31,7 +31,7 @@ class TestTableClient(AzureTestCase, TableTestCase): - @TablesPreparer() + @tables_decorator def test_user_agent_custom(self, tables_storage_account_name, tables_primary_storage_account_key): custom_app = "TestApp/v1.0" service = TableServiceClient( @@ -67,7 +67,7 @@ def callback(response): for table in tables: count += 1 - @TablesPreparer() + @tables_decorator def test_user_agent_append(self, tables_storage_account_name, tables_primary_storage_account_key): service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) @@ -83,7 +83,7 @@ def callback(response): for table in tables: count += 1 - @TablesPreparer() + @tables_decorator def test_user_agent_default(self, tables_storage_account_name, tables_primary_storage_account_key): service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) @@ -106,13 +106,14 @@ def callback(response): class TestTableUnitTests(TableTestCase): tables_storage_account_name = "fake_storage_account" tables_primary_storage_account_key = "fakeXMZjnGsZGvd4bVr3Il5SeHA" + credential = AzureNamedKeyCredential(name=tables_storage_account_name, key=tables_primary_storage_account_key) # --Helpers----------------------------------------------------------------- def validate_standard_account_endpoints(self, service, account_name, account_key): assert service is not None - assert service.account_name == account_name - assert service.credential.account_name == account_name - assert service.credential.account_key == account_key + assert service.account_name == account_name + assert service.credential.named_key.name == account_name + assert service.credential.named_key.key == account_key assert ('{}.{}'.format(account_name, 'table.core.windows.net') in service.url) or ('{}.{}'.format(account_name, 'table.cosmos.azure.com') in service.url) # --Direct Parameters Test Cases -------------------------------------------- @@ -122,11 +123,11 @@ def test_create_service_with_key(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, url), credential=self.tables_primary_storage_account_key, table_name='foo') + self.account_url(self.tables_storage_account_name, url), credential=self.credential, table_name='foo') # Assert self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) - assert service.scheme == 'https' + assert service.scheme == 'https' def test_create_service_with_connection_string(self): @@ -137,7 +138,7 @@ def test_create_service_with_connection_string(self): # Assert self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) - assert service.scheme == 'https' + assert service.scheme == 'https' def test_create_service_with_sas(self): # Arrange @@ -151,7 +152,7 @@ def test_create_service_with_sas(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name + assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + suffix) assert service.url.endswith(token) assert service.credential is None @@ -162,13 +163,13 @@ def test_create_service_china(self): # Act url = self.account_url(self.tables_storage_account_name, "table").replace('core.windows.net', 'core.chinacloudapi.cn') service = service_type[0]( - url, credential=self.tables_primary_storage_account_key, table_name='foo') + url, credential=self.credential, table_name='foo') # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.account_name == self.tables_storage_account_name + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) def test_create_service_protocol(self): @@ -178,11 +179,11 @@ def test_create_service_protocol(self): # Act url = self.account_url(self.tables_storage_account_name, "table").replace('https', 'http') service = service_type[0]( - url, credential=self.tables_primary_storage_account_key, table_name='foo') + url, credential=self.credential, table_name='foo') # Assert self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) - assert service.scheme == 'http' + assert service.scheme == 'http' def test_create_service_empty_key(self): # Arrange @@ -195,7 +196,7 @@ def test_create_service_empty_key(self): # test non-string account URL with pytest.raises(ValueError): - test_service = service_type(account_url=123456, credential=self.tables_primary_storage_account_key, table_name='foo') + test_service = service_type(account_url=123456, credential=self.credential, table_name='foo') assert str(e.value) == "You need to provide either a SAS token or an account shared key to authenticate." @@ -205,25 +206,25 @@ def test_create_service_with_socket_timeout(self): for service_type in SERVICES.items(): # Act default_service = service_type[0]( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='foo') + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='foo') service = service_type[0]( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='foo', connection_timeout=22) # Assert self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) assert service._client._client._pipeline._transport.connection_config.timeout == 22 assert default_service._client._client._pipeline._transport.connection_config.timeout == 300 - + # Assert Parent transport is shared with child client service = TableServiceClient( self.account_url(self.tables_storage_account_name, "table"), - credential=self.tables_primary_storage_account_key, + credential=self.credential, connection_timeout=22) assert service._client._client._pipeline._transport.connection_config.timeout == 22 table = service.get_table_client('tablename') assert table._client._client._pipeline._transport._transport.connection_config.timeout == 22 - + # --Connection String Test Cases -------------------------------------------- @@ -237,7 +238,7 @@ def test_create_service_with_connection_string_key(self): # Assert self.validate_standard_account_endpoints(service, self.tables_storage_account_name, self.tables_primary_storage_account_key) - assert service.scheme == 'https' + assert service.scheme == 'https' def test_create_service_with_connection_string_sas(self): # Arrange @@ -251,7 +252,7 @@ def test_create_service_with_connection_string_sas(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name + assert service.account_name == self.tables_storage_account_name assert service.url.startswith( 'https://' + self.tables_storage_account_name + '.table.core.windows.net') assert service.url.endswith(token) @@ -268,12 +269,12 @@ def test_create_service_with_connection_string_cosmos(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name + assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://' + self.tables_storage_account_name + '.table.cosmos.azure.com') - assert service.scheme == 'https' + assert service.scheme == 'https' def test_create_service_with_connection_string_endpoint_protocol(self): # Arrange @@ -286,11 +287,11 @@ def test_create_service_with_connection_string_endpoint_protocol(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.account_name == self.tables_storage_account_name + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('http://{}.{}.core.chinacloudapi.cn'.format(self.tables_storage_account_name, "table")) - assert service.scheme == 'http' + assert service.scheme == 'http' def test_create_service_with_connection_string_emulated(self): # Arrange @@ -312,9 +313,8 @@ def test_create_service_with_connection_string_custom_domain(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_custom_domain_trailing_slash(self): @@ -328,9 +328,8 @@ def test_create_service_with_conn_str_custom_domain_trailing_slash(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_custom_domain_sec_override(self): @@ -345,9 +344,8 @@ def test_create_service_with_conn_str_custom_domain_sec_override(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_conn_str_fails_if_sec_without_primary(self): @@ -377,9 +375,8 @@ def test_create_service_with_conn_str_succeeds_if_sec_with_primary(self): # Assert assert service is not None - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key assert service._primary_endpoint.startswith('https://www.mydomain.com') def test_create_service_with_custom_account_endpoint_path(self): @@ -393,50 +390,50 @@ def test_create_service_with_custom_account_endpoint_path(self): service = service_type[0].from_connection_string(conn_string, table_name="foo") # Assert - assert service.account_name == self.tables_storage_account_name - assert service.credential.account_name == self.tables_storage_account_name - assert service.credential.account_key == self.tables_primary_storage_account_key - assert service._primary_hostname == 'local-machine:11002/custom/account/path' + assert service.account_name == "custom" + assert service.credential.named_key.name == self.tables_storage_account_name + assert service.credential.named_key.key == self.tables_primary_storage_account_key + assert service._primary_hostname == 'local-machine:11002/custom/account/path' service = TableServiceClient(account_url=custom_account_url) assert service.account_name == "custom" - assert service.credential == None - assert service._primary_hostname == 'local-machine:11002/custom/account/path' + assert service.credential == None + assert service._primary_hostname == 'local-machine:11002/custom/account/path' assert service.url.startswith('http://local-machine:11002/custom/account/path') service = TableClient(account_url=custom_account_url, table_name="foo") assert service.account_name == "custom" - assert service.table_name == "foo" - assert service.credential == None - assert service._primary_hostname == 'local-machine:11002/custom/account/path' + assert service.table_name == "foo" + assert service.credential == None + assert service._primary_hostname == 'local-machine:11002/custom/account/path' assert service.url.startswith('http://local-machine:11002/custom/account/path') service = TableClient.from_table_url("http://local-machine:11002/custom/account/path/foo" + token) assert service.account_name == "custom" - assert service.table_name == "foo" - assert service.credential == None - assert service._primary_hostname == 'local-machine:11002/custom/account/path' + assert service.table_name == "foo" + assert service.credential == None + assert service._primary_hostname == 'local-machine:11002/custom/account/path' assert service.url.startswith('http://local-machine:11002/custom/account/path') def test_create_table_client_with_complete_table_url(self): # Arrange table_url = self.account_url(self.tables_storage_account_name, "table") + "/foo" - service = TableClient(table_url, table_name='bar', credential=self.tables_primary_storage_account_key) + service = TableClient(table_url, table_name='bar', credential=self.credential) # Assert - assert service.scheme == 'https' - assert service.table_name == 'bar' - assert service.account_name == self.tables_storage_account_name + assert service.scheme == 'https' + assert service.table_name == 'bar' + assert service.account_name == self.tables_storage_account_name def test_create_table_client_with_complete_url(self): # Arrange table_url = "https://{}.table.core.windows.net:443/foo".format(self.tables_storage_account_name) - service = TableClient(account_url=table_url, table_name='bar', credential=self.tables_primary_storage_account_key) + service = TableClient(account_url=table_url, table_name='bar', credential=self.credential) # Assert - assert service.scheme == 'https' - assert service.table_name == 'bar' - assert service.account_name == self.tables_storage_account_name + assert service.scheme == 'https' + assert service.table_name == 'bar' + assert service.account_name == self.tables_storage_account_name def test_create_table_client_with_invalid_name(self): # Arrange @@ -468,7 +465,7 @@ def test_closing_pipeline_client(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='table') + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='table') # Assert with service: @@ -480,7 +477,7 @@ def test_closing_pipeline_client_simple(self): for client, url in SERVICES.items(): # Act service = client( - self.account_url(self.tables_storage_account_name, "table"), credential=self.tables_primary_storage_account_key, table_name='table') + self.account_url(self.tables_storage_account_name, "table"), credential=self.credential, table_name='table') service.close() def test_create_service_with_token_and_http(self): @@ -501,7 +498,7 @@ def test_create_service_with_token(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + suffix) - assert service.credential == self.token_credential + assert service.credential == self.token_credential assert not hasattr(service.credential, 'account_key') assert hasattr(service.credential, 'get_token') @@ -511,21 +508,21 @@ def test_create_service_with_token(self): assert service is not None assert service.account_name == self.tables_storage_account_name assert service.url.startswith('https://' + self.tables_storage_account_name + suffix) - assert service.credential == self.token_credential + assert service.credential == self.token_credential assert not hasattr(service.credential, 'account_key') assert hasattr(service.credential, 'get_token') def test_create_client_with_api_version(self): url = self.account_url(self.tables_storage_account_name, "table") - client = TableServiceClient(url, credential=self.tables_primary_storage_account_key) + client = TableServiceClient(url, credential=self.credential) assert client._client._config.version == "2019-02-02" table = client.get_table_client('tablename') assert table._client._config.version == "2019-02-02" - client = TableServiceClient(url, credential=self.tables_primary_storage_account_key, api_version="2019-07-07") + client = TableServiceClient(url, credential=self.credential, api_version="2019-07-07") assert client._client._config.version == "2019-07-07" table = client.get_table_client('tablename') assert table._client._config.version == "2019-07-07" with pytest.raises(ValueError): - TableServiceClient(url, credential=self.tables_primary_storage_account_key, api_version="foo") + TableServiceClient(url, credential=self.credential, api_version="foo") From 430de479f6036b15638ec0f8b1d0a84c0a260992 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 30 Apr 2021 12:29:21 -0400 Subject: [PATCH 06/15] changelog and samples --- sdk/tables/azure-data-tables/CHANGELOG.md | 1 + .../async_samples/sample_insert_delete_entities_async.py | 4 +++- sdk/tables/azure-data-tables/samples/sample_authentication.py | 3 ++- sdk/tables/azure-data-tables/samples/sample_create_client.py | 4 +++- .../samples/sample_insert_delete_entities.py | 4 +++- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sdk/tables/azure-data-tables/CHANGELOG.md b/sdk/tables/azure-data-tables/CHANGELOG.md index ab83820aad4a..7f4536f52377 100644 --- a/sdk/tables/azure-data-tables/CHANGELOG.md +++ b/sdk/tables/azure-data-tables/CHANGELOG.md @@ -10,6 +10,7 @@ * `TableClient.send_batch` has been renamed to `TableClient.submit_transaction`. * Removed `BatchTransactionResult` object in favor of returning an iterable of batched entities with returned metadata. * `BatchErrorException` has been renamed to `TableTransactionError`. +* The only supported credentials are `AzureNamedKeyCredential`, `AzureSasCredential`, or authentication by connection string **Fixes** * Fixed issue with Cosmos merge operations. diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py index 1fa6febf5e0f..586f9a894f9d 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py @@ -25,6 +25,8 @@ import asyncio from dotenv import find_dotenv, load_dotenv +from azure.core.credentials import AzureNamedKeyCredential + class InsertDeleteEntity(object): def __init__(self): @@ -75,7 +77,7 @@ async def delete_entity(self): from azure.core.exceptions import ResourceNotFoundError, ResourceExistsError from azure.core import MatchConditions - table_client = TableClient(account_url=self.account_url, credential=self.access_key, table_name=self.table_name) + table_client = TableClient(account_url=self.account_url, credential=AzureNamedKeyCredential(self.account_name, self.access_key), table_name=self.table_name) # [START delete_entity] async with table_client: diff --git a/sdk/tables/azure-data-tables/samples/sample_authentication.py b/sdk/tables/azure-data-tables/samples/sample_authentication.py index 97e7fe161b6e..20189ae69937 100644 --- a/sdk/tables/azure-data-tables/samples/sample_authentication.py +++ b/sdk/tables/azure-data-tables/samples/sample_authentication.py @@ -29,6 +29,7 @@ from datetime import datetime, timedelta import os +from azure.core.credentials import AzureNamedKeyCredential from dotenv import find_dotenv, load_dotenv @@ -60,7 +61,7 @@ def authentication_by_shared_key(self): # Instantiate a TableServiceClient using a shared access key # [START auth_from_shared_key] from azure.data.tables import TableServiceClient - with TableServiceClient(account_url=self.account_url, credential=self.access_key) as table_service: + with TableServiceClient(account_url=self.account_url, credential=AzureNamedKeyCredential(self.account_name, self.access_key)) as table_service: properties = table_service.get_service_properties() print("Shared Key: {}".format(properties)) # [END auth_from_shared_key] diff --git a/sdk/tables/azure-data-tables/samples/sample_create_client.py b/sdk/tables/azure-data-tables/samples/sample_create_client.py index a2560a2d2e3b..7edb71329b33 100644 --- a/sdk/tables/azure-data-tables/samples/sample_create_client.py +++ b/sdk/tables/azure-data-tables/samples/sample_create_client.py @@ -26,6 +26,8 @@ from dotenv import find_dotenv, load_dotenv import os +from azure.core.credentials import AzureNamedKeyCredential + class CreateClients(object): def __init__(self): @@ -54,7 +56,7 @@ def create_table_service_client(self): # Instantiate a TableServiceClient using a shared access key # [START create_table_service_client] from azure.data.tables import TableServiceClient - with TableServiceClient(account_url=self.account_url, credential=self.access_key) as table_service: + with TableServiceClient(account_url=self.account_url, credential=AzureNamedKeyCredential(self.account_name, self.access_key)) as table_service: properties = table_service.get_service_properties() print("Properties: {}".format(properties)) # [END create_table_service_client] diff --git a/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py b/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py index e9f8bb833e04..0d93df31e1f5 100644 --- a/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py +++ b/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py @@ -23,6 +23,8 @@ import os from dotenv import find_dotenv, load_dotenv +from azure.core.credentials import AzureNamedKeyCredential + class InsertDeleteEntity(object): def __init__(self): @@ -72,7 +74,7 @@ def delete_entity(self): from azure.core.exceptions import ResourceNotFoundError, ResourceExistsError from azure.core import MatchConditions - with TableClient(account_url=self.account_url, credential=self.access_key, table_name=self.table_name) as table_client: + with TableClient(account_url=self.account_url, credential=AzureNamedKeyCredential(self.account_name, self.access_key), table_name=self.table_name) as table_client: # Create entity to delete (to showcase etag) try: From 2f3779faa641fe8db0f06e98f2d72a705a244895 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 30 Apr 2021 12:44:55 -0400 Subject: [PATCH 07/15] bumping core --- sdk/tables/azure-data-tables/setup.py | 2 +- shared_requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/tables/azure-data-tables/setup.py b/sdk/tables/azure-data-tables/setup.py index 2ce7123b3472..9c1043f5039a 100644 --- a/sdk/tables/azure-data-tables/setup.py +++ b/sdk/tables/azure-data-tables/setup.py @@ -79,7 +79,7 @@ 'azure.data', ]), install_requires=[ - "azure-core<2.0.0,>=1.13.0", + "azure-core<2.0.0,>=1.14.0", "msrest>=0.6.19" ], extras_require={ diff --git a/shared_requirements.txt b/shared_requirements.txt index b5df03e3402d..cbb8075d2851 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -130,7 +130,7 @@ pyjwt>=1.7.1 #override azure-core-tracing-opencensus azure-core<2.0.0,>=1.0.0 #override azure-core-tracing-opentelemetry azure-core<2.0.0,>=1.13.0 #override azure-cosmos azure-core<2.0.0,>=1.0.0 -#override azure-data-tables azure-core<2.0.0,>=1.13.0 +#override azure-data-tables azure-core<2.0.0,>=1.14.0 #override azure-eventhub azure-core<2.0.0,>=1.13.0 #override azure-identity azure-core<2.0.0,>=1.0.0 #override azure-keyvault-administration msrest>=0.6.21 From 5c71008c3452027b3cacc801931a3b4df375487c Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Fri, 30 Apr 2021 13:18:07 -0400 Subject: [PATCH 08/15] making everything work for python 2.7 --- .../azure/data/tables/_authentication.py | 5 +- .../tests/async_preparers.py | 47 +++++++++++++++++++ .../azure-data-tables/tests/preparers.py | 43 ----------------- .../tests/test_retry_async.py | 2 +- .../tests/test_table_async.py | 2 +- .../tests/test_table_batch_async.py | 2 +- .../tests/test_table_batch_cosmos_async.py | 2 +- .../tests/test_table_client_async.py | 2 +- .../tests/test_table_client_cosmos_async.py | 2 +- .../tests/test_table_cosmos_async.py | 2 +- .../tests/test_table_entity_async.py | 2 +- .../tests/test_table_entity_cosmos_async.py | 2 +- .../test_table_service_properties_async.py | 2 +- ...t_table_service_properties_cosmos_async.py | 2 +- .../tests/test_table_service_stats_async.py | 2 +- .../test_table_service_stats_cosmos_async.py | 2 +- 16 files changed, 64 insertions(+), 57 deletions(-) create mode 100644 sdk/tables/azure-data-tables/tests/async_preparers.py diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py b/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py index e15a41a78a26..a29ecba63873 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- import logging -from typing import Union, Awaitable +from typing import TYPE_CHECKING try: from urllib.parse import urlparse @@ -33,6 +33,9 @@ _wrap_exception, ) +if TYPE_CHECKING: + from typing import Union, Awaitable + logger = logging.getLogger(__name__) diff --git a/sdk/tables/azure-data-tables/tests/async_preparers.py b/sdk/tables/azure-data-tables/tests/async_preparers.py new file mode 100644 index 000000000000..f198df6f88e5 --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/async_preparers.py @@ -0,0 +1,47 @@ +import functools + +from azure.core.credentials import AzureNamedKeyCredential +from preparers import CosmosPreparer, TablesPreparer, trim_kwargs_from_test_function + +def cosmos_decorator_async(func, **kwargs): + + @CosmosPreparer() + def wrapper(*args, **kwargs): + key = kwargs.pop("tables_primary_cosmos_account_key") + name = kwargs.pop("tables_cosmos_account_name") + key = AzureNamedKeyCredential(key=key, name=name) + + kwargs["tables_primary_cosmos_account_key"] = key + kwargs["tables_cosmos_account_name"] = name + + trimmed_kwargs = {k:v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + @functools.wraps(func) + async def wrapped(*args, **kwargs): + return await func(*args, **trimmed_kwargs) + return wrapped + + return wrapper + + +def tables_decorator_async(func, **kwargs): + + @TablesPreparer() + def wrapper(*args, **kwargs): + key = kwargs.pop("tables_primary_storage_account_key") + name = kwargs.pop("tables_storage_account_name") + key = AzureNamedKeyCredential(key=key, name=name) + + kwargs["tables_primary_storage_account_key"] = key + kwargs["tables_storage_account_name"] = name + + trimmed_kwargs = {k:v for k, v in kwargs.items()} + trim_kwargs_from_test_function(func, trimmed_kwargs) + + @functools.wraps(func) + async def wrapped(*args, **kwargs): + return await func(*args, **trimmed_kwargs) + return wrapped + + return wrapper diff --git a/sdk/tables/azure-data-tables/tests/preparers.py b/sdk/tables/azure-data-tables/tests/preparers.py index d76ce6fd738d..baef0629be10 100644 --- a/sdk/tables/azure-data-tables/tests/preparers.py +++ b/sdk/tables/azure-data-tables/tests/preparers.py @@ -68,46 +68,3 @@ def wrapper(*args, **kwargs): return wrapper - -def cosmos_decorator_async(func, **kwargs): - - @CosmosPreparer() - def wrapper(*args, **kwargs): - key = kwargs.pop("tables_primary_cosmos_account_key") - name = kwargs.pop("tables_cosmos_account_name") - key = AzureNamedKeyCredential(key=key, name=name) - - kwargs["tables_primary_cosmos_account_key"] = key - kwargs["tables_cosmos_account_name"] = name - - trimmed_kwargs = {k:v for k, v in kwargs.items()} - trim_kwargs_from_test_function(func, trimmed_kwargs) - - @functools.wraps(func) - async def wrapped(*args, **kwargs): - return await func(*args, **trimmed_kwargs) - return wrapped - - return wrapper - - -def tables_decorator_async(func, **kwargs): - - @TablesPreparer() - def wrapper(*args, **kwargs): - key = kwargs.pop("tables_primary_storage_account_key") - name = kwargs.pop("tables_storage_account_name") - key = AzureNamedKeyCredential(key=key, name=name) - - kwargs["tables_primary_storage_account_key"] = key - kwargs["tables_storage_account_name"] = name - - trimmed_kwargs = {k:v for k, v in kwargs.items()} - trim_kwargs_from_test_function(func, trimmed_kwargs) - - @functools.wraps(func) - async def wrapped(*args, **kwargs): - return await func(*args, **trimmed_kwargs) - return wrapped - - return wrapper diff --git a/sdk/tables/azure-data-tables/tests/test_retry_async.py b/sdk/tables/azure-data-tables/tests/test_retry_async.py index 827ce5f7cbd6..728d44c1855f 100644 --- a/sdk/tables/azure-data-tables/tests/test_retry_async.py +++ b/sdk/tables/azure-data-tables/tests/test_retry_async.py @@ -29,7 +29,7 @@ RetryCounter ) -from preparers import tables_decorator_async +from async_preparers import tables_decorator_async class RetryAioHttpTransport(AioHttpTransport): diff --git a/sdk/tables/azure-data-tables/tests/test_table_async.py b/sdk/tables/azure-data-tables/tests/test_table_async.py index d715286928d3..940e141a8042 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_async.py @@ -20,7 +20,7 @@ from azure.data.tables.aio import TableServiceClient, TableClient from _shared.asynctestcase import AsyncTableTestCase -from preparers import tables_decorator_async +from async_preparers import tables_decorator_async TEST_TABLE_PREFIX = 'pytableasync' diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch_async.py b/sdk/tables/azure-data-tables/tests/test_table_batch_async.py index c4aafce665bd..70c022fef392 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch_async.py @@ -38,7 +38,7 @@ ) from _shared.asynctestcase import AsyncTableTestCase -from preparers import tables_decorator_async +from async_preparers import tables_decorator_async #------------------------------------------------------------------------------ TEST_TABLE_PREFIX = 'table' diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py index 6b400261770b..b69197ea0988 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch_cosmos_async.py @@ -36,7 +36,7 @@ from _shared.testcase import SLEEP_DELAY from _shared.asynctestcase import AsyncTableTestCase -from preparers import cosmos_decorator_async +from async_preparers import cosmos_decorator_async #------------------------------------------------------------------------------ TEST_TABLE_PREFIX = 'table' diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_async.py index 834838bff91c..ab61bdfb85b0 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_async.py @@ -14,7 +14,7 @@ from azure.data.tables._version import VERSION from _shared.asynctestcase import AsyncTableTestCase -from preparers import tables_decorator_async +from async_preparers import tables_decorator_async from devtools_testutils import AzureTestCase # ------------------------------------------------------------------------------ SERVICES = { diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py index d8d34c34f7e3..66f6b4c81723 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py @@ -15,7 +15,7 @@ from _shared.asynctestcase import AsyncTableTestCase from _shared.testcase import SLEEP_DELAY -from preparers import cosmos_decorator_async +from async_preparers import cosmos_decorator_async from devtools_testutils import AzureTestCase # ------------------------------------------------------------------------------ diff --git a/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py index 68faf37a36cb..b29fe43a6e1b 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py @@ -21,7 +21,7 @@ from _shared.asynctestcase import AsyncTableTestCase from _shared.testcase import SLEEP_DELAY -from preparers import cosmos_decorator_async +from async_preparers import cosmos_decorator_async TEST_TABLE_PREFIX = 'pytableasync' diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py index a32de1c1c452..500cd5525a7d 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py @@ -35,7 +35,7 @@ from azure.data.tables.aio import TableServiceClient from _shared.asynctestcase import AsyncTableTestCase -from preparers import tables_decorator_async +from async_preparers import tables_decorator_async class StorageTableEntityTest(AzureTestCase, AsyncTableTestCase): diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py index bd027bdecb7f..30941057c978 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py @@ -37,7 +37,7 @@ from _shared.asynctestcase import AsyncTableTestCase from _shared.testcase import SLEEP_DELAY -from preparers import cosmos_decorator_async +from async_preparers import cosmos_decorator_async # ------------------------------------------------------------------------------ # TODO: change to `with table_client as client:` to close sessions # ------------------------------------------------------------------------------ diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py b/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py index f87ee3843bbd..64a52b976815 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py @@ -16,7 +16,7 @@ from azure.data.tables.aio import TableServiceClient from _shared.testcase import TableTestCase -from preparers import tables_decorator_async +from async_preparers import tables_decorator_async # ------------------------------------------------------------------------------ diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py index 7f1f3bd905ed..13d6db99df0a 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py @@ -16,7 +16,7 @@ from _shared.testcase import SLEEP_DELAY from _shared.asynctestcase import AsyncTableTestCase -from preparers import cosmos_decorator_async +from async_preparers import cosmos_decorator_async # ------------------------------------------------------------------------------ class TableServicePropertiesTest(AzureTestCase, AsyncTableTestCase): diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_stats_async.py b/sdk/tables/azure-data-tables/tests/test_table_service_stats_async.py index 1decb7b6da95..3e794c8c82e5 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_stats_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_stats_async.py @@ -10,7 +10,7 @@ from azure.data.tables.aio import TableServiceClient from _shared.asynctestcase import AsyncTableTestCase -from preparers import tables_decorator_async +from async_preparers import tables_decorator_async SERVICE_UNAVAILABLE_RESP_BODY = 'unavailableunavailable Date: Mon, 3 May 2021 10:39:28 -0400 Subject: [PATCH 09/15] pr comments --- .../azure/data/tables/_authentication.py | 2 +- .../azure/data/tables/_shared_access_signature.py | 12 +++++------- .../async_samples/sample_authentication_async.py | 1 - .../samples/async_samples/sample_batching_async.py | 1 - .../async_samples/sample_create_client_async.py | 1 - .../sample_create_delete_table_async.py | 1 - .../sample_insert_delete_entities_async.py | 9 +++------ .../async_samples/sample_query_table_async.py | 1 - .../samples/sample_authentication.py | 6 +++--- .../azure-data-tables/samples/sample_batching.py | 1 - .../samples/sample_create_client.py | 7 ++++--- .../samples/sample_create_delete_table.py | 1 - .../samples/sample_insert_delete_entities.py | 8 +++----- 13 files changed, 19 insertions(+), 32 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py b/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py index a29ecba63873..ccdead3d853f 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py @@ -83,7 +83,7 @@ def _get_canonicalized_resource(self, request): ) ): uri_path = URL(uri_path) - return "/" + self._credential.name + str(uri_path) + return "/" + self._credential.named_key.name + str(uri_path) except TypeError: pass return "/" + self._credential.named_key.name + uri_path diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_shared_access_signature.py b/sdk/tables/azure-data-tables/azure/data/tables/_shared_access_signature.py index 71d8fb6b83fb..c3d1607a5f66 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_shared_access_signature.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_shared_access_signature.py @@ -28,17 +28,15 @@ class SharedAccessSignature(object): generate_*_shared_access_signature method directly. """ - def __init__(self, account_name, account_key, x_ms_version=DEFAULT_X_MS_VERSION): + def __init__(self, credential, x_ms_version=DEFAULT_X_MS_VERSION): """ - :param str account_name: - The storage account name used to generate the shared access signatures. - :param AzureNamedKeyCredential account_key: - The access key to generate the shares access signatures. + :param credential: The credential used for authenticating requests + :type credential: :class:`~azure.core.credentials.NamedKeyCredential` :param str x_ms_version: The service version used to generate the shared access signatures. """ - self.account_name = account_name - self.account_key = account_key.named_key.key + self.account_name = credential.named_key.name + self.account_key = credential.named_key.key self.x_ms_version = x_ms_version def generate_account( diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py index c29e6233cdb2..5c0b9d0be841 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py @@ -37,7 +37,6 @@ class TableAuthSamples(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py index 3398f740c83f..e29a70c8202a 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py @@ -32,7 +32,6 @@ class CreateClients(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py index 6ba620eca67b..00780a7bac34 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py @@ -37,7 +37,6 @@ class CreateClients(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py index 614c04c17e8e..2738a9220f78 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py @@ -33,7 +33,6 @@ class CreateDeleteTable(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py index 586f9a894f9d..daf1401138e3 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py @@ -21,17 +21,13 @@ """ import os -from time import sleep import asyncio from dotenv import find_dotenv, load_dotenv -from azure.core.credentials import AzureNamedKeyCredential - class InsertDeleteEntity(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") @@ -75,9 +71,10 @@ async def create_entity(self): async def delete_entity(self): from azure.data.tables.aio import TableClient from azure.core.exceptions import ResourceNotFoundError, ResourceExistsError - from azure.core import MatchConditions + from azure.core.credentials import AzureNamedKeyCredential - table_client = TableClient(account_url=self.account_url, credential=AzureNamedKeyCredential(self.account_name, self.access_key), table_name=self.table_name) + credential = AzureNamedKeyCredential(self.account_name, self.access_key) + table_client = TableClient(account_url=self.account_url, credential=credential, table_name=self.table_name) # [START delete_entity] async with table_client: diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py index 5bee5fb21b69..a0ec962d5c63 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py @@ -30,7 +30,6 @@ class SampleTablesQuery(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") diff --git a/sdk/tables/azure-data-tables/samples/sample_authentication.py b/sdk/tables/azure-data-tables/samples/sample_authentication.py index 20189ae69937..e97048c9ce69 100644 --- a/sdk/tables/azure-data-tables/samples/sample_authentication.py +++ b/sdk/tables/azure-data-tables/samples/sample_authentication.py @@ -29,7 +29,6 @@ from datetime import datetime, timedelta import os -from azure.core.credentials import AzureNamedKeyCredential from dotenv import find_dotenv, load_dotenv @@ -37,7 +36,6 @@ class TableAuthSamples(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") @@ -61,7 +59,9 @@ def authentication_by_shared_key(self): # Instantiate a TableServiceClient using a shared access key # [START auth_from_shared_key] from azure.data.tables import TableServiceClient - with TableServiceClient(account_url=self.account_url, credential=AzureNamedKeyCredential(self.account_name, self.access_key)) as table_service: + from azure.core.credentials import AzureNamedKeyCredential + credential = AzureNamedKeyCredential(self.account_name, self.access_key) + with TableServiceClient(account_url=self.account_url, credential=credential) as table_service: properties = table_service.get_service_properties() print("Shared Key: {}".format(properties)) # [END auth_from_shared_key] diff --git a/sdk/tables/azure-data-tables/samples/sample_batching.py b/sdk/tables/azure-data-tables/samples/sample_batching.py index 24fb23510e0b..da63ba086132 100644 --- a/sdk/tables/azure-data-tables/samples/sample_batching.py +++ b/sdk/tables/azure-data-tables/samples/sample_batching.py @@ -31,7 +31,6 @@ class CreateClients(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") diff --git a/sdk/tables/azure-data-tables/samples/sample_create_client.py b/sdk/tables/azure-data-tables/samples/sample_create_client.py index 7edb71329b33..486360e53bce 100644 --- a/sdk/tables/azure-data-tables/samples/sample_create_client.py +++ b/sdk/tables/azure-data-tables/samples/sample_create_client.py @@ -26,13 +26,11 @@ from dotenv import find_dotenv, load_dotenv import os -from azure.core.credentials import AzureNamedKeyCredential class CreateClients(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") @@ -56,7 +54,10 @@ def create_table_service_client(self): # Instantiate a TableServiceClient using a shared access key # [START create_table_service_client] from azure.data.tables import TableServiceClient - with TableServiceClient(account_url=self.account_url, credential=AzureNamedKeyCredential(self.account_name, self.access_key)) as table_service: + from azure.core.credentials import AzureNamedKeyCredential + + credential = AzureNamedKeyCredential(self.account_name, self.access_key) + with TableServiceClient(account_url=self.account_url, credential=credential) as table_service: properties = table_service.get_service_properties() print("Properties: {}".format(properties)) # [END create_table_service_client] diff --git a/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py b/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py index 55d917e52887..474270d26beb 100644 --- a/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py +++ b/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py @@ -27,7 +27,6 @@ class CreateDeleteTable(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") diff --git a/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py b/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py index 0d93df31e1f5..03d7adb4d6b2 100644 --- a/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py +++ b/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py @@ -23,13 +23,10 @@ import os from dotenv import find_dotenv, load_dotenv -from azure.core.credentials import AzureNamedKeyCredential - class InsertDeleteEntity(object): def __init__(self): load_dotenv(find_dotenv()) - # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") @@ -72,9 +69,10 @@ def create_entity(self): def delete_entity(self): from azure.data.tables import TableClient from azure.core.exceptions import ResourceNotFoundError, ResourceExistsError - from azure.core import MatchConditions + from azure.core.credentials import AzureNamedKeyCredential - with TableClient(account_url=self.account_url, credential=AzureNamedKeyCredential(self.account_name, self.access_key), table_name=self.table_name) as table_client: + credential = AzureNamedKeyCredential(self.account_name, self.access_key) + with TableClient(account_url=self.account_url, credential=credential, table_name=self.table_name) as table_client: # Create entity to delete (to showcase etag) try: From 02b8d7d3563bfe7658212544bf666c3be754f512 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 3 May 2021 11:32:41 -0400 Subject: [PATCH 10/15] lint fixes --- .../azure/data/tables/_authentication.py | 7 ++++--- .../azure/data/tables/_table_client.py | 4 +++- .../data/tables/_table_shared_access_signature.py | 12 ++++-------- .../azure/data/tables/aio/_table_client_async.py | 8 ++++++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py b/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py index ccdead3d853f..8b4cc239a9a0 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py @@ -5,7 +5,8 @@ # -------------------------------------------------------------------------- import logging -from typing import TYPE_CHECKING +import sys +from typing import Union try: from urllib.parse import urlparse @@ -33,8 +34,8 @@ _wrap_exception, ) -if TYPE_CHECKING: - from typing import Union, Awaitable +if sys.version_info > (3, 5): + from typing import Awaitable logger = logging.getLogger(__name__) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py index 82885b14ac10..f3b1d7f1adad 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py @@ -66,7 +66,9 @@ def __init__( account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string or an account shared access key. - :type credential: :class:`~azure.core.credentials.AzureNamedKeyCredential` or :class:`~azure.core.credentials.AzureSasCredential` + :type credential: + :class:`~azure.core.credentials.AzureNamedKeyCredential` or + :class:`~azure.core.credentials.AzureSasCredential` :returns: None """ if not table_name: diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py index f8d1306fa053..04fd0550cc6d 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py @@ -168,17 +168,13 @@ class TableSharedAccessSignature(SharedAccessSignature): generate_*_shared_access_signature method directly. """ - def __init__(self, account_name, account_key): + def __init__(self, credential): """ - :param account_name: - The storage account name used to generate the shared access signatures. - :type account_name: str - :param account_key: - The access key to generate the shares access signatures. - :type account_key: str + :param credential: The credential used for authenticating requests + :type credential: :class:`~azure.core.credentials.NamedKeyCredential` """ super(TableSharedAccessSignature, self).__init__( - account_name, account_key, x_ms_version=X_MS_VERSION + credential, x_ms_version=X_MS_VERSION ) def generate_table( diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py index 1eb66e465482..a70a996b6088 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py @@ -58,7 +58,9 @@ def __init__( account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string or an account shared access key. - :type credential: :class:`~azure.core.credentials.AzureNamedKeyCredential` or :class:`~azure.core.credentials.AzureSasCredential` + :type credential: + :class:`~azure.core.credentials.AzureNamedKeyCredential` or + :class:`~azure.core.credentials.AzureSasCredential` :returns: None """ @@ -120,7 +122,9 @@ def from_table_url( The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, an account shared access key. - :type credential: :class:`~azure.core.credentials.AzureNamedKeyCredential` or :class:`~azure.core.credentials.AzureSasCredential` + :type credential: + :class:`~azure.core.credentials.AzureNamedKeyCredential` or + :class:`~azure.core.credentials.AzureSasCredential` :returns: A table client. :rtype: :class:`~azure.data.tables.TableClient` """ From f41e30ea63690129c6e863c7416f5cc2c7de1fed Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 3 May 2021 11:42:10 -0400 Subject: [PATCH 11/15] fixing tests and sas generation --- .../tables/_table_shared_access_signature.py | 22 ++++++++----------- .../tests/_shared/testcase.py | 3 +-- .../azure-data-tables/tests/test_table.py | 1 - .../tests/test_table_async.py | 1 - .../tests/test_table_entity.py | 16 -------------- .../tests/test_table_entity_async.py | 8 ------- 6 files changed, 10 insertions(+), 41 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py index 04fd0550cc6d..970d801dbaa1 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from typing import Union +from typing import Union, Any from ._models import AccountSasPermissions from ._common_conversion import _sign_string @@ -17,8 +17,7 @@ def generate_account_sas( - account_name, # type:str - account_key, # type:str + credential, # type: AzureNamedKeyCredential resource_types, # type:ResourceTypes permission, # type:Union[str,AccountSasPermissions] expiry, # type:Union[datetime,str] @@ -29,10 +28,8 @@ def generate_account_sas( Generates a shared access signature for the table service. Use the returned signature with the sas_token parameter of TableService. - :param account_name: Account name - :type account_name: str - :param account_key: Account key - :type account_key: str + :param credential: Credential for the Azure account + :type credential: :class:`~azure.core.credentials.AzureNamedKeyCredential` :param resource_types: Specifies the resource types that are accessible with the account SAS. :type resource_types: ResourceTypes @@ -70,11 +67,11 @@ def generate_account_sas( :return: A Shared Access Signature (sas) token. :rtype: str """ - _validate_not_none("account_name", account_name) - _validate_not_none("account_key", account_key) + _validate_not_none("account_name", credential.named_key.name) + _validate_not_none("account_key", credential.named_key.key) if permission is str: permission = AccountSasPermissions.from_string(permission=permission) - sas = TableSharedAccessSignature(account_name, account_key) + sas = TableSharedAccessSignature(credential) return sas.generate_account( "t", resource_types, @@ -87,8 +84,7 @@ def generate_account_sas( def generate_table_sas( - account_name, # type: str - account_key, # type: str + credential, # type: AzureNamedKeyCredential table_name, # type: str **kwargs # type: Any ): # type: (...) -> str @@ -143,7 +139,7 @@ def generate_table_sas( :rtype: str """ - sas = TableSharedAccessSignature(account_name, account_key) + sas = TableSharedAccessSignature(credential) return sas.generate_table( table_name=table_name, permission=kwargs.pop("permission", None), diff --git a/sdk/tables/azure-data-tables/tests/_shared/testcase.py b/sdk/tables/azure-data-tables/tests/_shared/testcase.py index 59c066af2335..19ab9d6279f1 100644 --- a/sdk/tables/azure-data-tables/tests/_shared/testcase.py +++ b/sdk/tables/azure-data-tables/tests/_shared/testcase.py @@ -61,8 +61,7 @@ def generate_sas_token(self): fake_key = 'a'*30 + 'b'*30 return '?' + generate_account_sas( - account_name = 'test', # name of the storage account - account_key = AzureNamedKeyCredential(name="fakename", key=fake_key), # key for the storage account + credential = AzureNamedKeyCredential(name="fakename", key=fake_key), resource_types = ResourceTypes(object=True), permission = AccountSasPermissions(read=True,list=True), start = datetime.now() - timedelta(hours = 24), diff --git a/sdk/tables/azure-data-tables/tests/test_table.py b/sdk/tables/azure-data-tables/tests/test_table.py index 3bc428095a85..e56d308f1048 100644 --- a/sdk/tables/azure-data-tables/tests/test_table.py +++ b/sdk/tables/azure-data-tables/tests/test_table.py @@ -454,7 +454,6 @@ def test_account_sas(self, tables_storage_account_name, tables_primary_storage_a table.upsert_entity(mode=UpdateMode.MERGE, entity=entity) token = generate_account_sas( - tables_storage_account_name, tables_primary_storage_account_key, resource_types=ResourceTypes(object=True), permission=AccountSasPermissions(read=True), diff --git a/sdk/tables/azure-data-tables/tests/test_table_async.py b/sdk/tables/azure-data-tables/tests/test_table_async.py index 607a701984f5..dcc0c3dd697c 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_async.py @@ -367,7 +367,6 @@ async def test_account_sas(self, tables_storage_account_name, tables_primary_sto await table.upsert_entity(entity=entity) token = generate_account_sas( - tables_storage_account_name, tables_primary_storage_account_key, resource_types=ResourceTypes(object=True), permission=AccountSasPermissions(read=True), diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity.py b/sdk/tables/azure-data-tables/tests/test_table_entity.py index 3cdca2a7f231..9f52227efd5b 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity.py @@ -1746,7 +1746,6 @@ def test_sas_query(self, tables_storage_account_name, tables_primary_storage_acc entity, _ = self._insert_random_entity() token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(read=True), @@ -1778,7 +1777,6 @@ def test_sas_add(self, tables_storage_account_name, tables_primary_storage_accou # Arrange token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(add=True), @@ -1812,7 +1810,6 @@ def test_sas_add_inside_range(self, tables_storage_account_name, tables_primary_ # Arrange token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(add=True), @@ -1845,7 +1842,6 @@ def test_sas_add_outside_range(self, tables_storage_account_name, tables_primary # Arrange token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(add=True), @@ -1878,21 +1874,12 @@ def test_sas_update(self, tables_storage_account_name, tables_primary_storage_ac entity, _ = self._insert_random_entity() token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(update=True), expiry=datetime.utcnow() + timedelta(hours=1), ) - # token = generate_table_sas( - # tables_storage_account_name, - # tables_primary_storage_account_key, - # self.table_name, - # permission=TableSasPermissions(update=True), - # expiry=datetime.utcnow() + timedelta(hours=1), - # ) - # Act service = TableServiceClient( self.account_url(tables_storage_account_name, "table"), credential=AzureSasCredential(token), @@ -1918,7 +1905,6 @@ def test_sas_delete(self, tables_storage_account_name, tables_primary_storage_ac entity, _ = self._insert_random_entity() token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(delete=True), @@ -1958,7 +1944,6 @@ def test_sas_upper_case_table_name(self, tables_storage_account_name, tables_pri token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name.upper(), permission=TableSasPermissions(read=True), @@ -2000,7 +1985,6 @@ def test_sas_signed_identifier(self, tables_storage_account_name, tables_primary token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, policy_id='testid' diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py index 1552857d5004..889acf3f5362 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py @@ -1729,7 +1729,6 @@ async def test_sas_query(self, tables_storage_account_name, tables_primary_stora entity, _ = await self._insert_random_entity() token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(read=True), @@ -1763,7 +1762,6 @@ async def test_sas_add(self, tables_storage_account_name, tables_primary_storage # Arrange token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(add=True), @@ -1797,7 +1795,6 @@ async def test_sas_add_inside_range(self, tables_storage_account_name, tables_pr # Arrange token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(add=True), @@ -1830,7 +1827,6 @@ async def test_sas_add_outside_range(self, tables_storage_account_name, tables_p # Arrange token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(add=True), @@ -1863,7 +1859,6 @@ async def test_sas_update(self, tables_storage_account_name, tables_primary_stor entity, _ = await self._insert_random_entity() token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(update=True), @@ -1898,7 +1893,6 @@ async def test_sas_delete(self, tables_storage_account_name, tables_primary_stor entity, _ = await self._insert_random_entity() token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(delete=True), @@ -1931,7 +1925,6 @@ async def test_sas_upper_case_table_name(self, tables_storage_account_name, tabl # Table names are case insensitive, so simply upper case our existing table name to test token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name.upper(), permission=TableSasPermissions(read=True), @@ -1975,7 +1968,6 @@ async def test_sas_signed_identifier(self, tables_storage_account_name, tables_p token = self.generate_sas( generate_table_sas, - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, policy_id='testid', From 29839ca56449851e03fb3bbe2cebed2e10a40bd2 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Mon, 3 May 2021 11:48:51 -0400 Subject: [PATCH 12/15] linting fixes --- .../azure-data-tables/azure/data/tables/_authentication.py | 2 +- .../azure/data/tables/_table_service_client.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py b/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py index 8b4cc239a9a0..e6aafa709cc4 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_authentication.py @@ -35,7 +35,7 @@ ) if sys.version_info > (3, 5): - from typing import Awaitable + from typing import Awaitable # pylint: disable=ungrouped-imports logger = logging.getLogger(__name__) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py index 133754b6c4a7..e2f4b484d77d 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py @@ -36,7 +36,9 @@ class TableServiceClient(TablesBaseClient): account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string or an account shared access key. - :type credential: :class:`~azure.core.credentials.AzureNamedKeyCredential` or :class:`~azure.core.credentials.AzureSasCredential` + :type credential: + :class:`~azure.core.credentials.AzureNamedKeyCredential` or + :class:`~azure.core.credentials.AzureSasCredential` :returns: None .. admonition:: Example: From 0e931b29dfc56da09be1b3ff64ad3740b0e7e4f3 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 4 May 2021 10:55:51 -0400 Subject: [PATCH 13/15] fixing up two tests --- .../test_table_batch.test_batch_sas_auth.yaml | 345 +++++++++++------- ...test_table_batch.test_new_invalid_key.yaml | 56 ++- .../tests/test_table_batch.py | 3 +- 3 files changed, 246 insertions(+), 158 deletions(-) diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_sas_auth.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_sas_auth.yaml index 8257d38f947f..e09b769887ba 100644 --- a/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_sas_auth.yaml +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_batch_sas_auth.yaml @@ -15,26 +15,27 @@ interactions: DataServiceVersion: - '3.0' Date: - - Fri, 05 Mar 2021 16:54:43 GMT + - Tue, 04 May 2021 14:50:11 GMT User-Agent: - - azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 05 Mar 2021 16:54:43 GMT + - Tue, 04 May 2021 14:50:11 GMT x-ms-version: - '2019-02-02' method: POST uri: https://fake_table_account.table.core.windows.net/Tables response: body: - string: '{"odata.error":{"code":"TableAlreadyExists","message":{"lang":"en-US","value":"The - table specified already exists.\nRequestId:7fd90d5f-e002-003b-41e0-119f80000000\nTime:2021-03-05T16:54:43.1645315Z"}}}' + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#Tables/@Element","TableName":"uttabled4f0e8f"}' headers: cache-control: - no-cache content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Fri, 05 Mar 2021 16:54:42 GMT + - Tue, 04 May 2021 14:50:10 GMT + location: + - https://fake_table_account.table.core.windows.net/Tables('uttabled4f0e8f') server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -44,161 +45,253 @@ interactions: x-ms-version: - '2019-02-02' status: - code: 409 - message: Conflict + code: 201 + message: Created - request: - body: "--batch_8e6535d9-ecdb-4f9f-8547-dfe348188540\r\nContent-Type: multipart/mixed;\ - \ boundary=changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\n\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\ + body: "--batch_55293879-5ac0-43fa-bd37-76aaca1924dd\r\nContent-Type: multipart/mixed;\ + \ boundary=changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\n\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ - \ 0\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f?st=2021-03-05T16%3A53%3A44Z&se=2021-03-05T17%3A54%3A44Z&sp=a&sv=2019-02-02&tn=uttabled4f0e8f&sig=TStgoQP%2FZDFaSw7JFX8lYcHHSbNXkWMaIejc8v7EGso%3D\ - \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ - \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 223\r\nx-ms-date:\ - \ Fri, 05 Mar 2021 16:54:44 GMT\r\nDate: Fri, 05 Mar 2021 16:54:44 GMT\r\nx-ms-client-request-id:\ - \ 7c64afbf-7dd3-11eb-ab63-002b67128e4c\r\n\r\n{\"PartitionKey\": \"batch_inserts\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"test\": true, \"test2\": \"\ - value\", \"test2@odata.type\": \"Edm.String\", \"test3\": 3, \"test4\": 1234567890,\ - \ \"RowKey\": \"0\", \"RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\ + \ 0\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f HTTP/1.1\r\ + \nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer: return-no-content\r\ + \nContent-Type: application/json;odata=nometadata\r\nAccept: application/json;odata=minimalmetadata\r\ + \nContent-Length: 223\r\nx-ms-date: Tue, 04 May 2021 14:50:12 GMT\r\nDate: Tue,\ + \ 04 May 2021 14:50:12 GMT\r\n\r\n{\"PartitionKey\": \"batch_inserts\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"test\": true, \"test2\": \"value\", \"test2@odata.type\"\ + : \"Edm.String\", \"test3\": 3, \"test4\": 1234567890, \"RowKey\": \"0\", \"\ + RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ - \ 1\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f?st=2021-03-05T16%3A53%3A44Z&se=2021-03-05T17%3A54%3A44Z&sp=a&sv=2019-02-02&tn=uttabled4f0e8f&sig=TStgoQP%2FZDFaSw7JFX8lYcHHSbNXkWMaIejc8v7EGso%3D\ - \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ - \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 223\r\nx-ms-date:\ - \ Fri, 05 Mar 2021 16:54:44 GMT\r\nDate: Fri, 05 Mar 2021 16:54:44 GMT\r\nx-ms-client-request-id:\ - \ 7c64afc0-7dd3-11eb-8299-002b67128e4c\r\n\r\n{\"PartitionKey\": \"batch_inserts\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"test\": true, \"test2\": \"\ - value\", \"test2@odata.type\": \"Edm.String\", \"test3\": 3, \"test4\": 1234567890,\ - \ \"RowKey\": \"1\", \"RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\ + \ 1\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f HTTP/1.1\r\ + \nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer: return-no-content\r\ + \nContent-Type: application/json;odata=nometadata\r\nAccept: application/json;odata=minimalmetadata\r\ + \nContent-Length: 223\r\nx-ms-date: Tue, 04 May 2021 14:50:12 GMT\r\nDate: Tue,\ + \ 04 May 2021 14:50:12 GMT\r\n\r\n{\"PartitionKey\": \"batch_inserts\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"test\": true, \"test2\": \"value\", \"test2@odata.type\"\ + : \"Edm.String\", \"test3\": 3, \"test4\": 1234567890, \"RowKey\": \"1\", \"\ + RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ - \ 2\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f?st=2021-03-05T16%3A53%3A44Z&se=2021-03-05T17%3A54%3A44Z&sp=a&sv=2019-02-02&tn=uttabled4f0e8f&sig=TStgoQP%2FZDFaSw7JFX8lYcHHSbNXkWMaIejc8v7EGso%3D\ - \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ - \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 223\r\nx-ms-date:\ - \ Fri, 05 Mar 2021 16:54:44 GMT\r\nDate: Fri, 05 Mar 2021 16:54:44 GMT\r\nx-ms-client-request-id:\ - \ 7c64d743-7dd3-11eb-a56b-002b67128e4c\r\n\r\n{\"PartitionKey\": \"batch_inserts\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"test\": true, \"test2\": \"\ - value\", \"test2@odata.type\": \"Edm.String\", \"test3\": 3, \"test4\": 1234567890,\ - \ \"RowKey\": \"2\", \"RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\ + \ 2\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f HTTP/1.1\r\ + \nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer: return-no-content\r\ + \nContent-Type: application/json;odata=nometadata\r\nAccept: application/json;odata=minimalmetadata\r\ + \nContent-Length: 223\r\nx-ms-date: Tue, 04 May 2021 14:50:12 GMT\r\nDate: Tue,\ + \ 04 May 2021 14:50:12 GMT\r\n\r\n{\"PartitionKey\": \"batch_inserts\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"test\": true, \"test2\": \"value\", \"test2@odata.type\"\ + : \"Edm.String\", \"test3\": 3, \"test4\": 1234567890, \"RowKey\": \"2\", \"\ + RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ - \ 3\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f?st=2021-03-05T16%3A53%3A44Z&se=2021-03-05T17%3A54%3A44Z&sp=a&sv=2019-02-02&tn=uttabled4f0e8f&sig=TStgoQP%2FZDFaSw7JFX8lYcHHSbNXkWMaIejc8v7EGso%3D\ - \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ - \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 223\r\nx-ms-date:\ - \ Fri, 05 Mar 2021 16:54:44 GMT\r\nDate: Fri, 05 Mar 2021 16:54:44 GMT\r\nx-ms-client-request-id:\ - \ 7c65083f-7dd3-11eb-88e4-002b67128e4c\r\n\r\n{\"PartitionKey\": \"batch_inserts\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"test\": true, \"test2\": \"\ - value\", \"test2@odata.type\": \"Edm.String\", \"test3\": 3, \"test4\": 1234567890,\ - \ \"RowKey\": \"3\", \"RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\ + \ 3\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f HTTP/1.1\r\ + \nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer: return-no-content\r\ + \nContent-Type: application/json;odata=nometadata\r\nAccept: application/json;odata=minimalmetadata\r\ + \nContent-Length: 223\r\nx-ms-date: Tue, 04 May 2021 14:50:12 GMT\r\nDate: Tue,\ + \ 04 May 2021 14:50:12 GMT\r\n\r\n{\"PartitionKey\": \"batch_inserts\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"test\": true, \"test2\": \"value\", \"test2@odata.type\"\ + : \"Edm.String\", \"test3\": 3, \"test4\": 1234567890, \"RowKey\": \"3\", \"\ + RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ - \ 4\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f?st=2021-03-05T16%3A53%3A44Z&se=2021-03-05T17%3A54%3A44Z&sp=a&sv=2019-02-02&tn=uttabled4f0e8f&sig=TStgoQP%2FZDFaSw7JFX8lYcHHSbNXkWMaIejc8v7EGso%3D\ - \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ - \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 223\r\nx-ms-date:\ - \ Fri, 05 Mar 2021 16:54:44 GMT\r\nDate: Fri, 05 Mar 2021 16:54:44 GMT\r\nx-ms-client-request-id:\ - \ 7c650840-7dd3-11eb-8f93-002b67128e4c\r\n\r\n{\"PartitionKey\": \"batch_inserts\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"test\": true, \"test2\": \"\ - value\", \"test2@odata.type\": \"Edm.String\", \"test3\": 3, \"test4\": 1234567890,\ - \ \"RowKey\": \"4\", \"RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\ + \ 4\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f HTTP/1.1\r\ + \nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer: return-no-content\r\ + \nContent-Type: application/json;odata=nometadata\r\nAccept: application/json;odata=minimalmetadata\r\ + \nContent-Length: 223\r\nx-ms-date: Tue, 04 May 2021 14:50:12 GMT\r\nDate: Tue,\ + \ 04 May 2021 14:50:12 GMT\r\n\r\n{\"PartitionKey\": \"batch_inserts\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"test\": true, \"test2\": \"value\", \"test2@odata.type\"\ + : \"Edm.String\", \"test3\": 3, \"test4\": 1234567890, \"RowKey\": \"4\", \"\ + RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ - \ 5\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f?st=2021-03-05T16%3A53%3A44Z&se=2021-03-05T17%3A54%3A44Z&sp=a&sv=2019-02-02&tn=uttabled4f0e8f&sig=TStgoQP%2FZDFaSw7JFX8lYcHHSbNXkWMaIejc8v7EGso%3D\ - \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ - \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 223\r\nx-ms-date:\ - \ Fri, 05 Mar 2021 16:54:44 GMT\r\nDate: Fri, 05 Mar 2021 16:54:44 GMT\r\nx-ms-client-request-id:\ - \ 7c650841-7dd3-11eb-a3d0-002b67128e4c\r\n\r\n{\"PartitionKey\": \"batch_inserts\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"test\": true, \"test2\": \"\ - value\", \"test2@odata.type\": \"Edm.String\", \"test3\": 3, \"test4\": 1234567890,\ - \ \"RowKey\": \"5\", \"RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\ + \ 5\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f HTTP/1.1\r\ + \nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer: return-no-content\r\ + \nContent-Type: application/json;odata=nometadata\r\nAccept: application/json;odata=minimalmetadata\r\ + \nContent-Length: 223\r\nx-ms-date: Tue, 04 May 2021 14:50:12 GMT\r\nDate: Tue,\ + \ 04 May 2021 14:50:12 GMT\r\n\r\n{\"PartitionKey\": \"batch_inserts\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"test\": true, \"test2\": \"value\", \"test2@odata.type\"\ + : \"Edm.String\", \"test3\": 3, \"test4\": 1234567890, \"RowKey\": \"5\", \"\ + RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ - \ 6\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f?st=2021-03-05T16%3A53%3A44Z&se=2021-03-05T17%3A54%3A44Z&sp=a&sv=2019-02-02&tn=uttabled4f0e8f&sig=TStgoQP%2FZDFaSw7JFX8lYcHHSbNXkWMaIejc8v7EGso%3D\ - \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ - \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 223\r\nx-ms-date:\ - \ Fri, 05 Mar 2021 16:54:44 GMT\r\nDate: Fri, 05 Mar 2021 16:54:44 GMT\r\nx-ms-client-request-id:\ - \ 7c653e76-7dd3-11eb-9358-002b67128e4c\r\n\r\n{\"PartitionKey\": \"batch_inserts\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"test\": true, \"test2\": \"\ - value\", \"test2@odata.type\": \"Edm.String\", \"test3\": 3, \"test4\": 1234567890,\ - \ \"RowKey\": \"6\", \"RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\ + \ 6\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f HTTP/1.1\r\ + \nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer: return-no-content\r\ + \nContent-Type: application/json;odata=nometadata\r\nAccept: application/json;odata=minimalmetadata\r\ + \nContent-Length: 223\r\nx-ms-date: Tue, 04 May 2021 14:50:12 GMT\r\nDate: Tue,\ + \ 04 May 2021 14:50:12 GMT\r\n\r\n{\"PartitionKey\": \"batch_inserts\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"test\": true, \"test2\": \"value\", \"test2@odata.type\"\ + : \"Edm.String\", \"test3\": 3, \"test4\": 1234567890, \"RowKey\": \"6\", \"\ + RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ - \ 7\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f?st=2021-03-05T16%3A53%3A44Z&se=2021-03-05T17%3A54%3A44Z&sp=a&sv=2019-02-02&tn=uttabled4f0e8f&sig=TStgoQP%2FZDFaSw7JFX8lYcHHSbNXkWMaIejc8v7EGso%3D\ - \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ - \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 223\r\nx-ms-date:\ - \ Fri, 05 Mar 2021 16:54:44 GMT\r\nDate: Fri, 05 Mar 2021 16:54:44 GMT\r\nx-ms-client-request-id:\ - \ 7c653e77-7dd3-11eb-a991-002b67128e4c\r\n\r\n{\"PartitionKey\": \"batch_inserts\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"test\": true, \"test2\": \"\ - value\", \"test2@odata.type\": \"Edm.String\", \"test3\": 3, \"test4\": 1234567890,\ - \ \"RowKey\": \"7\", \"RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\ + \ 7\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f HTTP/1.1\r\ + \nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer: return-no-content\r\ + \nContent-Type: application/json;odata=nometadata\r\nAccept: application/json;odata=minimalmetadata\r\ + \nContent-Length: 223\r\nx-ms-date: Tue, 04 May 2021 14:50:12 GMT\r\nDate: Tue,\ + \ 04 May 2021 14:50:12 GMT\r\n\r\n{\"PartitionKey\": \"batch_inserts\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"test\": true, \"test2\": \"value\", \"test2@odata.type\"\ + : \"Edm.String\", \"test3\": 3, \"test4\": 1234567890, \"RowKey\": \"7\", \"\ + RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ - \ 8\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f?st=2021-03-05T16%3A53%3A44Z&se=2021-03-05T17%3A54%3A44Z&sp=a&sv=2019-02-02&tn=uttabled4f0e8f&sig=TStgoQP%2FZDFaSw7JFX8lYcHHSbNXkWMaIejc8v7EGso%3D\ - \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ - \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 223\r\nx-ms-date:\ - \ Fri, 05 Mar 2021 16:54:44 GMT\r\nDate: Fri, 05 Mar 2021 16:54:44 GMT\r\nx-ms-client-request-id:\ - \ 7c653e78-7dd3-11eb-9906-002b67128e4c\r\n\r\n{\"PartitionKey\": \"batch_inserts\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"test\": true, \"test2\": \"\ - value\", \"test2@odata.type\": \"Edm.String\", \"test3\": 3, \"test4\": 1234567890,\ - \ \"RowKey\": \"8\", \"RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6\r\ + \ 8\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f HTTP/1.1\r\ + \nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer: return-no-content\r\ + \nContent-Type: application/json;odata=nometadata\r\nAccept: application/json;odata=minimalmetadata\r\ + \nContent-Length: 223\r\nx-ms-date: Tue, 04 May 2021 14:50:12 GMT\r\nDate: Tue,\ + \ 04 May 2021 14:50:12 GMT\r\n\r\n{\"PartitionKey\": \"batch_inserts\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"test\": true, \"test2\": \"value\", \"test2@odata.type\"\ + : \"Edm.String\", \"test3\": 3, \"test4\": 1234567890, \"RowKey\": \"8\", \"\ + RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ - \ 9\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f?st=2021-03-05T16%3A53%3A44Z&se=2021-03-05T17%3A54%3A44Z&sp=a&sv=2019-02-02&tn=uttabled4f0e8f&sig=TStgoQP%2FZDFaSw7JFX8lYcHHSbNXkWMaIejc8v7EGso%3D\ - \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ - \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 223\r\nx-ms-date:\ - \ Fri, 05 Mar 2021 16:54:44 GMT\r\nDate: Fri, 05 Mar 2021 16:54:44 GMT\r\nx-ms-client-request-id:\ - \ 7c653e79-7dd3-11eb-81dd-002b67128e4c\r\n\r\n{\"PartitionKey\": \"batch_inserts\"\ - , \"PartitionKey@odata.type\": \"Edm.String\", \"test\": true, \"test2\": \"\ - value\", \"test2@odata.type\": \"Edm.String\", \"test3\": 3, \"test4\": 1234567890,\ - \ \"RowKey\": \"9\", \"RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_070b7ea2-9157-4ee4-8ce1-38b81ab0d4f6--\r\ - \n\r\n--batch_8e6535d9-ecdb-4f9f-8547-dfe348188540--\r\n" + \ 9\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttabled4f0e8f HTTP/1.1\r\ + \nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer: return-no-content\r\ + \nContent-Type: application/json;odata=nometadata\r\nAccept: application/json;odata=minimalmetadata\r\ + \nContent-Length: 223\r\nx-ms-date: Tue, 04 May 2021 14:50:12 GMT\r\nDate: Tue,\ + \ 04 May 2021 14:50:12 GMT\r\n\r\n{\"PartitionKey\": \"batch_inserts\", \"PartitionKey@odata.type\"\ + : \"Edm.String\", \"test\": true, \"test2\": \"value\", \"test2@odata.type\"\ + : \"Edm.String\", \"test3\": 3, \"test4\": 1234567890, \"RowKey\": \"9\", \"\ + RowKey@odata.type\": \"Edm.String\"}\r\n--changeset_d35eb054-0670-4875-a6d0-d99bc81ee1bd--\r\ + \n\r\n--batch_55293879-5ac0-43fa-bd37-76aaca1924dd--\r\n" headers: Accept: - - '*/*' + - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive Content-Length: - - '9418' + - '7338' Content-Type: - - multipart/mixed; boundary=batch_8e6535d9-ecdb-4f9f-8547-dfe348188540 + - multipart/mixed; boundary=batch_55293879-5ac0-43fa-bd37-76aaca1924dd DataServiceVersion: - '3.0' Date: - - Fri, 05 Mar 2021 16:54:44 GMT + - Tue, 04 May 2021 14:50:12 GMT MaxDataServiceVersion: - 3.0;NetFx User-Agent: - - azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 05 Mar 2021 16:54:44 GMT + - Tue, 04 May 2021 14:50:12 GMT x-ms-version: - '2019-02-02' method: POST - uri: https://fake_table_account.table.core.windows.net/$batch + uri: https://fake_table_account.table.core.windows.net/$batch?st=2021-05-04T14%3A49%3A12Z&se=2021-05-04T15%3A50%3A12Z&sp=raud&sv=2019-02-02&tn=uttabled4f0e8f&sig=pCtZ%2Bi0nYyGYgmjbsh7wtWU9ARxUw8pqcTCoW4y2Ps4%3D response: body: - string: 'ResourceNotFoundThe specified resource does not exist. - - RequestId:b6ba23cc-3002-005a-7ce0-11bcc3000000 - - Time:2021-03-05T16:54:44.0091854Z' + string: "--batchresponse_68119672-5138-44ac-b47f-8a768b9c4dd1\r\nContent-Type:\ + \ multipart/mixed; boundary=changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\ + \n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\nContent-Type:\ + \ application/http\r\nContent-Transfer-Encoding: binary\r\n\r\nHTTP/1.1 204\ + \ No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control: no-cache\r\ + \nPreference-Applied: return-no-content\r\nDataServiceVersion: 3.0;\r\nLocation:\ + \ https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='0')\r\ + \nDataServiceId: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='0')\r\ + \nETag: W/\"datetime'2021-05-04T14%3A50%3A10.7782844Z'\"\r\n\r\n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\ + \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\ + \nHTTP/1.1 204 No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control:\ + \ no-cache\r\nPreference-Applied: return-no-content\r\nDataServiceVersion:\ + \ 3.0;\r\nLocation: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='1')\r\ + \nDataServiceId: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='1')\r\ + \nETag: W/\"datetime'2021-05-04T14%3A50%3A10.7782844Z'\"\r\n\r\n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\ + \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\ + \nHTTP/1.1 204 No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control:\ + \ no-cache\r\nPreference-Applied: return-no-content\r\nDataServiceVersion:\ + \ 3.0;\r\nLocation: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='2')\r\ + \nDataServiceId: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='2')\r\ + \nETag: W/\"datetime'2021-05-04T14%3A50%3A10.7782844Z'\"\r\n\r\n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\ + \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\ + \nHTTP/1.1 204 No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control:\ + \ no-cache\r\nPreference-Applied: return-no-content\r\nDataServiceVersion:\ + \ 3.0;\r\nLocation: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='3')\r\ + \nDataServiceId: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='3')\r\ + \nETag: W/\"datetime'2021-05-04T14%3A50%3A10.7782844Z'\"\r\n\r\n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\ + \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\ + \nHTTP/1.1 204 No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control:\ + \ no-cache\r\nPreference-Applied: return-no-content\r\nDataServiceVersion:\ + \ 3.0;\r\nLocation: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='4')\r\ + \nDataServiceId: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='4')\r\ + \nETag: W/\"datetime'2021-05-04T14%3A50%3A10.7782844Z'\"\r\n\r\n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\ + \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\ + \nHTTP/1.1 204 No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control:\ + \ no-cache\r\nPreference-Applied: return-no-content\r\nDataServiceVersion:\ + \ 3.0;\r\nLocation: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='5')\r\ + \nDataServiceId: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='5')\r\ + \nETag: W/\"datetime'2021-05-04T14%3A50%3A10.7782844Z'\"\r\n\r\n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\ + \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\ + \nHTTP/1.1 204 No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control:\ + \ no-cache\r\nPreference-Applied: return-no-content\r\nDataServiceVersion:\ + \ 3.0;\r\nLocation: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='6')\r\ + \nDataServiceId: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='6')\r\ + \nETag: W/\"datetime'2021-05-04T14%3A50%3A10.7782844Z'\"\r\n\r\n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\ + \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\ + \nHTTP/1.1 204 No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control:\ + \ no-cache\r\nPreference-Applied: return-no-content\r\nDataServiceVersion:\ + \ 3.0;\r\nLocation: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='7')\r\ + \nDataServiceId: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='7')\r\ + \nETag: W/\"datetime'2021-05-04T14%3A50%3A10.7782844Z'\"\r\n\r\n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\ + \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\ + \nHTTP/1.1 204 No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control:\ + \ no-cache\r\nPreference-Applied: return-no-content\r\nDataServiceVersion:\ + \ 3.0;\r\nLocation: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='8')\r\ + \nDataServiceId: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='8')\r\ + \nETag: W/\"datetime'2021-05-04T14%3A50%3A10.7782844Z'\"\r\n\r\n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a\r\ + \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\ + \nHTTP/1.1 204 No Content\r\nX-Content-Type-Options: nosniff\r\nCache-Control:\ + \ no-cache\r\nPreference-Applied: return-no-content\r\nDataServiceVersion:\ + \ 3.0;\r\nLocation: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='9')\r\ + \nDataServiceId: https://seankaneprim.table.core.windows.net/uttabled4f0e8f(PartitionKey='batch_inserts',RowKey='9')\r\ + \nETag: W/\"datetime'2021-05-04T14%3A50%3A10.7782844Z'\"\r\n\r\n\r\n--changesetresponse_3e551cd8-6f28-443b-b103-79390a25d94a--\r\ + \n--batchresponse_68119672-5138-44ac-b47f-8a768b9c4dd1--\r\n" headers: - content-length: - - '322' + cache-control: + - no-cache content-type: - - application/xml + - multipart/mixed; boundary=batchresponse_68119672-5138-44ac-b47f-8a768b9c4dd1 date: - - Fri, 05 Mar 2021 16:54:43 GMT + - Tue, 04 May 2021 14:50:10 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 - x-ms-error-code: - - ResourceNotFound + transfer-encoding: + - chunked + x-content-type-options: + - nosniff + x-ms-version: + - '2019-02-02' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + DataServiceVersion: + - '3.0' + Date: + - Tue, 04 May 2021 14:50:13 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Tue, 04 May 2021 14:50:13 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_table_account.table.core.windows.net/uttabled4f0e8f()?st=2021-05-04T14%3A49%3A12Z&se=2021-05-04T15%3A50%3A12Z&sp=raud&sv=2019-02-02&tn=uttabled4f0e8f&sig=pCtZ%2Bi0nYyGYgmjbsh7wtWU9ARxUw8pqcTCoW4y2Ps4%3D + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttabled4f0e8f","value":[{"odata.etag":"W/\"datetime''2021-05-04T14%3A50%3A10.7782844Z''\"","PartitionKey":"batch_inserts","RowKey":"0","Timestamp":"2021-05-04T14:50:10.7782844Z","test":true,"test2":"value","test3":3,"test4":1234567890},{"odata.etag":"W/\"datetime''2021-05-04T14%3A50%3A10.7782844Z''\"","PartitionKey":"batch_inserts","RowKey":"1","Timestamp":"2021-05-04T14:50:10.7782844Z","test":true,"test2":"value","test3":3,"test4":1234567890},{"odata.etag":"W/\"datetime''2021-05-04T14%3A50%3A10.7782844Z''\"","PartitionKey":"batch_inserts","RowKey":"2","Timestamp":"2021-05-04T14:50:10.7782844Z","test":true,"test2":"value","test3":3,"test4":1234567890},{"odata.etag":"W/\"datetime''2021-05-04T14%3A50%3A10.7782844Z''\"","PartitionKey":"batch_inserts","RowKey":"3","Timestamp":"2021-05-04T14:50:10.7782844Z","test":true,"test2":"value","test3":3,"test4":1234567890},{"odata.etag":"W/\"datetime''2021-05-04T14%3A50%3A10.7782844Z''\"","PartitionKey":"batch_inserts","RowKey":"4","Timestamp":"2021-05-04T14:50:10.7782844Z","test":true,"test2":"value","test3":3,"test4":1234567890},{"odata.etag":"W/\"datetime''2021-05-04T14%3A50%3A10.7782844Z''\"","PartitionKey":"batch_inserts","RowKey":"5","Timestamp":"2021-05-04T14:50:10.7782844Z","test":true,"test2":"value","test3":3,"test4":1234567890},{"odata.etag":"W/\"datetime''2021-05-04T14%3A50%3A10.7782844Z''\"","PartitionKey":"batch_inserts","RowKey":"6","Timestamp":"2021-05-04T14:50:10.7782844Z","test":true,"test2":"value","test3":3,"test4":1234567890},{"odata.etag":"W/\"datetime''2021-05-04T14%3A50%3A10.7782844Z''\"","PartitionKey":"batch_inserts","RowKey":"7","Timestamp":"2021-05-04T14:50:10.7782844Z","test":true,"test2":"value","test3":3,"test4":1234567890},{"odata.etag":"W/\"datetime''2021-05-04T14%3A50%3A10.7782844Z''\"","PartitionKey":"batch_inserts","RowKey":"8","Timestamp":"2021-05-04T14:50:10.7782844Z","test":true,"test2":"value","test3":3,"test4":1234567890},{"odata.etag":"W/\"datetime''2021-05-04T14%3A50%3A10.7782844Z''\"","PartitionKey":"batch_inserts","RowKey":"9","Timestamp":"2021-05-04T14:50:10.7782844Z","test":true,"test2":"value","test3":3,"test4":1234567890}]}' + headers: + cache-control: + - no-cache + content-type: + - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: + - Tue, 04 May 2021 14:50:10 GMT + server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-content-type-options: + - nosniff x-ms-version: - '2019-02-02' status: - code: 404 - message: The specified resource does not exist. + code: 200 + message: OK - request: body: null headers: @@ -211,11 +304,11 @@ interactions: Content-Length: - '0' Date: - - Fri, 05 Mar 2021 16:54:45 GMT + - Tue, 04 May 2021 14:50:13 GMT User-Agent: - - azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 05 Mar 2021 16:54:45 GMT + - Tue, 04 May 2021 14:50:13 GMT x-ms-version: - '2019-02-02' method: DELETE @@ -229,7 +322,7 @@ interactions: content-length: - '0' date: - - Fri, 05 Mar 2021 16:54:43 GMT + - Tue, 04 May 2021 14:50:11 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 x-content-type-options: diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_new_invalid_key.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_new_invalid_key.yaml index 9020e81a4a6d..d2b4e314bb4a 100644 --- a/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_new_invalid_key.yaml +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_batch.test_new_invalid_key.yaml @@ -1,64 +1,60 @@ interactions: - request: - body: "--batch_bd3a859d-cba6-419a-b2bc-e33095037bf2\r\nContent-Type: multipart/mixed;\ - \ boundary=changeset_7d70e32d-ff86-487f-a866-ff12401112ba\r\n\r\n--changeset_7d70e32d-ff86-487f-a866-ff12401112ba\r\ + body: "--batch_a7d1e4a3-d81b-47be-a6bd-526144d0d5b3\r\nContent-Type: multipart/mixed;\ + \ boundary=changeset_41ffbf44-accb-44c5-a011-77bbb7b0231f\r\n\r\n--changeset_41ffbf44-accb-44c5-a011-77bbb7b0231f\r\ \nContent-Type: application/http\r\nContent-Transfer-Encoding: binary\r\nContent-ID:\ \ 0\r\n\r\nPOST https://seankaneprim.table.core.windows.net/uttable1d970f0e\ \ HTTP/1.1\r\nx-ms-version: 2019-02-02\r\nDataServiceVersion: 3.0\r\nPrefer:\ \ return-no-content\r\nContent-Type: application/json;odata=nometadata\r\nAccept:\ - \ application/json;odata=minimalmetadata\r\nContent-Length: 576\r\nx-ms-date:\ - \ Fri, 18 Dec 2020 15:42:30 GMT\r\nDate: Fri, 18 Dec 2020 15:42:30 GMT\r\nx-ms-client-request-id:\ - \ a34274b4-4147-11eb-8075-58961df361d1\r\n\r\n{\"PartitionKey\": \"001\", \"\ - PartitionKey@odata.type\": \"Edm.String\", \"RowKey\": \"batch_negative_1\"\ - , \"RowKey@odata.type\": \"Edm.String\", \"age\": 39, \"sex\": \"male\", \"\ - sex@odata.type\": \"Edm.String\", \"married\": true, \"deceased\": false, \"\ - ratio\": 3.1, \"evenratio\": 3.0, \"large\": 933311100, \"Birthday\": \"1973-10-04T00:00:00Z\"\ - , \"Birthday@odata.type\": \"Edm.DateTime\", \"birthday\": \"1970-10-04T00:00:00Z\"\ - , \"birthday@odata.type\": \"Edm.DateTime\", \"binary\": \"YmluYXJ5\", \"binary@odata.type\"\ - : \"Edm.Binary\", \"other\": 20, \"clsid\": \"c9da6455-213d-42c9-9a79-3e9149a57833\"\ - , \"clsid@odata.type\": \"Edm.Guid\"}\r\n--changeset_7d70e32d-ff86-487f-a866-ff12401112ba--\r\ - \n\r\n--batch_bd3a859d-cba6-419a-b2bc-e33095037bf2--\r\n" + \ application/json;odata=minimalmetadata\r\nContent-Length: 590\r\nx-ms-date:\ + \ Tue, 04 May 2021 14:55:37 GMT\r\nDate: Tue, 04 May 2021 14:55:37 GMT\r\n\r\ + \n{\"PartitionKey\": \"001\", \"PartitionKey@odata.type\": \"Edm.String\", \"\ + RowKey\": \"batch_negative_1\", \"RowKey@odata.type\": \"Edm.String\", \"age\"\ + : 39, \"sex\": \"male\", \"sex@odata.type\": \"Edm.String\", \"married\": true,\ + \ \"deceased\": false, \"ratio\": 3.1, \"evenratio\": 3.0, \"large\": 933311100,\ + \ \"Birthday\": \"1973-10-04T00:00:00.000000Z\", \"Birthday@odata.type\": \"\ + Edm.DateTime\", \"birthday\": \"1970-10-04T00:00:00.000000Z\", \"birthday@odata.type\"\ + : \"Edm.DateTime\", \"binary\": \"YmluYXJ5\", \"binary@odata.type\": \"Edm.Binary\"\ + , \"other\": 20, \"clsid\": \"c9da6455-213d-42c9-9a79-3e9149a57833\", \"clsid@odata.type\"\ + : \"Edm.Guid\"}\r\n--changeset_41ffbf44-accb-44c5-a011-77bbb7b0231f--\r\n\r\n\ + --batch_a7d1e4a3-d81b-47be-a6bd-526144d0d5b3--\r\n" headers: Accept: - - '*/*' + - application/json Accept-Encoding: - gzip, deflate Connection: - keep-alive Content-Length: - - '1364' + - '1316' Content-Type: - - multipart/mixed; boundary=batch_bd3a859d-cba6-419a-b2bc-e33095037bf2 + - multipart/mixed; boundary=batch_a7d1e4a3-d81b-47be-a6bd-526144d0d5b3 DataServiceVersion: - '3.0' Date: - - Fri, 18 Dec 2020 15:42:30 GMT + - Tue, 04 May 2021 14:55:37 GMT MaxDataServiceVersion: - 3.0;NetFx User-Agent: - - azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 18 Dec 2020 15:42:30 GMT + - Tue, 04 May 2021 14:55:37 GMT x-ms-version: - '2019-02-02' method: POST uri: https://fake_table_account.table.core.windows.net/$batch response: body: - string: 'AuthenticationFailedServer failed to authenticate the request. Make sure the - value of Authorization header is formed correctly including the signature. - - RequestId:42b2def8-3002-0065-3b54-d50d5d000000 - - Time:2020-12-18T15:42:31.0162251Z' + string: '{"odata.error":{"code":"AuthenticationFailed","message":{"lang":"en-US","value":"Server + failed to authenticate the request. Make sure the value of Authorization header + is formed correctly including the signature.\nRequestId:446bf59a-e002-0076-74f5-40506c000000\nTime:2021-05-04T14:55:35.4961294Z"}}}' headers: content-length: - - '419' + - '299' content-type: - - application/xml + - application/json date: - - Fri, 18 Dec 2020 15:42:30 GMT + - Tue, 04 May 2021 14:55:35 GMT server: - Microsoft-HTTPAPI/2.0 x-ms-error-code: diff --git a/sdk/tables/azure-data-tables/tests/test_table_batch.py b/sdk/tables/azure-data-tables/tests/test_table_batch.py index edc3ad000010..c30579c38f2b 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_batch.py +++ b/sdk/tables/azure-data-tables/tests/test_table_batch.py @@ -758,8 +758,8 @@ def test_new_non_existent_table(self, tables_storage_account_name, tables_primar @pytest.mark.skipif(sys.version_info < (3, 0), reason="requires Python3") @tables_decorator def test_new_invalid_key(self, tables_storage_account_name, tables_primary_storage_account_key): - # Arrange invalid_key = tables_primary_storage_account_key.named_key.key[0:-6] + "==" # cut off a bit from the end to invalidate + tables_primary_storage_account_key = AzureNamedKeyCredential(tables_storage_account_name, invalid_key) credential = AzureNamedKeyCredential(name=tables_storage_account_name, key=tables_primary_storage_account_key.named_key.key) self.ts = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential) self.table_name = self.get_resource_name('uttable') @@ -797,7 +797,6 @@ def test_batch_sas_auth(self, tables_storage_account_name, tables_primary_storag try: token = generate_table_sas( - tables_storage_account_name, tables_primary_storage_account_key, self.table_name, permission=TableSasPermissions(add=True, read=True, update=True, delete=True), From c5983005330cd32c6e43cd7696b2bf1b795fbcfc Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 4 May 2021 10:58:34 -0400 Subject: [PATCH 14/15] fixed sample in py27 --- .../azure-data-tables/samples/sample_authentication.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/tables/azure-data-tables/samples/sample_authentication.py b/sdk/tables/azure-data-tables/samples/sample_authentication.py index e97048c9ce69..21a245fffa43 100644 --- a/sdk/tables/azure-data-tables/samples/sample_authentication.py +++ b/sdk/tables/azure-data-tables/samples/sample_authentication.py @@ -71,13 +71,14 @@ def authentication_by_shared_access_signature(self): # [START auth_from_sas] from azure.data.tables import TableServiceClient + from azure.core.credentials import AzureNamedKeyCredential # Create a SAS token to use for authentication of a client from azure.data.tables import generate_account_sas, ResourceTypes, AccountSasPermissions print("Account name: {}".format(self.account_name)) + credential = AzureNamedKeyCredential(self.account_name, self.access_key) sas_token = generate_account_sas( - self.account_name, - self.access_key, + credential, resource_types=ResourceTypes(service=True), permission=AccountSasPermissions(read=True), expiry=datetime.utcnow() + timedelta(hours=1) From d6d9ecc12bb23edcd65334ed5a1c9e6a05d526d0 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Tue, 4 May 2021 16:56:53 -0400 Subject: [PATCH 15/15] one more sample fix --- .../samples/async_samples/sample_authentication_async.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py index 5c0b9d0be841..4146cf9186b4 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py @@ -69,13 +69,14 @@ async def authentication_by_shared_access_signature(self): # Instantiate a TableServiceClient using a connection string # [START auth_by_sas] from azure.data.tables.aio import TableServiceClient + from azure.core.credentials import AzureNamedKeyCredential # Create a SAS token to use for authentication of a client from azure.data.tables import generate_account_sas, ResourceTypes, AccountSasPermissions print("Account name: {}".format(self.account_name)) + credential = AzureNamedKeyCredential(self.account_name, self.access_key) sas_token = generate_account_sas( - self.account_name, - self.access_key, + credential, resource_types=ResourceTypes(service=True), permission=AccountSasPermissions(read=True), expiry=datetime.utcnow() + timedelta(hours=1)