Adding update_item and attribute_not_exists test

This commit is contained in:
Matthew Stevens 2019-04-14 19:37:43 -04:00 committed by Garrett Heel
parent 6303d07bac
commit 83082df4d9

View File

@ -1719,6 +1719,42 @@ def test_condition_expressions():
} }
) )
# Make sure update_item honors ConditionExpression as well
dynamodb.update_item(
TableName='test1',
Key={
'client': {'S': 'client1'},
'app': {'S': 'app1'},
},
UpdateExpression='set #match=:match',
ConditionExpression='attribute_exists(#existing)',
ExpressionAttributeNames={
'#existing': 'existing',
'#match': 'match',
},
ExpressionAttributeValues={
':match': {'S': 'match'}
}
)
with assert_raises(dynamodb.exceptions.ConditionalCheckFailedException):
dynamodb.update_item(
TableName='test1',
Key={
'client': { 'S': 'client1'},
'app': { 'S': 'app1'},
},
UpdateExpression='set #match=:match',
ConditionExpression='attribute_not_exists(#existing)',
ExpressionAttributeValues={
':match': {'S': 'match'}
},
ExpressionAttributeNames={
'#existing': 'existing',
'#match': 'match',
},
)
@mock_dynamodb2 @mock_dynamodb2
def test_query_gsi_with_range_key(): def test_query_gsi_with_range_key():