mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-02 04:56:58 +00:00
alternator-test: add stub case for set add duplication
The test case for adding two sets with common values is added. This case is a stub, because boto3 transforms the result into a Python set, which removes duplicates on its own. A proper TODO is left in order to migrate this case to a lower-level API and check the returned JSON directly for lack of duplicates.
This commit is contained in:
committed by
Nadav Har'El
parent
67c95cb303
commit
336c90daaa
@@ -654,6 +654,17 @@ def test_update_expression_add_sets(test_table_s):
|
||||
UpdateExpression='ADD a :val1',
|
||||
ExpressionAttributeValues={':val1': set(['pig'])})
|
||||
assert test_table_s.get_item(Key={'p': p}, ConsistentRead=True)['Item']['a'] == set(['dog', 'cat', 'mouse', 'pig'])
|
||||
|
||||
# TODO: right now this test won't detect duplicated values in the returned result,
|
||||
# because boto3 parses a set out of the returned JSON anyway. This check should leverage
|
||||
# lower level API (if exists) to ensure that the JSON contains no duplicates
|
||||
# in the set representation. It has been verified manually.
|
||||
test_table_s.put_item(Item={'p': p, 'a': set(['beaver', 'lynx', 'coati']), 'b': 'hi'})
|
||||
test_table_s.update_item(Key={'p': p},
|
||||
UpdateExpression='ADD a :val1',
|
||||
ExpressionAttributeValues={':val1': set(['coati', 'beaver', 'badger'])})
|
||||
assert test_table_s.get_item(Key={'p': p}, ConsistentRead=True)['Item']['a'] == set(['beaver', 'badger', 'lynx', 'coati'])
|
||||
|
||||
# The value to be added needs to be a set of the same type - it can't
|
||||
# be a single element or anything else. If the value has the wrong type,
|
||||
# we get an error like "Invalid UpdateExpression: Incorrect operand type
|
||||
|
||||
Reference in New Issue
Block a user