Skip to content

Instantly share code, notes, and snippets.

@sebastianschramm
Created August 19, 2022 14:56
Show Gist options
  • Save sebastianschramm/533539db735c23f08a7e571fa9407b4d to your computer and use it in GitHub Desktop.
Save sebastianschramm/533539db735c23f08a7e571fa9407b4d to your computer and use it in GitHub Desktop.
An easy way to integration test your calls to S3 with moto
import boto3
from moto import mock_s3
def create_s3_bucket(bucket_name: str, aws_region: str):
s3_client = boto3.client("s3", region_name=aws_region)
s3_client.create_bucket(
Bucket=bucket_name, CreateBucketConfiguration={"LocationConstraint": aws_region}
)
@mock_s3
def test_integration_with_s3():
create_s3_bucket(bucket_name="foo", aws_region="eu-central-1")
if __name__ == "__main__":
test_integration_with_s3()
@sebastianschramm
Copy link
Author

dependencies: python3.9, boto3 ==1.24.51, moto==3.1.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment