Skip to content

fix(idempotency): static pk is overwritten by hashed_idempotency_key #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 6 additions & 30 deletions tests/functional/idempotency/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,11 @@ def expected_params_update_item(serialized_lambda_response, hashed_idempotency_k

@pytest.fixture
def expected_params_update_item_compound_key_static_pk_value(
serialized_lambda_response, hashed_idempotency_key, static_pk_value
expected_params_update_item, hashed_idempotency_key, static_pk_value
):
return {
"ExpressionAttributeNames": {
"#expiry": "expiration",
"#response_data": "data",
"#status": "status",
},
"ExpressionAttributeValues": {
":expiry": {"N": stub.ANY},
":response_data": {"S": serialized_lambda_response},
":status": {"S": "COMPLETED"},
},
**expected_params_update_item,
"Key": {"id": {"S": static_pk_value}, "sk": {"S": hashed_idempotency_key}},
"TableName": "TEST_TABLE",
"UpdateExpression": "SET #response_data = :response_data, " "#expiry = :expiry, #status = :status",
}


Expand Down Expand Up @@ -172,31 +161,18 @@ def expected_params_put_item(hashed_idempotency_key):


@pytest.fixture
def expected_params_put_item_compound_key_static_pk_value(hashed_idempotency_key, static_pk_value):
def expected_params_put_item_compound_key_static_pk_value(
expected_params_put_item, hashed_idempotency_key, static_pk_value
):
return {
"ConditionExpression": (
"attribute_not_exists(#id) OR #expiry < :now OR "
"(#status = :inprogress AND attribute_exists(#in_progress_expiry) AND #in_progress_expiry < :now_in_millis)"
),
"ExpressionAttributeNames": {
"#id": "id",
"#expiry": "expiration",
"#status": "status",
"#in_progress_expiry": "in_progress_expiration",
},
"ExpressionAttributeValues": {
":now": {"N": stub.ANY},
":now_in_millis": {"N": stub.ANY},
":inprogress": {"S": "INPROGRESS"},
},
**expected_params_put_item,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! I want to completely overhaul the way functional tests are written - get rid of fixtures and use builders for all of this error-prone boilerplate in stubs.

Migrating this over to the other PR.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

"Item": {
"expiration": {"N": stub.ANY},
"in_progress_expiration": {"N": stub.ANY},
"id": {"S": static_pk_value},
"sk": {"S": hashed_idempotency_key},
"status": {"S": "INPROGRESS"},
},
"TableName": "TEST_TABLE",
}


Expand Down