Merge branch 'master' into bugfix/1874

This commit is contained in:
Bert Blommers 2019-10-09 08:33:53 +01:00
commit 1fb844972f
13 changed files with 1135 additions and 116 deletions

View file

@ -1995,6 +1995,23 @@ def test_condition_expressions():
},
)
with assert_raises(client.exceptions.ConditionalCheckFailedException):
client.delete_item(
TableName = 'test1',
Key = {
'client': {'S': 'client1'},
'app': {'S': 'app1'},
},
ConditionExpression = 'attribute_not_exists(#existing)',
ExpressionAttributeValues = {
':match': {'S': 'match'}
},
ExpressionAttributeNames = {
'#existing': 'existing',
'#match': 'match',
},
)
@mock_dynamodb2
def test_condition_expression__attr_doesnt_exist():

View file

@ -450,6 +450,70 @@ def test_update_item_remove():
})
@mock_dynamodb2_deprecated
def test_update_item_nested_remove():
conn = boto.dynamodb2.connect_to_region("us-east-1")
table = Table.create('messages', schema=[
HashKey('username')
])
data = {
'username': "steve",
'Meta': {
'FullName': 'Steve Urkel'
}
}
table.put_item(data=data)
key_map = {
'username': {"S": "steve"}
}
# Then remove the Meta.FullName field
conn.update_item("messages", key_map,
update_expression="REMOVE Meta.FullName")
returned_item = table.get_item(username="steve")
dict(returned_item).should.equal({
'username': "steve",
'Meta': {}
})
@mock_dynamodb2_deprecated
def test_update_item_double_nested_remove():
conn = boto.dynamodb2.connect_to_region("us-east-1")
table = Table.create('messages', schema=[
HashKey('username')
])
data = {
'username': "steve",
'Meta': {
'Name': {
'First': 'Steve',
'Last': 'Urkel'
}
}
}
table.put_item(data=data)
key_map = {
'username': {"S": "steve"}
}
# Then remove the Meta.FullName field
conn.update_item("messages", key_map,
update_expression="REMOVE Meta.Name.First")
returned_item = table.get_item(username="steve")
dict(returned_item).should.equal({
'username': "steve",
'Meta': {
'Name': {
'Last': 'Urkel'
}
}
})
@mock_dynamodb2_deprecated
def test_update_item_set():
conn = boto.dynamodb2.connect_to_region("us-east-1")