diff --git a/tests/apps/flask_app/app.py b/tests/apps/flask_app/app.py index 087a2d3f4..11d97f6a2 100755 --- a/tests/apps/flask_app/app.py +++ b/tests/apps/flask_app/app.py @@ -13,7 +13,12 @@ try: import boto3 - from moto import mock_sqs + # TODO: Remove branching when we drop support for Python 3.7 + import sys + if sys.version_info >= (3, 8): + from moto import mock_aws + else: + from moto import mock_sqs as mock_aws except ImportError: # Doesn't matter. We won't call routes using boto3 # in test sets that don't install/test for it. @@ -174,7 +179,7 @@ def boto3_sqs(): os.environ['AWS_SECURITY_TOKEN'] = 'testing' os.environ['AWS_SESSION_TOKEN'] = 'testing' - with mock_sqs(): + with mock_aws(): boto3_client = boto3.client('sqs', region_name='us-east-1') response = boto3_client.create_queue( QueueName='SQS_QUEUE_NAME', diff --git a/tests/clients/boto3/README.md b/tests/clients/boto3/README.md index 6159a2457..a7e775076 100644 --- a/tests/clients/boto3/README.md +++ b/tests/clients/boto3/README.md @@ -4,7 +4,7 @@ If you would like to run this test server manually from an ipython console: import os import urllib3 -from moto import mock_sqs +from moto import mock_aws import tests.apps.flask_app from tests.helpers import testenv from instana.singletons import tracer @@ -16,7 +16,7 @@ os.environ['AWS_SECRET_ACCESS_KEY'] = 'testing' os.environ['AWS_SECURITY_TOKEN'] = 'testing' os.environ['AWS_SESSION_TOKEN'] = 'testing' -@mock_sqs +@mock_aws def test_app_boto3_sqs(): with tracer.start_active_span('wsgi') as scope: scope.span.set_tag('span.kind', 'entry') @@ -26,4 +26,4 @@ def test_app_boto3_sqs(): scope.span.set_tag('http.status_code', 200) response = http_client.request('GET', testenv["wsgi_server"] + '/boto3/sqs') -``` \ No newline at end of file +``` diff --git a/tests/clients/boto3/test_boto3_lambda.py b/tests/clients/boto3/test_boto3_lambda.py index 699a20124..4c45af0e5 100644 --- a/tests/clients/boto3/test_boto3_lambda.py +++ b/tests/clients/boto3/test_boto3_lambda.py @@ -7,7 +7,12 @@ import boto3 import pytest -from moto import mock_lambda +# TODO: Remove branching when we drop support for Python 3.7 +import sys +if sys.version_info >= (3, 8): + from moto import mock_aws +else: + from moto import mock_sqs as mock_aws from instana.singletons import tracer from ...helpers import get_first_span_by_filter @@ -24,7 +29,7 @@ def aws_credentials(): @pytest.fixture(scope='function') def aws_lambda(aws_credentials): - with mock_lambda(): + with mock_aws(): yield boto3.client('lambda', region_name='us-east-1') diff --git a/tests/clients/boto3/test_boto3_s3.py b/tests/clients/boto3/test_boto3_s3.py index 4b6d60056..8ba64f897 100644 --- a/tests/clients/boto3/test_boto3_s3.py +++ b/tests/clients/boto3/test_boto3_s3.py @@ -7,7 +7,12 @@ import boto3 import pytest -from moto import mock_s3 +# TODO: Remove branching when we drop support for Python 3.7 +import sys +if sys.version_info >= (3, 8): + from moto import mock_aws +else: + from moto import mock_s3 as mock_aws from instana.singletons import tracer from ...helpers import get_first_span_by_filter @@ -34,7 +39,7 @@ def aws_credentials(): @pytest.fixture(scope='function') def s3(aws_credentials): - with mock_s3(): + with mock_aws(): yield boto3.client('s3', region_name='us-east-1') diff --git a/tests/clients/boto3/test_boto3_secretsmanager.py b/tests/clients/boto3/test_boto3_secretsmanager.py index e331353fe..2682646bd 100644 --- a/tests/clients/boto3/test_boto3_secretsmanager.py +++ b/tests/clients/boto3/test_boto3_secretsmanager.py @@ -7,7 +7,12 @@ import boto3 import pytest -from moto import mock_secretsmanager +# TODO: Remove branching when we drop support for Python 3.7 +import sys +if sys.version_info >= (3, 8): + from moto import mock_aws +else: + from moto import mock_secretsmanager as mock_aws from instana.singletons import tracer from ...helpers import get_first_span_by_filter @@ -30,7 +35,7 @@ def aws_credentials(): @pytest.fixture(scope='function') def secretsmanager(aws_credentials): - with mock_secretsmanager(): + with mock_aws(): yield boto3.client('secretsmanager', region_name='us-east-1') @@ -80,4 +85,4 @@ def test_get_secret_value(secretsmanager): assert boto_span.data['http']['status'] == 200 assert boto_span.data['http']['method'] == 'POST' - assert boto_span.data['http']['url'] == 'https://secretsmanager.us-east-1.amazonaws.com:443/GetSecretValue' \ No newline at end of file + assert boto_span.data['http']['url'] == 'https://secretsmanager.us-east-1.amazonaws.com:443/GetSecretValue' diff --git a/tests/clients/boto3/test_boto3_ses.py b/tests/clients/boto3/test_boto3_ses.py index 14657dc22..20d14bf2a 100644 --- a/tests/clients/boto3/test_boto3_ses.py +++ b/tests/clients/boto3/test_boto3_ses.py @@ -7,7 +7,12 @@ import boto3 import pytest -from moto import mock_ses +# TODO: Remove branching when we drop support for Python 3.7 +import sys +if sys.version_info >= (3, 8): + from moto import mock_aws +else: + from moto import mock_ses as mock_aws from instana.singletons import tracer from ...helpers import get_first_span_by_filter @@ -30,7 +35,7 @@ def aws_credentials(): @pytest.fixture(scope='function') def ses(aws_credentials): - with mock_ses(): + with mock_aws(): yield boto3.client('ses', region_name='us-east-1') @@ -71,4 +76,4 @@ def test_verify_email(ses): assert boto_span.data['http']['status'] == 200 assert boto_span.data['http']['method'] == 'POST' - assert boto_span.data['http']['url'] == 'https://email.us-east-1.amazonaws.com:443/VerifyEmailIdentity' \ No newline at end of file + assert boto_span.data['http']['url'] == 'https://email.us-east-1.amazonaws.com:443/VerifyEmailIdentity' diff --git a/tests/clients/boto3/test_boto3_sqs.py b/tests/clients/boto3/test_boto3_sqs.py index a42d3231f..56fa0ca35 100644 --- a/tests/clients/boto3/test_boto3_sqs.py +++ b/tests/clients/boto3/test_boto3_sqs.py @@ -8,7 +8,12 @@ import pytest import urllib3 -from moto import mock_sqs +# TODO: Remove branching when we drop support for Python 3.7 +import sys +if sys.version_info >= (3, 8): + from moto import mock_aws +else: + from moto import mock_sqs as mock_aws import tests.apps.flask_app from instana.singletons import tracer @@ -38,7 +43,7 @@ def http_client(): @pytest.fixture(scope='function') def sqs(aws_credentials): - with mock_sqs(): + with mock_aws(): yield boto3.client('sqs', region_name='us-east-1') @@ -113,7 +118,7 @@ def test_send_message(sqs): assert boto_span.data['http']['url'] == 'https://sqs.us-east-1.amazonaws.com:443/SendMessage' -@mock_sqs +@mock_aws def test_app_boto3_sqs(http_client): with tracer.start_active_span('test'): response = http_client.request('GET', testenv["wsgi_server"] + '/boto3/sqs')