MCPcopy Create free account
hub / github.com/ExtendDB/extenddb / test_transact_write_update

Function test_transact_write_update

tests/test_transaction_operations.py:53–70  ·  view source on GitHub ↗

TransactWriteItems with Update.

(dynamodb_client, hash_table)

Source from the content-addressed store, hash-verified

51 resp = dynamodb_client.get_item(TableName=hash_table, Key={"pk": {"S": "del-1"}})
52 assert "Item" not in resp
53def test_transact_write_update(dynamodb_client, hash_table):
54 """TransactWriteItems with Update."""
55 dynamodb_client.put_item(TableName=hash_table, Item={"pk": {"S": "upd-1"}, "counter": {"N": "0"}})
56 dynamodb_client.transact_write_items(
57 TransactItems=[
58 {
59 "Update": {
60 "TableName": hash_table,
61 "Key": {"pk": {"S": "upd-1"}},
62 "UpdateExpression": "SET #c = #c + :inc",
63 "ExpressionAttributeNames": {"#c": "counter"},
64 "ExpressionAttributeValues": {":inc": {"N": "5"}},
65 }
66 }
67 ]
68 )
69 resp = dynamodb_client.get_item(TableName=hash_table, Key={"pk": {"S": "upd-1"}})
70 assert resp["Item"]["counter"]["N"] == "5"
71def test_transact_write_condition_check_pass(dynamodb_client, hash_table):
72 """TransactWriteItems with ConditionCheck that passes."""
73 dynamodb_client.put_item(TableName=hash_table, Item={"pk": {"S": "cc-1"}, "status": {"S": "active"}})

Callers

nothing calls this directly

Calls 3

put_itemMethod · 0.80
transact_write_itemsMethod · 0.80
get_itemMethod · 0.80

Tested by

no test coverage detected