Skip to content

Commit

Permalink
fix(tests): Adapt to moto 5
Browse files Browse the repository at this point in the history
Signed-off-by: Ferenc Géczi <[email protected]>
  • Loading branch information
Ferenc- committed Jan 29, 2024
1 parent 715edda commit be753fe
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions tests/apps/flask_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

try:
import boto3
from moto import mock_sqs
from moto import mock_aws
except ImportError:
# Doesn't matter. We won't call routes using boto3
# in test sets that don't install/test for it.
Expand Down Expand Up @@ -174,7 +174,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',
Expand Down
6 changes: 3 additions & 3 deletions tests/clients/boto3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand All @@ -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')
```
```
4 changes: 2 additions & 2 deletions tests/clients/boto3/test_boto3_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import boto3
import pytest

from moto import mock_lambda
from moto import mock_aws

from instana.singletons import tracer
from ...helpers import get_first_span_by_filter
Expand All @@ -24,7 +24,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')


Expand Down
4 changes: 2 additions & 2 deletions tests/clients/boto3/test_boto3_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import boto3
import pytest

from moto import mock_s3
from moto import mock_aws

from instana.singletons import tracer
from ...helpers import get_first_span_by_filter
Expand All @@ -34,7 +34,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')


Expand Down
6 changes: 3 additions & 3 deletions tests/clients/boto3/test_boto3_secretsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import boto3
import pytest

from moto import mock_secretsmanager
from moto import mock_aws

from instana.singletons import tracer
from ...helpers import get_first_span_by_filter
Expand All @@ -30,7 +30,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')


Expand Down Expand Up @@ -80,4 +80,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'
assert boto_span.data['http']['url'] == 'https://secretsmanager.us-east-1.amazonaws.com:443/GetSecretValue'
6 changes: 3 additions & 3 deletions tests/clients/boto3/test_boto3_ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import boto3
import pytest

from moto import mock_ses
from moto import mock_aws

from instana.singletons import tracer
from ...helpers import get_first_span_by_filter
Expand All @@ -30,7 +30,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')


Expand Down Expand Up @@ -71,4 +71,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'
assert boto_span.data['http']['url'] == 'https://email.us-east-1.amazonaws.com:443/VerifyEmailIdentity'
6 changes: 3 additions & 3 deletions tests/clients/boto3/test_boto3_sqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest
import urllib3

from moto import mock_sqs
from moto import mock_aws

import tests.apps.flask_app
from instana.singletons import tracer
Expand Down Expand Up @@ -38,7 +38,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')


Expand Down Expand Up @@ -113,7 +113,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')
Expand Down

0 comments on commit be753fe

Please sign in to comment.