Skip to content

Commit 9771c18

Browse files
If match headers (#13315)
* verifying match conditions are correct, adding tests for other conditions * changes to verify etag is working, think it's being ignored by service * another change to test file, passing the correct etag to the service, it returns a 204 so no error is produced * renaming vars * testing for if-match conditions to make sure they are properly parsed and sent to service * reverting header back * testing update to reflect new response in create_entity
1 parent 749a38d commit 9771c18

9 files changed

+1948
-51
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def _get_match_headers(kwargs, match_param, etag_param):
4242
raise ValueError("'{}' specified without '{}'.".format(match_param, etag_param))
4343
elif match_condition == MatchConditions.IfMissing:
4444
if_none_match = '*'
45+
elif match_condition == MatchConditions.Unconditionally:
46+
if_none_match = '*'
4547
elif match_condition is None:
4648
if kwargs.get(etag_param):
4749
raise ValueError("'{}' specified without '{}'.".format(etag_param, match_param))

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def delete_entity(
239239
if_match, _ = _get_match_headers(kwargs=dict(kwargs, etag=kwargs.pop('etag', None),
240240
match_condition=kwargs.pop('match_condition', None)),
241241
etag_param='etag', match_param='match_condition')
242+
242243
try:
243244
self._client.table.delete_entity(
244245
table=self.table_name,

sdk/tables/azure-data-tables/tests/recordings/test_table_entity.test_get_entity_if_match.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,49 @@ interactions:
191191
status:
192192
code: 204
193193
message: No Content
194+
- request:
195+
body: null
196+
headers:
197+
Accept:
198+
- application/json;odata=minimalmetadata
199+
Accept-Encoding:
200+
- gzip, deflate
201+
Connection:
202+
- keep-alive
203+
DataServiceVersion:
204+
- '3.0'
205+
Date:
206+
- Tue, 25 Aug 2020 15:09:34 GMT
207+
User-Agent:
208+
- azsdk-python-data-tables/2019-07-07 Python/3.8.4 (Windows-10-10.0.19041-SP0)
209+
x-ms-date:
210+
- Tue, 25 Aug 2020 15:09:34 GMT
211+
x-ms-version:
212+
- '2019-07-07'
213+
method: GET
214+
uri: https://storagename.table.core.windows.net/uttable74691147(PartitionKey='pk74691147',RowKey='rk74691147')
215+
response:
216+
body:
217+
string: '{"odata.error":{"code":"ResourceNotFound","message":{"lang":"en-US","value":"The
218+
specified resource does not exist.\nRequestId:32d896fc-f002-0081-26f1-7abf70000000\nTime:2020-08-25T15:09:35.2385928Z"}}}'
219+
headers:
220+
cache-control:
221+
- no-cache
222+
content-type:
223+
- application/json;odata=minimalmetadata;streaming=true;charset=utf-8
224+
date:
225+
- Tue, 25 Aug 2020 15:09:34 GMT
226+
server:
227+
- Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
228+
transfer-encoding:
229+
- chunked
230+
x-content-type-options:
231+
- nosniff
232+
x-ms-version:
233+
- '2019-07-07'
234+
status:
235+
code: 404
236+
message: Not Found
194237
- request:
195238
body: null
196239
headers:

0 commit comments

Comments
 (0)