diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_append.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_append.yaml new file mode 100644 index 000000000000..21437a9db292 --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_append.yaml @@ -0,0 +1,44 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + DataServiceVersion: + - '3.0' + Date: + - Fri, 05 Feb 2021 20:18:34 GMT + User-Agent: + - customer_user_agent + x-ms-date: + - Fri, 05 Feb 2021 20:18:34 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_table_account.table.core.windows.net/Tables + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#Tables","value":[]}' + headers: + cache-control: + - no-cache + content-type: + - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: + - Fri, 05 Feb 2021 20:18:34 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: 200 + message: OK +version: 1 diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_custom.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_custom.yaml index 052b07dc743b..059c24cbfc59 100644 --- a/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_custom.yaml +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_custom.yaml @@ -11,11 +11,11 @@ interactions: DataServiceVersion: - '3.0' Date: - - Wed, 03 Feb 2021 20:56:20 GMT + - Fri, 05 Feb 2021 20:18:34 GMT User-Agent: - TestApp/v1.0 azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 03 Feb 2021 20:56:20 GMT + - Fri, 05 Feb 2021 20:18:34 GMT x-ms-version: - '2019-02-02' method: GET @@ -29,7 +29,7 @@ interactions: content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Wed, 03 Feb 2021 20:56:20 GMT + - Fri, 05 Feb 2021 20:18:35 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -53,12 +53,12 @@ interactions: DataServiceVersion: - '3.0' Date: - - Wed, 03 Feb 2021 20:56:21 GMT + - Fri, 05 Feb 2021 20:18:35 GMT User-Agent: - TestApp/v2.0 TestApp/v1.0 azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 03 Feb 2021 20:56:21 GMT + - Fri, 05 Feb 2021 20:18:35 GMT x-ms-version: - '2019-02-02' method: GET @@ -72,7 +72,7 @@ interactions: content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Wed, 03 Feb 2021 20:56:20 GMT + - Fri, 05 Feb 2021 20:18:35 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_default.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_default.yaml index 9ba5e2cece5b..a5311a290652 100644 --- a/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_default.yaml +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client.test_user_agent_default.yaml @@ -11,11 +11,11 @@ interactions: DataServiceVersion: - '3.0' Date: - - Wed, 03 Feb 2021 20:56:21 GMT + - Fri, 05 Feb 2021 20:18:35 GMT User-Agent: - azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 03 Feb 2021 20:56:21 GMT + - Fri, 05 Feb 2021 20:18:35 GMT x-ms-version: - '2019-02-02' method: GET @@ -29,7 +29,7 @@ interactions: content-type: - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 date: - - Wed, 03 Feb 2021 20:56:21 GMT + - Fri, 05 Feb 2021 20:18:35 GMT server: - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_async.test_user_agent_append.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_async.test_user_agent_append.yaml new file mode 100644 index 000000000000..c17b3798d378 --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_async.test_user_agent_append.yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 05 Feb 2021 20:18:35 GMT + User-Agent: + - customer_user_agent + x-ms-date: + - Fri, 05 Feb 2021 20:18:35 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_table_account.table.core.windows.net/Tables + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#Tables","value":[]}' + headers: + cache-control: no-cache + content-type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: Fri, 05 Feb 2021 20:18:35 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: 200 + message: OK + url: https://seankaneprim.table.core.windows.net/Tables +version: 1 diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_async.test_user_agent_custom_async.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_async.test_user_agent_custom_async.yaml new file mode 100644 index 000000000000..92601345d51b --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_async.test_user_agent_custom_async.yaml @@ -0,0 +1,67 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 05 Feb 2021 20:18:36 GMT + User-Agent: + - TestApp/v1.0 azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 05 Feb 2021 20:18:36 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_table_account.table.core.windows.net/Tables + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#Tables","value":[]}' + headers: + cache-control: no-cache + content-type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: Fri, 05 Feb 2021 20:18:36 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: 200 + message: OK + url: https://seankaneprim.table.core.windows.net/Tables +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 05 Feb 2021 20:18:36 GMT + User-Agent: + - TestApp/v2.0 TestApp/v1.0 azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 + (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 05 Feb 2021 20:18:36 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_table_account.table.core.windows.net/Tables + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#Tables","value":[]}' + headers: + cache-control: no-cache + content-type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: Fri, 05 Feb 2021 20:18:37 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: 200 + message: OK + url: https://seankaneprim.table.core.windows.net/Tables +version: 1 diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_async.test_user_agent_default_async.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_async.test_user_agent_default_async.yaml new file mode 100644 index 000000000000..4d2e30ccb4cb --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_async.test_user_agent_default_async.yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 05 Feb 2021 20:18:36 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 05 Feb 2021 20:18:36 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_table_account.table.core.windows.net/Tables + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#Tables","value":[]}' + headers: + cache-control: no-cache + content-type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: Fri, 05 Feb 2021 20:18:36 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: 200 + message: OK + url: https://seankaneprim.table.core.windows.net/Tables +version: 1 diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_append.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_append.yaml new file mode 100644 index 000000000000..c3cc529008dd --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_append.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + DataServiceVersion: + - '3.0' + Date: + - Fri, 05 Feb 2021 20:18:37 GMT + User-Agent: + - customer_user_agent + x-ms-date: + - Fri, 05 Feb 2021 20:18:37 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_cosmos_account.table.cosmos.azure.com/Tables + response: + body: + string: '{"value":[],"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/$metadata#Tables"}' + headers: + content-type: + - application/json;odata=minimalmetadata + date: + - Fri, 05 Feb 2021 20:18:38 GMT + server: + - Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + status: + code: 200 + message: Ok +version: 1 diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_custom.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_custom.yaml index 6c7412bda73c..9e9c26cd39a5 100644 --- a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_custom.yaml +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_custom.yaml @@ -11,11 +11,11 @@ interactions: DataServiceVersion: - '3.0' Date: - - Wed, 03 Feb 2021 21:17:55 GMT + - Fri, 05 Feb 2021 20:19:08 GMT User-Agent: - TestApp/v1.0 azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 03 Feb 2021 21:17:55 GMT + - Fri, 05 Feb 2021 20:19:08 GMT x-ms-version: - '2019-02-02' method: GET @@ -27,7 +27,7 @@ interactions: content-type: - application/json;odata=minimalmetadata date: - - Wed, 03 Feb 2021 21:17:56 GMT + - Fri, 05 Feb 2021 20:19:08 GMT server: - Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -47,12 +47,12 @@ interactions: DataServiceVersion: - '3.0' Date: - - Wed, 03 Feb 2021 21:17:56 GMT + - Fri, 05 Feb 2021 20:19:08 GMT User-Agent: - TestApp/v2.0 TestApp/v1.0 azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 03 Feb 2021 21:17:56 GMT + - Fri, 05 Feb 2021 20:19:08 GMT x-ms-version: - '2019-02-02' method: GET @@ -64,7 +64,7 @@ interactions: content-type: - application/json;odata=minimalmetadata date: - - Wed, 03 Feb 2021 21:17:56 GMT + - Fri, 05 Feb 2021 20:19:08 GMT server: - Microsoft-HTTPAPI/2.0 transfer-encoding: diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_default.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_default.yaml index 14fe819fa136..1b3d2a7d1853 100644 --- a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_default.yaml +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos.test_user_agent_default.yaml @@ -11,11 +11,11 @@ interactions: DataServiceVersion: - '3.0' Date: - - Wed, 03 Feb 2021 21:18:26 GMT + - Fri, 05 Feb 2021 20:19:38 GMT User-Agent: - azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) x-ms-date: - - Wed, 03 Feb 2021 21:18:26 GMT + - Fri, 05 Feb 2021 20:19:38 GMT x-ms-version: - '2019-02-02' method: GET @@ -27,7 +27,7 @@ interactions: content-type: - application/json;odata=minimalmetadata date: - - Wed, 03 Feb 2021 21:18:27 GMT + - Fri, 05 Feb 2021 20:19:39 GMT server: - Microsoft-HTTPAPI/2.0 transfer-encoding: diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos_async.test_user_agent_append.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos_async.test_user_agent_append.yaml new file mode 100644 index 000000000000..333e768138c8 --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos_async.test_user_agent_append.yaml @@ -0,0 +1,31 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 05 Feb 2021 20:32:50 GMT + User-Agent: + - customer_user_agent + x-ms-date: + - Fri, 05 Feb 2021 20:32:50 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_cosmos_account.table.cosmos.azure.com/Tables + response: + body: + string: '{"value":[],"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/$metadata#Tables"}' + headers: + content-type: application/json;odata=minimalmetadata + date: Fri, 05 Feb 2021 20:32:50 GMT + server: Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + status: + code: 200 + message: Ok + url: https://seankaneprim.table.cosmos.azure.com/Tables +version: 1 diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos_async.test_user_agent_custom_async.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos_async.test_user_agent_custom_async.yaml new file mode 100644 index 000000000000..af0065015799 --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos_async.test_user_agent_custom_async.yaml @@ -0,0 +1,31 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 05 Feb 2021 20:33:21 GMT + User-Agent: + - TestApp/v1.0 azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 05 Feb 2021 20:33:21 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_cosmos_account.table.cosmos.azure.com/Tables + response: + body: + string: '{"value":[],"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/$metadata#Tables"}' + headers: + content-type: application/json;odata=minimalmetadata + date: Fri, 05 Feb 2021 20:33:21 GMT + server: Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + status: + code: 200 + message: Ok + url: https://seankaneprim.table.cosmos.azure.com/Tables +version: 1 diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos_async.test_user_agent_default_async.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos_async.test_user_agent_default_async.yaml new file mode 100644 index 000000000000..0ba87ee23703 --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_client_cosmos_async.test_user_agent_default_async.yaml @@ -0,0 +1,31 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 05 Feb 2021 20:33:51 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 05 Feb 2021 20:33:51 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_cosmos_account.table.cosmos.azure.com/Tables + response: + body: + string: '{"value":[],"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/$metadata#Tables"}' + headers: + content-type: application/json;odata=minimalmetadata + date: Fri, 05 Feb 2021 20:33:52 GMT + server: Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + status: + code: 200 + message: Ok + url: https://seankaneprim.table.cosmos.azure.com/Tables +version: 1 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 aaf5a4c00a3b..6bb886d94d22 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client.py @@ -47,6 +47,11 @@ def callback(response): tables = list(service.list_tables(raw_response_hook=callback)) assert isinstance(tables, list) + count = 0 + for table in tables: + count += 1 + assert count == 0 + def callback(response): assert 'User-Agent' in response.http_request.headers assert "TestApp/v2.0 TestApp/v1.0 azsdk-python-data-tables/{} Python/{} ({})".format( @@ -57,20 +62,28 @@ def callback(response): tables = list(service.list_tables(raw_response_hook=callback, user_agent="TestApp/v2.0")) assert isinstance(tables, list) + count = 0 + for table in tables: + count += 1 + assert count == 0 + + @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) def callback(response): assert 'User-Agent' in response.http_request.headers - assert response.http_request.headers['User-Agent'] == "azsdk-python-data-tables/{} Python/{} ({}) customer_user_agent".format( - VERSION, - platform.python_version(), - platform.platform()) + assert response.http_request.headers['User-Agent'] == 'customer_user_agent' custom_headers = {'User-Agent': 'customer_user_agent'} tables = service.list_tables(raw_response_hook=callback, headers=custom_headers) + count = 0 + for table in tables: + count += 1 + assert count == 0 + @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) @@ -85,6 +98,11 @@ def callback(response): tables = list(service.list_tables(raw_response_hook=callback)) assert isinstance(tables, list) + count = 0 + for table in tables: + count += 1 + assert count == 0 + class TestTableUnitTests(TableTestCase): tables_storage_account_name = "fake_storage_account" 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 1f1b2431fac5..5f86252b93c8 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 @@ -33,14 +33,19 @@ async def test_user_agent_default_async(self, tables_storage_account_name, table def callback(response): assert 'User-Agent' in response.http_request.headers - assert response.http_request.headers['User-Agent'] in "azsdk-python-data-tables/{} Python/{} ({})".format( + assert "azsdk-python-data-tables/{} Python/{} ({})".format( VERSION, platform.python_version(), - platform.platform()) + platform.platform()) in response.http_request.headers['User-Agent'] tables = service.list_tables(raw_response_hook=callback) assert tables is not None + count = 0 + async for table in tables: + count += 1 + assert count == 0 + @TablesPreparer() async def test_user_agent_custom_async(self, tables_storage_account_name, tables_primary_storage_account_key): custom_app = "TestApp/v1.0" @@ -57,6 +62,11 @@ def callback(response): tables = service.list_tables(raw_response_hook=callback) assert tables is not None + count = 0 + async for table in tables: + count += 1 + assert count == 0 + def callback(response): assert 'User-Agent' in response.http_request.headers assert "TestApp/v2.0 TestApp/v1.0 azsdk-python-data-tables/{} Python/{} ({})".format( @@ -67,21 +77,27 @@ def callback(response): tables = service.list_tables(raw_response_hook=callback, user_agent="TestApp/v2.0") assert tables is not None + count = 0 + async for table in tables: + count += 1 + assert count == 0 + @TablesPreparer() async def test_user_agent_append(self, tables_storage_account_name, tables_primary_storage_account_key): - # TODO: fix this one service = TableServiceClient(self.account_url(tables_storage_account_name, "table"), credential=tables_primary_storage_account_key) def callback(response): assert 'User-Agent' in response.http_request.headers - assert response.http_request.headers['User-Agent'] == "azsdk-python-data-tables/{} Python/{} ({}) customer_user_agent".format( - VERSION, - platform.python_version(), - platform.platform()) + assert response.http_request.headers['User-Agent'] == 'customer_user_agent' custom_headers = {'User-Agent': 'customer_user_agent'} tables = service.list_tables(raw_response_hook=callback, headers=custom_headers) + count = 0 + async for table in tables: + count += 1 + assert count == 0 + class TestTableClientUnit(AsyncTableTestCase): tables_storage_account_name = "fake_storage_account" 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 3ee62a23136d..a107112fae0b 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 @@ -46,6 +46,11 @@ def callback(response): tables = list(service.list_tables(raw_response_hook=callback)) assert isinstance(tables, list) + count = 0 + for table in tables: + count += 1 + assert count == 0 + if self.is_live: sleep(SLEEP_DELAY) @@ -66,6 +71,11 @@ def callback(response): tables = list(service.list_tables(raw_response_hook=callback)) assert isinstance(tables, list) + count = 0 + for table in tables: + count += 1 + assert count == 0 + def callback(response): assert 'User-Agent' in response.http_request.headers assert "TestApp/v2.0 TestApp/v1.0 azsdk-python-data-tables/{} Python/{} ({})".format( @@ -76,6 +86,11 @@ def callback(response): tables = list(service.list_tables(raw_response_hook=callback, user_agent="TestApp/v2.0")) assert isinstance(tables, list) + count = 0 + for table in tables: + count += 1 + assert count == 0 + if self.is_live: sleep(SLEEP_DELAY) @@ -88,14 +103,16 @@ def test_user_agent_append(self, tables_cosmos_account_name, tables_primary_cosm def callback(response): assert 'User-Agent' in response.http_request.headers - assert response.http_request.headers['User-Agent'] == "azsdk-python-data-tables/{} Python/{} ({}) customer_user_agent".format( - VERSION, - platform.python_version(), - platform.platform()) + assert response.http_request.headers['User-Agent'] == 'customer_user_agent' custom_headers = {'User-Agent': 'customer_user_agent'} tables = service.list_tables(raw_response_hook=callback, headers=custom_headers) + count = 0 + for table in tables: + count += 1 + assert count == 0 + if self.is_live: sleep(SLEEP_DELAY) 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 4fe6326b433c..e2beaf32a1eb 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 @@ -36,14 +36,22 @@ async def test_user_agent_default_async(self, tables_cosmos_account_name, tables def callback(response): assert 'User-Agent' in response.http_request.headers - assert response.http_request.headers['User-Agent'] == "azsdk-python-storage-table/{} Python/{} ({})".format( + assert "azsdk-python-data-tables/{} Python/{} ({})".format( VERSION, platform.python_version(), - platform.platform()) + platform.platform()) in response.http_request.headers['User-Agent'] tables = service.list_tables(raw_response_hook=callback) assert tables is not None + count = 0 + async for table in tables: + count += 1 + assert count == 0 + + if self.is_live: + sleep(SLEEP_DELAY) + @CosmosPreparer() async def test_user_agent_custom_async(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): custom_app = "TestApp/v1.0" @@ -52,7 +60,7 @@ async def test_user_agent_custom_async(self, tables_cosmos_account_name, tables_ def callback(response): assert 'User-Agent' in response.http_request.headers - assert "TestApp/v1.0 azsdk-python-storage-table/{} Python/{} ({})".format( + assert "TestApp/v1.0 azsdk-python-data-tables/{} Python/{} ({})".format( VERSION, platform.python_version(), platform.platform()) in response.http_request.headers['User-Agent'] @@ -60,15 +68,25 @@ def callback(response): tables = service.list_tables(raw_response_hook=callback) assert tables is not None + count = 0 + async for table in tables: + count += 1 + assert count == 0 + def callback(response): assert 'User-Agent' in response.http_request.headers - assert "TestApp/v2.0 TestApp/v1.0 azsdk-python-storage-table/{} Python/{} ({})".format( + assert "TestApp/v2.0 TestApp/v1.0 azsdk-python-data-tables/{} Python/{} ({})".format( VERSION, platform.python_version(), platform.platform()) in response.http_request.headers['User-Agent'] - tables = service.list_tables(raw_response_hook=callback, user_agent="TestApp/v2.0") - assert tables is not None + count = 0 + async for table in tables: + count += 1 + assert count == 0 + + if self.is_live: + sleep(SLEEP_DELAY) @CosmosPreparer() async def test_user_agent_append(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): @@ -76,14 +94,19 @@ async def test_user_agent_append(self, tables_cosmos_account_name, tables_primar def callback(response): assert 'User-Agent' in response.http_request.headers - assert response.http_request.headers['User-Agent'] == "azsdk-python-storage-tables/{} Python/{} ({}) customer_user_agent".format( - VERSION, - platform.python_version(), - platform.platform()) + assert response.http_request.headers['User-Agent'] == 'customer_user_agent' custom_headers = {'User-Agent': 'customer_user_agent'} tables = service.list_tables(raw_response_hook=callback, headers=custom_headers) + count = 0 + async for table in tables: + count += 1 + assert count == 0 + + if self.is_live: + sleep(SLEEP_DELAY) + class TestTableClientUnit(AsyncTableTestCase): tables_cosmos_account_name = "fake_storage_account" diff --git a/tools/azure-devtools/src/azure_devtools/scenario_tests/preparers.py b/tools/azure-devtools/src/azure_devtools/scenario_tests/preparers.py index 7496b5de5de6..06934e301f41 100644 --- a/tools/azure-devtools/src/azure_devtools/scenario_tests/preparers.py +++ b/tools/azure-devtools/src/azure_devtools/scenario_tests/preparers.py @@ -46,6 +46,11 @@ def _prepare_create_resource(self, test_class_instance, **kwargs): # In cached mode we need to avoid this because then for tests with recordings, they would not have a moniker. if (self.live_test or test_class_instance.in_recording) \ and not (not test_class_instance.is_live and test_class_instance.in_recording and self._use_cache): + _logger.warning("This test (%s) does not generate a recording file, you should not inherit from AzureTestCase \ + for these tests, please remove this dependency.", test_class_instance.qualified_test_name) + + if (self.live_test or test_class_instance.in_recording) \ + and not (not self.live_test and test_class_instance.in_recording and self._use_cache): resource_name = self.random_name if not self.live_test and isinstance(self, RecordingProcessor): test_class_instance.recording_processors.append(self) @@ -224,7 +229,7 @@ def _perform_pending_deletes(cls): preparer.remove_resource_with_record_override(resource_name, **kwargs) except Exception as e: #pylint: disable=broad-except # Intentionally broad exception to attempt to leave as few orphan resources as possible even on error. - _logger.warn("Exception while performing delayed deletes (this can happen): %s", e) + _logger.warning("Exception while performing delayed deletes (this can happen): %s", e) class SingleValueReplacer(RecordingProcessor): # pylint: disable=no-member