2021-11-09 22:29:28 +00:00
|
|
|
import boto3
|
2021-11-22 23:06:59 +00:00
|
|
|
import pytest
|
2021-11-09 22:29:28 +00:00
|
|
|
|
|
|
|
from moto import mock_all
|
|
|
|
|
|
|
|
|
|
|
|
@mock_all()
|
2023-06-15 11:03:58 +00:00
|
|
|
def test_decorator() -> None:
|
2021-11-09 22:29:28 +00:00
|
|
|
rgn = "us-east-1"
|
|
|
|
sqs = boto3.client("sqs", region_name=rgn)
|
2021-11-22 23:06:59 +00:00
|
|
|
r = sqs.list_queues()
|
2023-07-10 21:04:31 +00:00
|
|
|
assert r["ResponseMetadata"]["HTTPStatusCode"] == 200
|
2021-11-09 22:29:28 +00:00
|
|
|
|
|
|
|
lmbda = boto3.client("lambda", region_name=rgn)
|
|
|
|
r = lmbda.list_event_source_mappings()
|
2023-07-10 21:04:31 +00:00
|
|
|
assert r["ResponseMetadata"]["HTTPStatusCode"] == 200
|
2021-11-09 22:29:28 +00:00
|
|
|
|
|
|
|
ddb = boto3.client("dynamodb", region_name=rgn)
|
|
|
|
r = ddb.list_tables()
|
2023-07-10 21:04:31 +00:00
|
|
|
assert r["ResponseMetadata"]["HTTPStatusCode"] == 200
|
2021-11-22 23:06:59 +00:00
|
|
|
|
|
|
|
|
2023-06-15 11:03:58 +00:00
|
|
|
def test_context_manager() -> None:
|
2021-11-22 23:06:59 +00:00
|
|
|
rgn = "us-east-1"
|
|
|
|
|
|
|
|
with mock_all():
|
|
|
|
sqs = boto3.client("sqs", region_name=rgn)
|
|
|
|
r = sqs.list_queues()
|
2023-07-10 21:04:31 +00:00
|
|
|
assert r["ResponseMetadata"]["HTTPStatusCode"] == 200
|
2021-11-22 23:06:59 +00:00
|
|
|
|
|
|
|
unpatched_sqs = boto3.Session().client("sqs", region_name=rgn)
|
|
|
|
|
|
|
|
with pytest.raises(Exception):
|
|
|
|
unpatched_sqs.list_queues()
|