moto/tests/test_ec2/__init__.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
839 B
Python
Raw Permalink Normal View History

import os
from functools import wraps
2024-01-07 12:03:33 +00:00
from moto import mock_aws
def ec2_aws_verified(func):
"""
Function that is verified to work against AWS.
Can be run against AWS at any time by setting:
MOTO_TEST_ALLOW_AWS_REQUEST=true
2024-01-07 12:03:33 +00:00
If this environment variable is not set, the function runs in a `mock_aws` context.
This decorator will:
- Create a bucket
- Run the test and pass the bucket_name as an argument
- Delete the objects and the bucket itself
"""
@wraps(func)
def pagination_wrapper():
allow_aws = (
os.environ.get("MOTO_TEST_ALLOW_AWS_REQUEST", "false").lower() == "true"
)
if allow_aws:
resp = func()
else:
2024-01-07 12:03:33 +00:00
with mock_aws():
resp = func()
return resp
return pagination_wrapper