Decorator to help for AWS/boto integration testing in pytest
Project description
The potemkin decorator allows standing up AWS resources in the form of a Cloudformation template. For "integration testing" boto code with AWS, this allows for a convenient way to setup initial conditions instead of having to develop boto code that is likely as complex as the "code under test".
Here is an example invocation from pytest:
import potemkin
import boto3
@potemkin.CloudFormationStack(
'test/integration/test_templates/aes256_bucket.yml',
stack_name_stem='TestStack',
parameters={'BucketName': 'unclefreddie33388'},
aws_profile='myprofile',
teardown=False
)
def test_bucket_has_aes256_encryption(stack_outputs):
full_bucket_name = stack_outputs['BucketNameOut']
s3 = boto3.Session(profile_name='myprofile').client('s3')
get_bucket_encryption_response = s3.get_bucket_encryption(
Bucket=full_bucket_name
)
assert get_bucket_encryption_response['ServerSideEncryptionConfiguration']['Rules'][0]['ApplyServerSideEncryptionByDefault']['SSEAlgorithm'] == 'AES256'
The CloudFormationStack creates the stack and binds the outputs to stack_outputs. The pytest method could invoke more boto code to manipulate the resources created by the decorator. In this case, the test just asserts that the initial condition is what is expected.
This is basically a python/pytest port of "aws-int-test-rspec-helper" that worked with Ruby/RSpec:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for potemkin_decorator-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29dc26848f6f074ff9bdbcb4a714fed5b69ab192f7bfe7ab0ed68ab219f5d290 |
|
MD5 | b2e4575ab739b58431236156b4d6d3ac |
|
BLAKE2b-256 | fa50faa79fba59fcf6f87d9d5e78a810e2265aba382cd6f79fe16b51a4c172f5 |