Allow doing an ADD update of a string set

Fix test
This commit is contained in:
Brian Rower 2017-09-11 12:06:24 -07:00
commit 386ac94abe
2 changed files with 36 additions and 0 deletions

View file

@ -1306,6 +1306,36 @@ def test_update_item_add_value():
})
@mock_dynamodb2
def test_update_item_add_value_string_set():
table = _create_table_with_range_key()
table.put_item(Item={
'forum_name': 'the-key',
'subject': '123',
'string_set': set(['str1', 'str2']),
})
item_key = {'forum_name': 'the-key', 'subject': '123'}
table.update_item(
Key=item_key,
AttributeUpdates={
'string_set': {
'Action': u'ADD',
'Value': set(['str3']),
},
},
)
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({
'string_set': set(['str1', 'str2', 'str3']),
'forum_name': 'the-key',
'subject': '123',
})
@mock_dynamodb2
def test_update_item_add_value_does_not_exist_is_created():
table = _create_table_with_range_key()