@@ -124,6 +124,7 @@ def test_transact_write__error__idempotent_parameter_mismatch(connection):
124
124
with TransactWrite (connection = connection , client_request_token = client_token ) as transaction :
125
125
transaction .save (User (3 ))
126
126
assert get_error_code (exc_info .value ) == IDEMPOTENT_PARAMETER_MISMATCH
127
+ assert User .Meta .table_name in exc_info .value .cause .MSG_TEMPLATE
127
128
128
129
# ensure that the first request succeeded in creating new users
129
130
assert User .get (1 )
@@ -143,6 +144,9 @@ def test_transact_write__error__different_regions(connection):
143
144
transact_write .save (BankStatement (1 ))
144
145
transact_write .save (User (1 ))
145
146
assert get_error_code (exc_info .value ) == RESOURCE_NOT_FOUND
147
+ assert DifferentRegion .Meta .table_name in exc_info .value .cause .MSG_TEMPLATE
148
+ assert BankStatement .Meta .table_name in exc_info .value .cause .MSG_TEMPLATE
149
+ assert User .Meta .table_name in exc_info .value .cause .MSG_TEMPLATE
146
150
147
151
148
152
@pytest .mark .ddblocal
@@ -158,6 +162,8 @@ def test_transact_write__error__transaction_cancelled__condition_check_failure(c
158
162
transaction .save (BankStatement (1 ), condition = (BankStatement .user_id .does_not_exist ()))
159
163
assert get_error_code (exc_info .value ) == TRANSACTION_CANCELLED
160
164
assert 'ConditionalCheckFailed' in get_error_message (exc_info .value )
165
+ assert User .Meta .table_name in exc_info .value .cause .MSG_TEMPLATE
166
+ assert BankStatement .Meta .table_name in exc_info .value .cause .MSG_TEMPLATE
161
167
162
168
163
169
@pytest .mark .ddblocal
@@ -170,6 +176,7 @@ def test_transact_write__error__multiple_operations_on_same_record(connection):
170
176
transaction .condition_check (BankStatement , 1 , condition = (BankStatement .user_id .exists ()))
171
177
transaction .update (BankStatement (1 ), actions = [(BankStatement .balance .add (10 ))])
172
178
assert get_error_code (exc_info .value ) == VALIDATION_EXCEPTION
179
+ assert BankStatement .Meta .table_name in exc_info .value .cause .MSG_TEMPLATE
173
180
174
181
175
182
@pytest .mark .ddblocal
@@ -343,6 +350,7 @@ def test_transaction_write_with_version_attribute_condition_failure(connection):
343
350
transaction .save (Foo (21 ))
344
351
assert get_error_code (exc_info .value ) == TRANSACTION_CANCELLED
345
352
assert 'ConditionalCheckFailed' in get_error_message (exc_info .value )
353
+ assert Foo .Meta .table_name in exc_info .value .cause .MSG_TEMPLATE
346
354
347
355
with pytest .raises (TransactWriteError ) as exc_info :
348
356
with TransactWrite (connection = connection ) as transaction :
@@ -354,6 +362,7 @@ def test_transaction_write_with_version_attribute_condition_failure(connection):
354
362
)
355
363
assert get_error_code (exc_info .value ) == TRANSACTION_CANCELLED
356
364
assert 'ConditionalCheckFailed' in get_error_message (exc_info .value )
365
+ assert Foo .Meta .table_name in exc_info .value .cause .MSG_TEMPLATE
357
366
# Version attribute is not updated on failure.
358
367
assert foo2 .version is None
359
368
@@ -362,3 +371,4 @@ def test_transaction_write_with_version_attribute_condition_failure(connection):
362
371
transaction .delete (foo2 )
363
372
assert get_error_code (exc_info .value ) == TRANSACTION_CANCELLED
364
373
assert 'ConditionalCheckFailed' in get_error_message (exc_info .value )
374
+ assert Foo .Meta .table_name in exc_info .value .cause .MSG_TEMPLATE
0 commit comments