Skip to content

Commit

Permalink
chore(idempotency): no need to update expire on update
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfonseca committed Jul 29, 2022
1 parent 81ed53d commit 66b62a6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,16 @@ def _put_record(self, data_record: DataRecord) -> None:

def _update_record(self, data_record: DataRecord):
logger.debug(f"Updating record for idempotency key: {data_record.idempotency_key}")
update_expression = (
"SET #response_data = :response_data, #expiry = :expiry, "
"#status = :status, #in_progress_expiry = :in_progress_expiry"
)
update_expression = "SET #response_data = :response_data, #expiry = :expiry, " "#status = :status"
expression_attr_values = {
":expiry": data_record.expiry_timestamp,
":response_data": data_record.response_data,
":status": data_record.status,
":in_progress_expiry": data_record.in_progress_expiry_timestamp,
}
expression_attr_names = {
"#response_data": self.data_attr,
"#expiry": self.expiry_attr,
"#response_data": self.data_attr,
"#status": self.status_attr,
"#in_progress_expiry": self.in_progress_expiry_attr,
}

if self.payload_validation_enabled:
Expand Down
10 changes: 1 addition & 9 deletions tests/functional/idempotency/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,15 @@ def expected_params_update_item(serialized_lambda_response, hashed_idempotency_k
"#expiry": "expiration",
"#response_data": "data",
"#status": "status",
"#in_progress_expiry": "in_progress_expiration",
},
"ExpressionAttributeValues": {
":expiry": stub.ANY,
":response_data": serialized_lambda_response,
":status": "COMPLETED",
":in_progress_expiry": stub.ANY,
},
"Key": {"id": hashed_idempotency_key},
"TableName": "TEST_TABLE",
"UpdateExpression": (
"SET #response_data = :response_data, "
"#expiry = :expiry, #status = :status, #in_progress_expiry = :in_progress_expiry"
),
"UpdateExpression": "SET #response_data = :response_data, " "#expiry = :expiry, #status = :status",
}


Expand All @@ -110,21 +105,18 @@ def expected_params_update_item_with_validation(
"#response_data": "data",
"#status": "status",
"#validation_key": "validation",
"#in_progress_expiry": "in_progress_expiration",
},
"ExpressionAttributeValues": {
":expiry": stub.ANY,
":response_data": serialized_lambda_response,
":status": "COMPLETED",
":validation_key": hashed_validation_key,
":in_progress_expiry": stub.ANY,
},
"Key": {"id": hashed_idempotency_key},
"TableName": "TEST_TABLE",
"UpdateExpression": (
"SET #response_data = :response_data, "
"#expiry = :expiry, #status = :status, "
"#in_progress_expiry = :in_progress_expiry, "
"#validation_key = :validation_key"
),
}
Expand Down
8 changes: 1 addition & 7 deletions tests/functional/idempotency/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,13 @@ def build_idempotency_update_item_stub(
"#expiry": "expiration",
"#response_data": "data",
"#status": "status",
"#in_progress_expiry": "in_progress_expiration",
},
"ExpressionAttributeValues": {
":expiry": stub.ANY,
":response_data": serialized_lambda_response,
":status": "COMPLETED",
":in_progress_expiry": stub.ANY,
},
"Key": {"id": idempotency_key_hash},
"TableName": "TEST_TABLE",
"UpdateExpression": (
"SET #response_data = :response_data, "
"#expiry = :expiry, #status = :status, "
"#in_progress_expiry = :in_progress_expiry"
),
"UpdateExpression": "SET #response_data = :response_data, " "#expiry = :expiry, #status = :status",
}

0 comments on commit 66b62a6

Please sign in to comment.