Skip to content

Commit 7c6e947

Browse files
authored
[Tables] Fix tests (#45101)
* [Tables] Fix tests Azure Core 1.38.1 introduced a change in URL formatting that impacts the recordings of four tests. The recordings were updated for these, and a conditional was added to ensure that it still passes the mindependency check. These conditionals can be removed once the minimum dependency of azure-core for this package is at least 1.38.1. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> * Update setup.py Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> * Add live test condition Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> --------- Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
1 parent de6a083 commit 7c6e947

6 files changed

Lines changed: 58 additions & 38 deletions

sdk/tables/azure-data-tables/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/tables/azure-data-tables",
5-
"Tag": "python/tables/azure-data-tables_48a9914a75"
5+
"Tag": "python/tables/azure-data-tables_afc53b2631"
66
}

sdk/tables/azure-data-tables/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/tables/azure-data-tables",
4646
keywords="azure, azure sdk",
4747
classifiers=[
48-
"Development Status :: 5 - Production/Stable",
48+
"Development Status :: 4 - Beta",
4949
"Programming Language :: Python",
5050
"Programming Language :: Python :: 3 :: Only",
5151
"Programming Language :: Python :: 3",

sdk/tables/azure-data-tables/tests/test_table_service_properties.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# --------------------------------------------------------------------------
88
import time
99
import pytest
10+
from packaging.version import Version
1011

1112
from devtools_testutils import AzureRecordedTestCase, recorded_by_proxy
1213

@@ -17,6 +18,7 @@
1718
TableRetentionPolicy,
1819
TableCorsRule,
1920
)
21+
from azure.core import VERSION as core_version
2022
from azure.core.exceptions import ResourceNotFoundError, HttpResponseError
2123

