Created
August 19, 2022 14:56
-
-
Save sebastianschramm/533539db735c23f08a7e571fa9407b4d to your computer and use it in GitHub Desktop.
An easy way to integration test your calls to S3 with moto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dependencies: python3.9, boto3 ==1.24.51, moto==3.1.18