Fix for ReturnValues.
This commit is contained in:
parent
bdd4ae824b
commit
4e9f4bfbbf
@ -400,8 +400,12 @@ class DynamoHandler(BaseResponse):
|
||||
key = self.body['Key']
|
||||
update_expression = self.body.get('UpdateExpression')
|
||||
attribute_updates = self.body.get('AttributeUpdates')
|
||||
existing_item = dynamodb_backend2.get_item(name, key)
|
||||
item = dynamodb_backend2.update_item(name, key, update_expression, attribute_updates)
|
||||
|
||||
item_dict = item.to_json()
|
||||
item_dict['ConsumedCapacityUnits'] = 0.5
|
||||
if not existing_item:
|
||||
item_dict['Attributes'] = {}
|
||||
|
||||
return dynamo_json_dump(item_dict)
|
||||
|
@ -859,7 +859,7 @@ def test_update_item_does_not_exist_is_created():
|
||||
table = _create_table_with_range_key()
|
||||
|
||||
item_key = {'forum_name': 'the-key', 'subject': '123'}
|
||||
table.update_item(
|
||||
result = table.update_item(
|
||||
Key=item_key,
|
||||
AttributeUpdates={
|
||||
'username': {
|
||||
@ -875,8 +875,11 @@ def test_update_item_does_not_exist_is_created():
|
||||
'Value': {'key': 'value'},
|
||||
}
|
||||
},
|
||||
ReturnValues='ALL_OLD',
|
||||
)
|
||||
|
||||
assert not result.get('Attributes')
|
||||
|
||||
returned_item = dict((k, str(v) if isinstance(v, Decimal) else v)
|
||||
for k, v in table.get_item(Key=item_key)['Item'].items())
|
||||
dict(returned_item).should.equal({
|
||||
|
@ -430,7 +430,7 @@ def test_update_item_remove():
|
||||
}
|
||||
table.put_item(data=data)
|
||||
key_map = {
|
||||
"S": "steve"
|
||||
'username': {"S": "steve"}
|
||||
}
|
||||
|
||||
# Then remove the SentBy field
|
||||
@ -455,7 +455,7 @@ def test_update_item_set():
|
||||
}
|
||||
table.put_item(data=data)
|
||||
key_map = {
|
||||
"S": "steve"
|
||||
'username': {"S": "steve"}
|
||||
}
|
||||
|
||||
conn.update_item("messages", key_map, update_expression="SET foo=:bar, blah=:baz REMOVE :SentBy")
|
||||
|
Loading…
Reference in New Issue
Block a user