Skip to content
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

feat(idempotency): makes customers unit testing easier #719

Merged
merged 7 commits into from
Oct 1, 2021

Conversation

to-mc
Copy link
Contributor

@to-mc to-mc commented Oct 1, 2021

Issue #, if available: #631

Description of changes:

Alter idempotency DynamoDB class to lazily load the boto3 Table object, so that it can be more easily patched in tests. Add a new environment variable to disable the idempotency logic altogether without needing code changes. Add "testing your code" section to docs.

Checklist

Breaking change checklist

RFC issue #:

  • Migration process documented
  • Implement warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


View rendered docs/utilities/idempotency.md

@boring-cyborg boring-cyborg bot added area/utilities documentation Improvements or additions to documentation labels Oct 1, 2021
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 1, 2021
@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2021

Codecov Report

Merging #719 (2b8a4f2) into develop (68e2c8e) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #719      +/-   ##
===========================================
- Coverage    99.97%   99.93%   -0.05%     
===========================================
  Files          116      116              
  Lines         4866     4898      +32     
  Branches       267      271       +4     
===========================================
+ Hits          4865     4895      +30     
- Misses           0        1       +1     
- Partials         1        2       +1     
Impacted Files Coverage Δ
aws_lambda_powertools/shared/constants.py 100.00% <100.00%> (ø)
...da_powertools/utilities/idempotency/idempotency.py 100.00% <100.00%> (ø)
...ools/utilities/idempotency/persistence/dynamodb.py 100.00% <100.00%> (ø)
aws_lambda_powertools/logging/logger.py 98.43% <0.00%> (-1.57%) ⬇️
aws_lambda_powertools/metrics/metrics.py 100.00% <0.00%> (ø)
aws_lambda_powertools/utilities/batch/sqs.py 100.00% <0.00%> (ø)
aws_lambda_powertools/shared/jmespath_utils.py 100.00% <0.00%> (ø)
aws_lambda_powertools/utilities/parameters/ssm.py 100.00% <0.00%> (ø)
..._lambda_powertools/utilities/feature_flags/base.py 100.00% <0.00%> (ø)
..._lambda_powertools/utilities/parameters/secrets.py 100.00% <0.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 68e2c8e...2b8a4f2. Read the comment docs.

@heitorlessa heitorlessa added the feature New feature or functionality label Oct 1, 2021
@heitorlessa heitorlessa changed the title feat: idempotency changes to make testing easier feat(idempotency): makes testing easier Oct 1, 2021
Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

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

those minor changes on bringing test setup along with the tests, and the indentation issues.

LGTM otherwise! 🎉

@boring-cyborg boring-cyborg bot added the tests label Oct 1, 2021
@heitorlessa heitorlessa changed the title feat(idempotency): makes testing easier feat(idempotency): makes customers unit testing easier Oct 1, 2021
@heitorlessa heitorlessa merged commit 19b1526 into develop Oct 1, 2021
@heitorlessa heitorlessa deleted the feat/testing_idempotency branch October 1, 2021 15:03
heitorlessa added a commit to heitorlessa/aws-lambda-powertools-python that referenced this pull request Oct 1, 2021
…tools-python into develop

* 'develop' of https://github.com/awslabs/aws-lambda-powertools-python:
  feat(feature-flags): improve "IN/NOT_IN"; new rule actions (aws-powertools#710)
  feat(idempotency): makes customers unit testing easier (aws-powertools#719)
  feat(feature-flags): get_raw_configuration property in Store (aws-powertools#720)
heitorlessa added a commit to gwlester/aws-lambda-powertools-python that referenced this pull request Oct 1, 2021
* develop:
  feat(feature-flags): improve "IN/NOT_IN"; new rule actions (aws-powertools#710)
  feat(idempotency): makes customers unit testing easier (aws-powertools#719)
  feat(feature-flags): get_raw_configuration property in Store (aws-powertools#720)
  feat: boto3 sessions in batch, parameters & idempotency (aws-powertools#717)
  feat: add get_raw_configuration property in store; expose store
  fix(mypy): a few return types, type signatures, and untyped areas (aws-powertools#718)
  docs: Terraform reference for SAR Lambda Layer (aws-powertools#716)
  chore(deps-dev): bump flake8-bugbear from 21.9.1 to 21.9.2 (aws-powertools#712)
  chore(deps): bump boto3 from 1.18.49 to 1.18.51 (aws-powertools#713)
  fix(idempotency): sorting keys before hashing
@heitorlessa heitorlessa removed the documentation Improvements or additions to documentation label Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants