Skip to content

Commit 8988814

Browse files
Fix test wrapper for tables (Azure#18971)
1 parent 040e528 commit 8988814

15 files changed

+1991
-73
lines changed

sdk/tables/azure-data-tables/tests/_shared/asynctestcase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from azure.data.tables import (
1515
EntityProperty,
1616
EdmType,
17-
TableServiceClient,
1817
)
18+
from azure.data.tables.aio import TableServiceClient
1919

2020
from devtools_testutils import is_live
2121

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def cosmos_decorator_async(func, **kwargs):
77

88
@CosmosPreparer()
9-
def wrapper(*args, **kwargs):
9+
async def wrapper(*args, **kwargs):
1010
key = kwargs.pop("tables_primary_cosmos_account_key")
1111
name = kwargs.pop("tables_cosmos_account_name")
1212
key = AzureNamedKeyCredential(key=key, name=name)
@@ -17,18 +17,15 @@ def wrapper(*args, **kwargs):
1717
trimmed_kwargs = {k:v for k, v in kwargs.items()}
1818
trim_kwargs_from_test_function(func, trimmed_kwargs)
1919

20-
@functools.wraps(func)
21-
async def wrapped(*args, **kwargs):
22-
return await func(*args, **trimmed_kwargs)
23-
return wrapped
20+
return await func(*args, **trimmed_kwargs)
2421

2522
return wrapper
2623

2724

2825
def tables_decorator_async(func, **kwargs):
2926

3027
@TablesPreparer()
31-
def wrapper(*args, **kwargs):
28+
async def wrapper(*args, **kwargs):
3229
key = kwargs.pop("tables_primary_storage_account_key")
3330
name = kwargs.pop("tables_storage_account_name")
3431
key = AzureNamedKeyCredential(key=key, name=name)
@@ -39,9 +36,6 @@ def wrapper(*args, **kwargs):
3936
trimmed_kwargs = {k:v for k, v in kwargs.items()}
4037
trim_kwargs_from_test_function(func, trimmed_kwargs)
4138

42-
@functools.wraps(func)
43-
async def wrapped(*args, **kwargs):
44-
return await func(*args, **trimmed_kwargs)
45-
return wrapped
39+
return await func(*args, **trimmed_kwargs)
4640

4741
return wrapper
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
interactions:
2+
- request:
3+
body: '{"TableName": "pytableasynce5ae0d85"}'
4+
headers:
5+
Accept:
6+
- application/json;odata=minimalmetadata
7+
Content-Length:
8+
- '37'
9+
Content-Type:
10+
- application/json;odata=nometadata
11+
DataServiceVersion:
12+
- '3.0'
13+
Date:
14+
- Wed, 26 May 2021 21:30:45 GMT
15+
User-Agent:
16+
- azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
17+
x-ms-date:
18+
- Wed, 26 May 2021 21:30:45 GMT
19+
x-ms-version:
20+
- '2019-02-02'
21+
method: POST
22+
uri: https://fake_table_account.table.core.windows.net/Tables
23+
response:
24+
body:
25+
string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#Tables/@Element","TableName":"pytableasynce5ae0d85"}'
26+
headers:
27+
cache-control: no-cache
28+
content-type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8
29+
date: Wed, 26 May 2021 21:30:46 GMT
30+
location: https://fake_table_account.table.core.windows.net/Tables('pytableasynce5ae0d85')
31+
server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
32+
transfer-encoding: chunked
33+
x-content-type-options: nosniff
34+
x-ms-version: '2019-02-02'
35+
status:
36+
code: 201
37+
message: Created
38+
url: https://seankaneprim.table.core.windows.net/Tables
39+
- request:
40+
body: '{"PartitionKey": "test", "PartitionKey@odata.type": "Edm.String", "RowKey":
41+
"test1", "RowKey@odata.type": "Edm.String", "text": "hello", "text@odata.type":
42+
"Edm.String"}'
43+
headers:
44+
Accept:
45+
- application/json
46+
Content-Length:
47+
- '169'
48+
Content-Type:
49+
- application/json
50+
DataServiceVersion:
51+
- '3.0'
52+
Date:
53+
- Wed, 26 May 2021 21:30:46 GMT
54+
User-Agent:
55+
- azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
56+
x-ms-date:
57+
- Wed, 26 May 2021 21:30:46 GMT
58+
x-ms-version:
59+
- '2019-02-02'
60+
method: PATCH
61+
uri: https://fake_table_account.table.core.windows.net/pytableasynce5ae0d85(PartitionKey='test',RowKey='test1')
62+
response:
63+
body:
64+
string: ''
65+
headers:
66+
cache-control: no-cache
67+
content-length: '0'
68+
date: Wed, 26 May 2021 21:30:47 GMT
69+
etag: W/"datetime'2021-05-26T21%3A30%3A47.2093495Z'"
70+
server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
71+
x-content-type-options: nosniff
72+
x-ms-version: '2019-02-02'
73+
status:
74+
code: 204
75+
message: No Content
76+
url: https://seankaneprim.table.core.windows.net/pytableasynce5ae0d85(PartitionKey='test',RowKey='test1')
77+
- request:
78+
body: '{"PartitionKey": "test", "PartitionKey@odata.type": "Edm.String", "RowKey":
79+
"test2", "RowKey@odata.type": "Edm.String", "text": "hello", "text@odata.type":
80+
"Edm.String"}'
81+
headers:
82+
Accept:
83+
- application/json
84+
Content-Length:
85+
- '169'
86+
Content-Type:
87+
- application/json
88+
DataServiceVersion:
89+
- '3.0'
90+
Date:
91+
- Wed, 26 May 2021 21:30:46 GMT
92+
User-Agent:
93+
- azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
94+
x-ms-date:
95+
- Wed, 26 May 2021 21:30:46 GMT
96+
x-ms-version:
97+
- '2019-02-02'
98+
method: PATCH
99+
uri: https://fake_table_account.table.core.windows.net/pytableasynce5ae0d85(PartitionKey='test',RowKey='test2')
100+
response:
101+
body:
102+
string: ''
103+
headers:
104+
cache-control: no-cache
105+
content-length: '0'
106+
date: Wed, 26 May 2021 21:30:47 GMT
107+
etag: W/"datetime'2021-05-26T21%3A30%3A47.3384413Z'"
108+
server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
109+
x-content-type-options: nosniff
110+
x-ms-version: '2019-02-02'
111+
status:
112+
code: 204
113+
message: No Content
114+
url: https://seankaneprim.table.core.windows.net/pytableasynce5ae0d85(PartitionKey='test',RowKey='test2')
115+
- request:
116+
body: null
117+
headers:
118+
Accept:
119+
- application/json;odata=minimalmetadata
120+
DataServiceVersion:
121+
- '3.0'
122+
Date:
123+
- Wed, 26 May 2021 21:30:46 GMT
124+
User-Agent:
125+
- azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
126+
x-ms-date:
127+
- Wed, 26 May 2021 21:30:46 GMT
128+
x-ms-version:
129+
- '2019-02-02'
130+
method: GET
131+
uri: https://fake_table_account.table.core.windows.net/pytableasynce5ae0d85()?st=start&se=end&sp=r&sv=2019-02-02&ss=t&srt=o&sig=fake_token_value
132+
response:
133+
body:
134+
string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#pytableasynce5ae0d85","value":[{"odata.etag":"W/\"datetime''2021-05-26T21%3A30%3A47.2093495Z''\"","PartitionKey":"test","RowKey":"test1","Timestamp":"2021-05-26T21:30:47.2093495Z","text":"hello"},{"odata.etag":"W/\"datetime''2021-05-26T21%3A30%3A47.3384413Z''\"","PartitionKey":"test","RowKey":"test2","Timestamp":"2021-05-26T21:30:47.3384413Z","text":"hello"}]}'
135+
headers:
136+
cache-control: no-cache
137+
content-type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8
138+
date: Wed, 26 May 2021 21:30:47 GMT
139+
server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
140+
transfer-encoding: chunked
141+
vary: Origin
142+
x-content-type-options: nosniff
143+
x-ms-version: '2019-02-02'
144+
status:
145+
code: 200
146+
message: OK
147+
url: https://seankaneprim.table.core.windows.net/pytableasynce5ae0d85()?st=2021-05-26T21:29:46Z&se=2021-05-26T22:30:46Z&sp=r&sv=2019-02-02&ss=t&srt=o&sig=%2B6bFrDjBUio4iokPWGI9PfUG9q1YmUGt9W1Fi3o4kqQ%3D
148+
- request:
149+
body: null
150+
headers:
151+
Accept:
152+
- application/json
153+
Date:
154+
- Wed, 26 May 2021 21:30:46 GMT
155+
User-Agent:
156+
- azsdk-python-data-tables/12.0.0b7 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
157+
x-ms-date:
158+
- Wed, 26 May 2021 21:30:46 GMT
159+
x-ms-version:
160+
- '2019-02-02'
161+
method: DELETE
162+
uri: https://fake_table_account.table.core.windows.net/Tables('pytableasynce5ae0d85')
163+
response:
164+
body:
165+
string: ''
166+
headers:
167+
cache-control: no-cache
168+
content-length: '0'
169+
date: Wed, 26 May 2021 21:30:47 GMT
170+
server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
171+
x-content-type-options: nosniff
172+
x-ms-version: '2019-02-02'
173+
status:
174+
code: 204
175+
message: No Content
176+
url: https://seankaneprim.table.core.windows.net/Tables('pytableasynce5ae0d85')
177+
version: 1

0 commit comments

Comments
 (0)