From e482f27e2fd0251439781a87d75ac69a67bdaa6f Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Tue, 9 Jul 2019 12:22:19 +0200 Subject: [PATCH] alternator-test: add test for reading key before write The test case checks if reading keys in order to use their values in read-before-write updates works fine. --- alternator-test/test_update_expression.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/alternator-test/test_update_expression.py b/alternator-test/test_update_expression.py index 6ba20475c5..b0091b5438 100644 --- a/alternator-test/test_update_expression.py +++ b/alternator-test/test_update_expression.py @@ -69,6 +69,16 @@ def test_update_expression_set_nested_copy(test_table_s): ExpressionAttributeNames={'#nnnn': 'nnnn', '#nnn': 'nnn'}, ExpressionAttributeValues={':val1': [1,3]}) assert test_table_s.get_item(Key={'p': p}, ConsistentRead=True)['Item'] == {'p': p, 'n': 2, 'nn': 5, 'nnn': [2,4], 'nnnn': [1,3,2,4]} +# Test for getting a key value with read-before-write +def test_update_expression_set_key(test_table_sn): + p = random_string() + test_table_sn.update_item(Key={'p': p, 'c': 7}); + test_table_sn.update_item(Key={'p': p, 'c': 7}, UpdateExpression='SET #n = #p', + ExpressionAttributeNames={'#n': 'n', '#p': 'p'}) + test_table_sn.update_item(Key={'p': p, 'c': 7}, UpdateExpression='SET #nn = #c + #c', + ExpressionAttributeNames={'#nn': 'nn', '#c': 'c'}) + assert test_table_sn.get_item(Key={'p': p, 'c': 7}, ConsistentRead=True)['Item'] == {'p': p, 'c': 7, 'n': p, 'nn': 14} + # Simple test for the "REMOVE" action def test_update_expression_remove(test_table_s): p = random_string()