2224
from _shared.testcase import TableTestCase
@@ -182,15 +184,18 @@ def test_client_with_url_ends_with_table_name(
182184
assert ("table specified does not exist") in str(exc.value)
183185
assert ("Please check your account URL.") in str(exc.value)
184186

185-
with pytest.raises(HttpResponseError) as exc:
186-
tsc.set_service_properties(analytics_logging=TableAnalyticsLogging(write=True))
187-
assert ("URI is invalid") in str(exc.value)
188-
assert ("Please check your account URL.") in str(exc.value)
189-
190-
with pytest.raises(HttpResponseError) as exc:
191-
tsc.get_service_properties()
192-
assert ("URI is invalid") in str(exc.value)
193-
assert ("Please check your account URL.") in str(exc.value)
187+
# Azure Core 1.38.1 introduced a change to URL formatting which can cause recording mismatches in
188+
# mindependency checks.
189+
if Version(core_version) >= Version("1.38.1") or self.is_live:
190+
with pytest.raises(HttpResponseError) as exc:
191+
tsc.set_service_properties(analytics_logging=TableAnalyticsLogging(write=True))
192+
assert ("URI is invalid") in str(exc.value)
193+
assert ("Please check your account URL.") in str(exc.value)
194+
195+
with pytest.raises(HttpResponseError) as exc:
196+
tsc.get_service_properties()
197+
assert ("URI is invalid") in str(exc.value)
198+
assert ("Please check your account URL.") in str(exc.value)
194199

195200
tsc.delete_table(table_name)
196201

sdk/tables/azure-data-tables/tests/test_table_service_properties_async.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
# Licensed under the MIT License. See License.txt in the project root for
66
# license information.
77
# --------------------------------------------------------------------------
8+
from packaging.version import Version
89
import time
910
import pytest
1011

1112
from devtools_testutils import AzureRecordedTestCase
1213
from devtools_testutils.aio import recorded_by_proxy_async
1314

15+
from azure.core import VERSION as core_version
1416
from azure.core.exceptions import ResourceNotFoundError, HttpResponseError
1517

1618
from azure.data.tables import TableAnalyticsLogging, TableMetrics, TableRetentionPolicy, TableCorsRule
@@ -183,15 +185,18 @@ async def test_client_with_url_ends_with_table_name(
183185
assert ("table specified does not exist") in str(exc.value)
184186
assert ("Please check your account URL.") in str(exc.value)
185187

186-
with pytest.raises(HttpResponseError) as exc:
187-
await tsc.set_service_properties(analytics_logging=TableAnalyticsLogging(write=True))
188-
assert ("URI is invalid") in str(exc.value)
189-
assert ("Please check your account URL.") in str(exc.value)
190-
191-
with pytest.raises(HttpResponseError) as exc:
192-
await tsc.get_service_properties()
193-
assert ("URI is invalid") in str(exc.value)
194-
assert ("Please check your account URL.") in str(exc.value)
188+
# Azure Core 1.38.1 introduced a change to URL formatting which can cause recording mismatches in
189+
# mindependency checks.
190+
if Version(core_version) >= Version("1.38.1") or self.is_live:
191+
with pytest.raises(HttpResponseError) as exc:
192+
await tsc.set_service_properties(analytics_logging=TableAnalyticsLogging(write=True))
193+
assert ("URI is invalid") in str(exc.value)
194+
assert ("Please check your account URL.") in str(exc.value)
195+
196+
with pytest.raises(HttpResponseError) as exc:
197+
await tsc.get_service_properties()
198+
assert ("URI is invalid") in str(exc.value)
199+
assert ("Please check your account URL.") in str(exc.value)
195200

196201
await tsc.delete_table(table_name)
197202

sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
# Licensed under the MIT License. See License.txt in the project root for
66
# license information.
77
# --------------------------------------------------------------------------
8+
from packaging.version import Version
89
import pytest
910

1011
from devtools_testutils import AzureRecordedTestCase, recorded_by_proxy
1112

13+
from azure.core import VERSION as core_version
1214
from azure.core.exceptions import HttpResponseError
1315

1416
from azure.data.tables import (
@@ -70,15 +72,18 @@ def test_client_with_url_ends_with_table_name(self, tables_cosmos_account_name,
7072
assert ("Server failed to authenticate the request") in str(exc.value)
7173
assert ("Please check your account URL.") in str(exc.value)
7274

73-
with pytest.raises(HttpResponseError) as exc:
74-
tsc.set_service_properties(analytics_logging=TableAnalyticsLogging(write=True))
75-
assert ("Server failed to authenticate the request") in str(exc.value)
76-
assert ("Please check your account URL.") in str(exc.value)
77-
78-
with pytest.raises(HttpResponseError) as exc:
79-
tsc.get_service_properties()
80-
assert ("Server failed to authenticate the request") in str(exc.value)
81-
assert ("Please check your account URL.") in str(exc.value)
75+
# Azure Core 1.38.1 introduced a change to URL formatting which can cause recording mismatches in
76+
# mindependency checks.
77+
if Version(core_version) >= Version("1.38.1") or self.is_live:
78+
with pytest.raises(HttpResponseError) as exc:
79+
tsc.set_service_properties(analytics_logging=TableAnalyticsLogging(write=True))
80+
assert ("Server failed to authenticate the request") in str(exc.value)
81+
assert ("Please check your account URL.") in str(exc.value)
82+
83+
with pytest.raises(HttpResponseError) as exc:
84+
tsc.get_service_properties()
85+
assert ("Server failed to authenticate the request") in str(exc.value)
86+
assert ("Please check your account URL.") in str(exc.value)
8287

8388
with pytest.raises(HttpResponseError) as exc:
8489
tsc.delete_table(table_name)

sdk/tables/azure-data-tables/tests/test_table_service_properties_cosmos_async.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
# Licensed under the MIT License. See License.txt in the project root for
66
# license information.
77
# --------------------------------------------------------------------------
8+
from packaging.version import Version
89
import pytest
910

1011
from devtools_testutils import AzureRecordedTestCase
1112
from devtools_testutils.aio import recorded_by_proxy_async
1213

1314
from azure.data.tables import TableAnalyticsLogging, TableMetrics, TableRetentionPolicy, TableCorsRule
1415
from azure.data.tables.aio import TableServiceClient
16+
from azure.core import VERSION as core_version
1517
from azure.core.exceptions import HttpResponseError
1618

1719
from _shared.asynctestcase import AsyncTableTestCase
@@ -71,15 +73,18 @@ async def test_client_with_url_ends_with_table_name(
7173
assert ("Server failed to authenticate the request") in str(exc.value)
7274
assert ("Please check your account URL.") in str(exc.value)
7375

74-
with pytest.raises(HttpResponseError) as exc:
75-
await tsc.set_service_properties(analytics_logging=TableAnalyticsLogging(write=True))
76-
assert ("Server failed to authenticate the request") in str(exc.value)
77-
assert ("Please check your account URL.") in str(exc.value)
78-
79-
with pytest.raises(HttpResponseError) as exc:
80-
await tsc.get_service_properties()
81-
assert ("Server failed to authenticate the request") in str(exc.value)
82-
assert ("Please check your account URL.") in str(exc.value)
76+
# Azure Core 1.38.1 introduced a change to URL formatting which can cause recording mismatches in
77+
# mindependency checks.
78+
if Version(core_version) >= Version("1.38.1") or self.is_live:
79+
with pytest.raises(HttpResponseError) as exc:
80+
await tsc.set_service_properties(analytics_logging=TableAnalyticsLogging(write=True))
81+
assert ("Server failed to authenticate the request") in str(exc.value)
82+
assert ("Please check your account URL.") in str(exc.value)
83+
84+
with pytest.raises(HttpResponseError) as exc:
85+
await tsc.get_service_properties()
86+
assert ("Server failed to authenticate the request") in str(exc.value)
87+
assert ("Please check your account URL.") in str(exc.value)
8388

8489
with pytest.raises(HttpResponseError) as exc:
8590
await tsc.delete_table(table_name)

0 commit comments

Comments
 (0)