Merge pull request #4 from ZoidBB/master

Initial work by ZoidBB
This commit is contained in:
Bert Blommers 2019-10-05 10:18:17 +01:00 committed by GitHub
commit d86dcb2ee9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 87 additions and 0 deletions

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")