diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2bc936ac7..aaac828b1 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -42,7 +42,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- python-version: [3.9, "3.10", "3.11", "3.12"]
+ python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
diff --git a/.github/workflows/dockertests.yml b/.github/workflows/dockertests.yml
index f1940c780..4a1134d50 100644
--- a/.github/workflows/dockertests.yml
+++ b/.github/workflows/dockertests.yml
@@ -203,6 +203,7 @@ jobs:
pwd
ls -la
cp server_output.log serverlogs3/server_output.log
+ ls -la serverlogs3
- name: Archive Logs
if: always()
uses: actions/upload-artifact@v4
diff --git a/docs/docs/configuration/environment_variables.rst b/docs/docs/configuration/environment_variables.rst
index 6b128a4be..2520bc0cf 100644
--- a/docs/docs/configuration/environment_variables.rst
+++ b/docs/docs/configuration/environment_variables.rst
@@ -32,4 +32,6 @@ The following is a non-exhaustive list of the environment variables that can be
+-------------------------------+----------+-----------+-------------------------------------------------------------------------------------------------+
| MOTO_S3_CUSTOM_ENDPOINTS | str | | See :ref:`s3`. |
+-------------------------------+----------+-----------+-------------------------------------------------------------------------------------------------+
+| MOTO_PRETTIFY_RESPONSES | bool | False | Prettify responses from Moto, making it easier to read and debug. |
++-------------------------------+----------+-----------+-------------------------------------------------------------------------------------------------+
diff --git a/docs/docs/configuration/index.rst b/docs/docs/configuration/index.rst
index fc9f5d04f..661e0e795 100644
--- a/docs/docs/configuration/index.rst
+++ b/docs/docs/configuration/index.rst
@@ -6,13 +6,21 @@ Configuration Options
Moto has a variety of ways to configure the mock behaviour.
+If you are using the decorators, some options are configurable within the decorator:
+
+.. sourcecode:: python
+
+ @mock_aws(config={
+ "batch": {"use_docker": True},
+ "lambda": {"use_docker": True}
+ })
+
.. toctree::
:maxdepth: 1
environment_variables
recorder/index
- prettify_responses
state_transition/index
state_transition/models
diff --git a/docs/docs/configuration/prettify_responses.rst b/docs/docs/configuration/prettify_responses.rst
deleted file mode 100644
index 1c5049877..000000000
--- a/docs/docs/configuration/prettify_responses.rst
+++ /dev/null
@@ -1,38 +0,0 @@
-.. _prettify_responses_page:
-
-.. role:: raw-html(raw)
- :format: html
-
-=============================
-Prettify responses
-=============================
-
-This option allows to prettify responses from moto. Pretty responses are more readable (eg. for debugging purposes).
-It also makes moto better in mocking AWS as AWS returns prettified responses.
-
-Ugly output:
-
-.. sourcecode:: python
-
- 178936da-50ad-4d58-8871-22d9979e8658example1lt-d920e32b0cccd6adbexample-name
-
-Prettified output:
-
-.. sourcecode:: python
-
-
- 178936da-50ad-4d58-8871-22d9979e8658example
-
- 1
- lt-d920e32b0cccd6adb
- example-name
-
-
-
-
-Enabling Pretty responses
-#########################
-
-As changing responses can interfere with some external tools, it is disabled by default.
-If you want to enable it, use environment variable:
-`MOTO_PRETTIFY_RESPONSES=True`
\ No newline at end of file
diff --git a/docs/docs/contributing/development_tips/tests.rst b/docs/docs/contributing/development_tips/tests.rst
index 6939c5372..04b8064fd 100644
--- a/docs/docs/contributing/development_tips/tests.rst
+++ b/docs/docs/contributing/development_tips/tests.rst
@@ -45,31 +45,3 @@ This means the following:
- Make sure you use unique names for functions/queues/etc
- Calls to `describe_reservations()`/`list_queues()`/etc might return resources from other tests
-
-
-Terraform tests
-^^^^^^^^^^^^^^^^^^^^^^
-
-To verify that Moto behaves correctly, we run a subset of Terraform's tests against the MotoServer to ensure it behaves the same as AWS does.
-
-These tests will be run automatically for every PR, so you should not need to make any changes here.
-
-A list of which tests currently pass against Moto can be found in `tests/terraformtests/terraform-tests.success.txt`.
-
-Use the following commands to see the full list of available tests:
-
-.. sourcecode:: bash
-
- cd tests/terraformtests/terraform-provider-aws
- # Choose the correct service in the next command - this example will list all tests for the ELB-service
- go test ./internal/service/elb/ -v -list TestAcc
-
-In order to check whether MotoServer behaves correctly against a specific test, you can use the following commands:
-
-.. sourcecode:: bash
-
- # Ensure you are back in the root-directory
- # Start the MotoServer on port 4566
- moto_server -p 4566
- # Run the new tests
- make terraformtests SERVICE_NAME=elb TEST_NAMES=NewTestName
diff --git a/docs/docs/getting_started.rst b/docs/docs/getting_started.rst
index a184aef0e..f0c467597 100644
--- a/docs/docs/getting_started.rst
+++ b/docs/docs/getting_started.rst
@@ -52,15 +52,15 @@ There are several ways to verify that the value will be persisted successfully.
Decorator
~~~~~~~~~
-With a decorator wrapping, all the calls to S3 are automatically mocked out.
+With a simple decorator wrapping, all calls to AWS are automatically mocked out.
.. sourcecode:: python
import boto3
- from moto import mock_s3
+ from moto import mock_aws
from mymodule import MyModel
- @mock_s3
+ @mock_aws
def test_my_model_save():
conn = boto3.resource("s3", region_name="us-east-1")
# We need to create the bucket since this is all in Moto's 'virtual' AWS account
@@ -82,7 +82,7 @@ Same as the Decorator, every call inside the ``with`` statement is mocked out.
.. sourcecode:: python
def test_my_model_save():
- with mock_s3():
+ with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="mybucket")
@@ -102,7 +102,7 @@ You can also start and stop the mocking manually.
.. sourcecode:: python
def test_my_model_save():
- mock = mock_s3()
+ mock = mock_aws()
mock.start()
conn = boto3.resource("s3", region_name="us-east-1")
@@ -126,7 +126,7 @@ If you use `unittest`_ to run tests, and you want to use `moto` inside `setUp`,
.. sourcecode:: python
import unittest
- from moto import mock_s3
+ from moto import mock_aws
import boto3
def func_to_test(bucket_name, key, content):
@@ -138,8 +138,8 @@ If you use `unittest`_ to run tests, and you want to use `moto` inside `setUp`,
bucket_name = "test-bucket"
def setUp(self):
- self.mock_s3 = mock_s3()
- self.mock_s3.start()
+ self.mock_aws = mock_aws()
+ self.mock_aws.start()
# you can use boto3.client("s3") if you prefer
s3 = boto3.resource("s3")
@@ -147,7 +147,7 @@ If you use `unittest`_ to run tests, and you want to use `moto` inside `setUp`,
bucket.create()
def tearDown(self):
- self.mock_s3.stop()
+ self.mock_aws.stop()
def test(self):
content = b"abc"
@@ -171,7 +171,7 @@ The decorator is effective for every test-method inside your class. State is not
.. sourcecode:: python
- @mock_s3
+ @mock_aws
class TestMockClassLevel(unittest.TestCase):
def setUp(self):
s3 = boto3.client("s3", region_name="us-east-1")
@@ -195,14 +195,13 @@ The decorator is effective for every test-method inside your class. State is not
Stand-alone server mode
~~~~~~~~~~~~~~~~~~~~~~~
-Moto also comes with a stand-alone server allowing you to mock out an AWS HTTP endpoint. For testing purposes, it's extremely useful even if you don't use Python.
+Moto also comes with a stand-alone server allowing you to mock out the AWS HTTP endpoints. This is useful if you are using any other language than Python.
.. sourcecode:: bash
$ moto_server -p3000
* Running on http://127.0.0.1:3000/
-However, this method isn't encouraged if you're using ``boto3``, the best solution would be to use a decorator method.
See :doc:`server_mode` for more information.
Recommended Usage
@@ -250,19 +249,19 @@ Here is an example:
os.environ["AWS_DEFAULT_REGION"] = "us-east-1"
@pytest.fixture(scope="function")
- def s3(aws_credentials):
- with mock_s3():
+ def aws(aws_credentials):
+ with mock_aws():
yield boto3.client("s3", region_name="us-east-1")
@pytest.fixture
- def create_bucket1(s3):
+ def create_bucket1(aws):
boto3.client("s3").create_bucket(Bucket="b1")
@pytest.fixture
- def create_bucket2(s3):
+ def create_bucket2(aws):
boto3.client("s3").create_bucket(Bucket="b2")
- def test_s3_directly(s3):
+ def test_s3_directly(aws):
s3.create_bucket(Bucket="somebucket")
result = s3.list_buckets()
@@ -303,7 +302,7 @@ Example:
.. sourcecode:: python
- def test_something(s3):
+ def test_something(aws):
# s3 is a fixture defined above that yields a boto3 s3 client.
from some.package.that.does.something.with.s3 import some_func # <-- Local import for unit test
@@ -323,7 +322,7 @@ If it is not possible to rearrange imports, we can patch the boto3-client or res
outside_client = boto3.client("s3")
s3 = boto3.resource("s3")
- @mock_s3
+ @mock_aws
def test_mock_works_with_client_or_resource_created_outside():
from moto.core import patch_client, patch_resource
patch_client(outside_client)
diff --git a/docs/docs/iam.rst b/docs/docs/iam.rst
index a88fcd2fd..b9afcdc4d 100644
--- a/docs/docs/iam.rst
+++ b/docs/docs/iam.rst
@@ -19,7 +19,7 @@ This is a decorator that works similarly to the environment variable, but the se
.. sourcecode:: python
@set_initial_no_auth_action_count(4)
- @mock_ec2
+ @mock_aws
def test_describe_instances_allowed():
policy_document = {
"Version": "2012-10-17",
diff --git a/docs/docs/releases.rst b/docs/docs/releases.rst
index c0ff5e9a7..0286480b8 100644
--- a/docs/docs/releases.rst
+++ b/docs/docs/releases.rst
@@ -50,4 +50,9 @@ For Moto 3.x:
- ECS ARN's now use the new (long) format by default
For Moto 4.x:
- - Removed decorators `mock_dynamodb2` and `mock_rds2` (they were functionally equivalent with `mock_dynamodb` and `mock_rds` since 3.x)
\ No newline at end of file
+ - Removed decorators `mock_dynamodb2` and `mock_rds2` (they were functionally equivalent with `mock_dynamodb` and `mock_rds` since 3.x)
+
+For Moto 5.x:
+ - All decorators have been replaced with `mock_aws`
+ - The `batch_simple` decorator has been replaced with: `@mock_aws(config={"batch": {"use_docker": False}})`
+ - The `awslambda_simple` decorator has been replaced with: `@mock_aws(config={"lambda": {"use_docker": False}})`
\ No newline at end of file
diff --git a/docs/docs/server_mode.rst b/docs/docs/server_mode.rst
index d3faf9647..b28f83426 100644
--- a/docs/docs/server_mode.rst
+++ b/docs/docs/server_mode.rst
@@ -76,7 +76,7 @@ See the following example:
def tearDown(self):
self.server.stop()
- @mock_s3
+ @mock_aws
def test_load_data_using_decorators(self):
server_client = boto3.client("s3", endpoint_url="http://127.0.0.1:5000")
server_client.create_bucket(Bucket="test")
@@ -120,7 +120,7 @@ Example Usage
To use Moto in your tests, pass the `endpoint_url`-parameter to the SDK of your choice.
-For some SDK's, this can be configured using the environment variable `AWS_ENDPOINT_URL`. See the official AWS documentation: https://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html
+For more recent SDK's, this can be configured using the environment variable `AWS_ENDPOINT_URL`. See the official AWS documentation: https://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html
If your SDK does not support this, here are some code samples to set this parameter the old-fashioned way.
diff --git a/docs/docs/services/acm-pca.rst b/docs/docs/services/acm-pca.rst
index dce965605..61ee344d7 100644
--- a/docs/docs/services/acm-pca.rst
+++ b/docs/docs/services/acm-pca.rst
@@ -14,17 +14,6 @@ acm-pca
.. autoclass:: moto.acmpca.models.ACMPCABackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_acmpca
- def test_acmpca_behaviour:
- boto3.client("acm-pca")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_certificate_authority
diff --git a/docs/docs/services/acm.rst b/docs/docs/services/acm.rst
index 3fd108aee..8b1ee3654 100644
--- a/docs/docs/services/acm.rst
+++ b/docs/docs/services/acm.rst
@@ -12,17 +12,6 @@
acm
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_acm
- def test_acm_behaviour:
- boto3.client("acm")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] add_tags_to_certificate
diff --git a/docs/docs/services/amp.rst b/docs/docs/services/amp.rst
index b2ff61916..b9525854d 100644
--- a/docs/docs/services/amp.rst
+++ b/docs/docs/services/amp.rst
@@ -14,17 +14,6 @@ amp
.. autoclass:: moto.amp.models.PrometheusServiceBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_amp
- def test_amp_behaviour:
- boto3.client("amp")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] create_alert_manager_definition
diff --git a/docs/docs/services/apigateway.rst b/docs/docs/services/apigateway.rst
index e539a9ed7..988edd6ab 100644
--- a/docs/docs/services/apigateway.rst
+++ b/docs/docs/services/apigateway.rst
@@ -14,17 +14,6 @@ apigateway
.. autoclass:: moto.apigateway.models.APIGatewayBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_apigateway
- def test_apigateway_behaviour:
- boto3.client("apigateway")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_api_key
diff --git a/docs/docs/services/apigatewaymanagementapi.rst b/docs/docs/services/apigatewaymanagementapi.rst
index 505438b48..e7970536e 100644
--- a/docs/docs/services/apigatewaymanagementapi.rst
+++ b/docs/docs/services/apigatewaymanagementapi.rst
@@ -14,17 +14,6 @@ apigatewaymanagementapi
.. autoclass:: moto.apigatewaymanagementapi.models.ApiGatewayManagementApiBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_apigatewaymanagementapi
- def test_apigatewaymanagementapi_behaviour:
- boto3.client("apigatewaymanagementapi")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] delete_connection
diff --git a/docs/docs/services/apigatewayv2.rst b/docs/docs/services/apigatewayv2.rst
index 7be34f0ff..17e5bd765 100644
--- a/docs/docs/services/apigatewayv2.rst
+++ b/docs/docs/services/apigatewayv2.rst
@@ -14,17 +14,6 @@ apigatewayv2
.. autoclass:: moto.apigatewayv2.models.ApiGatewayV2Backend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_apigatewayv2
- def test_apigatewayv2_behaviour:
- boto3.client("apigatewayv2")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_api
diff --git a/docs/docs/services/appconfig.rst b/docs/docs/services/appconfig.rst
index c06901dba..209ceb546 100644
--- a/docs/docs/services/appconfig.rst
+++ b/docs/docs/services/appconfig.rst
@@ -14,17 +14,6 @@ appconfig
.. autoclass:: moto.appconfig.models.AppConfigBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_appconfig
- def test_appconfig_behaviour:
- boto3.client("appconfig")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_application
diff --git a/docs/docs/services/application-autoscaling.rst b/docs/docs/services/application-autoscaling.rst
index 056269b6f..46d0ed411 100644
--- a/docs/docs/services/application-autoscaling.rst
+++ b/docs/docs/services/application-autoscaling.rst
@@ -12,17 +12,6 @@
application-autoscaling
=======================
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_applicationautoscaling
- def test_applicationautoscaling_behaviour:
- boto3.client("application-autoscaling")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] delete_scaling_policy
diff --git a/docs/docs/services/appsync.rst b/docs/docs/services/appsync.rst
index 83d0540c7..78b36c9cf 100644
--- a/docs/docs/services/appsync.rst
+++ b/docs/docs/services/appsync.rst
@@ -14,17 +14,6 @@ appsync
.. autoclass:: moto.appsync.models.AppSyncBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_appsync
- def test_appsync_behaviour:
- boto3.client("appsync")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] associate_api
diff --git a/docs/docs/services/athena.rst b/docs/docs/services/athena.rst
index 5f788c7a2..67f14ea67 100644
--- a/docs/docs/services/athena.rst
+++ b/docs/docs/services/athena.rst
@@ -12,17 +12,6 @@
athena
======
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_athena
- def test_athena_behaviour:
- boto3.client("athena")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_get_named_query
diff --git a/docs/docs/services/autoscaling.rst b/docs/docs/services/autoscaling.rst
index 35fd64370..11e306ab1 100644
--- a/docs/docs/services/autoscaling.rst
+++ b/docs/docs/services/autoscaling.rst
@@ -12,17 +12,6 @@
autoscaling
===========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_autoscaling
- def test_autoscaling_behaviour:
- boto3.client("autoscaling")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] attach_instances
diff --git a/docs/docs/services/batch.rst b/docs/docs/services/batch.rst
index fcfb6aba6..12f86a862 100644
--- a/docs/docs/services/batch.rst
+++ b/docs/docs/services/batch.rst
@@ -14,17 +14,6 @@ batch
.. autoclass:: moto.batch.models.BatchBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_batch
- def test_batch_behaviour:
- boto3.client("batch")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] cancel_job
diff --git a/docs/docs/services/budgets.rst b/docs/docs/services/budgets.rst
index c1e977467..56d8721b5 100644
--- a/docs/docs/services/budgets.rst
+++ b/docs/docs/services/budgets.rst
@@ -14,17 +14,6 @@ budgets
.. autoclass:: moto.budgets.models.BudgetsBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_budgets
- def test_budgets_behaviour:
- boto3.client("budgets")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_budget
diff --git a/docs/docs/services/ce.rst b/docs/docs/services/ce.rst
index f889fbb17..77d77b532 100644
--- a/docs/docs/services/ce.rst
+++ b/docs/docs/services/ce.rst
@@ -14,17 +14,6 @@ ce
.. autoclass:: moto.ce.models.CostExplorerBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ce
- def test_ce_behaviour:
- boto3.client("ce")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] create_anomaly_monitor
diff --git a/docs/docs/services/cloudformation.rst b/docs/docs/services/cloudformation.rst
index 3dc823fb2..28babf794 100644
--- a/docs/docs/services/cloudformation.rst
+++ b/docs/docs/services/cloudformation.rst
@@ -14,17 +14,6 @@ cloudformation
.. autoclass:: moto.cloudformation.models.CloudFormationBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_cloudformation
- def test_cloudformation_behaviour:
- boto3.client("cloudformation")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] activate_organizations_access
diff --git a/docs/docs/services/cloudfront.rst b/docs/docs/services/cloudfront.rst
index cac35592c..c31449d35 100644
--- a/docs/docs/services/cloudfront.rst
+++ b/docs/docs/services/cloudfront.rst
@@ -12,17 +12,6 @@
cloudfront
==========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_cloudfront
- def test_cloudfront_behaviour:
- boto3.client("cloudfront")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] associate_alias
diff --git a/docs/docs/services/cloudtrail.rst b/docs/docs/services/cloudtrail.rst
index 72134381e..df3d49077 100644
--- a/docs/docs/services/cloudtrail.rst
+++ b/docs/docs/services/cloudtrail.rst
@@ -14,17 +14,6 @@ cloudtrail
.. autoclass:: moto.cloudtrail.models.CloudTrailBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_cloudtrail
- def test_cloudtrail_behaviour:
- boto3.client("cloudtrail")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] add_tags
diff --git a/docs/docs/services/cloudwatch.rst b/docs/docs/services/cloudwatch.rst
index 0f44583e3..2578fc416 100644
--- a/docs/docs/services/cloudwatch.rst
+++ b/docs/docs/services/cloudwatch.rst
@@ -12,17 +12,6 @@
cloudwatch
==========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_cloudwatch
- def test_cloudwatch_behaviour:
- boto3.client("cloudwatch")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] delete_alarms
diff --git a/docs/docs/services/codebuild.rst b/docs/docs/services/codebuild.rst
index a0aaa07ed..1db156245 100644
--- a/docs/docs/services/codebuild.rst
+++ b/docs/docs/services/codebuild.rst
@@ -12,17 +12,6 @@
codebuild
=========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_codebuild
- def test_codebuild_behaviour:
- boto3.client("codebuild")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_delete_builds
diff --git a/docs/docs/services/codecommit.rst b/docs/docs/services/codecommit.rst
index dd09e58fd..914220918 100644
--- a/docs/docs/services/codecommit.rst
+++ b/docs/docs/services/codecommit.rst
@@ -12,17 +12,6 @@
codecommit
==========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_codecommit
- def test_codecommit_behaviour:
- boto3.client("codecommit")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] associate_approval_rule_template_with_repository
diff --git a/docs/docs/services/codepipeline.rst b/docs/docs/services/codepipeline.rst
index 6c88634da..9247933f1 100644
--- a/docs/docs/services/codepipeline.rst
+++ b/docs/docs/services/codepipeline.rst
@@ -12,17 +12,6 @@
codepipeline
============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_codepipeline
- def test_codepipeline_behaviour:
- boto3.client("codepipeline")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] acknowledge_job
diff --git a/docs/docs/services/cognito-identity.rst b/docs/docs/services/cognito-identity.rst
index f8b596a79..fb6042267 100644
--- a/docs/docs/services/cognito-identity.rst
+++ b/docs/docs/services/cognito-identity.rst
@@ -12,17 +12,6 @@
cognito-identity
================
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_cognitoidentity
- def test_cognitoidentity_behaviour:
- boto3.client("cognito-identity")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_identity_pool
diff --git a/docs/docs/services/cognito-idp.rst b/docs/docs/services/cognito-idp.rst
index 3b487dc2f..4de7c8f9b 100644
--- a/docs/docs/services/cognito-idp.rst
+++ b/docs/docs/services/cognito-idp.rst
@@ -14,17 +14,6 @@ cognito-idp
.. autoclass:: moto.cognitoidp.models.CognitoIdpBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_cognitoidp
- def test_cognitoidp_behaviour:
- boto3.client("cognito-idp")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] add_custom_attributes
diff --git a/docs/docs/services/comprehend.rst b/docs/docs/services/comprehend.rst
index a7255a75f..90f194bb8 100644
--- a/docs/docs/services/comprehend.rst
+++ b/docs/docs/services/comprehend.rst
@@ -14,17 +14,6 @@ comprehend
.. autoclass:: moto.comprehend.models.ComprehendBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_comprehend
- def test_comprehend_behaviour:
- boto3.client("comprehend")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_detect_dominant_language
diff --git a/docs/docs/services/config.rst b/docs/docs/services/config.rst
index a1c919599..8eb476e0b 100644
--- a/docs/docs/services/config.rst
+++ b/docs/docs/services/config.rst
@@ -12,17 +12,6 @@
config
======
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_config
- def test_config_behaviour:
- boto3.client("config")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] batch_get_aggregate_resource_config
diff --git a/docs/docs/services/databrew.rst b/docs/docs/services/databrew.rst
index 7b8dea091..db5cea250 100644
--- a/docs/docs/services/databrew.rst
+++ b/docs/docs/services/databrew.rst
@@ -12,17 +12,6 @@
databrew
========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_databrew
- def test_databrew_behaviour:
- boto3.client("databrew")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_delete_recipe_version
diff --git a/docs/docs/services/datapipeline.rst b/docs/docs/services/datapipeline.rst
index c3deab7ce..62572457a 100644
--- a/docs/docs/services/datapipeline.rst
+++ b/docs/docs/services/datapipeline.rst
@@ -12,17 +12,6 @@
datapipeline
============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_datapipeline
- def test_datapipeline_behaviour:
- boto3.client("datapipeline")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] activate_pipeline
diff --git a/docs/docs/services/datasync.rst b/docs/docs/services/datasync.rst
index 4d72d2f34..44eeed11c 100644
--- a/docs/docs/services/datasync.rst
+++ b/docs/docs/services/datasync.rst
@@ -12,17 +12,6 @@
datasync
========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_datasync
- def test_datasync_behaviour:
- boto3.client("datasync")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_storage_system
diff --git a/docs/docs/services/dax.rst b/docs/docs/services/dax.rst
index bd10c023f..ab4720b71 100644
--- a/docs/docs/services/dax.rst
+++ b/docs/docs/services/dax.rst
@@ -12,17 +12,6 @@
dax
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_dax
- def test_dax_behaviour:
- boto3.client("dax")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_cluster
diff --git a/docs/docs/services/dms.rst b/docs/docs/services/dms.rst
index 1386f093a..62d76e06c 100644
--- a/docs/docs/services/dms.rst
+++ b/docs/docs/services/dms.rst
@@ -12,17 +12,6 @@
dms
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_dms
- def test_dms_behaviour:
- boto3.client("dms")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_tags_to_resource
diff --git a/docs/docs/services/ds.rst b/docs/docs/services/ds.rst
index 8e449175a..105c341f5 100644
--- a/docs/docs/services/ds.rst
+++ b/docs/docs/services/ds.rst
@@ -14,17 +14,6 @@ ds
.. autoclass:: moto.ds.models.DirectoryServiceBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ds
- def test_ds_behaviour:
- boto3.client("ds")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] accept_shared_directory
diff --git a/docs/docs/services/dynamodb.rst b/docs/docs/services/dynamodb.rst
index fc37b3e28..8f7cede80 100644
--- a/docs/docs/services/dynamodb.rst
+++ b/docs/docs/services/dynamodb.rst
@@ -12,17 +12,6 @@
dynamodb
========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_dynamodb
- def test_dynamodb_behaviour:
- boto3.client("dynamodb")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] batch_execute_statement
diff --git a/docs/docs/services/dynamodbstreams.rst b/docs/docs/services/dynamodbstreams.rst
index f7a33e414..19525a108 100644
--- a/docs/docs/services/dynamodbstreams.rst
+++ b/docs/docs/services/dynamodbstreams.rst
@@ -12,17 +12,6 @@
dynamodbstreams
===============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_dynamodbstreams
- def test_dynamodbstreams_behaviour:
- boto3.client("dynamodbstreams")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] describe_stream
diff --git a/docs/docs/services/ebs.rst b/docs/docs/services/ebs.rst
index 74b9a053b..1f798e242 100644
--- a/docs/docs/services/ebs.rst
+++ b/docs/docs/services/ebs.rst
@@ -14,17 +14,6 @@ ebs
.. autoclass:: moto.ebs.models.EBSBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ebs
- def test_ebs_behaviour:
- boto3.client("ebs")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] complete_snapshot
diff --git a/docs/docs/services/ec2-instance-connect.rst b/docs/docs/services/ec2-instance-connect.rst
index 94e622761..008aab511 100644
--- a/docs/docs/services/ec2-instance-connect.rst
+++ b/docs/docs/services/ec2-instance-connect.rst
@@ -12,17 +12,6 @@
ec2-instance-connect
====================
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ec2instanceconnect
- def test_ec2instanceconnect_behaviour:
- boto3.client("ec2-instance-connect")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] send_serial_console_ssh_public_key
diff --git a/docs/docs/services/ec2.rst b/docs/docs/services/ec2.rst
index 866de236c..4398c475c 100644
--- a/docs/docs/services/ec2.rst
+++ b/docs/docs/services/ec2.rst
@@ -14,17 +14,6 @@ ec2
.. autoclass:: moto.ec2.models.EC2Backend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ec2
- def test_ec2_behaviour:
- boto3.client("ec2")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] accept_address_transfer
diff --git a/docs/docs/services/ecr.rst b/docs/docs/services/ecr.rst
index 857f737af..c03c6ac7f 100644
--- a/docs/docs/services/ecr.rst
+++ b/docs/docs/services/ecr.rst
@@ -12,17 +12,6 @@
ecr
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ecr
- def test_ecr_behaviour:
- boto3.client("ecr")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_check_layer_availability
diff --git a/docs/docs/services/ecs.rst b/docs/docs/services/ecs.rst
index 735415407..4ca3d861d 100644
--- a/docs/docs/services/ecs.rst
+++ b/docs/docs/services/ecs.rst
@@ -14,17 +14,6 @@ ecs
.. autoclass:: moto.ecs.models.EC2ContainerServiceBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ecs
- def test_ecs_behaviour:
- boto3.client("ecs")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_capacity_provider
diff --git a/docs/docs/services/efs.rst b/docs/docs/services/efs.rst
index bad8c2223..fa9626395 100644
--- a/docs/docs/services/efs.rst
+++ b/docs/docs/services/efs.rst
@@ -14,17 +14,6 @@ efs
.. autoclass:: moto.efs.models.EFSBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_efs
- def test_efs_behaviour:
- boto3.client("efs")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_access_point
diff --git a/docs/docs/services/eks.rst b/docs/docs/services/eks.rst
index ecb31c1bb..410409e9e 100644
--- a/docs/docs/services/eks.rst
+++ b/docs/docs/services/eks.rst
@@ -12,17 +12,6 @@
eks
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_eks
- def test_eks_behaviour:
- boto3.client("eks")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] associate_access_policy
diff --git a/docs/docs/services/elasticache.rst b/docs/docs/services/elasticache.rst
index ff44a3044..f11f21dfd 100644
--- a/docs/docs/services/elasticache.rst
+++ b/docs/docs/services/elasticache.rst
@@ -14,17 +14,6 @@ elasticache
.. autoclass:: moto.elasticache.models.ElastiCacheBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_elasticache
- def test_elasticache_behaviour:
- boto3.client("elasticache")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_tags_to_resource
diff --git a/docs/docs/services/elasticbeanstalk.rst b/docs/docs/services/elasticbeanstalk.rst
index 93e54cdaf..07504798e 100644
--- a/docs/docs/services/elasticbeanstalk.rst
+++ b/docs/docs/services/elasticbeanstalk.rst
@@ -12,17 +12,6 @@
elasticbeanstalk
================
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_elasticbeanstalk
- def test_elasticbeanstalk_behaviour:
- boto3.client("elasticbeanstalk")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] abort_environment_update
diff --git a/docs/docs/services/elastictranscoder.rst b/docs/docs/services/elastictranscoder.rst
index b273ab55b..720a6889f 100644
--- a/docs/docs/services/elastictranscoder.rst
+++ b/docs/docs/services/elastictranscoder.rst
@@ -12,17 +12,6 @@
elastictranscoder
=================
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_elastictranscoder
- def test_elastictranscoder_behaviour:
- boto3.client("elastictranscoder")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] cancel_job
diff --git a/docs/docs/services/elb.rst b/docs/docs/services/elb.rst
index 6286d27a5..aff8a1baa 100644
--- a/docs/docs/services/elb.rst
+++ b/docs/docs/services/elb.rst
@@ -12,17 +12,6 @@
elb
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_elb
- def test_elb_behaviour:
- boto3.client("elb")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_tags
diff --git a/docs/docs/services/elbv2.rst b/docs/docs/services/elbv2.rst
index 4bca500fa..f78cb6792 100644
--- a/docs/docs/services/elbv2.rst
+++ b/docs/docs/services/elbv2.rst
@@ -12,17 +12,6 @@
elbv2
=====
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_elbv2
- def test_elbv2_behaviour:
- boto3.client("elbv2")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] add_listener_certificates
diff --git a/docs/docs/services/emr-containers.rst b/docs/docs/services/emr-containers.rst
index 9f48a685f..779f0d27f 100644
--- a/docs/docs/services/emr-containers.rst
+++ b/docs/docs/services/emr-containers.rst
@@ -14,17 +14,6 @@ emr-containers
.. autoclass:: moto.emrcontainers.models.EMRContainersBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_emrcontainers
- def test_emrcontainers_behaviour:
- boto3.client("emr-containers")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] cancel_job_run
diff --git a/docs/docs/services/emr-serverless.rst b/docs/docs/services/emr-serverless.rst
index 3adacb74c..4513d1743 100644
--- a/docs/docs/services/emr-serverless.rst
+++ b/docs/docs/services/emr-serverless.rst
@@ -14,17 +14,6 @@ emr-serverless
.. autoclass:: moto.emrserverless.models.EMRServerlessBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_emrserverless
- def test_emrserverless_behaviour:
- boto3.client("emr-serverless")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] cancel_job_run
diff --git a/docs/docs/services/emr.rst b/docs/docs/services/emr.rst
index 595fb150c..006f2fd60 100644
--- a/docs/docs/services/emr.rst
+++ b/docs/docs/services/emr.rst
@@ -12,17 +12,6 @@
emr
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_emr
- def test_emr_behaviour:
- boto3.client("emr")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_instance_fleet
diff --git a/docs/docs/services/es.rst b/docs/docs/services/es.rst
index 0d8c92232..dcee8b764 100644
--- a/docs/docs/services/es.rst
+++ b/docs/docs/services/es.rst
@@ -14,17 +14,6 @@ es
.. autoclass:: moto.es.models.ElasticsearchServiceBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_es
- def test_es_behaviour:
- boto3.client("es")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] accept_inbound_cross_cluster_search_connection
diff --git a/docs/docs/services/events.rst b/docs/docs/services/events.rst
index e7e6e1aaf..823156f24 100644
--- a/docs/docs/services/events.rst
+++ b/docs/docs/services/events.rst
@@ -14,17 +14,6 @@ events
.. autoclass:: moto.events.models.EventsBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_events
- def test_events_behaviour:
- boto3.client("events")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] activate_event_source
diff --git a/docs/docs/services/firehose.rst b/docs/docs/services/firehose.rst
index c472063d9..662159780 100644
--- a/docs/docs/services/firehose.rst
+++ b/docs/docs/services/firehose.rst
@@ -14,17 +14,6 @@ firehose
.. autoclass:: moto.firehose.models.FirehoseBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_firehose
- def test_firehose_behaviour:
- boto3.client("firehose")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_delivery_stream
diff --git a/docs/docs/services/forecast.rst b/docs/docs/services/forecast.rst
index a8aec17ef..fb3959296 100644
--- a/docs/docs/services/forecast.rst
+++ b/docs/docs/services/forecast.rst
@@ -12,17 +12,6 @@
forecast
========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_forecast
- def test_forecast_behaviour:
- boto3.client("forecast")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] create_auto_predictor
diff --git a/docs/docs/services/glacier.rst b/docs/docs/services/glacier.rst
index c64c74fc9..44e4fcca2 100644
--- a/docs/docs/services/glacier.rst
+++ b/docs/docs/services/glacier.rst
@@ -12,17 +12,6 @@
glacier
=======
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_glacier
- def test_glacier_behaviour:
- boto3.client("glacier")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] abort_multipart_upload
diff --git a/docs/docs/services/glue.rst b/docs/docs/services/glue.rst
index 58fd07358..72fb46094 100644
--- a/docs/docs/services/glue.rst
+++ b/docs/docs/services/glue.rst
@@ -12,17 +12,6 @@
glue
====
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_glue
- def test_glue_behaviour:
- boto3.client("glue")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] batch_create_partition
diff --git a/docs/docs/services/greengrass.rst b/docs/docs/services/greengrass.rst
index e524226d6..0fb6ea460 100644
--- a/docs/docs/services/greengrass.rst
+++ b/docs/docs/services/greengrass.rst
@@ -12,17 +12,6 @@
greengrass
==========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_greengrass
- def test_greengrass_behaviour:
- boto3.client("greengrass")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] associate_role_to_group
diff --git a/docs/docs/services/guardduty.rst b/docs/docs/services/guardduty.rst
index c339fb57c..359f7247f 100644
--- a/docs/docs/services/guardduty.rst
+++ b/docs/docs/services/guardduty.rst
@@ -12,17 +12,6 @@
guardduty
=========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_guardduty
- def test_guardduty_behaviour:
- boto3.client("guardduty")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] accept_administrator_invitation
diff --git a/docs/docs/services/iam.rst b/docs/docs/services/iam.rst
index 365a0d9f9..86655948c 100644
--- a/docs/docs/services/iam.rst
+++ b/docs/docs/services/iam.rst
@@ -12,17 +12,6 @@
iam
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_iam
- def test_iam_behaviour:
- boto3.client("iam")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_client_id_to_open_id_connect_provider
diff --git a/docs/docs/services/identitystore.rst b/docs/docs/services/identitystore.rst
index 78a153af3..a588595bf 100644
--- a/docs/docs/services/identitystore.rst
+++ b/docs/docs/services/identitystore.rst
@@ -14,17 +14,6 @@ identitystore
.. autoclass:: moto.identitystore.models.IdentityStoreBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_identitystore
- def test_identitystore_behaviour:
- boto3.client("identitystore")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_group
diff --git a/docs/docs/services/index.rst b/docs/docs/services/index.rst
index 34d4fa3d3..1a27ed0a4 100644
--- a/docs/docs/services/index.rst
+++ b/docs/docs/services/index.rst
@@ -6,24 +6,6 @@ Implemented Services
====================
Please see a list of all currently supported services. Each service will have a list of the endpoints that are implemented.
-Each service will also have an example on how to mock an individual service.
-
-Note that you can mock multiple services at the same time:
-
-.. sourcecode:: python
-
- @mock_s3
- @mock_sqs
- def test_both_s3_and_sqs():
- ...
-
-
-.. sourcecode:: python
-
- @mock_all()
- def test_all_supported_services_at_the_same_time():
- ...
-
.. toctree::
:titlesonly:
diff --git a/docs/docs/services/inspector2.rst b/docs/docs/services/inspector2.rst
index 8c8d39e8e..ccde2b5d3 100644
--- a/docs/docs/services/inspector2.rst
+++ b/docs/docs/services/inspector2.rst
@@ -12,17 +12,6 @@
inspector2
==========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_inspector2
- def test_inspector2_behaviour:
- boto3.client("inspector2")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] associate_member
diff --git a/docs/docs/services/iot-data.rst b/docs/docs/services/iot-data.rst
index 09506a20a..daa99e83c 100644
--- a/docs/docs/services/iot-data.rst
+++ b/docs/docs/services/iot-data.rst
@@ -12,17 +12,6 @@
iot-data
========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_iotdata
- def test_iotdata_behaviour:
- boto3.client("iot-data")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] delete_thing_shadow
diff --git a/docs/docs/services/iot.rst b/docs/docs/services/iot.rst
index 5b9c1c847..669556954 100644
--- a/docs/docs/services/iot.rst
+++ b/docs/docs/services/iot.rst
@@ -12,17 +12,6 @@
iot
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_iot
- def test_iot_behaviour:
- boto3.client("iot")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] accept_certificate_transfer
diff --git a/docs/docs/services/ivs.rst b/docs/docs/services/ivs.rst
index e3b0f66e3..b5f713126 100644
--- a/docs/docs/services/ivs.rst
+++ b/docs/docs/services/ivs.rst
@@ -14,17 +14,6 @@ ivs
.. autoclass:: moto.ivs.models.IVSBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ivs
- def test_ivs_behaviour:
- boto3.client("ivs")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] batch_get_channel
diff --git a/docs/docs/services/kinesis-video-archived-media.rst b/docs/docs/services/kinesis-video-archived-media.rst
index 3dcf80432..c7259d92c 100644
--- a/docs/docs/services/kinesis-video-archived-media.rst
+++ b/docs/docs/services/kinesis-video-archived-media.rst
@@ -12,17 +12,6 @@
kinesis-video-archived-media
============================
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_kinesisvideoarchivedmedia
- def test_kinesisvideoarchivedmedia_behaviour:
- boto3.client("kinesis-video-archived-media")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] get_clip
diff --git a/docs/docs/services/kinesis.rst b/docs/docs/services/kinesis.rst
index a456deeef..84a1d3fc8 100644
--- a/docs/docs/services/kinesis.rst
+++ b/docs/docs/services/kinesis.rst
@@ -12,17 +12,6 @@
kinesis
=======
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_kinesis
- def test_kinesis_behaviour:
- boto3.client("kinesis")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] add_tags_to_stream
diff --git a/docs/docs/services/kinesisvideo.rst b/docs/docs/services/kinesisvideo.rst
index 75d188dbb..1b85fb5a8 100644
--- a/docs/docs/services/kinesisvideo.rst
+++ b/docs/docs/services/kinesisvideo.rst
@@ -12,17 +12,6 @@
kinesisvideo
============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_kinesisvideo
- def test_kinesisvideo_behaviour:
- boto3.client("kinesisvideo")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] create_signaling_channel
diff --git a/docs/docs/services/kms.rst b/docs/docs/services/kms.rst
index b6ce534a5..4395958d8 100644
--- a/docs/docs/services/kms.rst
+++ b/docs/docs/services/kms.rst
@@ -12,17 +12,6 @@
kms
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_kms
- def test_kms_behaviour:
- boto3.client("kms")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] cancel_key_deletion
diff --git a/docs/docs/services/lakeformation.rst b/docs/docs/services/lakeformation.rst
index 13b5dc8c1..58fd04c93 100644
--- a/docs/docs/services/lakeformation.rst
+++ b/docs/docs/services/lakeformation.rst
@@ -12,17 +12,6 @@
lakeformation
=============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_lakeformation
- def test_lakeformation_behaviour:
- boto3.client("lakeformation")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] add_lf_tags_to_resource
diff --git a/docs/docs/services/lambda.rst b/docs/docs/services/lambda.rst
index ecc51425b..dbbad8de8 100644
--- a/docs/docs/services/lambda.rst
+++ b/docs/docs/services/lambda.rst
@@ -14,17 +14,6 @@ lambda
.. autoclass:: moto.awslambda.models.LambdaBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_lambda
- def test_lambda_behaviour:
- boto3.client("lambda")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_layer_version_permission
diff --git a/docs/docs/services/logs.rst b/docs/docs/services/logs.rst
index 395c1e82d..b18c1586d 100644
--- a/docs/docs/services/logs.rst
+++ b/docs/docs/services/logs.rst
@@ -12,17 +12,6 @@
logs
====
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_logs
- def test_logs_behaviour:
- boto3.client("logs")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] associate_kms_key
diff --git a/docs/docs/services/managedblockchain.rst b/docs/docs/services/managedblockchain.rst
index 4cbd70c72..baa980a22 100644
--- a/docs/docs/services/managedblockchain.rst
+++ b/docs/docs/services/managedblockchain.rst
@@ -12,17 +12,6 @@
managedblockchain
=================
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_managedblockchain
- def test_managedblockchain_behaviour:
- boto3.client("managedblockchain")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] create_accessor
diff --git a/docs/docs/services/mediaconnect.rst b/docs/docs/services/mediaconnect.rst
index 4c415253d..4ec97a42b 100644
--- a/docs/docs/services/mediaconnect.rst
+++ b/docs/docs/services/mediaconnect.rst
@@ -12,17 +12,6 @@
mediaconnect
============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_mediaconnect
- def test_mediaconnect_behaviour:
- boto3.client("mediaconnect")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_bridge_outputs
diff --git a/docs/docs/services/medialive.rst b/docs/docs/services/medialive.rst
index efbab63fe..5509f0486 100644
--- a/docs/docs/services/medialive.rst
+++ b/docs/docs/services/medialive.rst
@@ -12,17 +12,6 @@
medialive
=========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_medialive
- def test_medialive_behaviour:
- boto3.client("medialive")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] accept_input_device_transfer
diff --git a/docs/docs/services/mediapackage.rst b/docs/docs/services/mediapackage.rst
index 2b0f7dbe5..1ad3d2c22 100644
--- a/docs/docs/services/mediapackage.rst
+++ b/docs/docs/services/mediapackage.rst
@@ -12,17 +12,6 @@
mediapackage
============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_mediapackage
- def test_mediapackage_behaviour:
- boto3.client("mediapackage")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] configure_logs
diff --git a/docs/docs/services/mediastore-data.rst b/docs/docs/services/mediastore-data.rst
index b5f5bc417..fd5b81566 100644
--- a/docs/docs/services/mediastore-data.rst
+++ b/docs/docs/services/mediastore-data.rst
@@ -12,17 +12,6 @@
mediastore-data
===============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_mediastoredata
- def test_mediastoredata_behaviour:
- boto3.client("mediastore-data")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] delete_object
diff --git a/docs/docs/services/mediastore.rst b/docs/docs/services/mediastore.rst
index 2ab9b45a8..7e8e2b025 100644
--- a/docs/docs/services/mediastore.rst
+++ b/docs/docs/services/mediastore.rst
@@ -12,17 +12,6 @@
mediastore
==========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_mediastore
- def test_mediastore_behaviour:
- boto3.client("mediastore")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_container
diff --git a/docs/docs/services/meteringmarketplace.rst b/docs/docs/services/meteringmarketplace.rst
index 36d0cfe86..ca884d7d9 100644
--- a/docs/docs/services/meteringmarketplace.rst
+++ b/docs/docs/services/meteringmarketplace.rst
@@ -12,17 +12,6 @@
meteringmarketplace
===================
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_meteringmarketplace
- def test_meteringmarketplace_behaviour:
- boto3.client("meteringmarketplace")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] batch_meter_usage
diff --git a/docs/docs/services/mq.rst b/docs/docs/services/mq.rst
index 8d87185aa..41b08faaf 100644
--- a/docs/docs/services/mq.rst
+++ b/docs/docs/services/mq.rst
@@ -14,17 +14,6 @@ mq
.. autoclass:: moto.mq.models.MQBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_mq
- def test_mq_behaviour:
- boto3.client("mq")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_broker
diff --git a/docs/docs/services/neptune.rst b/docs/docs/services/neptune.rst
index a41846118..4a39a9180 100644
--- a/docs/docs/services/neptune.rst
+++ b/docs/docs/services/neptune.rst
@@ -14,17 +14,6 @@ neptune
.. autoclass:: moto.neptune.models.NeptuneBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_neptune
- def test_neptune_behaviour:
- boto3.client("neptune")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_role_to_db_cluster
diff --git a/docs/docs/services/opensearch.rst b/docs/docs/services/opensearch.rst
index 7402bf828..75e6fb221 100644
--- a/docs/docs/services/opensearch.rst
+++ b/docs/docs/services/opensearch.rst
@@ -14,17 +14,6 @@ opensearch
.. autoclass:: moto.opensearch.models.OpenSearchServiceBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_opensearch
- def test_opensearch_behaviour:
- boto3.client("opensearch")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] accept_inbound_connection
diff --git a/docs/docs/services/opsworks.rst b/docs/docs/services/opsworks.rst
index b93894bf7..06328e48f 100644
--- a/docs/docs/services/opsworks.rst
+++ b/docs/docs/services/opsworks.rst
@@ -12,17 +12,6 @@
opsworks
========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_opsworks
- def test_opsworks_behaviour:
- boto3.client("opsworks")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] assign_instance
diff --git a/docs/docs/services/organizations.rst b/docs/docs/services/organizations.rst
index dd84a63de..ac1ff53b2 100644
--- a/docs/docs/services/organizations.rst
+++ b/docs/docs/services/organizations.rst
@@ -12,17 +12,6 @@
organizations
=============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_organizations
- def test_organizations_behaviour:
- boto3.client("organizations")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] accept_handshake
diff --git a/docs/docs/services/panorama.rst b/docs/docs/services/panorama.rst
index f2a7f25ee..116fd497f 100644
--- a/docs/docs/services/panorama.rst
+++ b/docs/docs/services/panorama.rst
@@ -12,17 +12,6 @@
panorama
========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_panorama
- def test_panorama_behaviour:
- boto3.client("panorama")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] create_application_instance
diff --git a/docs/docs/services/personalize.rst b/docs/docs/services/personalize.rst
index 943a533dc..2a07c5726 100644
--- a/docs/docs/services/personalize.rst
+++ b/docs/docs/services/personalize.rst
@@ -14,17 +14,6 @@ personalize
.. autoclass:: moto.personalize.models.PersonalizeBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_personalize
- def test_personalize_behaviour:
- boto3.client("personalize")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] create_batch_inference_job
diff --git a/docs/docs/services/pinpoint.rst b/docs/docs/services/pinpoint.rst
index 1e0dc01c9..3aa4c8ea8 100644
--- a/docs/docs/services/pinpoint.rst
+++ b/docs/docs/services/pinpoint.rst
@@ -14,17 +14,6 @@ pinpoint
.. autoclass:: moto.pinpoint.models.PinpointBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_pinpoint
- def test_pinpoint_behaviour:
- boto3.client("pinpoint")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_app
diff --git a/docs/docs/services/polly.rst b/docs/docs/services/polly.rst
index a9dffebd9..73847efd8 100644
--- a/docs/docs/services/polly.rst
+++ b/docs/docs/services/polly.rst
@@ -12,17 +12,6 @@
polly
=====
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_polly
- def test_polly_behaviour:
- boto3.client("polly")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] delete_lexicon
diff --git a/docs/docs/services/quicksight.rst b/docs/docs/services/quicksight.rst
index 0690940e3..15ff6cd9c 100644
--- a/docs/docs/services/quicksight.rst
+++ b/docs/docs/services/quicksight.rst
@@ -14,17 +14,6 @@ quicksight
.. autoclass:: moto.quicksight.models.QuickSightBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_quicksight
- def test_quicksight_behaviour:
- boto3.client("quicksight")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] cancel_ingestion
diff --git a/docs/docs/services/ram.rst b/docs/docs/services/ram.rst
index f60258cbd..f78561123 100644
--- a/docs/docs/services/ram.rst
+++ b/docs/docs/services/ram.rst
@@ -12,17 +12,6 @@
ram
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ram
- def test_ram_behaviour:
- boto3.client("ram")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] accept_resource_share_invitation
diff --git a/docs/docs/services/rds-data.rst b/docs/docs/services/rds-data.rst
index 233418847..07ec2a91f 100644
--- a/docs/docs/services/rds-data.rst
+++ b/docs/docs/services/rds-data.rst
@@ -12,17 +12,6 @@
rds-data
========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_rdsdata
- def test_rdsdata_behaviour:
- boto3.client("rds-data")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_execute_statement
diff --git a/docs/docs/services/rds.rst b/docs/docs/services/rds.rst
index 6eb5e48ae..a647e0655 100644
--- a/docs/docs/services/rds.rst
+++ b/docs/docs/services/rds.rst
@@ -12,17 +12,6 @@
rds
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_rds
- def test_rds_behaviour:
- boto3.client("rds")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_role_to_db_cluster
diff --git a/docs/docs/services/redshift-data.rst b/docs/docs/services/redshift-data.rst
index 7da592ffd..9c524f81d 100644
--- a/docs/docs/services/redshift-data.rst
+++ b/docs/docs/services/redshift-data.rst
@@ -12,17 +12,6 @@
redshift-data
=============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_redshiftdata
- def test_redshiftdata_behaviour:
- boto3.client("redshift-data")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_execute_statement
diff --git a/docs/docs/services/redshift.rst b/docs/docs/services/redshift.rst
index 6abb8ead6..a256ae261 100644
--- a/docs/docs/services/redshift.rst
+++ b/docs/docs/services/redshift.rst
@@ -12,17 +12,6 @@
redshift
========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_redshift
- def test_redshift_behaviour:
- boto3.client("redshift")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] accept_reserved_node_exchange
diff --git a/docs/docs/services/rekognition.rst b/docs/docs/services/rekognition.rst
index f297f190c..9b6243fc8 100644
--- a/docs/docs/services/rekognition.rst
+++ b/docs/docs/services/rekognition.rst
@@ -14,17 +14,6 @@ rekognition
.. autoclass:: moto.rekognition.models.RekognitionBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_rekognition
- def test_rekognition_behaviour:
- boto3.client("rekognition")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] associate_faces
diff --git a/docs/docs/services/resource-groups.rst b/docs/docs/services/resource-groups.rst
index 37335d015..200b1fc78 100644
--- a/docs/docs/services/resource-groups.rst
+++ b/docs/docs/services/resource-groups.rst
@@ -12,17 +12,6 @@
resource-groups
===============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_resourcegroups
- def test_resourcegroups_behaviour:
- boto3.client("resource-groups")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_group
diff --git a/docs/docs/services/resourcegroupstaggingapi.rst b/docs/docs/services/resourcegroupstaggingapi.rst
index 98c033535..8a675e343 100644
--- a/docs/docs/services/resourcegroupstaggingapi.rst
+++ b/docs/docs/services/resourcegroupstaggingapi.rst
@@ -12,17 +12,6 @@
resourcegroupstaggingapi
========================
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_resourcegroupstaggingapi
- def test_resourcegroupstaggingapi_behaviour:
- boto3.client("resourcegroupstaggingapi")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] describe_report_creation
diff --git a/docs/docs/services/robomaker.rst b/docs/docs/services/robomaker.rst
index 33c099ab3..1934eaff9 100644
--- a/docs/docs/services/robomaker.rst
+++ b/docs/docs/services/robomaker.rst
@@ -12,17 +12,6 @@
robomaker
=========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_robomaker
- def test_robomaker_behaviour:
- boto3.client("robomaker")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_delete_worlds
diff --git a/docs/docs/services/route53.rst b/docs/docs/services/route53.rst
index 60130848c..cc449fc0d 100644
--- a/docs/docs/services/route53.rst
+++ b/docs/docs/services/route53.rst
@@ -12,17 +12,6 @@
route53
=======
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_route53
- def test_route53_behaviour:
- boto3.client("route53")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] activate_key_signing_key
diff --git a/docs/docs/services/route53resolver.rst b/docs/docs/services/route53resolver.rst
index 2e9ef9a4b..8189920b9 100644
--- a/docs/docs/services/route53resolver.rst
+++ b/docs/docs/services/route53resolver.rst
@@ -14,17 +14,6 @@ route53resolver
.. autoclass:: moto.route53resolver.models.Route53ResolverBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_route53resolver
- def test_route53resolver_behaviour:
- boto3.client("route53resolver")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] associate_firewall_rule_group
diff --git a/docs/docs/services/s3.rst b/docs/docs/services/s3.rst
index 88eef2c87..389f827a4 100644
--- a/docs/docs/services/s3.rst
+++ b/docs/docs/services/s3.rst
@@ -14,17 +14,6 @@ s3
.. autoclass:: moto.s3.models.S3Backend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_s3
- def test_s3_behaviour:
- boto3.client("s3")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] abort_multipart_upload
diff --git a/docs/docs/services/s3control.rst b/docs/docs/services/s3control.rst
index d4224f091..c5476c1cb 100644
--- a/docs/docs/services/s3control.rst
+++ b/docs/docs/services/s3control.rst
@@ -12,17 +12,6 @@
s3control
=========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_s3control
- def test_s3control_behaviour:
- boto3.client("s3control")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] associate_access_grants_identity_center
diff --git a/docs/docs/services/sagemaker-runtime.rst b/docs/docs/services/sagemaker-runtime.rst
index 8c9352f52..68c711f83 100644
--- a/docs/docs/services/sagemaker-runtime.rst
+++ b/docs/docs/services/sagemaker-runtime.rst
@@ -14,17 +14,6 @@ sagemaker-runtime
.. autoclass:: moto.sagemakerruntime.models.SageMakerRuntimeBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_sagemakerruntime
- def test_sagemakerruntime_behaviour:
- boto3.client("sagemaker-runtime")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] invoke_endpoint
diff --git a/docs/docs/services/sagemaker.rst b/docs/docs/services/sagemaker.rst
index 50a86186f..c7a2cb9e5 100644
--- a/docs/docs/services/sagemaker.rst
+++ b/docs/docs/services/sagemaker.rst
@@ -12,17 +12,6 @@
sagemaker
=========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_sagemaker
- def test_sagemaker_behaviour:
- boto3.client("sagemaker")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_association
diff --git a/docs/docs/services/scheduler.rst b/docs/docs/services/scheduler.rst
index 029553b9f..ced78b900 100644
--- a/docs/docs/services/scheduler.rst
+++ b/docs/docs/services/scheduler.rst
@@ -14,17 +14,6 @@ scheduler
.. autoclass:: moto.scheduler.models.EventBridgeSchedulerBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_scheduler
- def test_scheduler_behaviour:
- boto3.client("scheduler")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_schedule
diff --git a/docs/docs/services/sdb.rst b/docs/docs/services/sdb.rst
index d877f4b00..fd4e67d3f 100644
--- a/docs/docs/services/sdb.rst
+++ b/docs/docs/services/sdb.rst
@@ -12,17 +12,6 @@
sdb
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_sdb
- def test_sdb_behaviour:
- boto3.client("sdb")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_delete_attributes
diff --git a/docs/docs/services/secretsmanager.rst b/docs/docs/services/secretsmanager.rst
index 24210f931..a3209a6ea 100644
--- a/docs/docs/services/secretsmanager.rst
+++ b/docs/docs/services/secretsmanager.rst
@@ -12,17 +12,6 @@
secretsmanager
==============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_secretsmanager
- def test_secretsmanager_behaviour:
- boto3.client("secretsmanager")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_get_secret_value
diff --git a/docs/docs/services/service-quotas.rst b/docs/docs/services/service-quotas.rst
index bbbd58af3..3e19c9895 100644
--- a/docs/docs/services/service-quotas.rst
+++ b/docs/docs/services/service-quotas.rst
@@ -14,17 +14,6 @@ service-quotas
.. autoclass:: moto.servicequotas.models.ServiceQuotasBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_servicequotas
- def test_servicequotas_behaviour:
- boto3.client("service-quotas")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] associate_service_quota_template
diff --git a/docs/docs/services/servicediscovery.rst b/docs/docs/services/servicediscovery.rst
index 08fe3b774..489b459d1 100644
--- a/docs/docs/services/servicediscovery.rst
+++ b/docs/docs/services/servicediscovery.rst
@@ -14,17 +14,6 @@ servicediscovery
.. autoclass:: moto.servicediscovery.models.ServiceDiscoveryBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_servicediscovery
- def test_servicediscovery_behaviour:
- boto3.client("servicediscovery")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] create_http_namespace
diff --git a/docs/docs/services/ses.rst b/docs/docs/services/ses.rst
index 02e51c6a5..7fadf5dd5 100644
--- a/docs/docs/services/ses.rst
+++ b/docs/docs/services/ses.rst
@@ -14,17 +14,6 @@ ses
.. autoclass:: moto.ses.models.SESBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ses
- def test_ses_behaviour:
- boto3.client("ses")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] clone_receipt_rule_set
diff --git a/docs/docs/services/sesv2.rst b/docs/docs/services/sesv2.rst
index 7ffe443ee..b11b3b199 100644
--- a/docs/docs/services/sesv2.rst
+++ b/docs/docs/services/sesv2.rst
@@ -14,17 +14,6 @@ sesv2
.. autoclass:: moto.sesv2.models.SESV2Backend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_sesv2
- def test_sesv2_behaviour:
- boto3.client("sesv2")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] batch_get_metric_data
diff --git a/docs/docs/services/signer.rst b/docs/docs/services/signer.rst
index f74807b8a..99cb12745 100644
--- a/docs/docs/services/signer.rst
+++ b/docs/docs/services/signer.rst
@@ -14,17 +14,6 @@ signer
.. autoclass:: moto.signer.models.SignerBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_signer
- def test_signer_behaviour:
- boto3.client("signer")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_profile_permission
diff --git a/docs/docs/services/sns.rst b/docs/docs/services/sns.rst
index a00be10ab..82b8be949 100644
--- a/docs/docs/services/sns.rst
+++ b/docs/docs/services/sns.rst
@@ -14,17 +14,6 @@ sns
.. autoclass:: moto.sns.models.SNSBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_sns
- def test_sns_behaviour:
- boto3.client("sns")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] add_permission
diff --git a/docs/docs/services/sqs.rst b/docs/docs/services/sqs.rst
index 24e4d0bc5..aca1912b5 100644
--- a/docs/docs/services/sqs.rst
+++ b/docs/docs/services/sqs.rst
@@ -12,17 +12,6 @@
sqs
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_sqs
- def test_sqs_behaviour:
- boto3.client("sqs")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] add_permission
diff --git a/docs/docs/services/ssm.rst b/docs/docs/services/ssm.rst
index 8a3349539..24db63e85 100644
--- a/docs/docs/services/ssm.rst
+++ b/docs/docs/services/ssm.rst
@@ -14,17 +14,6 @@ ssm
.. autoclass:: moto.ssm.models.SimpleSystemManagerBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ssm
- def test_ssm_behaviour:
- boto3.client("ssm")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] add_tags_to_resource
diff --git a/docs/docs/services/sso-admin.rst b/docs/docs/services/sso-admin.rst
index b58400745..2768397ff 100644
--- a/docs/docs/services/sso-admin.rst
+++ b/docs/docs/services/sso-admin.rst
@@ -14,17 +14,6 @@ sso-admin
.. autoclass:: moto.ssoadmin.models.SSOAdminBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_ssoadmin
- def test_ssoadmin_behaviour:
- boto3.client("sso-admin")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] attach_customer_managed_policy_reference_to_permission_set
diff --git a/docs/docs/services/stepfunctions.rst b/docs/docs/services/stepfunctions.rst
index 785f3696a..01ae82cfa 100644
--- a/docs/docs/services/stepfunctions.rst
+++ b/docs/docs/services/stepfunctions.rst
@@ -12,17 +12,6 @@
stepfunctions
=============
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_stepfunctions
- def test_stepfunctions_behaviour:
- boto3.client("stepfunctions")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] create_activity
diff --git a/docs/docs/services/sts.rst b/docs/docs/services/sts.rst
index b4596bf33..1759e4b76 100644
--- a/docs/docs/services/sts.rst
+++ b/docs/docs/services/sts.rst
@@ -12,17 +12,6 @@
sts
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_sts
- def test_sts_behaviour:
- boto3.client("sts")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] assume_role
diff --git a/docs/docs/services/support.rst b/docs/docs/services/support.rst
index ea6a205a1..9b654d992 100644
--- a/docs/docs/services/support.rst
+++ b/docs/docs/services/support.rst
@@ -12,17 +12,6 @@
support
=======
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_support
- def test_support_behaviour:
- boto3.client("support")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] add_attachments_to_set
diff --git a/docs/docs/services/swf.rst b/docs/docs/services/swf.rst
index e05eff71c..26ee47df8 100644
--- a/docs/docs/services/swf.rst
+++ b/docs/docs/services/swf.rst
@@ -12,17 +12,6 @@
swf
===
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_swf
- def test_swf_behaviour:
- boto3.client("swf")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] count_closed_workflow_executions
diff --git a/docs/docs/services/textract.rst b/docs/docs/services/textract.rst
index 9ad48949b..6a16fb11a 100644
--- a/docs/docs/services/textract.rst
+++ b/docs/docs/services/textract.rst
@@ -14,17 +14,6 @@ textract
.. autoclass:: moto.textract.models.TextractBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_textract
- def test_textract_behaviour:
- boto3.client("textract")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] analyze_document
diff --git a/docs/docs/services/timestream-write.rst b/docs/docs/services/timestream-write.rst
index 214ffd5a7..a357f5493 100644
--- a/docs/docs/services/timestream-write.rst
+++ b/docs/docs/services/timestream-write.rst
@@ -14,17 +14,6 @@ timestream-write
.. autoclass:: moto.timestreamwrite.models.TimestreamWriteBackend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_timestreamwrite
- def test_timestreamwrite_behaviour:
- boto3.client("timestream-write")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] create_batch_load_task
diff --git a/docs/docs/services/transcribe.rst b/docs/docs/services/transcribe.rst
index 4d3536203..9e703516f 100644
--- a/docs/docs/services/transcribe.rst
+++ b/docs/docs/services/transcribe.rst
@@ -12,17 +12,6 @@
transcribe
==========
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_transcribe
- def test_transcribe_behaviour:
- boto3.client("transcribe")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [ ] create_call_analytics_category
diff --git a/docs/docs/services/wafv2.rst b/docs/docs/services/wafv2.rst
index 469a83524..b77d8e025 100644
--- a/docs/docs/services/wafv2.rst
+++ b/docs/docs/services/wafv2.rst
@@ -14,17 +14,6 @@ wafv2
.. autoclass:: moto.wafv2.models.WAFV2Backend
-|start-h3| Example usage |end-h3|
-
-.. sourcecode:: python
-
- @mock_wafv2
- def test_wafv2_behaviour:
- boto3.client("wafv2")
- ...
-
-
-
|start-h3| Implemented features for this service |end-h3|
- [X] associate_web_acl
diff --git a/moto/__init__.py b/moto/__init__.py
index 4455aa379..1107f1d87 100644
--- a/moto/__init__.py
+++ b/moto/__init__.py
@@ -1,261 +1,43 @@
-import importlib
-import sys
-from contextlib import ContextDecorator
-from typing import (
- TYPE_CHECKING,
- Any,
- Callable,
- List,
- Optional,
- TypeVar,
- Union,
- overload,
-)
+from typing import TYPE_CHECKING, Callable, Dict, Optional, TypeVar, Union, overload
-from moto.core.models import BaseDecorator, BaseMockAWS, base_decorator
+from moto import settings
+from moto.core.models import MockAWS, ProxyModeMockAWS, ServerModeMockAWS
if TYPE_CHECKING:
from typing_extensions import ParamSpec
- from moto.xray import XRaySegment as xray_segment_type
-
P = ParamSpec("P")
-
T = TypeVar("T")
-def lazy_load(
- module_name: str,
- element: str,
- boto3_name: Optional[str] = None,
- backend: Optional[str] = None,
-) -> BaseDecorator:
- @overload
- def f(func: None = None) -> BaseMockAWS:
- ...
-
- @overload
- def f(func: "Callable[P, T]") -> "Callable[P, T]":
- ...
-
- def f(
- func: "Optional[Callable[P, T]]" = None,
- ) -> "Union[BaseMockAWS, Callable[P, T]]":
- module = importlib.import_module(module_name, "moto")
- decorator: base_decorator = getattr(module, element)
- return decorator(func)
-
- setattr(f, "name", module_name.replace(".", ""))
- setattr(f, "element", element)
- setattr(f, "boto3_name", boto3_name or f.name) # type: ignore[attr-defined]
- setattr(f, "backend", backend or f"{f.name}_backends") # type: ignore[attr-defined]
- return f
+@overload
+def mock_aws(func: "Callable[P, T]") -> "Callable[P, T]":
+ ...
-def load_xray_segment() -> Callable[[], "xray_segment_type"]:
- def f() -> "xray_segment_type":
- # We can't use `lazy_load` here
- # XRaySegment will always be run as a context manager
- # I.e.: no function is passed directly: `with XRaySegment()`
- from moto.xray import XRaySegment as xray_segment
-
- return xray_segment()
-
- return f
+@overload
+def mock_aws(
+ func: None = None, config: Optional[Dict[str, Dict[str, bool]]] = None
+) -> "MockAWS":
+ ...
-mock_acm = lazy_load(".acm", "mock_acm")
-mock_acmpca = lazy_load(".acmpca", "mock_acmpca", boto3_name="acm-pca")
-mock_amp = lazy_load(".amp", "mock_amp")
-mock_apigateway = lazy_load(".apigateway", "mock_apigateway")
-mock_apigatewaymanagementapi = lazy_load(
- ".apigatewaymanagementapi", "mock_apigatewaymanagementapi"
-)
-mock_apigatewayv2 = lazy_load(".apigatewayv2", "mock_apigatewayv2")
-mock_appconfig = lazy_load(".appconfig", "mock_appconfig")
-mock_appsync = lazy_load(".appsync", "mock_appsync")
-mock_athena = lazy_load(".athena", "mock_athena")
-mock_applicationautoscaling = lazy_load(
- ".applicationautoscaling", "mock_applicationautoscaling"
-)
-mock_autoscaling = lazy_load(".autoscaling", "mock_autoscaling")
-mock_lambda = lazy_load(
- ".awslambda", "mock_lambda", boto3_name="lambda", backend="lambda_backends"
-)
-mock_lambda_simple = lazy_load(
- ".awslambda_simple",
- "mock_lambda_simple",
- boto3_name="lambda",
- backend="lambda_simple_backends",
-)
-mock_batch = lazy_load(".batch", "mock_batch")
-mock_batch_simple = lazy_load(
- ".batch_simple",
- "mock_batch_simple",
- boto3_name="batch",
- backend="batch_simple_backends",
-)
-mock_budgets = lazy_load(".budgets", "mock_budgets")
-mock_ce = lazy_load(".ce", "mock_ce")
-mock_cloudformation = lazy_load(".cloudformation", "mock_cloudformation")
-mock_cloudfront = lazy_load(".cloudfront", "mock_cloudfront")
-mock_cloudtrail = lazy_load(".cloudtrail", "mock_cloudtrail")
-mock_cloudwatch = lazy_load(".cloudwatch", "mock_cloudwatch")
-mock_codecommit = lazy_load(".codecommit", "mock_codecommit")
-mock_codebuild = lazy_load(".codebuild", "mock_codebuild")
-mock_codepipeline = lazy_load(".codepipeline", "mock_codepipeline")
-mock_cognitoidentity = lazy_load(
- ".cognitoidentity", "mock_cognitoidentity", boto3_name="cognito-identity"
-)
-mock_cognitoidp = lazy_load(".cognitoidp", "mock_cognitoidp", boto3_name="cognito-idp")
-mock_comprehend = lazy_load(".comprehend", "mock_comprehend")
-mock_config = lazy_load(".config", "mock_config")
-mock_databrew = lazy_load(".databrew", "mock_databrew")
-mock_datapipeline = lazy_load(".datapipeline", "mock_datapipeline")
-mock_datasync = lazy_load(".datasync", "mock_datasync")
-mock_dax = lazy_load(".dax", "mock_dax")
-mock_dms = lazy_load(".dms", "mock_dms")
-mock_ds = lazy_load(".ds", "mock_ds")
-mock_dynamodb = lazy_load(".dynamodb", "mock_dynamodb")
-mock_dynamodbstreams = lazy_load(".dynamodbstreams", "mock_dynamodbstreams")
-mock_elasticbeanstalk = lazy_load(
- ".elasticbeanstalk", "mock_elasticbeanstalk", backend="eb_backends"
-)
-mock_ebs = lazy_load(".ebs", "mock_ebs")
-mock_ec2 = lazy_load(".ec2", "mock_ec2")
-mock_ec2instanceconnect = lazy_load(".ec2instanceconnect", "mock_ec2instanceconnect")
-mock_ecr = lazy_load(".ecr", "mock_ecr")
-mock_ecs = lazy_load(".ecs", "mock_ecs")
-mock_efs = lazy_load(".efs", "mock_efs")
-mock_eks = lazy_load(".eks", "mock_eks")
-mock_elasticache = lazy_load(".elasticache", "mock_elasticache")
-mock_elastictranscoder = lazy_load(".elastictranscoder", "mock_elastictranscoder")
-mock_elb = lazy_load(".elb", "mock_elb")
-mock_elbv2 = lazy_load(".elbv2", "mock_elbv2")
-mock_emr = lazy_load(".emr", "mock_emr")
-mock_emrcontainers = lazy_load(
- ".emrcontainers", "mock_emrcontainers", boto3_name="emr-containers"
-)
-mock_emrserverless = lazy_load(
- ".emrserverless", "mock_emrserverless", boto3_name="emr-serverless"
-)
-mock_es = lazy_load(".es", "mock_es")
-mock_events = lazy_load(".events", "mock_events")
-mock_firehose = lazy_load(".firehose", "mock_firehose")
-mock_forecast = lazy_load(".forecast", "mock_forecast")
-mock_greengrass = lazy_load(".greengrass", "mock_greengrass")
-mock_glacier = lazy_load(".glacier", "mock_glacier")
-mock_glue = lazy_load(".glue", "mock_glue")
-mock_guardduty = lazy_load(".guardduty", "mock_guardduty")
-mock_iam = lazy_load(".iam", "mock_iam")
-mock_identitystore = lazy_load(".identitystore", "mock_identitystore")
-mock_inspector2 = lazy_load(".inspector2", "mock_inspector2")
-mock_iot = lazy_load(".iot", "mock_iot")
-mock_iotdata = lazy_load(".iotdata", "mock_iotdata", boto3_name="iot-data")
-mock_ivs = lazy_load(".ivs", "mock_ivs")
-mock_kinesis = lazy_load(".kinesis", "mock_kinesis")
-mock_kinesisvideo = lazy_load(".kinesisvideo", "mock_kinesisvideo")
-mock_kinesisvideoarchivedmedia = lazy_load(
- ".kinesisvideoarchivedmedia",
- "mock_kinesisvideoarchivedmedia",
- boto3_name="kinesis-video-archived-media",
-)
-mock_kms = lazy_load(".kms", "mock_kms")
-mock_lakeformation = lazy_load(".lakeformation", "mock_lakeformation")
-mock_logs = lazy_load(".logs", "mock_logs")
-mock_managedblockchain = lazy_load(".managedblockchain", "mock_managedblockchain")
-mock_mediaconnect = lazy_load(".mediaconnect", "mock_mediaconnect")
-mock_medialive = lazy_load(".medialive", "mock_medialive")
-mock_mediapackage = lazy_load(".mediapackage", "mock_mediapackage")
-mock_mediastore = lazy_load(".mediastore", "mock_mediastore")
-mock_mediastoredata = lazy_load(
- ".mediastoredata", "mock_mediastoredata", boto3_name="mediastore-data"
-)
-mock_meteringmarketplace = lazy_load(".meteringmarketplace", "mock_meteringmarketplace")
-mock_mq = lazy_load(".mq", "mock_mq")
-mock_neptune = lazy_load(".rds", "mock_rds", boto3_name="neptune")
-mock_opensearch = lazy_load(".opensearch", "mock_opensearch")
-mock_opsworks = lazy_load(".opsworks", "mock_opsworks")
-mock_organizations = lazy_load(".organizations", "mock_organizations")
-mock_panorama = lazy_load(".panorama", "mock_panorama")
-mock_personalize = lazy_load(".personalize", "mock_personalize")
-mock_pinpoint = lazy_load(".pinpoint", "mock_pinpoint")
-mock_polly = lazy_load(".polly", "mock_polly")
-mock_quicksight = lazy_load(".quicksight", "mock_quicksight")
-mock_ram = lazy_load(".ram", "mock_ram")
-mock_rds = lazy_load(".rds", "mock_rds")
-mock_rdsdata = lazy_load(".rdsdata", "mock_rdsdata", boto3_name="rds-data")
-mock_redshift = lazy_load(".redshift", "mock_redshift")
-mock_redshiftdata = lazy_load(
- ".redshiftdata", "mock_redshiftdata", boto3_name="redshift-data"
-)
-mock_rekognition = lazy_load(".rekognition", "mock_rekognition")
-mock_resourcegroups = lazy_load(
- ".resourcegroups", "mock_resourcegroups", boto3_name="resource-groups"
-)
-mock_resourcegroupstaggingapi = lazy_load(
- ".resourcegroupstaggingapi", "mock_resourcegroupstaggingapi"
-)
-mock_robomaker = lazy_load(".robomaker", "mock_robomaker")
-mock_route53 = lazy_load(".route53", "mock_route53")
-mock_route53resolver = lazy_load(".route53resolver", "mock_route53resolver")
-mock_s3 = lazy_load(".s3", "mock_s3")
-mock_s3control = lazy_load(".s3control", "mock_s3control")
-mock_sagemaker = lazy_load(".sagemaker", "mock_sagemaker")
-mock_sagemakerruntime = lazy_load(
- ".sagemakerruntime", "mock_sagemakerruntime", boto3_name="sagemaker-runtime"
-)
-mock_scheduler = lazy_load(".scheduler", "mock_scheduler")
-mock_sdb = lazy_load(".sdb", "mock_sdb")
-mock_secretsmanager = lazy_load(".secretsmanager", "mock_secretsmanager")
-mock_servicequotas = lazy_load(
- ".servicequotas", "mock_servicequotas", boto3_name="service-quotas"
-)
-mock_ses = lazy_load(".ses", "mock_ses")
-mock_sesv2 = lazy_load(".sesv2", "mock_sesv2")
-mock_servicediscovery = lazy_load(".servicediscovery", "mock_servicediscovery")
-mock_signer = lazy_load(".signer", "mock_signer")
-mock_sns = lazy_load(".sns", "mock_sns")
-mock_sqs = lazy_load(".sqs", "mock_sqs")
-mock_ssm = lazy_load(".ssm", "mock_ssm")
-mock_ssoadmin = lazy_load(".ssoadmin", "mock_ssoadmin", boto3_name="sso-admin")
-mock_stepfunctions = lazy_load(
- ".stepfunctions", "mock_stepfunctions", backend="stepfunction_backends"
-)
-mock_sts = lazy_load(".sts", "mock_sts")
-mock_support = lazy_load(".support", "mock_support")
-mock_swf = lazy_load(".swf", "mock_swf")
-mock_textract = lazy_load(".textract", "mock_textract")
-mock_timestreamwrite = lazy_load(
- ".timestreamwrite", "mock_timestreamwrite", boto3_name="timestream-write"
-)
-mock_transcribe = lazy_load(".transcribe", "mock_transcribe")
-XRaySegment = load_xray_segment()
-mock_xray = lazy_load(".xray", "mock_xray")
-mock_xray_client = lazy_load(".xray", "mock_xray_client")
-mock_wafv2 = lazy_load(".wafv2", "mock_wafv2")
-mock_backup = lazy_load(".backup", "mock_backup", boto3_name="backup")
+def mock_aws(
+ func: "Optional[Callable[P, T]]" = None,
+ config: Optional[Dict[str, Dict[str, bool]]] = None,
+) -> Union["MockAWS", "Callable[P, T]"]:
+ clss = (
+ ServerModeMockAWS
+ if settings.TEST_SERVER_MODE
+ else (ProxyModeMockAWS if settings.test_proxy_mode() else MockAWS)
+ )
+ if func is not None:
+ return clss().__call__(func=func)
+ else:
+ return clss(config)
-class MockAll(ContextDecorator):
- def __init__(self) -> None:
- self.mocks: List[Any] = []
- for mock in dir(sys.modules["moto"]):
- if mock.startswith("mock_") and not mock == "mock_all":
- self.mocks.append(globals()[mock]())
-
- def __enter__(self) -> None:
- for mock in self.mocks:
- mock.start()
-
- def __exit__(self, *exc: Any) -> None:
- for mock in self.mocks:
- mock.stop()
-
-
-mock_all = MockAll
-
__title__ = "moto"
__version__ = "4.2.15.dev"
diff --git a/moto/acm/__init__.py b/moto/acm/__init__.py
index a77deff4f..003cd029b 100644
--- a/moto/acm/__init__.py
+++ b/moto/acm/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import acm_backends
-
-acm_backend = acm_backends["us-east-1"]
-mock_acm = base_decorator(acm_backends)
+from .models import acm_backends # noqa: F401
diff --git a/moto/acmpca/__init__.py b/moto/acmpca/__init__.py
index 85ccfb456..4f8bbb399 100644
--- a/moto/acmpca/__init__.py
+++ b/moto/acmpca/__init__.py
@@ -1,5 +1 @@
-"""acmpca module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import acmpca_backends
-
-mock_acmpca = base_decorator(acmpca_backends)
+from .models import acmpca_backends # noqa: F401
diff --git a/moto/amp/__init__.py b/moto/amp/__init__.py
index 8af2fc704..62bd043e3 100644
--- a/moto/amp/__init__.py
+++ b/moto/amp/__init__.py
@@ -1,5 +1 @@
-"""amp module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import amp_backends
-
-mock_amp = base_decorator(amp_backends)
+from .models import amp_backends # noqa: F401
diff --git a/moto/apigateway/__init__.py b/moto/apigateway/__init__.py
index 24465d1ca..6dc64ec90 100644
--- a/moto/apigateway/__init__.py
+++ b/moto/apigateway/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import apigateway_backends
-
-apigateway_backend = apigateway_backends["us-east-1"]
-mock_apigateway = base_decorator(apigateway_backends)
+from .models import apigateway_backends # noqa: F401
diff --git a/moto/apigatewaymanagementapi/__init__.py b/moto/apigatewaymanagementapi/__init__.py
index 9d128abae..a69496b22 100644
--- a/moto/apigatewaymanagementapi/__init__.py
+++ b/moto/apigatewaymanagementapi/__init__.py
@@ -1,5 +1 @@
-"""apigatewaymanagementapi module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import apigatewaymanagementapi_backends
-
-mock_apigatewaymanagementapi = base_decorator(apigatewaymanagementapi_backends)
+from .models import apigatewaymanagementapi_backends # noqa: F401
diff --git a/moto/apigatewayv2/__init__.py b/moto/apigatewayv2/__init__.py
index 1a095965d..c67b580be 100644
--- a/moto/apigatewayv2/__init__.py
+++ b/moto/apigatewayv2/__init__.py
@@ -1,5 +1 @@
-"""apigatewayv2 module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import apigatewayv2_backends
-
-mock_apigatewayv2 = base_decorator(apigatewayv2_backends)
+from .models import apigatewayv2_backends # noqa: F401
diff --git a/moto/appconfig/__init__.py b/moto/appconfig/__init__.py
index de813dde3..98d34e49b 100644
--- a/moto/appconfig/__init__.py
+++ b/moto/appconfig/__init__.py
@@ -1,5 +1 @@
-"""appconfig module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import appconfig_backends
-
-mock_appconfig = base_decorator(appconfig_backends)
+from .models import appconfig_backends # noqa: F401
diff --git a/moto/applicationautoscaling/__init__.py b/moto/applicationautoscaling/__init__.py
index b48596b94..05ede73ea 100644
--- a/moto/applicationautoscaling/__init__.py
+++ b/moto/applicationautoscaling/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import applicationautoscaling_backends
-
-mock_applicationautoscaling = base_decorator(applicationautoscaling_backends)
+from .models import applicationautoscaling_backends # noqa: F401
diff --git a/moto/appsync/__init__.py b/moto/appsync/__init__.py
index 90023abd4..992b13c1e 100644
--- a/moto/appsync/__init__.py
+++ b/moto/appsync/__init__.py
@@ -1,5 +1 @@
-"""appsync module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import appsync_backends
-
-mock_appsync = base_decorator(appsync_backends)
+from .models import appsync_backends # noqa: F401
diff --git a/moto/athena/__init__.py b/moto/athena/__init__.py
index 7e4e6b15b..f0fe7ac7c 100644
--- a/moto/athena/__init__.py
+++ b/moto/athena/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import athena_backends
-
-athena_backend = athena_backends["us-east-1"]
-mock_athena = base_decorator(athena_backends)
+from .models import athena_backends # noqa: F401
diff --git a/moto/autoscaling/__init__.py b/moto/autoscaling/__init__.py
index a4887b434..b6d151546 100644
--- a/moto/autoscaling/__init__.py
+++ b/moto/autoscaling/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import autoscaling_backends
-
-autoscaling_backend = autoscaling_backends["us-east-1"]
-mock_autoscaling = base_decorator(autoscaling_backends)
+from .models import autoscaling_backends # noqa: F401
diff --git a/moto/awslambda/__init__.py b/moto/awslambda/__init__.py
index 8b36f2205..c61dbe1bc 100644
--- a/moto/awslambda/__init__.py
+++ b/moto/awslambda/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import lambda_backends
-
-lambda_backend = lambda_backends["us-east-1"]
-mock_lambda = base_decorator(lambda_backends)
+from .models import lambda_backends # noqa: F401
diff --git a/moto/awslambda/models.py b/moto/awslambda/models.py
index bc177aec6..10cc9f0e5 100644
--- a/moto/awslambda/models.py
+++ b/moto/awslambda/models.py
@@ -2137,14 +2137,13 @@ class LambdaBackend(BaseBackend):
def send_sqs_batch(self, function_arn: str, messages: Any, queue_arn: str) -> bool:
success = True
for message in messages:
- func = self.get_function_by_arn(function_arn)
- result = self._send_sqs_message(func, message, queue_arn) # type: ignore[arg-type]
+ result = self._send_sqs_message(function_arn, message, queue_arn) # type: ignore[arg-type]
if not result:
success = False
return success
def _send_sqs_message(
- self, func: LambdaFunction, message: Any, queue_arn: str
+ self, function_arn: str, message: Any, queue_arn: str
) -> bool:
event = {
"Records": [
@@ -2177,7 +2176,13 @@ class LambdaBackend(BaseBackend):
request_headers: Dict[str, Any] = {}
response_headers: Dict[str, Any] = {}
- func.invoke(json.dumps(event), request_headers, response_headers)
+ self.invoke(
+ function_name=function_arn,
+ qualifier=None,
+ body=json.dumps(event),
+ headers=request_headers,
+ response_headers=response_headers,
+ )
return "x-amz-function-error" not in response_headers
def send_sns_message(
@@ -2319,7 +2324,7 @@ class LambdaBackend(BaseBackend):
def invoke(
self,
function_name: str,
- qualifier: str,
+ qualifier: Optional[str],
body: Any,
headers: Any,
response_headers: Any,
diff --git a/moto/awslambda/responses.py b/moto/awslambda/responses.py
index d1cdef3b8..43d7257da 100644
--- a/moto/awslambda/responses.py
+++ b/moto/awslambda/responses.py
@@ -11,7 +11,8 @@ from .exceptions import (
FunctionAlreadyExists,
UnknownFunctionException,
)
-from .models import LambdaBackend, lambda_backends
+from .models import LambdaBackend
+from .utils import get_backend
class LambdaResponse(BaseResponse):
@@ -24,7 +25,7 @@ class LambdaResponse(BaseResponse):
@property
def backend(self) -> LambdaBackend:
- return lambda_backends[self.current_account][self.region]
+ return get_backend(self.current_account, self.region)
def root(self, request: Any, full_url: str, headers: Any) -> TYPE_RESPONSE:
self.setup_class(request, full_url, headers)
diff --git a/moto/awslambda/utils.py b/moto/awslambda/utils.py
index 641d1ce68..946905faa 100644
--- a/moto/awslambda/utils.py
+++ b/moto/awslambda/utils.py
@@ -1,6 +1,9 @@
from collections import namedtuple
from functools import partial
-from typing import Any, Callable
+from typing import TYPE_CHECKING, Any, Callable
+
+if TYPE_CHECKING:
+ from .models import LambdaBackend
ARN = namedtuple("ARN", ["region", "account", "function_name", "version"])
LAYER_ARN = namedtuple("LAYER_ARN", ["region", "account", "layer_name", "version"])
@@ -35,3 +38,16 @@ def split_arn(arn_type: Callable[[str, str, str, str], str], arn: str) -> Any:
split_function_arn = partial(split_arn, ARN)
split_layer_arn = partial(split_arn, LAYER_ARN)
+
+
+def get_backend(account_id: str, region: str) -> "LambdaBackend":
+ from moto.core.models import default_user_config
+
+ if default_user_config.get("lambda", {}).get("use_docker", True) is False:
+ from moto.awslambda_simple.models import lambda_simple_backends
+
+ return lambda_simple_backends[account_id][region]
+ else:
+ from moto.awslambda.models import lambda_backends
+
+ return lambda_backends[account_id][region]
diff --git a/moto/awslambda_simple/__init__.py b/moto/awslambda_simple/__init__.py
index a7b640769..e69de29bb 100644
--- a/moto/awslambda_simple/__init__.py
+++ b/moto/awslambda_simple/__init__.py
@@ -1,5 +0,0 @@
-from ..core.models import base_decorator
-from .models import lambda_simple_backends
-
-lambda_simple_backend = lambda_simple_backends["us-east-1"]
-mock_lambda_simple = base_decorator(lambda_simple_backends)
diff --git a/moto/awslambda_simple/models.py b/moto/awslambda_simple/models.py
index 9cd700140..915c9f674 100644
--- a/moto/awslambda_simple/models.py
+++ b/moto/awslambda_simple/models.py
@@ -1,52 +1,20 @@
from typing import Any, Optional, Union
-from ..awslambda.models import (
- BaseBackend,
- LambdaBackend,
- lambda_backends,
-)
+from ..awslambda.models import LambdaBackend
from ..core import BackendDict
-class LambdaSimpleBackend(BaseBackend):
+class LambdaSimpleBackend(LambdaBackend):
"""
Implements a Lambda-Backend that does not use Docker containers, will always succeed.
- Annotate your tests with `@mock_lambda_simple`-decorator to use this Lambda-implementation.
+ Annotate your tests with `@mock_aws(config={"lambda": {"use_docker": False}}) to use this Lambda-implementation.
"""
- @property
- def backend(self) -> LambdaBackend:
- return lambda_backends[self.account_id][self.region_name]
-
- def __getattribute__(self, name: str) -> Any:
- """
- Magic part that makes this class behave like a wrapper around the regular lambda_backend
- """
- if name in [
- "backend",
- "account_id",
- "region_name",
- "urls",
- "_url_module",
- "__class__",
- "url_bases",
- ]:
- return object.__getattribute__(self, name)
- if name in ["invoke", "invoke_async"]:
-
- def newfunc(*args: Any, **kwargs: Any) -> Any:
- attr = object.__getattribute__(self, name)
- return attr(*args, **kwargs)
-
- return newfunc
- else:
- return object.__getattribute__(self.backend, name)
-
# pylint: disable=unused-argument
def invoke(
self,
function_name: str,
- qualifier: str,
+ qualifier: Optional[str],
body: Any,
headers: Any,
response_headers: Any,
diff --git a/moto/awslambda_simple/urls.py b/moto/awslambda_simple/urls.py
deleted file mode 100644
index 10571fa64..000000000
--- a/moto/awslambda_simple/urls.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from ..awslambda.urls import url_bases as lambda_url_bases
-from ..awslambda.urls import url_paths as lambda_url_paths
-from .responses import LambdaSimpleResponse
-
-url_bases = lambda_url_bases.copy()
-url_paths = {
- k: LambdaSimpleResponse.method_dispatch(v) for k, v in lambda_url_paths.items() # type: ignore
-}
diff --git a/moto/backend_index.py b/moto/backend_index.py
index 91c8e707a..83c12602d 100644
--- a/moto/backend_index.py
+++ b/moto/backend_index.py
@@ -3,7 +3,7 @@ import re
backend_url_patterns = [
("acm", re.compile("https?://acm\\.(.+)\\.amazonaws\\.com")),
- ("acm-pca", re.compile("https?://acm-pca\\.(.+)\\.amazonaws\\.com")),
+ ("acmpca", re.compile("https?://acm-pca\\.(.+)\\.amazonaws\\.com")),
("amp", re.compile("https?://aps\\.(.+)\\.amazonaws\\.com")),
("apigateway", re.compile("https?://apigateway\\.(.+)\\.amazonaws.com")),
(
@@ -18,6 +18,7 @@ backend_url_patterns = [
("appsync", re.compile("https?://appsync\\.(.+)\\.amazonaws\\.com")),
("athena", re.compile("https?://athena\\.(.+)\\.amazonaws\\.com")),
("autoscaling", re.compile("https?://autoscaling\\.(.+)\\.amazonaws\\.com")),
+ ("awslambda", re.compile("https?://lambda\\.(.+)\\.amazonaws\\.com")),
("backup", re.compile("https?://backup\\.(.+)\\.amazonaws\\.com")),
("batch", re.compile("https?://batch\\.(.+)\\.amazonaws.com")),
("budgets", re.compile("https?://budgets\\.amazonaws\\.com")),
@@ -29,11 +30,8 @@ backend_url_patterns = [
("codebuild", re.compile("https?://codebuild\\.(.+)\\.amazonaws\\.com")),
("codecommit", re.compile("https?://codecommit\\.(.+)\\.amazonaws\\.com")),
("codepipeline", re.compile("https?://codepipeline\\.(.+)\\.amazonaws\\.com")),
- (
- "cognito-identity",
- re.compile("https?://cognito-identity\\.(.+)\\.amazonaws.com"),
- ),
- ("cognito-idp", re.compile("https?://cognito-idp\\.(.+)\\.amazonaws.com")),
+ ("cognitoidentity", re.compile("https?://cognito-identity\\.(.+)\\.amazonaws.com")),
+ ("cognitoidp", re.compile("https?://cognito-idp\\.(.+)\\.amazonaws.com")),
("comprehend", re.compile("https?://comprehend\\.(.+)\\.amazonaws\\.com")),
("config", re.compile("https?://config\\.(.+)\\.amazonaws\\.com")),
("databrew", re.compile("https?://databrew\\.(.+)\\.amazonaws.com")),
@@ -74,8 +72,8 @@ backend_url_patterns = [
("elbv2", re.compile("https?://elasticloadbalancing\\.(.+)\\.amazonaws.com")),
("emr", re.compile("https?://(.+)\\.elasticmapreduce\\.amazonaws.com")),
("emr", re.compile("https?://elasticmapreduce\\.(.+)\\.amazonaws.com")),
- ("emr-containers", re.compile("https?://emr-containers\\.(.+)\\.amazonaws\\.com")),
- ("emr-serverless", re.compile("https?://emr-serverless\\.(.+)\\.amazonaws\\.com")),
+ ("emrcontainers", re.compile("https?://emr-containers\\.(.+)\\.amazonaws\\.com")),
+ ("emrserverless", re.compile("https?://emr-serverless\\.(.+)\\.amazonaws\\.com")),
("es", re.compile("https?://es\\.(.+)\\.amazonaws\\.com")),
("events", re.compile("https?://events\\.(.+)\\.amazonaws\\.com")),
("firehose", re.compile("https?://firehose\\.(.+)\\.amazonaws\\.com")),
@@ -87,21 +85,21 @@ backend_url_patterns = [
("iam", re.compile("https?://iam\\.(.*\\.)?amazonaws\\.com")),
("identitystore", re.compile("https?://identitystore\\.(.+)\\.amazonaws\\.com")),
("inspector2", re.compile("https?://inspector2\\.(.+)\\.amazonaws\\.com")),
+ ("instance_metadata", re.compile("http://169.254.169.254")),
("iot", re.compile("https?://iot\\.(.+)\\.amazonaws\\.com")),
- ("iot-data", re.compile("https?://data\\.iot\\.(.+)\\.amazonaws.com")),
- ("iot-data", re.compile("https?://data-ats\\.iot\\.(.+)\\.amazonaws.com")),
+ ("iotdata", re.compile("https?://data\\.iot\\.(.+)\\.amazonaws.com")),
+ ("iotdata", re.compile("https?://data-ats\\.iot\\.(.+)\\.amazonaws.com")),
("ivs", re.compile("https?://ivs\\.(.+)\\.amazonaws\\.com")),
("kinesis", re.compile("https?://kinesis\\.(.+)\\.amazonaws\\.com")),
("kinesis", re.compile("https?://(.+)\\.control-kinesis\\.(.+)\\.amazonaws\\.com")),
("kinesis", re.compile("https?://(.+)\\.data-kinesis\\.(.+)\\.amazonaws\\.com")),
("kinesisvideo", re.compile("https?://kinesisvideo\\.(.+)\\.amazonaws.com")),
(
- "kinesis-video-archived-media",
+ "kinesisvideoarchivedmedia",
re.compile("https?://.*\\.kinesisvideo\\.(.+)\\.amazonaws.com"),
),
("kms", re.compile("https?://kms\\.(.+)\\.amazonaws\\.com")),
("lakeformation", re.compile("https?://lakeformation\\.(.+)\\.amazonaws\\.com")),
- ("lambda", re.compile("https?://lambda\\.(.+)\\.amazonaws\\.com")),
("logs", re.compile("https?://logs\\.(.+)\\.amazonaws\\.com")),
(
"managedblockchain",
@@ -111,15 +109,13 @@ backend_url_patterns = [
("medialive", re.compile("https?://medialive\\.(.+)\\.amazonaws.com")),
("mediapackage", re.compile("https?://mediapackage\\.(.+)\\.amazonaws.com")),
("mediastore", re.compile("https?://mediastore\\.(.+)\\.amazonaws\\.com")),
- (
- "mediastore-data",
- re.compile("https?://data\\.mediastore\\.(.+)\\.amazonaws.com"),
- ),
+ ("mediastoredata", re.compile("https?://data\\.mediastore\\.(.+)\\.amazonaws.com")),
(
"meteringmarketplace",
re.compile("https?://metering.marketplace.(.+).amazonaws.com"),
),
("meteringmarketplace", re.compile("https?://aws-marketplace.(.+).amazonaws.com")),
+ ("moto_api._internal", re.compile("https?://motoapi.amazonaws.com")),
("mq", re.compile("https?://mq\\.(.+)\\.amazonaws\\.com")),
("opsworks", re.compile("https?://opsworks\\.us-east-1\\.amazonaws.com")),
("organizations", re.compile("https?://organizations\\.(.+)\\.amazonaws\\.com")),
@@ -133,10 +129,10 @@ backend_url_patterns = [
("rds", re.compile("https?://rds\\.amazonaws\\.com")),
("rds-data", re.compile("https?://rds-data\\.(.+)\\.amazonaws\\.com")),
("redshift", re.compile("https?://redshift\\.(.+)\\.amazonaws\\.com")),
- ("redshift-data", re.compile("https?://redshift-data\\.(.+)\\.amazonaws\\.com")),
+ ("redshiftdata", re.compile("https?://redshift-data\\.(.+)\\.amazonaws\\.com")),
("rekognition", re.compile("https?://rekognition\\.(.+)\\.amazonaws\\.com")),
(
- "resource-groups",
+ "resourcegroups",
re.compile("https?://resource-groups(-fips)?\\.(.+)\\.amazonaws.com"),
),
("resourcegroupstaggingapi", re.compile("https?://tagging\\.(.+)\\.amazonaws.com")),
@@ -159,7 +155,7 @@ backend_url_patterns = [
),
("sagemaker", re.compile("https?://api\\.sagemaker\\.(.+)\\.amazonaws.com")),
(
- "sagemaker-runtime",
+ "sagemakerruntime",
re.compile("https?://runtime\\.sagemaker\\.(.+)\\.amazonaws\\.com"),
),
("scheduler", re.compile("https?://scheduler\\.(.+)\\.amazonaws\\.com")),
@@ -169,7 +165,7 @@ backend_url_patterns = [
"servicediscovery",
re.compile("https?://servicediscovery\\.(.+)\\.amazonaws\\.com"),
),
- ("service-quotas", re.compile("https?://servicequotas\\.(.+)\\.amazonaws\\.com")),
+ ("servicequotas", re.compile("https?://servicequotas\\.(.+)\\.amazonaws\\.com")),
("ses", re.compile("https?://email\\.(.+)\\.amazonaws\\.com")),
("ses", re.compile("https?://ses\\.(.+)\\.amazonaws\\.com")),
("sesv2", re.compile("https?://email\\.(.+)\\.amazonaws\\.com")),
@@ -178,22 +174,21 @@ backend_url_patterns = [
("sqs", re.compile("https?://(.*\\.)?(queue|sqs)\\.(.*\\.)?amazonaws\\.com")),
("ssm", re.compile("https?://ssm\\.(.+)\\.amazonaws\\.com")),
("ssm", re.compile("https?://ssm\\.(.+)\\.amazonaws\\.com\\.cn")),
- ("sso-admin", re.compile("https?://sso\\.(.+)\\.amazonaws\\.com")),
+ ("ssoadmin", re.compile("https?://sso\\.(.+)\\.amazonaws\\.com")),
("stepfunctions", re.compile("https?://states\\.(.+)\\.amazonaws.com")),
("sts", re.compile("https?://sts\\.(.*\\.)?amazonaws\\.com")),
("support", re.compile("https?://support\\.(.+)\\.amazonaws\\.com")),
("swf", re.compile("https?://swf\\.(.+)\\.amazonaws\\.com")),
("textract", re.compile("https?://textract\\.(.+)\\.amazonaws\\.com")),
(
- "timestream-write",
+ "timestreamwrite",
re.compile("https?://ingest\\.timestream\\.(.+)\\.amazonaws\\.com"),
),
(
- "timestream-write",
+ "timestreamwrite",
re.compile("https?://ingest\\.timestream\\.(.+)\\.amazonaws\\.com/"),
),
("transcribe", re.compile("https?://transcribe\\.(.+)\\.amazonaws\\.com")),
("wafv2", re.compile("https?://wafv2\\.(.+)\\.amazonaws.com")),
("xray", re.compile("https?://xray\\.(.+)\\.amazonaws.com")),
- ("dynamodb_v20111205", re.compile("https?://dynamodb\\.(.+)\\.amazonaws\\.com")),
]
diff --git a/moto/backends.py b/moto/backends.py
index 18943a2a4..584a2f871 100644
--- a/moto/backends.py
+++ b/moto/backends.py
@@ -1,6 +1,6 @@
import importlib
-import sys
-from typing import TYPE_CHECKING, Iterable, Tuple, Union, overload
+import os
+from typing import TYPE_CHECKING, Iterable, Union, overload
import moto
@@ -33,7 +33,7 @@ if TYPE_CHECKING:
from moto.cognitoidp.models import CognitoIdpBackend
from moto.comprehend.models import ComprehendBackend
from moto.config.models import ConfigBackend
- from moto.core import SERVICE_BACKEND, BackendDict, BaseBackend
+ from moto.core import SERVICE_BACKEND, BackendDict
from moto.databrew.models import DataBrewBackend
from moto.datapipeline.models import DataPipelineBackend
from moto.datasync.models import DataSyncBackend
@@ -136,13 +136,24 @@ if TYPE_CHECKING:
from moto.xray.models import XRayBackend
-decorators = [d for d in dir(moto) if d.startswith("mock_") and not d == "mock_all"]
-decorator_functions = [getattr(moto, f) for f in decorators]
-BACKENDS = {f.boto3_name: (f.name, f.backend) for f in decorator_functions}
-BACKENDS["dynamodb_v20111205"] = ("dynamodb_v20111205", "dynamodb_backends")
-BACKENDS["moto_api"] = ("moto_api._internal", "moto_api_backends")
-BACKENDS["instance_metadata"] = ("instance_metadata", "instance_metadata_backends")
-BACKENDS["s3bucket_path"] = ("s3", "s3_backends")
+ALT_SERVICE_NAMES = {"lambda": "awslambda", "moto_api": "moto_api._internal"}
+ALT_BACKEND_NAMES = {
+ "moto_api._internal": "moto_api",
+ "awslambda": "lambda",
+ "awslambda_simple": "lambda_simple",
+ "dynamodb_v20111205": "dynamodb",
+ "elasticbeanstalk": "eb",
+}
+
+
+def list_of_moto_modules() -> Iterable[str]:
+ path = os.path.dirname(moto.__file__)
+ for backend in sorted(os.listdir(path)):
+ is_dir = os.path.isdir(os.path.join(path, backend))
+ valid_folder = not backend.startswith("__")
+ if is_dir and valid_folder:
+ yield backend
+
# There's a similar Union that we could import from boto3-stubs, but it wouldn't have
# moto's custom service backends
@@ -283,30 +294,6 @@ def _import_backend(
return getattr(module, backends_name)
-def backends() -> "Iterable[BackendDict[BaseBackend]]":
- for module_name, backends_name in BACKENDS.values():
- yield _import_backend(module_name, backends_name)
-
-
-def service_backends() -> "Iterable[BackendDict[BaseBackend]]":
- services = [(f.name, f.backend) for f in decorator_functions]
- for module_name, backends_name in sorted(set(services)):
- yield _import_backend(module_name, backends_name)
-
-
-def loaded_backends() -> "Iterable[Tuple[str, BackendDict[BaseBackend]]]":
- loaded_modules = sys.modules.keys()
- moto_modules = [m for m in loaded_modules if m.startswith("moto.")]
- imported_backends = [
- name
- for name, (module_name, _) in BACKENDS.items()
- if f"moto.{module_name}" in moto_modules
- ]
- for name in imported_backends:
- module_name, backends_name = BACKENDS[name]
- yield name, _import_backend(module_name, backends_name)
-
-
# fmt: off
# This is more or less the dummy-implementation style that's currently in black's preview
# style. It should be live in black v24.0+, at which point we should remove the # fmt: off
@@ -565,5 +552,8 @@ def get_backend(name: "Literal['xray']") -> "BackendDict[XRayBackend]": ...
def get_backend(name: SERVICE_NAMES) -> "BackendDict[SERVICE_BACKEND]":
- module_name, backends_name = BACKENDS[name]
- return _import_backend(module_name, backends_name)
+ safe_name = name.replace("-", "")
+ return _import_backend(
+ ALT_SERVICE_NAMES.get(safe_name, safe_name),
+ f"{ALT_BACKEND_NAMES.get(safe_name, safe_name)}_backends",
+ )
diff --git a/moto/backup/__init__.py b/moto/backup/__init__.py
index 092556a72..5b783ccdd 100644
--- a/moto/backup/__init__.py
+++ b/moto/backup/__init__.py
@@ -1,5 +1 @@
-"""backup module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import backup_backends
-
-mock_backup = base_decorator(backup_backends)
+from .models import backup_backends # noqa: F401
diff --git a/moto/batch/__init__.py b/moto/batch/__init__.py
index e90336773..0d52ff765 100644
--- a/moto/batch/__init__.py
+++ b/moto/batch/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import batch_backends
-
-batch_backend = batch_backends["us-east-1"]
-mock_batch = base_decorator(batch_backends)
+from .models import batch_backends # noqa: F401
diff --git a/moto/batch/responses.py b/moto/batch/responses.py
index b074feac3..b3e4f173b 100644
--- a/moto/batch/responses.py
+++ b/moto/batch/responses.py
@@ -1,6 +1,7 @@
import json
from urllib.parse import unquote, urlsplit
+from moto.core.models import default_user_config
from moto.core.responses import BaseResponse
from moto.utilities.aws_headers import amzn_request_id
@@ -13,11 +14,12 @@ class BatchResponse(BaseResponse):
@property
def batch_backend(self) -> BatchBackend:
- """
- :return: Batch Backend
- :rtype: moto.batch.models.BatchBackend
- """
- return batch_backends[self.current_account][self.region]
+ if default_user_config.get("batch", {}).get("use_docker", True) is False:
+ from moto.batch_simple.models import batch_simple_backends
+
+ return batch_simple_backends[self.current_account][self.region]
+ else:
+ return batch_backends[self.current_account][self.region]
def _get_action(self) -> str:
# Return element after the /v1/*
diff --git a/moto/batch_simple/__init__.py b/moto/batch_simple/__init__.py
index 31637eedd..e69de29bb 100644
--- a/moto/batch_simple/__init__.py
+++ b/moto/batch_simple/__init__.py
@@ -1,5 +0,0 @@
-from ..core.models import base_decorator
-from .models import batch_simple_backends
-
-batch_backend = batch_simple_backends["us-east-1"]
-mock_batch_simple = base_decorator(batch_simple_backends)
diff --git a/moto/batch_simple/models.py b/moto/batch_simple/models.py
index 25dd69531..508553092 100644
--- a/moto/batch_simple/models.py
+++ b/moto/batch_simple/models.py
@@ -4,7 +4,6 @@ from time import sleep
from typing import Any, Dict, List, Optional, Tuple
from ..batch.models import (
- BaseBackend,
BatchBackend,
ClientException,
Job,
@@ -13,13 +12,13 @@ from ..batch.models import (
from ..core import BackendDict
-class BatchSimpleBackend(BaseBackend):
+class BatchSimpleBackend(BatchBackend):
"""
Implements a Batch-Backend that does not use Docker containers. Submitted Jobs are marked as Success by default.
Set the environment variable MOTO_SIMPLE_BATCH_FAIL_AFTER=0 to fail jobs immediately, or set this variable to a positive integer to control after how many seconds the job fails.
- Annotate your tests with `@mock_batch_simple`-decorator to use this Batch-implementation.
+ Annotate your tests with `@mock_aws(config={"batch": {"use_docker": False}})`-decorator to use this Batch-implementation.
"""
@property
diff --git a/moto/batch_simple/urls.py b/moto/batch_simple/urls.py
deleted file mode 100644
index aaeae8a0f..000000000
--- a/moto/batch_simple/urls.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from ..batch.urls import url_bases as batch_url_bases
-from ..batch.urls import url_paths as batch_url_paths
-from .responses import BatchSimpleResponse
-
-url_bases = batch_url_bases.copy()
-url_paths = {k: BatchSimpleResponse.dispatch for k in batch_url_paths}
diff --git a/moto/budgets/__init__.py b/moto/budgets/__init__.py
index 3573df9f0..acbef0cc3 100644
--- a/moto/budgets/__init__.py
+++ b/moto/budgets/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import budgets_backends
-
-mock_budgets = base_decorator(budgets_backends)
+from .models import budgets_backends # noqa: F401
diff --git a/moto/ce/__init__.py b/moto/ce/__init__.py
index d2e9ae19e..10d903326 100644
--- a/moto/ce/__init__.py
+++ b/moto/ce/__init__.py
@@ -1,5 +1 @@
-"""ce module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import ce_backends
-
-mock_ce = base_decorator(ce_backends)
+from .models import ce_backends # noqa: F401
diff --git a/moto/cloudformation/__init__.py b/moto/cloudformation/__init__.py
index 539456f54..f481ec494 100644
--- a/moto/cloudformation/__init__.py
+++ b/moto/cloudformation/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import cloudformation_backends
-
-cloudformation_backend = cloudformation_backends["us-east-1"]
-mock_cloudformation = base_decorator(cloudformation_backends)
+from .models import cloudformation_backends # noqa: F401
diff --git a/moto/cloudfront/__init__.py b/moto/cloudfront/__init__.py
index 78f567e62..244c4bf4a 100644
--- a/moto/cloudfront/__init__.py
+++ b/moto/cloudfront/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import cloudfront_backends
-
-mock_cloudfront = base_decorator(cloudfront_backends)
+from .models import cloudfront_backends # noqa: F401
diff --git a/moto/cloudtrail/__init__.py b/moto/cloudtrail/__init__.py
index d0f92058d..1735646c3 100644
--- a/moto/cloudtrail/__init__.py
+++ b/moto/cloudtrail/__init__.py
@@ -1,5 +1 @@
-"""cloudtrail module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import cloudtrail_backends
-
-mock_cloudtrail = base_decorator(cloudtrail_backends)
+from .models import cloudtrail_backends # noqa: F401
diff --git a/moto/cloudwatch/__init__.py b/moto/cloudwatch/__init__.py
index 9a890c471..283114e4d 100644
--- a/moto/cloudwatch/__init__.py
+++ b/moto/cloudwatch/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import cloudwatch_backends
-
-mock_cloudwatch = base_decorator(cloudwatch_backends)
+from .models import cloudwatch_backends # noqa: F401
diff --git a/moto/codebuild/__init__.py b/moto/codebuild/__init__.py
index 764bd3255..1726f9833 100644
--- a/moto/codebuild/__init__.py
+++ b/moto/codebuild/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import codebuild_backends
-
-mock_codebuild = base_decorator(codebuild_backends)
+from .models import codebuild_backends # noqa: F401
diff --git a/moto/codecommit/__init__.py b/moto/codecommit/__init__.py
index 6deffd1d6..c2852ad77 100644
--- a/moto/codecommit/__init__.py
+++ b/moto/codecommit/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import codecommit_backends
-
-mock_codecommit = base_decorator(codecommit_backends)
+from .models import codecommit_backends # noqa: F401
diff --git a/moto/codepipeline/__init__.py b/moto/codepipeline/__init__.py
index ad16612da..c0eadc56f 100644
--- a/moto/codepipeline/__init__.py
+++ b/moto/codepipeline/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import codepipeline_backends
-
-mock_codepipeline = base_decorator(codepipeline_backends)
+from .models import codepipeline_backends # noqa: F401
diff --git a/moto/cognitoidentity/__init__.py b/moto/cognitoidentity/__init__.py
index b872dea30..d26676ff0 100644
--- a/moto/cognitoidentity/__init__.py
+++ b/moto/cognitoidentity/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import cognitoidentity_backends
-
-mock_cognitoidentity = base_decorator(cognitoidentity_backends)
+from .models import cognitoidentity_backends # noqa: F401
diff --git a/moto/cognitoidp/__init__.py b/moto/cognitoidp/__init__.py
index 266037962..74841d149 100644
--- a/moto/cognitoidp/__init__.py
+++ b/moto/cognitoidp/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import cognitoidp_backends
-
-mock_cognitoidp = base_decorator(cognitoidp_backends)
+from .models import cognitoidp_backends # noqa: F401
diff --git a/moto/comprehend/__init__.py b/moto/comprehend/__init__.py
index cbbfbb193..967cad71f 100644
--- a/moto/comprehend/__init__.py
+++ b/moto/comprehend/__init__.py
@@ -1,5 +1 @@
-"""comprehend module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import comprehend_backends
-
-mock_comprehend = base_decorator(comprehend_backends)
+from .models import comprehend_backends # noqa: F401
diff --git a/moto/config/__init__.py b/moto/config/__init__.py
index 785efe1b0..e6a61b225 100644
--- a/moto/config/__init__.py
+++ b/moto/config/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import config_backends
-
-mock_config = base_decorator(config_backends)
+from .models import config_backends # noqa: F401
diff --git a/moto/config/models.py b/moto/config/models.py
index 821bfd73a..a8cc82040 100644
--- a/moto/config/models.py
+++ b/moto/config/models.py
@@ -684,10 +684,10 @@ class Source(ConfigEmptyDictable):
# Import is slow and as it's not needed for all config service
# operations, only load it if needed.
- from moto.awslambda import lambda_backends
+ from moto.awslambda.utils import get_backend
try:
- lambda_backends[account_id][region].get_function(source_identifier)
+ get_backend(account_id, region).get_function(source_identifier)
except Exception:
raise InsufficientPermissionsException(
f"The AWS Lambda function {source_identifier} cannot be "
diff --git a/moto/core/_mock_architecture.md b/moto/core/_mock_architecture.md
new file mode 100644
index 000000000..9a69daf6f
--- /dev/null
+++ b/moto/core/_mock_architecture.md
@@ -0,0 +1,41 @@
+Introduction
+-------------
+
+Aim: to document how Moto's mocks work, and provide some architectural background info.
+
+`Moto` is responsible for mocking the AWS API, and it does this by providing two key capabilities:
+
+
+## Mock requests coming from botocore
+
+Requests coming from botocore are mocked by the `BotocoreStubber`. This class is responsible for two main functions:
+ - Inspect the incoming request to determine which method should handle this request
+ - Execute the method and process the result as appropriate
+
+`botocore` has an event handling system used to enhance/augment requests that were made. Using this approach, `Moto` automatically registers the `BotocoreStubber` as an event handler that is invoked for every `before_send`-event.
+
+This event is one of the last ones to fire before the actual HTTP request is made, which means that `botocore` is still responsible for any client-side validation.
+
+### Usage of the event handling system
+
+The intention of the `botocore` event system is to register event handlers with a specific botocore `Session`. That approach has multiple problems:
+ - Moto can enrich the default session, but has no control (or knowledge) of any Session's created by the end-user.
+ - `botocore` copies event handlers for some reason, which means that
+ - the same request is sometimes processed by multiple `BotocoreStubber`'s, resulting in duplicate resources
+ - `Moto` has no control over all event handlers, so they can't be enabled/disabled - resulting in the mock still being active after the `Moto` decorator ends
+
+That's why `Moto` uses a single global instance of the `BotocoreStubber`, which is enabled and disabled for the duration of a `mock_aws`-decorator. Note that if the end-user nests multiple `mock_aws`-decorators, `Moto` will only disable the mock after the last decorator finishes.
+
+## Mock requests coming from the `requests`-module
+
+Users can manually invoke the AWS API using the `requests`-module. That means that `Moto` needs to intercept all these requests and determine the result on the fly.
+
+Because the `BotocoreStubber` already contains all the logic necessary to parse incoming HTTP requests to AWS, we re-use this logic for requests intercepted by from the `responses` module.
+
+### Supported requests
+
+`Moto` maintains a list of URL's for each supported AWS service. This list can be seen in `moto/backend_index.py`.
+
+If a `botocore` request comes through, `Moto` will cycle through this list to see whether the request is supported. If it is not supported, it will return a `404 NotYetImplemented` response.
+
+The `requests`-module achieves the same result, but using a different approach. It has specific callbacks for every supported URL, and a separate `NotYetImplemented`-callback that catches every (unhandled) request to `*.amazonaws.com`.
\ No newline at end of file
diff --git a/moto/core/base_backend.py b/moto/core/base_backend.py
index 853fd5eb8..1d686c3c2 100644
--- a/moto/core/base_backend.py
+++ b/moto/core/base_backend.py
@@ -1,8 +1,19 @@
import re
import string
+import sys
from functools import lru_cache
from threading import RLock
-from typing import Any, Callable, ClassVar, Dict, Iterator, List, Optional, TypeVar
+from typing import (
+ TYPE_CHECKING,
+ Any,
+ Callable,
+ ClassVar,
+ Dict,
+ Iterator,
+ List,
+ Optional,
+ TypeVar,
+)
from uuid import uuid4
from boto3 import Session
@@ -13,6 +24,18 @@ from .model_instances import model_data
from .responses import TYPE_RESPONSE
from .utils import convert_regex_to_flask_path
+if TYPE_CHECKING:
+ from moto.core.common_models import BaseModel
+
+ if sys.version_info >= (3, 9):
+ from builtins import type as Type
+ else:
+ # https://github.com/python/mypy/issues/10068
+ # Legacy generic type annotation classes
+ # Deprecated in Python 3.9
+ # Remove once we no longer support Python 3.8 or lower
+ from typing import Type
+
class InstanceTrackerMeta(type):
def __new__(meta, name: str, bases: Any, dct: Dict[str, Any]) -> type:
@@ -23,7 +46,7 @@ class InstanceTrackerMeta(type):
service = cls.__module__.split(".")[1]
if name not in model_data[service]:
model_data[service][name] = cls
- cls.instances: ClassVar[List[Any]] = [] # type: ignore
+ cls.instances: ClassVar[List["BaseModel"]] = [] # type: ignore
return cls
@@ -251,7 +274,6 @@ class AccountSpecificBackend(Dict[str, SERVICE_BACKEND]):
def __setitem__(self, key: str, value: SERVICE_BACKEND) -> None:
super().__setitem__(key, value)
- @lru_cache()
def __getitem__(self, region_name: str) -> SERVICE_BACKEND:
if region_name in self.keys():
return super().__getitem__(region_name)
@@ -276,9 +298,31 @@ class BackendDict(Dict[str, AccountSpecificBackend[SERVICE_BACKEND]]):
[account_id: str][region: str] = BaseBackend
"""
+ # We keep track of the BackendDict's that were:
+ # - instantiated
+ # - contain at least one AccountSpecificBackend
+ #
+ # In other words, this is the list of backends which are in use by the user
+ # making it trivial to determine which backends to reset when the mocks end
+ _instances: List["BackendDict[SERVICE_BACKEND]"] = []
+
+ @classmethod
+ def reset(cls) -> None:
+ with backend_lock:
+ for backend in BackendDict._instances: # type: ignore[misc]
+ for account_specific_backend in backend.values():
+ account_specific_backend.reset()
+ # account_specific_backend.__getitem__.cache_clear()
+ backend.clear()
+ # https://github.com/getmoto/moto/issues/6592
+ # Could be fixed by removing the cache, forcing all data to be regenerated every reset
+ # But this also incurs a significant performance hit
+ # backend.__getitem__.cache_clear()
+ BackendDict._instances.clear() # type: ignore[misc]
+
def __init__(
self,
- backend: "type[SERVICE_BACKEND]",
+ backend: "Type[SERVICE_BACKEND]",
service_name: str,
use_boto3_regions: bool = True,
additional_regions: Optional[List[str]] = None,
@@ -300,7 +344,6 @@ class BackendDict(Dict[str, AccountSpecificBackend[SERVICE_BACKEND]]):
def __ne__(self, other: Any) -> bool:
return not self.__eq__(other)
- @lru_cache()
def __getitem__(self, account_id: str) -> AccountSpecificBackend[SERVICE_BACKEND]:
self._create_account_specific_backend(account_id)
return super().__getitem__(account_id)
@@ -331,3 +374,4 @@ class BackendDict(Dict[str, AccountSpecificBackend[SERVICE_BACKEND]]):
use_boto3_regions=self._use_boto3_regions,
additional_regions=self._additional_regions,
)
+ BackendDict._instances.append(self) # type: ignore[misc]
diff --git a/moto/core/botocore_stubber.py b/moto/core/botocore_stubber.py
index 54f7e150f..caf05ef04 100644
--- a/moto/core/botocore_stubber.py
+++ b/moto/core/botocore_stubber.py
@@ -1,12 +1,14 @@
-from collections import defaultdict
+import re
from io import BytesIO
-from typing import Any, Callable, Dict, List, Optional, Pattern, Tuple, Union
+from typing import Any, Optional, Union
+from urllib.parse import urlparse
from botocore.awsrequest import AWSResponse
-from moto.core.exceptions import HTTPException
-
-from .responses import TYPE_RESPONSE
+import moto.backend_index as backend_index
+from moto import settings
+from moto.core.base_backend import BackendDict
+from moto.core.common_types import TYPE_RESPONSE
class MockRawResponse(BytesIO):
@@ -25,18 +27,9 @@ class MockRawResponse(BytesIO):
class BotocoreStubber:
def __init__(self) -> None:
self.enabled = False
- self.methods: Dict[
- str, List[Tuple[Pattern[str], Callable[..., TYPE_RESPONSE]]]
- ] = defaultdict(list)
def reset(self) -> None:
- self.methods.clear()
-
- def register_response(
- self, method: str, pattern: Pattern[str], response: Callable[..., TYPE_RESPONSE]
- ) -> None:
- matchers = self.methods[method]
- matchers.append((pattern, response))
+ BackendDict.reset()
def __call__(
self, event_name: str, request: Any, **kwargs: Any
@@ -44,34 +37,78 @@ class BotocoreStubber:
if not self.enabled:
return None
- from moto.moto_api import recorder
+ response = self.process_request(request)
+ if response is not None:
+ status, headers, body = response
+ return AWSResponse(request.url, status, headers, MockRawResponse(body)) # type: ignore[arg-type]
+ else:
+ return response
- response = None
- response_callback = None
- matchers = self.methods.get(request.method, [])
+ def process_request(self, request: Any) -> Optional[TYPE_RESPONSE]:
+ # Remove the querystring from the URL, as we'll never match on that
+ x = urlparse(request.url)
+ host = x.netloc
- base_url = request.url.split("?", 1)[0]
- for pattern, callback in matchers:
- if pattern.match(base_url):
- response_callback = callback
- break
+ # https://github.com/getmoto/moto/pull/6412
+ # Support ISO regions
+ iso_region_domains = [
+ "amazonaws.com.cn",
+ "c2s.ic.gov",
+ "sc2s.sgov.gov",
+ "cloud.adc-e.uk",
+ "csp.hci.ic.gov",
+ ]
+ for domain in iso_region_domains:
+ if host.endswith(domain):
+ host = host.replace(domain, "amazonaws.com")
- if response_callback is not None:
- for header, value in request.headers.items():
- if isinstance(value, bytes):
- request.headers[header] = value.decode("utf-8")
- try:
- recorder._record_request(request)
+ # https://github.com/getmoto/moto/issues/2993
+ # Support S3-compatible tools (Ceph, Digital Ocean, etc)
+ for custom_endpoint in settings.get_s3_custom_endpoints():
+ if host == custom_endpoint or host == custom_endpoint.split("://")[-1]:
+ host = "s3.amazonaws.com"
- status, headers, body = response_callback(
- request, request.url, request.headers
- )
+ clean_url = f"{x.scheme}://{host}{x.path}"
- except HTTPException as e:
- status = e.code # type: ignore[assignment]
- headers = e.get_headers() # type: ignore[assignment]
- body = e.get_body()
- raw_response = MockRawResponse(body)
- response = AWSResponse(request.url, status, headers, raw_response) # type: ignore[arg-type]
+ for service, pattern in backend_index.backend_url_patterns:
+ if pattern.match(clean_url):
- return response
+ import moto.backends as backends
+ from moto.core import DEFAULT_ACCOUNT_ID
+ from moto.core.exceptions import HTTPException
+
+ # TODO: cache this part - we only need backend.urls
+ backend_dict = backends.get_backend(service) # type: ignore[call-overload]
+
+ if isinstance(backend_dict, BackendDict):
+ if "us-east-1" in backend_dict[DEFAULT_ACCOUNT_ID]:
+ backend = backend_dict[DEFAULT_ACCOUNT_ID]["us-east-1"]
+ else:
+ backend = backend_dict[DEFAULT_ACCOUNT_ID]["global"]
+ else:
+ backend = backend_dict["global"]
+
+ for header, value in request.headers.items():
+ if isinstance(value, bytes):
+ request.headers[header] = value.decode("utf-8")
+
+ for url, method_to_execute in backend.urls.items():
+ if re.compile(url).match(clean_url):
+ from moto.moto_api import recorder
+
+ try:
+ recorder._record_request(request)
+ status, headers, body = method_to_execute(
+ request, request.url, request.headers
+ )
+ except HTTPException as e:
+ status = e.code
+ headers = e.get_headers()
+ body = e.get_body()
+
+ return status, headers, body
+
+ if re.compile(r"https?://.+\.amazonaws.com/.*").match(clean_url):
+ return 404, {}, "Not yet implemented"
+
+ return None
diff --git a/moto/core/models.py b/moto/core/models.py
index 648ac1903..a4a1807ad 100644
--- a/moto/core/models.py
+++ b/moto/core/models.py
@@ -4,6 +4,7 @@ import itertools
import os
import re
import unittest
+from threading import Lock
from types import FunctionType
from typing import (
TYPE_CHECKING,
@@ -14,8 +15,6 @@ from typing import (
Optional,
Set,
TypeVar,
- Union,
- overload,
)
from unittest.mock import patch
@@ -25,9 +24,9 @@ import responses
from botocore.config import Config
from botocore.handlers import BUILTIN_HANDLERS
+import moto.backend_index as backend_index
from moto import settings
-from .base_backend import SERVICE_BACKEND, BackendDict, BaseBackend
from .botocore_stubber import BotocoreStubber
from .custom_responses_mock import (
CallbackResponse,
@@ -38,63 +37,39 @@ from .custom_responses_mock import (
from .model_instances import reset_model_data
if TYPE_CHECKING:
- from typing_extensions import ParamSpec, Protocol
+ from typing_extensions import ParamSpec
P = ParamSpec("P")
-else:
- Protocol = object
DEFAULT_ACCOUNT_ID = "123456789012"
T = TypeVar("T")
-class BaseMockAWS(ContextManager["BaseMockAWS"]):
+class MockAWS(ContextManager["MockAWS"]):
nested_count = 0
mocks_active = False
+ mock_init_lock = Lock()
- def __init__(self, backends: BackendDict[SERVICE_BACKEND]):
- from moto.instance_metadata import instance_metadata_backends
- from moto.moto_api._internal.models import moto_api_backend
-
- self.backends = backends
-
- self.backends_for_urls: list[BaseBackend] = []
- default_account_id = DEFAULT_ACCOUNT_ID
- default_backends = [
- instance_metadata_backends[default_account_id]["global"],
- moto_api_backend,
- ]
- backend_default_account = self.backends[default_account_id]
- if "us-east-1" in backend_default_account:
- # We only need to know the URL for a single region - they will be the same everywhere
- self.backends_for_urls.append(backend_default_account["us-east-1"])
- elif "global" in backend_default_account:
- # If us-east-1 is not available, it's probably a global service
- self.backends_for_urls.append(backend_default_account["global"])
- self.backends_for_urls.extend(default_backends)
-
+ def __init__(self, config: Optional[Dict[str, Any]] = None) -> None:
self.FAKE_KEYS = {
"AWS_ACCESS_KEY_ID": "FOOBARKEY",
"AWS_SECRET_ACCESS_KEY": "FOOBARSECRET",
}
self.ORIG_KEYS: Dict[str, Optional[str]] = {}
self.default_session_mock = patch("boto3.DEFAULT_SESSION", None)
-
- if self.__class__.nested_count == 0:
- self.reset() # type: ignore[attr-defined]
+ current_user_config = default_user_config.copy()
+ current_user_config.update(config or {})
+ self.user_config_mock = patch.dict(default_user_config, current_user_config)
def __call__(
- self,
- func: "Callable[P, T]",
- reset: bool = True,
- remove_data: bool = True,
+ self, func: "Callable[P, T]", reset: bool = True, remove_data: bool = True
) -> "Callable[P, T]":
if inspect.isclass(func):
- return self.decorate_class(func) # type: ignore
+ return self.decorate_class(func)
return self.decorate_callable(func, reset, remove_data)
- def __enter__(self) -> "BaseMockAWS":
+ def __enter__(self) -> "MockAWS":
self.start()
return self
@@ -102,44 +77,35 @@ class BaseMockAWS(ContextManager["BaseMockAWS"]):
self.stop()
def start(self, reset: bool = True) -> None:
- if not self.__class__.mocks_active:
- self.default_session_mock.start()
- self.mock_env_variables()
- self.__class__.mocks_active = True
+ with MockAWS.mock_init_lock:
+ if not self.__class__.mocks_active:
+ self.mock_env_variables()
+ self.__class__.mocks_active = True
+ self.default_session_mock.start()
- self.__class__.nested_count += 1
- if reset:
- for backend in self.backends.values():
- backend.reset()
+ self.__class__.nested_count += 1
- self.enable_patching(reset) # type: ignore[attr-defined]
+ if self.__class__.nested_count == 1:
+ self.enable_patching(reset=reset)
def stop(self, remove_data: bool = True) -> None:
- self.__class__.nested_count -= 1
+ with MockAWS.mock_init_lock:
+ self.__class__.nested_count -= 1
- if self.__class__.nested_count < 0:
- raise RuntimeError("Called stop() before start().")
+ if self.__class__.nested_count < 0:
+ raise RuntimeError("Called stop() before start().")
- if self.__class__.nested_count == 0:
- if self.__class__.mocks_active:
- self.default_session_mock.stop()
- self.unmock_env_variables()
- self.__class__.mocks_active = False
- if remove_data:
- # Reset the data across all backends
- for backend in self.backends.values():
- backend.reset()
- # Remove references to all model instances that were created
- reset_model_data()
- self.disable_patching() # type: ignore[attr-defined]
+ if self.__class__.nested_count == 0:
+ if self.__class__.mocks_active:
+ self.default_session_mock.stop()
+ self.unmock_env_variables()
+ self.__class__.mocks_active = False
+ self.disable_patching(remove_data)
def decorate_callable(
- self,
- func: "Callable[P, T]",
- reset: bool,
- remove_data: bool,
+ self, func: "Callable[P, T]", reset: bool, remove_data: bool
) -> "Callable[P, T]":
- def wrapper(*args: "P.args", **kwargs: "P.kwargs") -> T:
+ def wrapper(*args: Any, **kwargs: Any) -> T:
self.start(reset=reset)
try:
result = func(*args, **kwargs)
@@ -151,7 +117,8 @@ class BaseMockAWS(ContextManager["BaseMockAWS"]):
wrapper.__wrapped__ = func # type: ignore[attr-defined]
return wrapper
- def decorate_class(self, klass: type) -> object:
+ def decorate_class(self, klass: "Callable[P, T]") -> "Callable[P, T]":
+ assert inspect.isclass(klass) # Keep mypy happy
direct_methods = get_direct_methods_of(klass)
defined_classes = set(
x for x, y in klass.__dict__.items() if inspect.isclass(y)
@@ -236,6 +203,48 @@ class BaseMockAWS(ContextManager["BaseMockAWS"]):
else:
del os.environ[k]
+ def reset(self) -> None:
+ botocore_stubber.reset()
+ reset_responses_mock(responses_mock)
+
+ def enable_patching(
+ self, reset: bool = True # pylint: disable=unused-argument
+ ) -> None:
+ botocore_stubber.enabled = True
+ if reset:
+ self.reset()
+ responses_mock.start()
+ self.user_config_mock.start()
+
+ for method in RESPONSES_METHODS:
+ for _, pattern in backend_index.backend_url_patterns:
+ responses_mock.add(
+ CallbackResponse(
+ method=method,
+ url=pattern,
+ callback=botocore_stubber.process_request,
+ )
+ )
+ responses_mock.add(
+ CallbackResponse(
+ method=method,
+ url=re.compile(r"https?://.+\.amazonaws.com/.*"),
+ callback=not_implemented_callback,
+ )
+ )
+
+ def disable_patching(self, remove_data: bool) -> None:
+ botocore_stubber.enabled = False
+ if remove_data:
+ self.reset()
+ reset_model_data()
+
+ try:
+ responses_mock.stop()
+ except RuntimeError:
+ pass
+ self.user_config_mock.stop()
+
def get_direct_methods_of(klass: object) -> Set[str]:
return set(
@@ -255,11 +264,6 @@ RESPONSES_METHODS = [
responses.PUT,
]
-botocore_mock = responses.RequestsMock(
- assert_all_requests_are_fired=False,
- target="botocore.vendored.requests.adapters.HTTPAdapter.send",
-)
-
responses_mock = get_response_mock()
BOTOCORE_HTTP_METHODS = ["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
@@ -268,6 +272,8 @@ BOTOCORE_HTTP_METHODS = ["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "P
botocore_stubber = BotocoreStubber()
BUILTIN_HANDLERS.append(("before-send", botocore_stubber))
+default_user_config = {"batch": {"use_docker": True}, "lambda": {"use_docker": True}}
+
def patch_client(client: botocore.client.BaseClient) -> None:
"""
@@ -336,69 +342,7 @@ def override_responses_real_send(user_mock: Optional[responses.RequestsMock]) ->
responses_mock._real_send = user_mock.unbound_on_send()
-class BotocoreEventMockAWS(BaseMockAWS):
- def reset(self) -> None:
- botocore_stubber.reset()
- reset_responses_mock(responses_mock)
-
- def enable_patching(
- self, reset: bool = True # pylint: disable=unused-argument
- ) -> None:
- # Circumvent circular imports
- from .utils import convert_flask_to_responses_response
-
- botocore_stubber.enabled = True
- for method in BOTOCORE_HTTP_METHODS:
- for backend in self.backends_for_urls:
- for key, value in backend.urls.items():
- pattern = re.compile(key)
- botocore_stubber.register_response(method, pattern, value)
-
- if not hasattr(responses_mock, "_patcher") or not hasattr(
- responses_mock._patcher, "target"
- ):
- responses_mock.start()
-
- for method in RESPONSES_METHODS:
- # for backend in default_backends.values():
- for backend in self.backends_for_urls:
- for key, value in backend.urls.items():
- responses_mock.add(
- CallbackResponse(
- method=method,
- url=re.compile(key),
- callback=convert_flask_to_responses_response(value),
- )
- )
- responses_mock.add(
- CallbackResponse(
- method=method,
- url=re.compile(r"https?://.+\.amazonaws.com/.*"),
- callback=not_implemented_callback,
- )
- )
- botocore_mock.add(
- CallbackResponse(
- method=method,
- url=re.compile(r"https?://.+\.amazonaws.com/.*"),
- callback=not_implemented_callback,
- )
- )
-
- def disable_patching(self) -> None:
- botocore_stubber.enabled = False
- self.reset()
-
- try:
- responses_mock.stop()
- except RuntimeError:
- pass
-
-
-MockAWS = BotocoreEventMockAWS
-
-
-class ServerModeMockAWS(BaseMockAWS):
+class ServerModeMockAWS(MockAWS):
RESET_IN_PROGRESS = False
def __init__(self, *args: Any, **kwargs: Any):
@@ -456,13 +400,15 @@ class ServerModeMockAWS(BaseMockAWS):
return region
return None
- def disable_patching(self) -> None:
+ def disable_patching(self, remove_data: bool) -> None:
if self._client_patcher:
self._client_patcher.stop()
self._resource_patcher.stop()
+ if remove_data:
+ self.reset()
-class ProxyModeMockAWS(BaseMockAWS):
+class ProxyModeMockAWS(MockAWS):
RESET_IN_PROGRESS = False
@@ -520,52 +466,7 @@ class ProxyModeMockAWS(BaseMockAWS):
self._client_patcher.start()
self._resource_patcher.start()
- def disable_patching(self) -> None:
+ def disable_patching(self, remove_data: bool) -> None:
if self._client_patcher:
self._client_patcher.stop()
self._resource_patcher.stop()
-
-
-class base_decorator:
- mock_backend = MockAWS
-
- def __init__(self, backends: BackendDict[SERVICE_BACKEND]):
- self.backends = backends
-
- @overload
- def __call__(self, func: None = None) -> BaseMockAWS:
- ...
-
- @overload
- def __call__(self, func: "Callable[P, T]") -> "Callable[P, T]":
- ...
-
- def __call__(
- self, func: "Optional[Callable[P, T]]" = None
- ) -> "Union[BaseMockAWS, Callable[P, T]]":
- if settings.test_proxy_mode():
- mocked_backend: BaseMockAWS = ProxyModeMockAWS(self.backends)
- elif settings.TEST_SERVER_MODE:
- mocked_backend = ServerModeMockAWS(self.backends)
- else:
- mocked_backend = self.mock_backend(self.backends)
-
- if func:
- return mocked_backend(func)
- else:
- return mocked_backend
-
-
-class BaseDecorator(Protocol):
- """A protocol for base_decorator's signature.
-
- This enables typing of callables with the same behavior as base_decorator.
- """
-
- @overload
- def __call__(self, func: None = None) -> BaseMockAWS:
- ...
-
- @overload
- def __call__(self, func: "Callable[P, T]") -> "Callable[P, T]":
- ...
diff --git a/moto/core/responses_custom_registry.py b/moto/core/responses_custom_registry.py
index b83a2d286..135e47c8e 100644
--- a/moto/core/responses_custom_registry.py
+++ b/moto/core/responses_custom_registry.py
@@ -27,8 +27,7 @@ class CustomRegistry(responses.registries.FirstMatchRegistry):
return res
def add(self, response: responses.BaseResponse) -> responses.BaseResponse:
- if response not in self._registered[response.method]:
- self._registered[response.method].append(response)
+ self._registered[response.method].append(response)
return response
def reset(self) -> None:
@@ -56,6 +55,15 @@ class CustomRegistry(responses.registries.FirstMatchRegistry):
if type(m) is not CallbackResponse or m.callback != not_implemented_callback
]
if implemented_matches:
+ # Prioritize responses.CallbackResponse
+ # Usecases:
+ #
+ # - Callbacks created by APIGateway to intercept URL requests to *.execute-api.amazonaws.com
+ #
+ for match in implemented_matches:
+ if type(match) == responses.CallbackResponse:
+ return match, match_failed_reasons
+ # Return moto.core.custom_responses_mock.CallbackResponse otherwise
return implemented_matches[0], match_failed_reasons
elif found:
# We had matches, but all were of type not_implemented_callback
diff --git a/moto/databrew/__init__.py b/moto/databrew/__init__.py
index 66de01886..cd500e83f 100644
--- a/moto/databrew/__init__.py
+++ b/moto/databrew/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import databrew_backends
-
-mock_databrew = base_decorator(databrew_backends)
+from .models import databrew_backends # noqa: F401
diff --git a/moto/datapipeline/__init__.py b/moto/datapipeline/__init__.py
index 65d36727c..892325cb8 100644
--- a/moto/datapipeline/__init__.py
+++ b/moto/datapipeline/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import datapipeline_backends
-
-mock_datapipeline = base_decorator(datapipeline_backends)
+from .models import datapipeline_backends # noqa: F401
diff --git a/moto/datasync/__init__.py b/moto/datasync/__init__.py
index f9b9ff1aa..0c8d05bbc 100644
--- a/moto/datasync/__init__.py
+++ b/moto/datasync/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import datasync_backends
-
-datasync_backend = datasync_backends["us-east-1"]
-mock_datasync = base_decorator(datasync_backends)
+from .models import datasync_backends # noqa: F401
diff --git a/moto/dax/__init__.py b/moto/dax/__init__.py
index 13e8910ba..0888faa63 100644
--- a/moto/dax/__init__.py
+++ b/moto/dax/__init__.py
@@ -1,5 +1 @@
-"""dax module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import dax_backends
-
-mock_dax = base_decorator(dax_backends)
+from .models import dax_backends # noqa: F401
diff --git a/moto/dms/__init__.py b/moto/dms/__init__.py
index 75679f6fc..752a5fc15 100644
--- a/moto/dms/__init__.py
+++ b/moto/dms/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import dms_backends
-
-dms_backend = dms_backends["us-east-1"]
-mock_dms = base_decorator(dms_backends)
+from .models import dms_backends # noqa: F401
diff --git a/moto/ds/__init__.py b/moto/ds/__init__.py
index 1fec2356d..fa952daf5 100644
--- a/moto/ds/__init__.py
+++ b/moto/ds/__init__.py
@@ -1,5 +1 @@
-"""ds module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import ds_backends
-
-mock_ds = base_decorator(ds_backends)
+from .models import ds_backends # noqa: F401
diff --git a/moto/dynamodb/__init__.py b/moto/dynamodb/__init__.py
index cd9bdca12..bdb0e39da 100644
--- a/moto/dynamodb/__init__.py
+++ b/moto/dynamodb/__init__.py
@@ -1,6 +1 @@
-from moto.dynamodb.models import dynamodb_backends
-
-from ..core.models import base_decorator
-
-dynamodb_backend = dynamodb_backends["us-east-1"]
-mock_dynamodb = base_decorator(dynamodb_backends)
+from moto.dynamodb.models import dynamodb_backends # noqa: F401
diff --git a/moto/dynamodb/models/table.py b/moto/dynamodb/models/table.py
index c675a7bec..42a625923 100644
--- a/moto/dynamodb/models/table.py
+++ b/moto/dynamodb/models/table.py
@@ -203,14 +203,14 @@ class StreamShard(BaseModel):
seq = len(self.items) + self.starting_sequence_number
self.items.append(StreamRecord(self.table, t, event_name, old, new, seq))
result = None
- from moto.awslambda import lambda_backends
+ from moto.awslambda.utils import get_backend
for arn, esm in self.table.lambda_event_source_mappings.items():
region = arn[
len("arn:aws:lambda:") : arn.index(":", len("arn:aws:lambda:"))
]
- result = lambda_backends[self.account_id][region].send_dynamodb_items(
+ result = get_backend(self.account_id, region).send_dynamodb_items(
arn, self.items, esm.event_source_arn
)
diff --git a/moto/dynamodb_v20111205/__init__.py b/moto/dynamodb_v20111205/__init__.py
index 934802628..af5babadb 100644
--- a/moto/dynamodb_v20111205/__init__.py
+++ b/moto/dynamodb_v20111205/__init__.py
@@ -1,9 +1 @@
-from ..core.models import base_decorator
-from .models import dynamodb_backends
-
-"""
-An older API version of DynamoDB.
-Please see the corresponding tests (tests/test_dynamodb_v20111205) on how to invoke this API.
-"""
-
-mock_dynamodb = base_decorator(dynamodb_backends)
+from .models import dynamodb_backends # noqa: F401
diff --git a/moto/dynamodbstreams/__init__.py b/moto/dynamodbstreams/__init__.py
index dc6b8edf4..873e0f776 100644
--- a/moto/dynamodbstreams/__init__.py
+++ b/moto/dynamodbstreams/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import dynamodbstreams_backends
-
-dynamodbstreams_backend = dynamodbstreams_backends["us-east-1"]
-mock_dynamodbstreams = base_decorator(dynamodbstreams_backends)
+from .models import dynamodbstreams_backends # noqa: F401
diff --git a/moto/ebs/__init__.py b/moto/ebs/__init__.py
index cc67e7d8f..4efe8973a 100644
--- a/moto/ebs/__init__.py
+++ b/moto/ebs/__init__.py
@@ -1,5 +1 @@
-"""ebs module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import ebs_backends
-
-mock_ebs = base_decorator(ebs_backends)
+from .models import ebs_backends # noqa: F401
diff --git a/moto/ec2/__init__.py b/moto/ec2/__init__.py
index d3cc5b4ac..7598a65d0 100644
--- a/moto/ec2/__init__.py
+++ b/moto/ec2/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import ec2_backends
-
-mock_ec2 = base_decorator(ec2_backends)
+from .models import ec2_backends # noqa: F401
diff --git a/moto/ec2/models/vpcs.py b/moto/ec2/models/vpcs.py
index 347b5d8b7..41a9ad72d 100644
--- a/moto/ec2/models/vpcs.py
+++ b/moto/ec2/models/vpcs.py
@@ -44,7 +44,7 @@ IMPLEMENTED_ENDPOINT_SERVICES = [
"applicationautoscaling",
"athena",
"autoscaling",
- "lambda",
+ "awslambda",
"cloudformation",
"cloudwatch",
"codecommit",
diff --git a/moto/ec2instanceconnect/__init__.py b/moto/ec2instanceconnect/__init__.py
index c53958f7e..02e9a4461 100644
--- a/moto/ec2instanceconnect/__init__.py
+++ b/moto/ec2instanceconnect/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import ec2instanceconnect_backends
-
-mock_ec2instanceconnect = base_decorator(ec2instanceconnect_backends)
+from .models import ec2instanceconnect_backends # noqa: F401
diff --git a/moto/ecr/__init__.py b/moto/ecr/__init__.py
index d093f47ea..ab2198b2e 100644
--- a/moto/ecr/__init__.py
+++ b/moto/ecr/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import ecr_backends
-
-ecr_backend = ecr_backends["us-east-1"]
-mock_ecr = base_decorator(ecr_backends)
+from .models import ecr_backends # noqa: F401
diff --git a/moto/ecs/__init__.py b/moto/ecs/__init__.py
index 52199aece..5fba66d4b 100644
--- a/moto/ecs/__init__.py
+++ b/moto/ecs/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import ecs_backends
-
-ecs_backend = ecs_backends["us-east-1"]
-mock_ecs = base_decorator(ecs_backends)
+from .models import ecs_backends # noqa: F401
diff --git a/moto/efs/__init__.py b/moto/efs/__init__.py
index e03e33d7f..abcdc6fb3 100644
--- a/moto/efs/__init__.py
+++ b/moto/efs/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import efs_backends
-
-efs_backend = efs_backends["us-east-1"]
-mock_efs = base_decorator(efs_backends)
+from .models import efs_backends # noqa: F401
diff --git a/moto/eks/__init__.py b/moto/eks/__init__.py
index 2cbbabf23..f932f85b9 100644
--- a/moto/eks/__init__.py
+++ b/moto/eks/__init__.py
@@ -1,6 +1 @@
-from ..core.models import base_decorator
-from .models import eks_backends
-
-REGION = "us-east-1"
-eks_backend = eks_backends[REGION]
-mock_eks = base_decorator(eks_backends)
+from .models import eks_backends # noqa: F401
diff --git a/moto/elasticache/__init__.py b/moto/elasticache/__init__.py
index 741fe68ee..454088603 100644
--- a/moto/elasticache/__init__.py
+++ b/moto/elasticache/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import elasticache_backends
-
-mock_elasticache = base_decorator(elasticache_backends)
+from .models import elasticache_backends # noqa: F401
diff --git a/moto/elasticbeanstalk/__init__.py b/moto/elasticbeanstalk/__init__.py
index 41eb28565..8ddbdac99 100644
--- a/moto/elasticbeanstalk/__init__.py
+++ b/moto/elasticbeanstalk/__init__.py
@@ -1,5 +1 @@
-from moto.core.models import base_decorator
-
-from .models import eb_backends
-
-mock_elasticbeanstalk = base_decorator(eb_backends)
+from .models import eb_backends # noqa: F401
diff --git a/moto/elastictranscoder/__init__.py b/moto/elastictranscoder/__init__.py
index b5013cc35..74fda7f6d 100644
--- a/moto/elastictranscoder/__init__.py
+++ b/moto/elastictranscoder/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import elastictranscoder_backends
-
-mock_elastictranscoder = base_decorator(elastictranscoder_backends)
+from .models import elastictranscoder_backends # noqa: F401
diff --git a/moto/elb/__init__.py b/moto/elb/__init__.py
index ee35c435c..d43dee42d 100644
--- a/moto/elb/__init__.py
+++ b/moto/elb/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import elb_backends
-
-elb_backend = elb_backends["us-east-1"]
-mock_elb = base_decorator(elb_backends)
+from .models import elb_backends # noqa: F401
diff --git a/moto/elbv2/__init__.py b/moto/elbv2/__init__.py
index 3a82b9b5b..01f0f07fb 100644
--- a/moto/elbv2/__init__.py
+++ b/moto/elbv2/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import elbv2_backends
-
-elb_backend = elbv2_backends["us-east-1"]
-mock_elbv2 = base_decorator(elbv2_backends)
+from .models import elbv2_backends # noqa: F401
diff --git a/moto/emr/__init__.py b/moto/emr/__init__.py
index c96f2bf11..def1ce61a 100644
--- a/moto/emr/__init__.py
+++ b/moto/emr/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import emr_backends
-
-emr_backend = emr_backends["us-east-1"]
-mock_emr = base_decorator(emr_backends)
+from .models import emr_backends # noqa: F401
diff --git a/moto/emrcontainers/__init__.py b/moto/emrcontainers/__init__.py
index f4989de54..bf47253d3 100644
--- a/moto/emrcontainers/__init__.py
+++ b/moto/emrcontainers/__init__.py
@@ -1,6 +1 @@
-"""emrcontainers module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import emrcontainers_backends
-
-REGION = "us-east-1"
-mock_emrcontainers = base_decorator(emrcontainers_backends)
+from .models import emrcontainers_backends # noqa: F401
diff --git a/moto/emrserverless/__init__.py b/moto/emrserverless/__init__.py
index 91a973dce..54a2c4c96 100644
--- a/moto/emrserverless/__init__.py
+++ b/moto/emrserverless/__init__.py
@@ -1,7 +1,4 @@
-"""emrserverless module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import emrserverless_backends
+from .models import emrserverless_backends # noqa: F401
REGION = "us-east-1"
RELEASE_LABEL = "emr-6.6.0"
-mock_emrserverless = base_decorator(emrserverless_backends)
diff --git a/moto/es/__init__.py b/moto/es/__init__.py
index 23fa6f338..91bcebcac 100644
--- a/moto/es/__init__.py
+++ b/moto/es/__init__.py
@@ -1,5 +1 @@
-"""es module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import es_backends
-
-mock_es = base_decorator(es_backends)
+from .models import es_backends # noqa: F401
diff --git a/moto/es/urls.py b/moto/es/urls.py
index c1c234de0..d125e9a09 100644
--- a/moto/es/urls.py
+++ b/moto/es/urls.py
@@ -16,6 +16,6 @@ url_paths = {
"{0}/2021-01-01/opensearch/domain": OpenSearchServiceResponse.dispatch,
"{0}/2021-01-01/opensearch/domain/(?P[^/]+)": OpenSearchServiceResponse.dispatch,
"{0}/2021-01-01/opensearch/domain/(?P[^/]+)/config": OpenSearchServiceResponse.dispatch,
- "{0}/2021-01-01/tags/": OpenSearchServiceResponse.dispatch,
+ "{0}/2021-01-01/tags/?": OpenSearchServiceResponse.dispatch,
"{0}/2021-01-01/tags-removal/": OpenSearchServiceResponse.dispatch,
}
diff --git a/moto/events/__init__.py b/moto/events/__init__.py
index d40e230b1..eeec314b7 100644
--- a/moto/events/__init__.py
+++ b/moto/events/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import events_backends
-
-events_backend = events_backends["us-east-1"]
-mock_events = base_decorator(events_backends)
+from .models import events_backends # noqa: F401
diff --git a/moto/events/notifications.py b/moto/events/notifications.py
index 3dd94fcad..fede9a8b4 100644
--- a/moto/events/notifications.py
+++ b/moto/events/notifications.py
@@ -57,12 +57,12 @@ def _send_safe_notification(
def _invoke_lambda(account_id: str, fn_arn: str, event: Any) -> None:
- from moto.awslambda import lambda_backends
+ from moto.awslambda.utils import get_backend
lambda_region = fn_arn.split(":")[3]
body = json.dumps(event)
- lambda_backends[account_id][lambda_region].invoke(
+ get_backend(account_id, lambda_region).invoke(
function_name=fn_arn,
qualifier=None, # type: ignore[arg-type]
body=body,
diff --git a/moto/firehose/__init__.py b/moto/firehose/__init__.py
index 815ab47be..b9b7d19c5 100644
--- a/moto/firehose/__init__.py
+++ b/moto/firehose/__init__.py
@@ -1,5 +1 @@
-"""Firehose module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import firehose_backends
-
-mock_firehose = base_decorator(firehose_backends)
+from .models import firehose_backends # noqa: F401
diff --git a/moto/forecast/__init__.py b/moto/forecast/__init__.py
index 147250b16..b2bdf8b15 100644
--- a/moto/forecast/__init__.py
+++ b/moto/forecast/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import forecast_backends
-
-forecast_backend = forecast_backends["us-east-1"]
-mock_forecast = base_decorator(forecast_backends)
+from .models import forecast_backends # noqa: F401
diff --git a/moto/glacier/__init__.py b/moto/glacier/__init__.py
index 57a9ff943..170a9422a 100644
--- a/moto/glacier/__init__.py
+++ b/moto/glacier/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import glacier_backends
-
-glacier_backend = glacier_backends["us-east-1"]
-mock_glacier = base_decorator(glacier_backends)
+from .models import glacier_backends # noqa: F401
diff --git a/moto/glue/__init__.py b/moto/glue/__init__.py
index aa9b85fa3..354597e7e 100644
--- a/moto/glue/__init__.py
+++ b/moto/glue/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import glue_backends
-
-mock_glue = base_decorator(glue_backends)
+from .models import glue_backends # noqa: F401
diff --git a/moto/greengrass/__init__.py b/moto/greengrass/__init__.py
index 550542cee..1001a8df5 100644
--- a/moto/greengrass/__init__.py
+++ b/moto/greengrass/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import greengrass_backends
-
-mock_greengrass = base_decorator(greengrass_backends)
+from .models import greengrass_backends # noqa: F401
diff --git a/moto/guardduty/__init__.py b/moto/guardduty/__init__.py
index 01a69fe39..d3e61e807 100644
--- a/moto/guardduty/__init__.py
+++ b/moto/guardduty/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import guardduty_backends
-
-guardduty_backend = guardduty_backends["us-east-1"]
-mock_guardduty = base_decorator(guardduty_backends)
+from .models import guardduty_backends # noqa: F401
diff --git a/moto/iam/__init__.py b/moto/iam/__init__.py
index bade9a5a7..8a5b4b174 100644
--- a/moto/iam/__init__.py
+++ b/moto/iam/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import iam_backends
-
-mock_iam = base_decorator(iam_backends)
+from .models import iam_backends # noqa: F401
diff --git a/moto/identitystore/__init__.py b/moto/identitystore/__init__.py
index 423ff5262..dbb84a2ee 100644
--- a/moto/identitystore/__init__.py
+++ b/moto/identitystore/__init__.py
@@ -1,5 +1 @@
-"""identitystore module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import identitystore_backends
-
-mock_identitystore = base_decorator(identitystore_backends)
+from .models import identitystore_backends # noqa: F401
diff --git a/moto/inspector2/__init__.py b/moto/inspector2/__init__.py
index dfc08a4cc..fbdfd6393 100644
--- a/moto/inspector2/__init__.py
+++ b/moto/inspector2/__init__.py
@@ -1,5 +1 @@
-"""inspector2 module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import inspector2_backends
-
-mock_inspector2 = base_decorator(inspector2_backends)
+from .models import inspector2_backends # noqa: F401
diff --git a/moto/iot/__init__.py b/moto/iot/__init__.py
index 853b80fe2..0d22e84db 100644
--- a/moto/iot/__init__.py
+++ b/moto/iot/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import iot_backends
-
-mock_iot = base_decorator(iot_backends)
+from .models import iot_backends # noqa: F401
diff --git a/moto/iotdata/__init__.py b/moto/iotdata/__init__.py
index 1c30e234e..917d495ee 100644
--- a/moto/iotdata/__init__.py
+++ b/moto/iotdata/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import iotdata_backends
-
-mock_iotdata = base_decorator(iotdata_backends)
+from .models import iotdata_backends # noqa: F401
diff --git a/moto/ivs/__init__.py b/moto/ivs/__init__.py
index ccda88cd1..fb9889d8e 100644
--- a/moto/ivs/__init__.py
+++ b/moto/ivs/__init__.py
@@ -1,5 +1 @@
-"""ivs module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import ivs_backends
-
-mock_ivs = base_decorator(ivs_backends)
+from .models import ivs_backends # noqa: F401
diff --git a/moto/kinesis/__init__.py b/moto/kinesis/__init__.py
index 05810378d..216f20f97 100644
--- a/moto/kinesis/__init__.py
+++ b/moto/kinesis/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import kinesis_backends
-
-kinesis_backend = kinesis_backends["us-east-1"]
-mock_kinesis = base_decorator(kinesis_backends)
+from .models import kinesis_backends # noqa: F401
diff --git a/moto/kinesisvideo/__init__.py b/moto/kinesisvideo/__init__.py
index 5a887492d..e08af65e6 100644
--- a/moto/kinesisvideo/__init__.py
+++ b/moto/kinesisvideo/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import kinesisvideo_backends
-
-kinesisvideo_backend = kinesisvideo_backends["us-east-1"]
-mock_kinesisvideo = base_decorator(kinesisvideo_backends)
+from .models import kinesisvideo_backends # noqa: F401
diff --git a/moto/kinesisvideoarchivedmedia/__init__.py b/moto/kinesisvideoarchivedmedia/__init__.py
index a94140017..2a232ab32 100644
--- a/moto/kinesisvideoarchivedmedia/__init__.py
+++ b/moto/kinesisvideoarchivedmedia/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import kinesisvideoarchivedmedia_backends
-
-kinesisvideoarchivedmedia_backend = kinesisvideoarchivedmedia_backends["us-east-1"]
-mock_kinesisvideoarchivedmedia = base_decorator(kinesisvideoarchivedmedia_backends)
+from .models import kinesisvideoarchivedmedia_backends # noqa: F401
diff --git a/moto/kms/__init__.py b/moto/kms/__init__.py
index 05db0ad9c..d329b58a6 100644
--- a/moto/kms/__init__.py
+++ b/moto/kms/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import kms_backends
-
-kms_backend = kms_backends["us-east-1"]
-mock_kms = base_decorator(kms_backends)
+from .models import kms_backends # noqa: F401
diff --git a/moto/lakeformation/__init__.py b/moto/lakeformation/__init__.py
index 34e54adf6..c2a564acb 100644
--- a/moto/lakeformation/__init__.py
+++ b/moto/lakeformation/__init__.py
@@ -1,5 +1 @@
-"""lakeformation module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import lakeformation_backends
-
-mock_lakeformation = base_decorator(lakeformation_backends)
+from .models import lakeformation_backends # noqa: F401
diff --git a/moto/logs/__init__.py b/moto/logs/__init__.py
index 6eb4aca07..8568f0f13 100644
--- a/moto/logs/__init__.py
+++ b/moto/logs/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import logs_backends
-
-mock_logs = base_decorator(logs_backends)
+from .models import logs_backends # noqa: F401
diff --git a/moto/logs/models.py b/moto/logs/models.py
index fbff77a9f..ae144aaab 100644
--- a/moto/logs/models.py
+++ b/moto/logs/models.py
@@ -209,9 +209,9 @@ class LogStream(BaseModel):
) -> None:
if service == "lambda":
- from moto.awslambda import lambda_backends # due to circular dependency
+ from moto.awslambda.utils import get_backend
- lambda_backends[self.account_id][self.region].send_log_event(
+ get_backend(self.account_id, self.region).send_log_event(
destination_arn,
filter_name,
self.log_group.name,
@@ -1146,10 +1146,10 @@ class LogsBackend(BaseBackend):
service = destination_arn.split(":")[2]
if service == "lambda":
- from moto.awslambda import lambda_backends
+ from moto.awslambda.utils import get_backend
try:
- lambda_backends[self.account_id][self.region_name].get_function(
+ get_backend(self.account_id, self.region_name).get_function(
destination_arn
)
# no specific permission check implemented
diff --git a/moto/managedblockchain/__init__.py b/moto/managedblockchain/__init__.py
index 3ee8532f1..2dc9f268b 100644
--- a/moto/managedblockchain/__init__.py
+++ b/moto/managedblockchain/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import managedblockchain_backends
-
-managedblockchain_backend = managedblockchain_backends["us-east-1"]
-mock_managedblockchain = base_decorator(managedblockchain_backends)
+from .models import managedblockchain_backends # noqa: F401
diff --git a/moto/mediaconnect/__init__.py b/moto/mediaconnect/__init__.py
index 77e66a657..49e68cd6a 100644
--- a/moto/mediaconnect/__init__.py
+++ b/moto/mediaconnect/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import mediaconnect_backends
-
-mediaconnect_backend = mediaconnect_backends["us-east-1"]
-mock_mediaconnect = base_decorator(mediaconnect_backends)
+from .models import mediaconnect_backends # noqa: F401
diff --git a/moto/medialive/__init__.py b/moto/medialive/__init__.py
index 1deaf15f4..a3234e69a 100644
--- a/moto/medialive/__init__.py
+++ b/moto/medialive/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import medialive_backends
-
-mock_medialive = base_decorator(medialive_backends)
+from .models import medialive_backends # noqa: F401
diff --git a/moto/mediapackage/__init__.py b/moto/mediapackage/__init__.py
index 914f6e730..4b0dc8356 100644
--- a/moto/mediapackage/__init__.py
+++ b/moto/mediapackage/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import mediapackage_backends
-
-mediapackage_backend = mediapackage_backends["us-east-1"]
-mock_mediapackage = base_decorator(mediapackage_backends)
+from .models import mediapackage_backends # noqa: F401
diff --git a/moto/mediastore/__init__.py b/moto/mediastore/__init__.py
index 22092c022..63e3d965c 100644
--- a/moto/mediastore/__init__.py
+++ b/moto/mediastore/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import mediastore_backends
-
-mediastore_backend = mediastore_backends["us-east-1"]
-mock_mediastore = base_decorator(mediastore_backends)
+from .models import mediastore_backends # noqa: F401
diff --git a/moto/mediastoredata/__init__.py b/moto/mediastoredata/__init__.py
index 6a1ed3cac..6501ba20b 100644
--- a/moto/mediastoredata/__init__.py
+++ b/moto/mediastoredata/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import mediastoredata_backends
-
-mediastoredata_backend = mediastoredata_backends["us-east-1"]
-mock_mediastoredata = base_decorator(mediastoredata_backends)
+from .models import mediastoredata_backends # noqa: F401
diff --git a/moto/meteringmarketplace/__init__.py b/moto/meteringmarketplace/__init__.py
index 132a05560..00b836c69 100644
--- a/moto/meteringmarketplace/__init__.py
+++ b/moto/meteringmarketplace/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import meteringmarketplace_backends
-
-meteringmarketplace_backend = meteringmarketplace_backends["us-east-1"]
-mock_meteringmarketplace = base_decorator(meteringmarketplace_backends)
+from .models import meteringmarketplace_backends # noqa: F401
diff --git a/moto/moto_api/_internal/models.py b/moto/moto_api/_internal/models.py
index 1da14c4ec..3a5c596c2 100644
--- a/moto/moto_api/_internal/models.py
+++ b/moto/moto_api/_internal/models.py
@@ -1,6 +1,6 @@
from typing import Any, Dict, List, Optional
-from moto.core import DEFAULT_ACCOUNT_ID, BaseBackend
+from moto.core import DEFAULT_ACCOUNT_ID, BackendDict, BaseBackend
from moto.core.model_instances import reset_model_data
@@ -9,13 +9,7 @@ class MotoAPIBackend(BaseBackend):
region_name = self.region_name
account_id = self.account_id
- import moto.backends as backends
-
- for name, backends_ in backends.loaded_backends():
- if name == "moto_api":
- continue
- for backend in backends_.values():
- backend.reset()
+ BackendDict.reset()
reset_model_data()
self.__init__(region_name, account_id) # type: ignore[misc]
diff --git a/moto/moto_server/werkzeug_app.py b/moto/moto_server/werkzeug_app.py
index 25b76ad17..2b5b3275c 100644
--- a/moto/moto_server/werkzeug_app.py
+++ b/moto/moto_server/werkzeug_app.py
@@ -75,7 +75,7 @@ class DomainDispatcherApplication:
if self.service:
return self.service
- if host in backends.BACKENDS:
+ if host in backends.list_of_moto_modules():
return host
for backend, pattern in self.backend_url_patterns:
diff --git a/moto/mq/__init__.py b/moto/mq/__init__.py
index d98737807..4179472f3 100644
--- a/moto/mq/__init__.py
+++ b/moto/mq/__init__.py
@@ -1,5 +1 @@
-"""mq module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import mq_backends
-
-mock_mq = base_decorator(mq_backends)
+from .models import mq_backends # noqa: F401
diff --git a/moto/neptune/__init__.py b/moto/neptune/__init__.py
index 8507c7410..f3eb618b4 100644
--- a/moto/neptune/__init__.py
+++ b/moto/neptune/__init__.py
@@ -5,7 +5,4 @@ It shares almost everything with RDS: the endpoint URL, and the features. Only t
Because the endpoint URL is the same (rds.amazonaws.com), every request is intercepted by the RDS service.
RDS then has to determine whether any incoming call was meant for RDS, or for neptune.
"""
-from ..core.models import base_decorator
-from .models import neptune_backends
-
-mock_neptune = base_decorator(neptune_backends)
+from .models import neptune_backends # noqa: F401
diff --git a/moto/opensearch/__init__.py b/moto/opensearch/__init__.py
index 8589bcb50..976f959c1 100644
--- a/moto/opensearch/__init__.py
+++ b/moto/opensearch/__init__.py
@@ -1,5 +1 @@
-"""opensearch module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import opensearch_backends
-
-mock_opensearch = base_decorator(opensearch_backends)
+from .models import opensearch_backends # noqa: F401
diff --git a/moto/opsworks/__init__.py b/moto/opsworks/__init__.py
index 9fc813dbf..29a46bdcb 100644
--- a/moto/opsworks/__init__.py
+++ b/moto/opsworks/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import opsworks_backends
-
-opsworks_backend = opsworks_backends["us-east-1"]
-mock_opsworks = base_decorator(opsworks_backends)
+from .models import opsworks_backends # noqa: F401
diff --git a/moto/organizations/__init__.py b/moto/organizations/__init__.py
index 8a343171e..58ee412e2 100644
--- a/moto/organizations/__init__.py
+++ b/moto/organizations/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import organizations_backends
-
-mock_organizations = base_decorator(organizations_backends)
+from .models import organizations_backends # noqa: F401
diff --git a/moto/panorama/__init__.py b/moto/panorama/__init__.py
index 53d80c28b..e2250152c 100644
--- a/moto/panorama/__init__.py
+++ b/moto/panorama/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import panorama_backends
-
-mock_panorama = base_decorator(panorama_backends)
+from .models import panorama_backends # noqa: F401
diff --git a/moto/personalize/__init__.py b/moto/personalize/__init__.py
index 963636aab..3f0658236 100644
--- a/moto/personalize/__init__.py
+++ b/moto/personalize/__init__.py
@@ -1,5 +1 @@
-"""personalize module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import personalize_backends
-
-mock_personalize = base_decorator(personalize_backends)
+from .models import personalize_backends # noqa: F401
diff --git a/moto/pinpoint/__init__.py b/moto/pinpoint/__init__.py
index 711f49426..aeb84f21f 100644
--- a/moto/pinpoint/__init__.py
+++ b/moto/pinpoint/__init__.py
@@ -1,5 +1 @@
-"""pinpoint module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import pinpoint_backends
-
-mock_pinpoint = base_decorator(pinpoint_backends)
+from .models import pinpoint_backends # noqa: F401
diff --git a/moto/polly/__init__.py b/moto/polly/__init__.py
index 906646c33..f6ef2dca7 100644
--- a/moto/polly/__init__.py
+++ b/moto/polly/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import polly_backends
-
-polly_backend = polly_backends["us-east-1"]
-mock_polly = base_decorator(polly_backends)
+from .models import polly_backends # noqa: F401
diff --git a/moto/quicksight/__init__.py b/moto/quicksight/__init__.py
index 123c078b7..8d73e9eba 100644
--- a/moto/quicksight/__init__.py
+++ b/moto/quicksight/__init__.py
@@ -1,5 +1 @@
-"""quicksight module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import quicksight_backends
-
-mock_quicksight = base_decorator(quicksight_backends)
+from .models import quicksight_backends # noqa: F401
diff --git a/moto/ram/__init__.py b/moto/ram/__init__.py
index 767c2d0ca..813e6a8d4 100644
--- a/moto/ram/__init__.py
+++ b/moto/ram/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import ram_backends
-
-ram_backend = ram_backends["us-east-1"]
-mock_ram = base_decorator(ram_backends)
+from .models import ram_backends # noqa: F401
diff --git a/moto/rds/__init__.py b/moto/rds/__init__.py
index 2d5a3732f..462651251 100644
--- a/moto/rds/__init__.py
+++ b/moto/rds/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import rds_backends
-
-rds_backend = rds_backends["us-west-1"]
-mock_rds = base_decorator(rds_backends)
+from .models import rds_backends # noqa: F401
diff --git a/moto/rdsdata/__init__.py b/moto/rdsdata/__init__.py
index 5db4af5ca..8e62c5ae8 100644
--- a/moto/rdsdata/__init__.py
+++ b/moto/rdsdata/__init__.py
@@ -1,5 +1 @@
-"""rdsdata module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import rdsdata_backends
-
-mock_rdsdata = base_decorator(rdsdata_backends)
+from .models import rdsdata_backends # noqa: F401
diff --git a/moto/redshift/__init__.py b/moto/redshift/__init__.py
index 50fb3c90d..808d6705f 100644
--- a/moto/redshift/__init__.py
+++ b/moto/redshift/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import redshift_backends
-
-mock_redshift = base_decorator(redshift_backends)
+from .models import redshift_backends # noqa: F401
diff --git a/moto/redshiftdata/__init__.py b/moto/redshiftdata/__init__.py
index c0736a0a5..2162f5299 100644
--- a/moto/redshiftdata/__init__.py
+++ b/moto/redshiftdata/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import redshiftdata_backends
-
-mock_redshiftdata = base_decorator(redshiftdata_backends)
+from .models import redshiftdata_backends # noqa: F401
diff --git a/moto/rekognition/__init__.py b/moto/rekognition/__init__.py
index 7e9a8f5b0..51242c0a3 100644
--- a/moto/rekognition/__init__.py
+++ b/moto/rekognition/__init__.py
@@ -1,5 +1 @@
-"""rekognition module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import rekognition_backends
-
-mock_rekognition = base_decorator(rekognition_backends)
+from .models import rekognition_backends # noqa: F401
diff --git a/moto/resourcegroups/__init__.py b/moto/resourcegroups/__init__.py
index c889fe6e7..e331292a5 100644
--- a/moto/resourcegroups/__init__.py
+++ b/moto/resourcegroups/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import resourcegroups_backends
-
-resourcegroups_backend = resourcegroups_backends["us-east-1"]
-mock_resourcegroups = base_decorator(resourcegroups_backends)
+from .models import resourcegroups_backends # noqa: F401
diff --git a/moto/resourcegroupstaggingapi/__init__.py b/moto/resourcegroupstaggingapi/__init__.py
index effa91700..53652fe7e 100644
--- a/moto/resourcegroupstaggingapi/__init__.py
+++ b/moto/resourcegroupstaggingapi/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import resourcegroupstaggingapi_backends
-
-resourcegroupstaggingapi_backend = resourcegroupstaggingapi_backends["us-east-1"]
-mock_resourcegroupstaggingapi = base_decorator(resourcegroupstaggingapi_backends)
+from .models import resourcegroupstaggingapi_backends # noqa: F401
diff --git a/moto/robomaker/__init__.py b/moto/robomaker/__init__.py
index 0efef621e..b2294b094 100644
--- a/moto/robomaker/__init__.py
+++ b/moto/robomaker/__init__.py
@@ -1,5 +1 @@
-"""robomaker module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import robomaker_backends
-
-mock_robomaker = base_decorator(robomaker_backends)
+from .models import robomaker_backends # noqa: F401
diff --git a/moto/route53/__init__.py b/moto/route53/__init__.py
index 7baa67891..ff5e058cf 100644
--- a/moto/route53/__init__.py
+++ b/moto/route53/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import route53_backends
-
-mock_route53 = base_decorator(route53_backends)
+from .models import route53_backends # noqa: F401
diff --git a/moto/route53resolver/__init__.py b/moto/route53resolver/__init__.py
index 6d01fbf05..2addca3d7 100644
--- a/moto/route53resolver/__init__.py
+++ b/moto/route53resolver/__init__.py
@@ -1,5 +1 @@
-"""route53resolver module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import route53resolver_backends
-
-mock_route53resolver = base_decorator(route53resolver_backends)
+from .models import route53resolver_backends # noqa: F401
diff --git a/moto/s3/__init__.py b/moto/s3/__init__.py
index 252a29767..f28b8170f 100644
--- a/moto/s3/__init__.py
+++ b/moto/s3/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import s3_backends
-
-mock_s3 = base_decorator(s3_backends)
+from .models import s3_backends # noqa: F401
diff --git a/moto/s3/models.py b/moto/s3/models.py
index 480601e47..a65f278b3 100644
--- a/moto/s3/models.py
+++ b/moto/s3/models.py
@@ -1578,7 +1578,7 @@ class S3Backend(BaseBackend, CloudWatchMetricProvider):
os.environ["MOTO_S3_CUSTOM_ENDPOINTS"] = "http://custom.internal.endpoint,http://custom.other.endpoint"
- @mock_s3
+ @mock_aws
def test_my_custom_endpoint():
boto3.client("s3", endpoint_url="http://custom.internal.endpoint")
...
diff --git a/moto/s3/notifications.py b/moto/s3/notifications.py
index 389b60070..9836200c8 100644
--- a/moto/s3/notifications.py
+++ b/moto/s3/notifications.py
@@ -151,9 +151,9 @@ def _invoke_awslambda(
account_id: str, event_body: Any, fn_arn: str, region_name: str
) -> None:
try:
- from moto.awslambda.models import lambda_backends
+ from moto.awslambda.utils import get_backend
- lambda_backend = lambda_backends[account_id][region_name]
+ lambda_backend = get_backend(account_id, region_name)
func = lambda_backend.get_function(fn_arn)
func.invoke(json.dumps(event_body), dict(), dict())
except: # noqa
diff --git a/moto/s3control/__init__.py b/moto/s3control/__init__.py
index 595b08d42..019cc2591 100644
--- a/moto/s3control/__init__.py
+++ b/moto/s3control/__init__.py
@@ -1,5 +1 @@
-"""s3control module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import s3control_backends
-
-mock_s3control = base_decorator(s3control_backends)
+from .models import s3control_backends # noqa: F401
diff --git a/moto/sagemaker/__init__.py b/moto/sagemaker/__init__.py
index 71b9bd2e1..a7c9bcde4 100644
--- a/moto/sagemaker/__init__.py
+++ b/moto/sagemaker/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import sagemaker_backends
-
-sagemaker_backend = sagemaker_backends["us-east-1"]
-mock_sagemaker = base_decorator(sagemaker_backends)
+from .models import sagemaker_backends # noqa: F401
diff --git a/moto/sagemakerruntime/__init__.py b/moto/sagemakerruntime/__init__.py
index be055bdf7..b351bbed7 100644
--- a/moto/sagemakerruntime/__init__.py
+++ b/moto/sagemakerruntime/__init__.py
@@ -1,5 +1 @@
-"""sagemakerruntime module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import sagemakerruntime_backends
-
-mock_sagemakerruntime = base_decorator(sagemakerruntime_backends)
+from .models import sagemakerruntime_backends # noqa: F401
diff --git a/moto/scheduler/__init__.py b/moto/scheduler/__init__.py
index 0a0632a45..2aedb98f5 100644
--- a/moto/scheduler/__init__.py
+++ b/moto/scheduler/__init__.py
@@ -1,5 +1 @@
-"""scheduler module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import scheduler_backends
-
-mock_scheduler = base_decorator(scheduler_backends)
+from .models import scheduler_backends # noqa: F401
diff --git a/moto/sdb/__init__.py b/moto/sdb/__init__.py
index 3ddbb5658..2720756ae 100644
--- a/moto/sdb/__init__.py
+++ b/moto/sdb/__init__.py
@@ -1,5 +1 @@
-"""sdb module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import sdb_backends
-
-mock_sdb = base_decorator(sdb_backends)
+from .models import sdb_backends # noqa: F401
diff --git a/moto/secretsmanager/__init__.py b/moto/secretsmanager/__init__.py
index 30d0731c7..10af06e36 100644
--- a/moto/secretsmanager/__init__.py
+++ b/moto/secretsmanager/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import secretsmanager_backends
-
-secretsmanager_backend = secretsmanager_backends["us-east-1"]
-mock_secretsmanager = base_decorator(secretsmanager_backends)
+from .models import secretsmanager_backends # noqa: F401
diff --git a/moto/secretsmanager/models.py b/moto/secretsmanager/models.py
index 933236db2..9452957f6 100644
--- a/moto/secretsmanager/models.py
+++ b/moto/secretsmanager/models.py
@@ -637,9 +637,9 @@ class SecretsManagerBackend(BaseBackend):
# Begin the rotation process for the given secret by invoking the lambda function.
if secret.rotation_lambda_arn:
- from moto.awslambda.models import lambda_backends
+ from moto.awslambda.utils import get_backend
- lambda_backend = lambda_backends[self.account_id][self.region_name]
+ lambda_backend = get_backend(self.account_id, self.region_name)
request_headers: Dict[str, Any] = {}
response_headers: Dict[str, Any] = {}
diff --git a/moto/servicediscovery/__init__.py b/moto/servicediscovery/__init__.py
index 5f021995f..febe8f8f9 100644
--- a/moto/servicediscovery/__init__.py
+++ b/moto/servicediscovery/__init__.py
@@ -1,5 +1 @@
-"""servicediscovery module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import servicediscovery_backends
-
-mock_servicediscovery = base_decorator(servicediscovery_backends)
+from .models import servicediscovery_backends # noqa: F401
diff --git a/moto/servicequotas/__init__.py b/moto/servicequotas/__init__.py
index 7ed935ece..22ecb2fbf 100644
--- a/moto/servicequotas/__init__.py
+++ b/moto/servicequotas/__init__.py
@@ -1,5 +1 @@
-"""servicequotas module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import servicequotas_backends
-
-mock_servicequotas = base_decorator(servicequotas_backends)
+from .models import servicequotas_backends # noqa: F401
diff --git a/moto/ses/__init__.py b/moto/ses/__init__.py
index e0e64559b..1f228af80 100644
--- a/moto/ses/__init__.py
+++ b/moto/ses/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import ses_backends
-
-mock_ses = base_decorator(ses_backends)
+from .models import ses_backends # noqa: F401
diff --git a/moto/sesv2/__init__.py b/moto/sesv2/__init__.py
index b59780cc1..007c3caf0 100644
--- a/moto/sesv2/__init__.py
+++ b/moto/sesv2/__init__.py
@@ -1,5 +1 @@
-"""sesv2 module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import sesv2_backends
-
-mock_sesv2 = base_decorator(sesv2_backends)
+from .models import sesv2_backends # noqa: F401
diff --git a/moto/signer/__init__.py b/moto/signer/__init__.py
index a676e064d..285cac74a 100644
--- a/moto/signer/__init__.py
+++ b/moto/signer/__init__.py
@@ -1,5 +1 @@
-"""signer module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import signer_backends
-
-mock_signer = base_decorator(signer_backends)
+from .models import signer_backends # noqa: F401
diff --git a/moto/sns/__init__.py b/moto/sns/__init__.py
index eb729f1f6..b02e1b9d3 100644
--- a/moto/sns/__init__.py
+++ b/moto/sns/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import sns_backends
-
-mock_sns = base_decorator(sns_backends)
+from .models import sns_backends # noqa: F401
diff --git a/moto/sns/models.py b/moto/sns/models.py
index c7f678a75..8491ac371 100644
--- a/moto/sns/models.py
+++ b/moto/sns/models.py
@@ -280,9 +280,9 @@ class Subscription(BaseModel):
else:
assert False
- from moto.awslambda import lambda_backends
+ from moto.awslambda.utils import get_backend
- lambda_backends[self.account_id][region].send_sns_message(
+ get_backend(self.account_id, region).send_sns_message(
function_name, message, subject=subject, qualifier=qualifier
)
diff --git a/moto/sqs/__init__.py b/moto/sqs/__init__.py
index d4c35ecc1..0dd7b141f 100644
--- a/moto/sqs/__init__.py
+++ b/moto/sqs/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import sqs_backends
-
-mock_sqs = base_decorator(sqs_backends)
+from .models import sqs_backends # noqa: F401
diff --git a/moto/sqs/models.py b/moto/sqs/models.py
index 9c01f5f79..481ca0cb2 100644
--- a/moto/sqs/models.py
+++ b/moto/sqs/models.py
@@ -586,9 +586,9 @@ class Queue(CloudFormationModel):
self.visibility_timeout, # type: ignore
)
- from moto.awslambda import lambda_backends
+ from moto.awslambda.utils import get_backend
- result = lambda_backends[self.account_id][self.region].send_sqs_batch(
+ result = get_backend(self.account_id, self.region).send_sqs_batch(
arn, messages, self.queue_arn
)
diff --git a/moto/ssm/__init__.py b/moto/ssm/__init__.py
index baef803d7..28930db40 100644
--- a/moto/ssm/__init__.py
+++ b/moto/ssm/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import ssm_backends
-
-mock_ssm = base_decorator(ssm_backends)
+from .models import ssm_backends # noqa: F401
diff --git a/moto/ssoadmin/__init__.py b/moto/ssoadmin/__init__.py
index d6f5fe987..59a77d4cc 100644
--- a/moto/ssoadmin/__init__.py
+++ b/moto/ssoadmin/__init__.py
@@ -1,5 +1 @@
-"""ssoadmin module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import ssoadmin_backends
-
-mock_ssoadmin = base_decorator(ssoadmin_backends)
+from .models import ssoadmin_backends # noqa: F401
diff --git a/moto/stepfunctions/__init__.py b/moto/stepfunctions/__init__.py
index 7181c73d3..24920f412 100644
--- a/moto/stepfunctions/__init__.py
+++ b/moto/stepfunctions/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import stepfunction_backends
-
-mock_stepfunctions = base_decorator(stepfunction_backends)
+from .models import stepfunctions_backends # noqa: F401
diff --git a/moto/stepfunctions/models.py b/moto/stepfunctions/models.py
index c37e7e0a6..77e6bb154 100644
--- a/moto/stepfunctions/models.py
+++ b/moto/stepfunctions/models.py
@@ -188,7 +188,7 @@ class StateMachine(CloudFormationModel):
definition = properties.get("DefinitionString", "")
role_arn = properties.get("RoleArn", "")
tags = cfn_to_api_tags(properties.get("Tags", []))
- sf_backend = stepfunction_backends[account_id][region_name]
+ sf_backend = stepfunctions_backends[account_id][region_name]
return sf_backend.create_state_machine(name, definition, role_arn, tags=tags)
@classmethod
@@ -199,7 +199,7 @@ class StateMachine(CloudFormationModel):
account_id: str,
region_name: str,
) -> None:
- sf_backend = stepfunction_backends[account_id][region_name]
+ sf_backend = stepfunctions_backends[account_id][region_name]
sf_backend.delete_state_machine(resource_name)
@classmethod
@@ -231,7 +231,7 @@ class StateMachine(CloudFormationModel):
definition = properties.get("DefinitionString")
role_arn = properties.get("RoleArn")
tags = cfn_to_api_tags(properties.get("Tags", []))
- sf_backend = stepfunction_backends[account_id][region_name]
+ sf_backend = stepfunctions_backends[account_id][region_name]
state_machine = sf_backend.update_state_machine(
original_resource.arn, definition=definition, role_arn=role_arn
)
@@ -684,4 +684,4 @@ class StepFunctionBackend(BaseBackend):
return self.describe_state_machine(state_machine_arn)
-stepfunction_backends = BackendDict(StepFunctionBackend, "stepfunctions")
+stepfunctions_backends = BackendDict(StepFunctionBackend, "stepfunctions")
diff --git a/moto/stepfunctions/responses.py b/moto/stepfunctions/responses.py
index 997188c84..ee38ff011 100644
--- a/moto/stepfunctions/responses.py
+++ b/moto/stepfunctions/responses.py
@@ -4,7 +4,7 @@ from moto.core.common_types import TYPE_RESPONSE
from moto.core.responses import BaseResponse
from moto.utilities.aws_headers import amzn_request_id
-from .models import StepFunctionBackend, stepfunction_backends
+from .models import StepFunctionBackend, stepfunctions_backends
class StepFunctionResponse(BaseResponse):
@@ -13,7 +13,7 @@ class StepFunctionResponse(BaseResponse):
@property
def stepfunction_backend(self) -> StepFunctionBackend:
- return stepfunction_backends[self.current_account][self.region]
+ return stepfunctions_backends[self.current_account][self.region]
@amzn_request_id
def create_state_machine(self) -> TYPE_RESPONSE:
diff --git a/moto/sts/__init__.py b/moto/sts/__init__.py
index fa08e2649..6b4c3dd50 100644
--- a/moto/sts/__init__.py
+++ b/moto/sts/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import sts_backends
-
-mock_sts = base_decorator(sts_backends)
+from .models import sts_backends # noqa: F401
diff --git a/moto/support/__init__.py b/moto/support/__init__.py
index 082fda2df..ad31d9661 100644
--- a/moto/support/__init__.py
+++ b/moto/support/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import support_backends
-
-mock_support = base_decorator(support_backends)
+from .models import support_backends # noqa: F401
diff --git a/moto/swf/__init__.py b/moto/swf/__init__.py
index 79339bdf5..d268712ae 100644
--- a/moto/swf/__init__.py
+++ b/moto/swf/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import swf_backends
-
-mock_swf = base_decorator(swf_backends)
+from .models import swf_backends # noqa: F401
diff --git a/moto/textract/__init__.py b/moto/textract/__init__.py
index a516837af..1c1dd1587 100644
--- a/moto/textract/__init__.py
+++ b/moto/textract/__init__.py
@@ -1,5 +1 @@
-"""textract module initialization; sets value for base decorator."""
-from ..core.models import base_decorator
-from .models import textract_backends
-
-mock_textract = base_decorator(textract_backends)
+from .models import textract_backends # noqa: F401
diff --git a/moto/timestreamwrite/__init__.py b/moto/timestreamwrite/__init__.py
index 9bf046209..1c3ca2191 100644
--- a/moto/timestreamwrite/__init__.py
+++ b/moto/timestreamwrite/__init__.py
@@ -1,4 +1 @@
-from ..core.models import base_decorator
-from .models import timestreamwrite_backends
-
-mock_timestreamwrite = base_decorator(timestreamwrite_backends)
+from .models import timestreamwrite_backends # noqa: F401
diff --git a/moto/transcribe/__init__.py b/moto/transcribe/__init__.py
index 885f41a37..c39fbcacd 100644
--- a/moto/transcribe/__init__.py
+++ b/moto/transcribe/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import transcribe_backends
-
-transcribe_backend = transcribe_backends["us-east-1"]
-mock_transcribe = base_decorator(transcribe_backends)
+from .models import transcribe_backends # noqa: F401
diff --git a/moto/wafv2/__init__.py b/moto/wafv2/__init__.py
index edb4bdb69..00e787bae 100644
--- a/moto/wafv2/__init__.py
+++ b/moto/wafv2/__init__.py
@@ -1,5 +1 @@
-from ..core.models import base_decorator
-from .models import wafv2_backends
-
-wafv2_backend = wafv2_backends["us-east-1"]
-mock_wafv2 = base_decorator(wafv2_backends)
+from .models import wafv2_backends # noqa: F401
diff --git a/moto/xray/__init__.py b/moto/xray/__init__.py
index 2ef57babd..e5cd16cd1 100644
--- a/moto/xray/__init__.py
+++ b/moto/xray/__init__.py
@@ -1,7 +1,4 @@
-from ..core.models import base_decorator
from .mock_client import MockXrayClient, XRaySegment # noqa
-from .models import xray_backends
+from .models import xray_backends # noqa: F401
-xray_backend = xray_backends["us-east-1"]
-mock_xray = base_decorator(xray_backends)
mock_xray_client = MockXrayClient()
diff --git a/scripts/implementation_coverage.py b/scripts/implementation_coverage.py
index 0aa3d50a0..8e4ad0863 100755
--- a/scripts/implementation_coverage.py
+++ b/scripts/implementation_coverage.py
@@ -5,38 +5,20 @@ from botocore import xform_name
from botocore.session import Session
import boto3
+from moto.backends import get_backend
+
script_dir = os.path.dirname(os.path.abspath(__file__))
alternative_service_names = {"lambda": "awslambda"}
def get_moto_implementation(service_name):
- service_name = (
- service_name.replace("-", "") if "-" in service_name else service_name
- )
- alt_service_name = (
- alternative_service_names[service_name]
- if service_name in alternative_service_names
- else service_name
- )
- mock = None
- mock_name = None
- if hasattr(moto, "mock_{}".format(alt_service_name)):
- mock_name = "mock_{}".format(alt_service_name)
- mock = getattr(moto, mock_name)
- elif hasattr(moto, "mock_{}".format(service_name)):
- mock_name = "mock_{}".format(service_name)
- mock = getattr(moto, mock_name)
- if mock is None:
- return None, None
- backends = list(mock().backends.values())
- if backends:
+ try:
+ backends = get_backend(service_name)
backend = backends[0]["us-east-1"] if "us-east-1" in backends[0] else backends[0]["global"]
- # Special use-case - neptune is only reachable via the RDS backend
- # RDS has an attribute called 'neptune' pointing to the actual NeptuneBackend
- if service_name == "neptune":
- backend = backend.neptune
- return backend, mock_name
+ return backend, service_name
+ except ModuleNotFoundError:
+ return None, service_name
def get_module_name(o):
@@ -223,17 +205,6 @@ def write_implementation_coverage_to_docs(coverage):
file.write(".. autoclass:: " + coverage[service_name].get("module_name"))
file.write("\n\n")
- file.write("|start-h3| Example usage |end-h3|\n\n")
- file.write(f""".. sourcecode:: python
-
- @{coverage[service_name]['name']}
- def test_{coverage[service_name]['name'][5:]}_behaviour:
- boto3.client("{service_name}")
- ...
-
-""")
- file.write("\n\n")
-
file.write("|start-h3| Implemented features for this service |end-h3|\n\n")
for op in operations:
@@ -257,19 +228,6 @@ def write_implementation_coverage_to_docs(coverage):
file.write("====================\n")
file.write("\n")
file.write("Please see a list of all currently supported services. Each service will have a list of the endpoints that are implemented.\n")
- file.write("Each service will also have an example on how to mock an individual service.\n\n")
- file.write("Note that you can mock multiple services at the same time:\n\n")
- file.write(".. sourcecode:: python\n\n")
- file.write(" @mock_s3\n")
- file.write(" @mock_sqs\n")
- file.write(" def test_both_s3_and_sqs():\n")
- file.write(" ...\n")
- file.write("\n\n")
- file.write(".. sourcecode:: python\n\n")
- file.write(" @mock_all()\n")
- file.write(" def test_all_supported_services_at_the_same_time():\n")
- file.write(" ...\n")
- file.write("\n")
file.write("\n")
file.write(".. toctree::\n")
diff --git a/scripts/update_backend_index.py b/scripts/update_backend_index.py
index 40dc8daa9..40050bdd6 100755
--- a/scripts/update_backend_index.py
+++ b/scripts/update_backend_index.py
@@ -3,32 +3,37 @@
import importlib
import os
import re
+from moto.backends import list_of_moto_modules
from pathlib import Path
import black
import pprint
-import moto.backends as backends
+import moto
output_file = "moto/backend_index.py"
script_dir = os.path.dirname(os.path.abspath(__file__))
output_path = os.path.join(script_dir, "..", output_file)
-# Ignore the MotoAPI and InstanceMetadata backend, as they do not represent AWS services
+# Ignore the Moto API/Server/Proxy backends, as they do not represent AWS services
# Ignore the APIGatewayV2, as it's URL's are managed by APIGateway
# Ignore S3bucket_path, as the functionality is covered in the S3 service
# Ignore neptune, as it shares a URL with RDS
# Ignore OpenSearch, as it shares a URL with ElasticSearch
-IGNORE_BACKENDS = ["moto_api", "instance_metadata", "apigatewayv2", "s3bucket_path", "neptune", "opensearch"]
+IGNORE_BACKENDS = ["moto_server", "moto_proxy", "apigatewayv2", "awslambda_simple", "batch_simple", "core", "dynamodb_v20111205", "packages", "utilities", "s3bucket_path", "neptune", "opensearch"]
def iter_backend_url_patterns():
- for backend, (module_name, _) in backends.BACKENDS.items():
+ path = os.path.dirname(moto.__file__)
+ for backend in list_of_moto_modules():
+ # Special case
+ if backend == "moto_api":
+ backend = "moto_api._internal"
if backend in IGNORE_BACKENDS:
continue
# otherwise we need to import the module
- url_module_name = f"moto.{module_name}.urls"
+ url_module_name = f"moto.{backend}.urls"
module = importlib.import_module(url_module_name)
for pattern in getattr(module, "url_bases"):
yield backend, pattern
diff --git a/setup.cfg b/setup.cfg
index b3bc9264c..8d24d68e5 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -27,7 +27,7 @@ project_urls =
python_requires = >=3.8
install_requires =
boto3>=1.9.201
- botocore>=1.12.201
+ botocore>=1.13.46
cryptography>=3.3.1
requests>=2.5
xmltodict
@@ -279,7 +279,7 @@ disable = W,C,R,E
enable = anomalous-backslash-in-string, arguments-renamed, dangerous-default-value, deprecated-module, function-redefined, import-self, redefined-builtin, redefined-outer-name, reimported, pointless-statement, super-with-arguments, unused-argument, unused-import, unused-variable, useless-else-on-loop, wildcard-import
[mypy]
-files= moto, tests/test_core/
+files= moto, tests/test_core, tests/test_batch_simple
show_column_numbers=True
show_error_codes = True
disable_error_code=abstract
diff --git a/tests/test_acm/test_acm.py b/tests/test_acm/test_acm.py
index c6704c5ed..aacb7c320 100644
--- a/tests/test_acm/test_acm.py
+++ b/tests/test_acm/test_acm.py
@@ -10,7 +10,7 @@ from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from freezegun import freeze_time
-from moto import mock_acm, mock_elb, settings
+from moto import mock_aws, settings
from moto.acm.models import AWS_ROOT_CA
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
@@ -38,7 +38,7 @@ def _import_cert(client):
# Also tests GetCertificate
-@mock_acm
+@mock_aws
def test_import_certificate():
client = boto3.client("acm", region_name="eu-central-1")
@@ -51,7 +51,7 @@ def test_import_certificate():
assert "CertificateChain" in resp
-@mock_acm
+@mock_aws
def test_import_certificate_with_tags():
client = boto3.client("acm", region_name="eu-central-1")
@@ -75,7 +75,7 @@ def test_import_certificate_with_tags():
assert tags["KeyOnly"] == "__NONE__"
-@mock_acm
+@mock_aws
def test_import_bad_certificate():
client = boto3.client("acm", region_name="eu-central-1")
@@ -87,7 +87,7 @@ def test_import_bad_certificate():
raise RuntimeError("Should have raised ValidationException")
-@mock_acm
+@mock_aws
def test_list_certificates():
client = boto3.client("acm", region_name="eu-central-1")
issued_arn = _import_cert(client)
@@ -131,7 +131,7 @@ def test_list_certificates():
assert pending_arn in [c["CertificateArn"] for c in certs]
-@mock_acm
+@mock_aws
def test_get_invalid_certificate():
client = boto3.client("acm", region_name="eu-central-1")
@@ -144,7 +144,7 @@ def test_get_invalid_certificate():
# Also tests deleting invalid certificate
-@mock_acm
+@mock_aws
def test_delete_certificate():
client = boto3.client("acm", region_name="eu-central-1")
arn = _import_cert(client)
@@ -160,7 +160,7 @@ def test_delete_certificate():
raise RuntimeError("Should have raised ResourceNotFoundException")
-@mock_acm
+@mock_aws
def test_describe_certificate():
client = boto3.client("acm", region_name="eu-central-1")
arn = _import_cert(client)
@@ -183,7 +183,7 @@ def test_describe_certificate():
assert validation_option["DomainName"] == SERVER_COMMON_NAME
-@mock_acm
+@mock_aws
def test_describe_certificate_with_bad_arn():
client = boto3.client("acm", region_name="eu-central-1")
@@ -193,7 +193,7 @@ def test_describe_certificate_with_bad_arn():
assert err.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_acm
+@mock_aws
def test_export_certificate():
client = boto3.client("acm", region_name="eu-central-1")
arn = _import_cert(client)
@@ -215,7 +215,7 @@ def test_export_certificate():
assert private_key == SERVER_KEY
-@mock_acm
+@mock_aws
def test_export_certificate_with_bad_arn():
client = boto3.client("acm", region_name="eu-central-1")
@@ -226,7 +226,7 @@ def test_export_certificate_with_bad_arn():
# Also tests ListTagsForCertificate
-@mock_acm
+@mock_aws
def test_add_tags_to_certificate():
client = boto3.client("acm", region_name="eu-central-1")
arn = _import_cert(client)
@@ -247,7 +247,7 @@ def test_add_tags_to_certificate():
assert tags["key2"] == "__NONE__"
-@mock_acm
+@mock_aws
def test_add_tags_to_invalid_certificate():
client = boto3.client("acm", region_name="eu-central-1")
@@ -262,7 +262,7 @@ def test_add_tags_to_invalid_certificate():
raise RuntimeError("Should have raised ResourceNotFoundException")
-@mock_acm
+@mock_aws
def test_list_tags_for_invalid_certificate():
client = boto3.client("acm", region_name="eu-central-1")
@@ -274,7 +274,7 @@ def test_list_tags_for_invalid_certificate():
raise RuntimeError("Should have raised ResourceNotFoundException")
-@mock_acm
+@mock_aws
def test_remove_tags_from_certificate():
client = boto3.client("acm", region_name="eu-central-1")
arn = _import_cert(client)
@@ -308,7 +308,7 @@ def test_remove_tags_from_certificate():
assert "key1" in tags
-@mock_acm
+@mock_aws
def test_remove_tags_from_invalid_certificate():
client = boto3.client("acm", region_name="eu-central-1")
@@ -323,7 +323,7 @@ def test_remove_tags_from_invalid_certificate():
raise RuntimeError("Should have raised ResourceNotFoundException")
-@mock_acm
+@mock_aws
def test_resend_validation_email():
client = boto3.client("acm", region_name="eu-central-1")
arn = _import_cert(client)
@@ -334,7 +334,7 @@ def test_resend_validation_email():
# Returns nothing, boto would raise Exceptions otherwise
-@mock_acm
+@mock_aws
def test_resend_validation_email_invalid():
client = boto3.client("acm", region_name="eu-central-1")
arn = _import_cert(client)
@@ -364,7 +364,7 @@ def test_resend_validation_email_invalid():
raise RuntimeError("Should have raised ResourceNotFoundException")
-@mock_acm
+@mock_aws
def test_request_certificate():
client = boto3.client("acm", region_name="eu-central-1")
@@ -387,7 +387,7 @@ def test_request_certificate():
assert resp["CertificateArn"] == arn
-@mock_acm
+@mock_aws
@mock.patch("moto.settings.ACM_VALIDATION_WAIT", 1)
def test_request_certificate_with_optional_arguments():
if not settings.TEST_DECORATOR_MODE:
@@ -470,7 +470,7 @@ def test_request_certificate_with_optional_arguments():
assert arn_1 != arn_4 # if tags are matched, ACM would have returned same arn
-@mock_acm
+@mock_aws
def test_operations_with_invalid_tags():
client = boto3.client("acm", region_name="eu-central-1")
@@ -521,7 +521,7 @@ def test_operations_with_invalid_tags():
assert "AWS internal tags cannot be changed with this API" in err["Message"]
-@mock_acm
+@mock_aws
def test_add_too_many_tags():
client = boto3.client("acm", region_name="eu-central-1")
arn = _import_cert(client)
@@ -554,7 +554,7 @@ def test_add_too_many_tags():
assert len(client.list_tags_for_certificate(CertificateArn=arn)["Tags"]) == 49
-@mock_acm
+@mock_aws
def test_request_certificate_no_san():
client = boto3.client("acm", region_name="eu-central-1")
@@ -574,7 +574,7 @@ def test_request_certificate_no_san():
# Also tests the SAN code
-@mock_acm
+@mock_aws
def test_request_certificate_issued_status():
# After requesting a certificate, it should then auto-validate after 1 minute
# Some sneaky programming for that ;-)
@@ -612,7 +612,7 @@ def test_request_certificate_issued_status():
@mock.patch("moto.settings.ACM_VALIDATION_WAIT", 3)
-@mock_acm
+@mock_aws
def test_request_certificate_issued_status_with_wait_in_envvar():
# After requesting a certificate, it should then auto-validate after 3 seconds
if not settings.TEST_DECORATOR_MODE:
@@ -641,7 +641,7 @@ def test_request_certificate_issued_status_with_wait_in_envvar():
assert resp["Certificate"]["Status"] == "ISSUED"
-@mock_acm
+@mock_aws
def test_request_certificate_with_mutiple_times():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Cant manipulate time in server mode")
@@ -689,8 +689,7 @@ def test_request_certificate_with_mutiple_times():
assert arn != original_arn
-@mock_acm
-@mock_elb
+@mock_aws
def test_elb_acm_in_use_by():
acm_client = boto3.client("acm", region_name="us-west-2")
elb_client = boto3.client("elb", region_name="us-west-2")
diff --git a/tests/test_acmpca/test_acmpca.py b/tests/test_acmpca/test_acmpca.py
index cdb3ed792..56d415711 100644
--- a/tests/test_acmpca/test_acmpca.py
+++ b/tests/test_acmpca/test_acmpca.py
@@ -1,4 +1,3 @@
-"""Unit tests for acmpca-supported APIs."""
import datetime
import boto3
@@ -10,7 +9,7 @@ from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.x509 import NameOID
-from moto import mock_acmpca
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID
from moto.core.utils import utcnow
@@ -18,7 +17,7 @@ from moto.core.utils import utcnow
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_acmpca
+@mock_aws
def test_create_certificate_authority():
client = boto3.client("acm-pca", region_name="eu-west-1")
resp = client.create_certificate_authority(
@@ -37,7 +36,7 @@ def test_create_certificate_authority():
)
-@mock_acmpca
+@mock_aws
def test_describe_certificate_authority():
client = boto3.client("acm-pca", region_name="ap-southeast-1")
ca_arn = client.create_certificate_authority(
@@ -66,7 +65,7 @@ def test_describe_certificate_authority():
assert ca["KeyStorageSecurityStandard"] == "FIPS_140_2_LEVEL_3_OR_HIGHER"
-@mock_acmpca
+@mock_aws
def test_describe_certificate_authority_with_security_standard():
client = boto3.client("acm-pca", region_name="ap-southeast-1")
ca_arn = client.create_certificate_authority(
@@ -96,7 +95,7 @@ def test_describe_certificate_authority_with_security_standard():
assert ca["KeyStorageSecurityStandard"] == "FIPS_140_2_LEVEL_2_OR_HIGHER"
-@mock_acmpca
+@mock_aws
def test_describe_unknown_certificate_authority():
client = boto3.client("acm-pca", region_name="ap-southeast-1")
@@ -106,7 +105,7 @@ def test_describe_unknown_certificate_authority():
assert err["Code"] == "ResourceNotFoundException"
-@mock_acmpca
+@mock_aws
def test_get_certificate_authority_certificate():
client = boto3.client("acm-pca", region_name="ap-southeast-1")
ca_arn = client.create_certificate_authority(
@@ -125,7 +124,7 @@ def test_get_certificate_authority_certificate():
assert resp["Certificate"] == ""
-@mock_acmpca
+@mock_aws
def test_get_certificate_authority_csr():
client = boto3.client("acm-pca", region_name="us-east-2")
ca_arn = client.create_certificate_authority(
@@ -143,7 +142,7 @@ def test_get_certificate_authority_csr():
assert "Csr" in resp
-@mock_acmpca
+@mock_aws
def test_list_tags_when_ca_has_no_tags():
client = boto3.client("acm-pca", region_name="us-east-2")
ca_arn = client.create_certificate_authority(
@@ -160,7 +159,7 @@ def test_list_tags_when_ca_has_no_tags():
assert resp["Tags"] == []
-@mock_acmpca
+@mock_aws
def test_list_tags():
client = boto3.client("acm-pca", region_name="us-east-2")
ca_arn = client.create_certificate_authority(
@@ -178,7 +177,7 @@ def test_list_tags():
assert resp["Tags"] == [{"Key": "t1", "Value": "v1"}, {"Key": "t2", "Value": "v2"}]
-@mock_acmpca
+@mock_aws
def test_update_certificate_authority():
client = boto3.client("acm-pca", region_name="eu-west-1")
ca_arn = client.create_certificate_authority(
@@ -202,7 +201,7 @@ def test_update_certificate_authority():
assert "LastStateChangeAt" in ca
-@mock_acmpca
+@mock_aws
def test_delete_certificate_authority():
client = boto3.client("acm-pca", region_name="ap-southeast-1")
ca_arn = client.create_certificate_authority(
@@ -222,7 +221,7 @@ def test_delete_certificate_authority():
assert ca["Status"] == "DELETED"
-@mock_acmpca
+@mock_aws
def test_issue_certificate():
client = boto3.client("acm-pca", region_name="ap-southeast-1")
ca_arn = client.create_certificate_authority(
@@ -246,7 +245,7 @@ def test_issue_certificate():
assert "CertificateArn" in resp
-@mock_acmpca
+@mock_aws
def test_get_certificate():
client = boto3.client("acm-pca", region_name="us-east-2")
ca_arn = client.create_certificate_authority(
@@ -273,7 +272,7 @@ def test_get_certificate():
assert "Certificate" in resp
-@mock_acmpca
+@mock_aws
def test_import_certificate_authority_certificate():
client = boto3.client("acm-pca", region_name="eu-west-1")
ca_arn = client.create_certificate_authority(
@@ -303,7 +302,7 @@ def test_import_certificate_authority_certificate():
assert "-----BEGIN CERTIFICATE-----" in resp["Certificate"]
-@mock_acmpca
+@mock_aws
def test_tag_certificate_authority():
client = boto3.client("acm-pca", region_name="eu-west-1")
ca_arn = client.create_certificate_authority(
@@ -324,7 +323,7 @@ def test_tag_certificate_authority():
assert resp["Tags"] == [{"Key": "t1", "Value": "v1"}, {"Key": "t2", "Value": "v2"}]
-@mock_acmpca
+@mock_aws
def test_untag_certificate_authority():
client = boto3.client("acm-pca", region_name="eu-west-1")
ca_arn = client.create_certificate_authority(
diff --git a/tests/test_amp/test_amp_logging_config.py b/tests/test_amp/test_amp_logging_config.py
index 583064fdf..ac7945b9e 100644
--- a/tests/test_amp/test_amp_logging_config.py
+++ b/tests/test_amp/test_amp_logging_config.py
@@ -2,10 +2,10 @@ import unittest
import boto3
-from moto import mock_amp
+from moto import mock_aws
-@mock_amp
+@mock_aws
class TestAmpLoggingConfig(unittest.TestCase):
def setUp(self) -> None:
self.client = boto3.client("amp", region_name="us-east-2")
diff --git a/tests/test_amp/test_amp_rulegroupnamespaces.py b/tests/test_amp/test_amp_rulegroupnamespaces.py
index c9a097a1c..07db7437d 100644
--- a/tests/test_amp/test_amp_rulegroupnamespaces.py
+++ b/tests/test_amp/test_amp_rulegroupnamespaces.py
@@ -1,15 +1,14 @@
-"""Unit tests for amp-supported APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_amp
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_amp
+@mock_aws
def test_create_rule_groups_namespace():
client = boto3.client("amp", region_name="ap-southeast-1")
workspace_id = client.create_workspace()["workspaceId"]
@@ -22,7 +21,7 @@ def test_create_rule_groups_namespace():
assert "status" in resp
-@mock_amp
+@mock_aws
def test_delete_rule_groups_namespace():
client = boto3.client("amp", region_name="us-east-2")
workspace_id = client.create_workspace()["workspaceId"]
@@ -39,7 +38,7 @@ def test_delete_rule_groups_namespace():
assert err["Message"] == "RuleGroupNamespace not found"
-@mock_amp
+@mock_aws
def test_describe_rule_groups_namespace():
client = boto3.client("amp", region_name="us-east-2")
@@ -62,7 +61,7 @@ def test_describe_rule_groups_namespace():
assert "status" in ns
-@mock_amp
+@mock_aws
def test_put_rule_groups_namespace():
client = boto3.client("amp", region_name="eu-west-1")
@@ -86,7 +85,7 @@ def test_put_rule_groups_namespace():
assert ns["data"] == b"updated"
-@mock_amp
+@mock_aws
def test_list_rule_groups_namespaces():
client = boto3.client("amp", region_name="ap-southeast-1")
w_id = client.create_workspace()["workspaceId"]
@@ -110,7 +109,7 @@ def test_list_rule_groups_namespaces():
assert set(names) == {"ns10"}
-@mock_amp
+@mock_aws
def test_list_rule_groups_namespaces__paginated():
client = boto3.client("amp", region_name="ap-southeast-1")
w_id = client.create_workspace()["workspaceId"]
@@ -143,7 +142,7 @@ def test_list_rule_groups_namespaces__paginated():
assert "nextToken" not in full_page
-@mock_amp
+@mock_aws
def test_tag_resource():
client = boto3.client("amp", region_name="us-east-2")
diff --git a/tests/test_amp/test_amp_workspaces.py b/tests/test_amp/test_amp_workspaces.py
index 81c81a630..bd650f60b 100644
--- a/tests/test_amp/test_amp_workspaces.py
+++ b/tests/test_amp/test_amp_workspaces.py
@@ -4,13 +4,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_amp
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_amp
+@mock_aws
def test_create_workspace():
client = boto3.client("amp", region_name="ap-southeast-1")
resp = client.create_workspace(alias="test", clientToken="mytoken")
@@ -20,7 +20,7 @@ def test_create_workspace():
assert "workspaceId" in resp
-@mock_amp
+@mock_aws
def test_describe_workspace():
client = boto3.client("amp", region_name="eu-west-1")
workspace_id = client.create_workspace(alias="test", clientToken="mytoken")[
@@ -39,7 +39,7 @@ def test_describe_workspace():
assert workspace["workspaceId"] == workspace_id
-@mock_amp
+@mock_aws
def test_list_workspaces():
my_alias = str(uuid4())[0:6]
client = boto3.client("amp", region_name="ap-southeast-1")
@@ -56,7 +56,7 @@ def test_list_workspaces():
assert resp["workspaces"][0]["alias"] == my_alias
-@mock_amp
+@mock_aws
def test_list_workspaces__paginated():
client = boto3.client("amp", region_name="ap-southeast-1")
for _ in range(125):
@@ -79,7 +79,7 @@ def test_list_workspaces__paginated():
assert length >= 125
-@mock_amp
+@mock_aws
def test_list_tags_for_resource():
client = boto3.client("amp", region_name="ap-southeast-1")
arn = client.create_workspace(
@@ -89,7 +89,7 @@ def test_list_tags_for_resource():
assert get_tags(arn, client) == {"t1": "v1", "t2": "v2"}
-@mock_amp
+@mock_aws
def test_update_workspace_alias():
client = boto3.client("amp", region_name="ap-southeast-1")
@@ -104,7 +104,7 @@ def test_update_workspace_alias():
assert w["alias"] == "updated"
-@mock_amp
+@mock_aws
def test_delete_workspace():
client = boto3.client("amp", region_name="us-east-2")
@@ -121,7 +121,7 @@ def test_delete_workspace():
assert err["Message"] == "Workspace not found"
-@mock_amp
+@mock_aws
def test_tag_resource():
client = boto3.client("amp", region_name="us-east-2")
diff --git a/tests/test_apigateway/test_apigateway.py b/tests/test_apigateway/test_apigateway.py
index 19eb37c1a..6832ec956 100644
--- a/tests/test_apigateway/test_apigateway.py
+++ b/tests/test_apigateway/test_apigateway.py
@@ -5,13 +5,13 @@ import pytest
from botocore.exceptions import ClientError
from freezegun import freeze_time
-from moto import mock_apigateway, mock_cognitoidp, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import DEFAULT_ACCOUNT_ID
@freeze_time("2015-01-01")
-@mock_apigateway
+@mock_aws
def test_create_and_get_rest_api():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -37,7 +37,7 @@ def test_create_and_get_rest_api():
}
-@mock_apigateway
+@mock_aws
def test_update_rest_api():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -86,7 +86,7 @@ def test_update_rest_api():
assert err["Code"] == "ValidationException"
-@mock_apigateway
+@mock_aws
def test_update_rest_api_invalid_api_id():
client = boto3.client("apigateway", region_name="us-west-2")
patchOperations = [
@@ -97,7 +97,7 @@ def test_update_rest_api_invalid_api_id():
assert ex.value.response["Error"]["Code"] == "NotFoundException"
-@mock_apigateway
+@mock_aws
def test_update_rest_api_operation_add_remove():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -118,7 +118,7 @@ def test_update_rest_api_operation_add_remove():
assert response["description"] == ""
-@mock_apigateway
+@mock_aws
def test_list_and_delete_apis():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -135,7 +135,7 @@ def test_list_and_delete_apis():
assert len(response["items"]) == 1
-@mock_apigateway
+@mock_aws
def test_create_rest_api_with_tags():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -150,7 +150,7 @@ def test_create_rest_api_with_tags():
assert response["tags"] == {"MY_TAG1": "MY_VALUE1"}
-@mock_apigateway
+@mock_aws
def test_create_rest_api_with_policy():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -166,7 +166,7 @@ def test_create_rest_api_with_policy():
assert response["policy"] == policy
-@mock_apigateway
+@mock_aws
def test_create_rest_api_invalid_apikeysource():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -179,7 +179,7 @@ def test_create_rest_api_invalid_apikeysource():
assert ex.value.response["Error"]["Code"] == "ValidationException"
-@mock_apigateway
+@mock_aws
def test_create_rest_api_valid_apikeysources():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -202,7 +202,7 @@ def test_create_rest_api_valid_apikeysources():
assert response["apiKeySource"] == "AUTHORIZER"
-@mock_apigateway
+@mock_aws
def test_create_rest_api_invalid_endpointconfiguration():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -215,7 +215,7 @@ def test_create_rest_api_invalid_endpointconfiguration():
assert ex.value.response["Error"]["Code"] == "ValidationException"
-@mock_apigateway
+@mock_aws
def test_create_rest_api_valid_endpointconfigurations():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -253,7 +253,7 @@ def test_create_rest_api_valid_endpointconfigurations():
assert response["endpointConfiguration"] == {"types": ["EDGE"]}
-@mock_apigateway
+@mock_aws
def test_create_resource__validate_name():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -281,7 +281,7 @@ def test_create_resource__validate_name():
client.create_resource(restApiId=api_id, parentId=root_id, pathPart=name)
-@mock_apigateway
+@mock_aws
def test_create_resource():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -315,7 +315,7 @@ def test_create_resource():
assert len(client.get_resources(restApiId=api_id)["items"]) == 1
-@mock_apigateway
+@mock_aws
def test_child_resource():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -349,7 +349,7 @@ def test_child_resource():
}
-@mock_apigateway
+@mock_aws
def test_create_method():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -383,7 +383,7 @@ def test_create_method():
}
-@mock_apigateway
+@mock_aws
def test_create_method_apikeyrequired():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -416,7 +416,7 @@ def test_create_method_apikeyrequired():
}
-@mock_apigateway
+@mock_aws
def test_create_method_response():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -464,7 +464,7 @@ def test_create_method_response():
assert response == {"ResponseMetadata": {"HTTPStatusCode": 204}}
-@mock_apigateway
+@mock_aws
def test_get_method_unknown_resource_id():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -477,7 +477,7 @@ def test_get_method_unknown_resource_id():
assert err["Message"] == "Invalid resource identifier specified"
-@mock_apigateway
+@mock_aws
def test_delete_method():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -503,7 +503,7 @@ def test_delete_method():
assert err["Message"] == "Invalid Method identifier specified"
-@mock_apigateway
+@mock_aws
def test_integrations():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -634,7 +634,7 @@ def test_integrations():
assert response["timeoutInMillis"] == 29000
-@mock_apigateway
+@mock_aws
def test_integration_response():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -783,8 +783,7 @@ def test_integration_response():
}
-@mock_apigateway
-@mock_cognitoidp
+@mock_aws
def test_update_authorizer_configuration():
client = boto3.client("apigateway", region_name="us-west-2")
authorizer_name = "my_authorizer"
@@ -854,7 +853,7 @@ def test_update_authorizer_configuration():
assert 'Patch operation "add" not implemented' in str(exc.value)
-@mock_apigateway
+@mock_aws
def test_non_existent_authorizer():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -877,8 +876,7 @@ def test_non_existent_authorizer():
assert err["Message"] == "Invalid Authorizer identifier specified"
-@mock_apigateway
-@mock_cognitoidp
+@mock_aws
def test_create_authorizer():
client = boto3.client("apigateway", region_name="us-west-2")
authorizer_name = "my_authorizer"
@@ -967,8 +965,7 @@ def test_create_authorizer():
assert stage["authorizerResultTtlInSeconds"] == 300
-@mock_apigateway
-@mock_cognitoidp
+@mock_aws
def test_delete_authorizer():
client = boto3.client("apigateway", region_name="us-west-2")
authorizer_name = "my_authorizer"
@@ -1027,7 +1024,7 @@ def test_delete_authorizer():
assert [authorizer["name"] for authorizer in authorizers] == [authorizer_name]
-@mock_apigateway
+@mock_aws
def test_put_integration_response_with_response_template():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -1084,7 +1081,7 @@ def test_put_integration_response_with_response_template():
}
-@mock_apigateway
+@mock_aws
def test_put_integration_response_but_integration_not_found():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -1114,7 +1111,7 @@ def test_put_integration_response_but_integration_not_found():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_apigateway
+@mock_aws
def test_put_integration_validation():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -1291,7 +1288,7 @@ def test_put_integration_validation():
)
-@mock_apigateway
+@mock_aws
def test_create_domain_names():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -1313,7 +1310,7 @@ def test_create_domain_names():
assert ex.value.response["Error"]["Code"] == "BadRequestException"
-@mock_apigateway
+@mock_aws
def test_get_domain_names():
client = boto3.client("apigateway", region_name="us-west-2")
# without any domain names already present
@@ -1335,7 +1332,7 @@ def test_get_domain_names():
assert result["items"][0]["domainNameStatus"] == "AVAILABLE"
-@mock_apigateway
+@mock_aws
def test_get_domain_name():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -1347,7 +1344,7 @@ def test_get_domain_name():
assert result["domainNameStatus"] == "AVAILABLE"
-@mock_apigateway
+@mock_aws
def test_create_model():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -1389,7 +1386,7 @@ def test_create_model():
assert ex.value.response["Error"]["Code"] == "BadRequestException"
-@mock_apigateway
+@mock_aws
def test_get_api_models():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -1413,7 +1410,7 @@ def test_get_api_models():
result["items"][0]["description"] = description
-@mock_apigateway
+@mock_aws
def test_get_model_by_name():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -1440,7 +1437,7 @@ def test_get_model_by_name():
assert ex.value.response["Error"]["Code"] == "NotFoundException"
-@mock_apigateway
+@mock_aws
def test_get_model_with_invalid_name():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -1452,7 +1449,7 @@ def test_get_model_with_invalid_name():
assert ex.value.response["Error"]["Code"] == "NotFoundException"
-@mock_apigateway
+@mock_aws
def test_api_key_value_min_length():
region_name = "us-east-1"
client = boto3.client("apigateway", region_name=region_name)
@@ -1473,7 +1470,7 @@ def test_api_key_value_min_length():
)
-@mock_apigateway
+@mock_aws
def test_get_api_key_include_value():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1501,7 +1498,7 @@ def test_get_api_key_include_value():
assert "value" in response
-@mock_apigateway
+@mock_aws
def test_get_api_keys_include_values():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1533,7 +1530,7 @@ def test_get_api_keys_include_values():
assert "value" not in api_key
-@mock_apigateway
+@mock_aws
def test_create_api_key():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1553,7 +1550,7 @@ def test_create_api_key():
assert len(response["items"]) == 1
-@mock_apigateway
+@mock_aws
def test_create_api_key_twice():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1568,7 +1565,7 @@ def test_create_api_key_twice():
assert ex.value.response["Error"]["Code"] == "ConflictException"
-@mock_apigateway
+@mock_aws
def test_api_keys():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1624,7 +1621,7 @@ def test_api_keys():
assert len(response["items"]) == 1
-@mock_apigateway
+@mock_aws
def test_usage_plans():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1675,7 +1672,7 @@ def test_usage_plans():
assert len(response["items"]) == 1
-@mock_apigateway
+@mock_aws
def test_update_usage_plan():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1709,7 +1706,7 @@ def test_update_usage_plan():
assert response["productCode"] == "new-productionCode"
-@mock_apigateway
+@mock_aws
def test_usage_plan_keys():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1774,7 +1771,7 @@ def test_usage_plan_keys():
assert err["Message"] == "Invalid Usage Plan ID specified"
-@mock_apigateway
+@mock_aws
def test_create_usage_plan_key_non_existent_api_key():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1790,7 +1787,7 @@ def test_create_usage_plan_key_non_existent_api_key():
assert err["Message"] == "Invalid API Key identifier specified"
-@mock_apigateway
+@mock_aws
def test_get_usage_plans_using_key_id():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1855,7 +1852,7 @@ def create_method_integration(client, api_id, httpMethod="GET"):
return root_id
-@mock_apigateway
+@mock_aws
def test_get_integration_response_unknown_response():
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
@@ -1874,7 +1871,7 @@ def test_get_integration_response_unknown_response():
assert err["Code"] == "NotFoundException"
-@mock_apigateway
+@mock_aws
def test_get_api_key_unknown_apikey():
client = boto3.client("apigateway", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -1884,7 +1881,7 @@ def test_get_api_key_unknown_apikey():
assert err["Code"] == "NotFoundException"
-@mock_apigateway
+@mock_aws
def test_get_domain_name_unknown_domainname():
client = boto3.client("apigateway", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -1894,7 +1891,7 @@ def test_get_domain_name_unknown_domainname():
assert err["Code"] == "NotFoundException"
-@mock_apigateway
+@mock_aws
def test_delete_domain_name_unknown_domainname():
client = boto3.client("apigateway", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -1904,7 +1901,7 @@ def test_delete_domain_name_unknown_domainname():
assert err["Code"] == "NotFoundException"
-@mock_apigateway
+@mock_aws
def test_create_base_path_mapping():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -1946,7 +1943,7 @@ def test_create_base_path_mapping():
assert response["stage"] == stage_name
-@mock_apigateway
+@mock_aws
def test_create_base_path_mapping_with_unknown_api():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -1964,7 +1961,7 @@ def test_create_base_path_mapping_with_unknown_api():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_apigateway
+@mock_aws
def test_create_base_path_mapping_with_invalid_base_path():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -1995,7 +1992,7 @@ def test_create_base_path_mapping_with_invalid_base_path():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_apigateway
+@mock_aws
def test_create_base_path_mapping_with_unknown_stage():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2023,7 +2020,7 @@ def test_create_base_path_mapping_with_unknown_stage():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_apigateway
+@mock_aws
def test_create_base_path_mapping_with_duplicate_base_path():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2049,7 +2046,7 @@ def test_create_base_path_mapping_with_duplicate_base_path():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 409
-@mock_apigateway
+@mock_aws
def test_get_base_path_mappings():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2092,7 +2089,7 @@ def test_get_base_path_mappings():
assert items[2]["stage"] == stage_name
-@mock_apigateway
+@mock_aws
def test_get_base_path_mappings_with_unknown_domain():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -2104,7 +2101,7 @@ def test_get_base_path_mappings_with_unknown_domain():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_apigateway
+@mock_aws
def test_get_base_path_mapping():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2133,7 +2130,7 @@ def test_get_base_path_mapping():
assert response["stage"] == stage_name
-@mock_apigateway
+@mock_aws
def test_get_base_path_mapping_with_unknown_domain():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -2148,7 +2145,7 @@ def test_get_base_path_mapping_with_unknown_domain():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_apigateway
+@mock_aws
def test_get_base_path_mapping_with_unknown_base_path():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2174,7 +2171,7 @@ def test_get_base_path_mapping_with_unknown_base_path():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_apigateway
+@mock_aws
def test_delete_base_path_mapping():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2207,7 +2204,7 @@ def test_delete_base_path_mapping():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_apigateway
+@mock_aws
def test_delete_base_path_mapping_with_unknown_domain():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -2222,7 +2219,7 @@ def test_delete_base_path_mapping_with_unknown_domain():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_apigateway
+@mock_aws
def test_delete_base_path_mapping_with_unknown_base_path():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2248,7 +2245,7 @@ def test_delete_base_path_mapping_with_unknown_base_path():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_apigateway
+@mock_aws
def test_update_path_mapping():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2288,7 +2285,7 @@ def test_update_path_mapping():
assert response["stage"] == stage_name
-@mock_apigateway
+@mock_aws
def test_update_path_mapping_with_unknown_domain():
client = boto3.client("apigateway", region_name="us-west-2")
with pytest.raises(ClientError) as ex:
@@ -2304,7 +2301,7 @@ def test_update_path_mapping_with_unknown_domain():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_apigateway
+@mock_aws
def test_update_path_mapping_with_unknown_base_path():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2332,7 +2329,7 @@ def test_update_path_mapping_with_unknown_base_path():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_apigateway
+@mock_aws
def test_update_path_mapping_to_same_base_path():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2375,7 +2372,7 @@ def test_update_path_mapping_to_same_base_path():
assert "stage" not in items[0]
-@mock_apigateway
+@mock_aws
def test_update_path_mapping_with_unknown_api():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
@@ -2407,7 +2404,7 @@ def test_update_path_mapping_with_unknown_api():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_apigateway
+@mock_aws
def test_update_path_mapping_with_unknown_stage():
client = boto3.client("apigateway", region_name="us-west-2")
domain_name = "testDomain"
diff --git a/tests/test_apigateway/test_apigateway_cloudformation.py b/tests/test_apigateway/test_apigateway_cloudformation.py
index 507e83049..3552cca06 100644
--- a/tests/test_apigateway/test_apigateway_cloudformation.py
+++ b/tests/test_apigateway/test_apigateway_cloudformation.py
@@ -2,7 +2,7 @@ import json
import boto3
-from moto import mock_apigateway, mock_cloudformation, mock_iam, mock_lambda, mock_logs
+from moto import mock_aws
template = """{
"AWSTemplateFormatVersion": "2010-09-09",
@@ -313,11 +313,7 @@ template_with_missing_sub = """{
}"""
-@mock_cloudformation
-@mock_lambda
-@mock_iam
-@mock_logs
-@mock_apigateway
+@mock_aws
def test_simple_apigateway_with_lambda_proxy():
region = "us-east-1"
apigw = boto3.client("apigateway", region_name=region)
@@ -375,8 +371,7 @@ def test_simple_apigateway_with_lambda_proxy():
)
-@mock_apigateway
-@mock_cloudformation
+@mock_aws
def test_apigateway_with_unknown_description():
region = "us-east-1"
apigw = boto3.client("apigateway", region_name=region)
diff --git a/tests/test_apigateway/test_apigateway_deployments.py b/tests/test_apigateway/test_apigateway_deployments.py
index b8352e07b..ff4919530 100644
--- a/tests/test_apigateway/test_apigateway_deployments.py
+++ b/tests/test_apigateway/test_apigateway_deployments.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigateway
+from moto import mock_aws
from .test_apigateway import create_method_integration
-@mock_apigateway
+@mock_aws
def test_create_deployment_requires_REST_methods():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -23,7 +23,7 @@ def test_create_deployment_requires_REST_methods():
)
-@mock_apigateway
+@mock_aws
def test_create_deployment_requires_REST_method_integrations():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -42,7 +42,7 @@ def test_create_deployment_requires_REST_method_integrations():
assert ex.value.response["Error"]["Message"] == "No integration defined for method"
-@mock_apigateway
+@mock_aws
def test_create_simple_deployment_with_get_method():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -54,7 +54,7 @@ def test_create_simple_deployment_with_get_method():
assert "id" in deployment
-@mock_apigateway
+@mock_aws
def test_create_simple_deployment_with_post_method():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -66,7 +66,7 @@ def test_create_simple_deployment_with_post_method():
assert "id" in deployment
-@mock_apigateway
+@mock_aws
def test_create_deployment_minimal():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -82,7 +82,7 @@ def test_create_deployment_minimal():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_apigateway
+@mock_aws
def test_create_deployment_with_empty_stage():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -102,7 +102,7 @@ def test_create_deployment_with_empty_stage():
assert stages == []
-@mock_apigateway
+@mock_aws
def test_get_deployments():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -120,7 +120,7 @@ def test_get_deployments():
assert response["items"] == [{"id": deployment_id}]
-@mock_apigateway
+@mock_aws
def test_create_multiple_deployments():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -143,7 +143,7 @@ def test_create_multiple_deployments():
assert response["items"][1]["id"] in [deployment_id, deployment_id2]
-@mock_apigateway
+@mock_aws
def test_delete_deployment__requires_stage_to_be_deleted():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -193,7 +193,7 @@ def test_delete_deployment__requires_stage_to_be_deleted():
assert len(stages) == 0
-@mock_apigateway
+@mock_aws
def test_delete_unknown_deployment():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
diff --git a/tests/test_apigateway/test_apigateway_export.py b/tests/test_apigateway/test_apigateway_export.py
index 27873956d..a16056e22 100644
--- a/tests/test_apigateway/test_apigateway_export.py
+++ b/tests/test_apigateway/test_apigateway_export.py
@@ -5,10 +5,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigateway
+from moto import mock_aws
-@mock_apigateway
+@mock_aws
def test_import_rest_api__api_is_created():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -44,7 +44,7 @@ def test_import_rest_api__api_is_created():
assert set(body["paths"]["/pet/{petId}"].keys()) == {"DELETE", "GET", "POST"}
-@mock_apigateway
+@mock_aws
def test_export_api__unknown_api():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -55,7 +55,7 @@ def test_export_api__unknown_api():
assert err["Message"] == "Invalid stage identifier specified"
-@mock_apigateway
+@mock_aws
def test_export_api__unknown_export_type():
client = boto3.client("apigateway", region_name="us-east-1")
diff --git a/tests/test_apigateway/test_apigateway_gatewayresponses.py b/tests/test_apigateway/test_apigateway_gatewayresponses.py
index a9d9a06e6..abe352f5c 100644
--- a/tests/test_apigateway/test_apigateway_gatewayresponses.py
+++ b/tests/test_apigateway/test_apigateway_gatewayresponses.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigateway
+from moto import mock_aws
-@mock_apigateway
+@mock_aws
def test_put_gateway_response_minimal():
client = boto3.client("apigateway", region_name="us-east-2")
api_id = client.create_rest_api(name="my_api", description="d")["id"]
@@ -16,7 +16,7 @@ def test_put_gateway_response_minimal():
assert resp["defaultResponse"] is False
-@mock_apigateway
+@mock_aws
def test_put_gateway_response():
client = boto3.client("apigateway", region_name="us-east-2")
api_id = client.create_rest_api(name="my_api", description="d")["id"]
@@ -42,7 +42,7 @@ def test_put_gateway_response():
}
-@mock_apigateway
+@mock_aws
def test_get_gateway_response_minimal():
client = boto3.client("apigateway", region_name="ap-southeast-1")
api_id = client.create_rest_api(name="my_api", description="d")["id"]
@@ -55,7 +55,7 @@ def test_get_gateway_response_minimal():
assert resp["defaultResponse"] is False
-@mock_apigateway
+@mock_aws
def test_get_gateway_response():
client = boto3.client("apigateway", region_name="us-east-2")
api_id = client.create_rest_api(name="my_api", description="d")["id"]
@@ -83,7 +83,7 @@ def test_get_gateway_response():
}
-@mock_apigateway
+@mock_aws
def test_get_gateway_response_unknown():
client = boto3.client("apigateway", region_name="us-east-2")
api_id = client.create_rest_api(name="my_api", description="d")["id"]
@@ -94,7 +94,7 @@ def test_get_gateway_response_unknown():
assert err["Code"] == "NotFoundException"
-@mock_apigateway
+@mock_aws
def test_get_gateway_responses_empty():
client = boto3.client("apigateway", region_name="ap-southeast-1")
api_id = client.create_rest_api(name="my_api", description="d")["id"]
@@ -103,7 +103,7 @@ def test_get_gateway_responses_empty():
assert resp["items"] == []
-@mock_apigateway
+@mock_aws
def test_get_gateway_responses():
client = boto3.client("apigateway", region_name="ap-southeast-1")
api_id = client.create_rest_api(name="my_api", description="d")["id"]
@@ -123,7 +123,7 @@ def test_get_gateway_responses():
} in resp["items"]
-@mock_apigateway
+@mock_aws
def test_delete_gateway_response():
client = boto3.client("apigateway", region_name="ap-southeast-1")
api_id = client.create_rest_api(name="my_api", description="d")["id"]
diff --git a/tests/test_apigateway/test_apigateway_importrestapi.py b/tests/test_apigateway/test_apigateway_importrestapi.py
index 07d0c73e3..c0178f4b8 100644
--- a/tests/test_apigateway/test_apigateway_importrestapi.py
+++ b/tests/test_apigateway/test_apigateway_importrestapi.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigateway
+from moto import mock_aws
-@mock_apigateway
+@mock_aws
def test_import_rest_api__api_is_created():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -24,7 +24,7 @@ def test_import_rest_api__api_is_created():
assert response["description"] == "description from JSON file"
-@mock_apigateway
+@mock_aws
def test_import_rest_api__nested_api():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -43,7 +43,7 @@ def test_import_rest_api__nested_api():
assert "/test/some/deep/path" in paths
-@mock_apigateway
+@mock_aws
def test_import_rest_api__invalid_api_creates_nothing():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -61,7 +61,7 @@ def test_import_rest_api__invalid_api_creates_nothing():
assert len(client.get_rest_apis()["items"]) == 0
-@mock_apigateway
+@mock_aws
def test_import_rest_api__methods_are_created():
client = boto3.client("apigateway", region_name="us-east-1")
diff --git a/tests/test_apigateway/test_apigateway_integration.py b/tests/test_apigateway/test_apigateway_integration.py
index 0856c1e47..8c82ee3c1 100644
--- a/tests/test_apigateway/test_apigateway_integration.py
+++ b/tests/test_apigateway/test_apigateway_integration.py
@@ -4,11 +4,11 @@ from unittest import SkipTest
import boto3
import requests
-from moto import mock_apigateway, mock_dynamodb, settings
+from moto import mock_aws, settings
from moto.core.models import responses_mock
-@mock_apigateway
+@mock_aws
def test_http_integration():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Cannot test mock of execute-api.apigateway in ServerMode")
@@ -55,8 +55,7 @@ def test_http_integration():
assert requests.get(deploy_url).content == b"a fake response"
-@mock_apigateway
-@mock_dynamodb
+@mock_aws
def test_aws_integration_dynamodb():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Cannot test mock of execute-api.apigateway in ServerMode")
@@ -80,8 +79,7 @@ def test_aws_integration_dynamodb():
assert res.content == b"{}"
-@mock_apigateway
-@mock_dynamodb
+@mock_aws
def test_aws_integration_dynamodb_multiple_stages():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Cannot test mock of execute-api.apigateway in ServerMode")
@@ -117,8 +115,7 @@ def test_aws_integration_dynamodb_multiple_stages():
assert res.status_code == 400
-@mock_apigateway
-@mock_dynamodb
+@mock_aws
def test_aws_integration_dynamodb_multiple_resources():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Cannot test mock of execute-api.apigateway in ServerMode")
@@ -167,7 +164,7 @@ def test_aws_integration_dynamodb_multiple_resources():
}
-@mock_apigateway
+@mock_aws
def test_aws_integration_sagemaker():
region = "us-west-2"
client = boto3.client("apigateway", region_name=region)
diff --git a/tests/test_apigateway/test_apigateway_putrestapi.py b/tests/test_apigateway/test_apigateway_putrestapi.py
index fc42bef65..100de6205 100644
--- a/tests/test_apigateway/test_apigateway_putrestapi.py
+++ b/tests/test_apigateway/test_apigateway_putrestapi.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigateway
+from moto import mock_aws
-@mock_apigateway
+@mock_aws
def test_put_rest_api__api_details_are_persisted():
client = boto3.client("apigateway", region_name="us-west-2")
@@ -28,7 +28,7 @@ def test_put_rest_api__api_details_are_persisted():
assert response["description"] == "this is my api"
-@mock_apigateway
+@mock_aws
def test_put_rest_api__methods_are_created():
client = boto3.client("apigateway", region_name="us-east-2")
@@ -56,7 +56,7 @@ def test_put_rest_api__methods_are_created():
assert resp["methodResponses"] == {"201": {"statusCode": "201"}}
-@mock_apigateway
+@mock_aws
def test_put_rest_api__existing_methods_are_overwritten():
client = boto3.client("apigateway", region_name="us-east-2")
@@ -107,7 +107,7 @@ def test_put_rest_api__existing_methods_are_overwritten():
client.get_method(restApiId=api_id, resourceId=new_root_id, httpMethod="GET")
-@mock_apigateway
+@mock_aws
def test_put_rest_api__existing_methods_still_exist():
client = boto3.client("apigateway", region_name="us-east-2")
@@ -141,7 +141,7 @@ def test_put_rest_api__existing_methods_still_exist():
assert response["httpMethod"] == "POST"
-@mock_apigateway
+@mock_aws
def test_put_rest_api__fail_on_invalid_spec():
client = boto3.client("apigateway", region_name="us-east-2")
@@ -162,7 +162,7 @@ def test_put_rest_api__fail_on_invalid_spec():
)
-@mock_apigateway
+@mock_aws
def test_put_rest_api__fail_on_invalid_version():
client = boto3.client("apigateway", region_name="us-east-2")
@@ -180,7 +180,7 @@ def test_put_rest_api__fail_on_invalid_version():
assert err["Message"] == "Only OpenAPI 3.x.x are currently supported"
-@mock_apigateway
+@mock_aws
def test_put_rest_api__fail_on_invalid_mode():
client = boto3.client("apigateway", region_name="us-east-2")
@@ -199,7 +199,7 @@ def test_put_rest_api__fail_on_invalid_mode():
)
-@mock_apigateway
+@mock_aws
def test_put_rest_api__as_yaml():
client = boto3.client("apigateway", region_name="us-west-2")
diff --git a/tests/test_apigateway/test_apigateway_stage.py b/tests/test_apigateway/test_apigateway_stage.py
index 4d6fcd7eb..6805b71d9 100644
--- a/tests/test_apigateway/test_apigateway_stage.py
+++ b/tests/test_apigateway/test_apigateway_stage.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigateway
+from moto import mock_aws
from .test_apigateway import create_method_integration
-@mock_apigateway
+@mock_aws
def test_create_stage_minimal():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -37,7 +37,7 @@ def test_create_stage_minimal():
assert stage["deploymentId"] == deployment_id
-@mock_apigateway
+@mock_aws
def test_create_stage_with_env_vars():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -71,7 +71,7 @@ def test_create_stage_with_env_vars():
assert stage["variables"]["env"] == "dev"
-@mock_apigateway
+@mock_aws
def test_create_stage_with_vars_and_cache():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -107,7 +107,7 @@ def test_create_stage_with_vars_and_cache():
assert stage["cacheClusterSize"] == "0.5"
-@mock_apigateway
+@mock_aws
def test_create_stage_with_cache_settings():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -148,7 +148,7 @@ def test_create_stage_with_cache_settings():
assert stage["cacheClusterSize"] == "1.6"
-@mock_apigateway
+@mock_aws
def test_recreate_stage_from_deployment():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -166,7 +166,7 @@ def test_recreate_stage_from_deployment():
assert err["Message"] == "Stage already exists"
-@mock_apigateway
+@mock_aws
def test_create_stage_twice():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -189,7 +189,7 @@ def test_create_stage_twice():
assert err["Message"] == "Stage already exists"
-@mock_apigateway
+@mock_aws
def test_delete_stage():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -229,7 +229,7 @@ def test_delete_stage():
assert new_stage_name_with_vars not in stage_names
-@mock_apigateway
+@mock_aws
def test_delete_stage_created_by_deployment():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -262,7 +262,7 @@ def test_delete_stage_created_by_deployment():
assert set(depls[0].keys()) == {"id", "createdDate"}
-@mock_apigateway
+@mock_aws
def test_delete_stage_unknown_stage():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
@@ -274,7 +274,7 @@ def test_delete_stage_unknown_stage():
assert err["Code"] == "NotFoundException"
-@mock_apigateway
+@mock_aws
def test_update_stage_configuration():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -367,7 +367,7 @@ def test_update_stage_configuration():
assert stage["methodSettings"]["*/*"]["cacheDataEncrypted"] is True
-@mock_apigateway
+@mock_aws
def test_update_stage_add_access_log_settings():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -403,7 +403,7 @@ def test_update_stage_add_access_log_settings():
}
-@mock_apigateway
+@mock_aws
def test_update_stage_tracing_disabled():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -433,7 +433,7 @@ def test_update_stage_tracing_disabled():
assert stage["tracingEnabled"] is True
-@mock_apigateway
+@mock_aws
def test_update_stage_remove_access_log_settings():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -455,7 +455,7 @@ def test_update_stage_remove_access_log_settings():
assert "accessLogSettings" not in stage
-@mock_apigateway
+@mock_aws
def test_update_stage_configuration_unknown_operation():
client = boto3.client("apigateway", region_name="us-west-2")
stage_name = "staging"
@@ -483,7 +483,7 @@ def test_update_stage_configuration_unknown_operation():
)
-@mock_apigateway
+@mock_aws
def test_non_existent_stage():
client = boto3.client("apigateway", region_name="us-west-2")
response = client.create_rest_api(name="my_api", description="this is my api")
diff --git a/tests/test_apigateway/test_apigateway_validators.py b/tests/test_apigateway/test_apigateway_validators.py
index 25819e187..931a0e23e 100644
--- a/tests/test_apigateway/test_apigateway_validators.py
+++ b/tests/test_apigateway/test_apigateway_validators.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigateway
+from moto import mock_aws
ID = "id"
NAME = "name"
@@ -12,7 +12,7 @@ PARAM_NAME = "my-validator"
RESPONSE_METADATA = "ResponseMetadata"
-@mock_apigateway
+@mock_aws
def test_create_request_validator():
client = create_client()
api_id = create_rest_api_id(client)
@@ -26,7 +26,7 @@ def test_create_request_validator():
}
-@mock_apigateway
+@mock_aws
def test_get_request_validators():
client = create_client()
api_id = create_rest_api_id(client)
@@ -66,7 +66,7 @@ def test_get_request_validators():
}
-@mock_apigateway
+@mock_aws
def test_get_request_validator():
client = create_client()
api_id = create_rest_api_id(client)
@@ -84,7 +84,7 @@ def test_get_request_validator():
}
-@mock_apigateway
+@mock_aws
def test_delete_request_validator():
client = create_client()
api_id = create_rest_api_id(client)
@@ -114,7 +114,7 @@ def test_delete_request_validator():
assert err["Message"] == "Invalid Request Validator Id specified"
-@mock_apigateway
+@mock_aws
def test_update_request_validator():
client = create_client()
api_id = create_rest_api_id(client)
diff --git a/tests/test_apigateway/test_apigateway_vpclink.py b/tests/test_apigateway/test_apigateway_vpclink.py
index 2e98f69e5..ef9204a6f 100644
--- a/tests/test_apigateway/test_apigateway_vpclink.py
+++ b/tests/test_apigateway/test_apigateway_vpclink.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigateway
+from moto import mock_aws
-@mock_apigateway
+@mock_aws
def test_get_vpc_links_empty():
client = boto3.client("apigateway", region_name="eu-west-1")
@@ -13,7 +13,7 @@ def test_get_vpc_links_empty():
assert resp["items"] == []
-@mock_apigateway
+@mock_aws
def test_create_vpc_link():
client = boto3.client("apigateway", region_name="eu-west-1")
@@ -32,7 +32,7 @@ def test_create_vpc_link():
assert resp["tags"] == {"key1": "value1"}
-@mock_apigateway
+@mock_aws
def test_get_vpc_link():
client = boto3.client("apigateway", region_name="eu-west-1")
@@ -53,7 +53,7 @@ def test_get_vpc_link():
assert resp["tags"] == {"key1": "value1"}
-@mock_apigateway
+@mock_aws
def test_get_vpc_link_unknown():
client = boto3.client("apigateway", region_name="ap-southeast-1")
@@ -64,7 +64,7 @@ def test_get_vpc_link_unknown():
assert err["Message"] == "VPCLink not found"
-@mock_apigateway
+@mock_aws
def test_get_vpc_links():
client = boto3.client("apigateway", region_name="eu-west-1")
@@ -90,7 +90,7 @@ def test_get_vpc_links():
assert len(links) == 2
-@mock_apigateway
+@mock_aws
def test_delete_vpc_link():
client = boto3.client("apigateway", region_name="eu-north-1")
diff --git a/tests/test_apigatewaymanagementapi/test_apigatewaymanagementapi.py b/tests/test_apigatewaymanagementapi/test_apigatewaymanagementapi.py
index c17ab4dd5..c461752f7 100644
--- a/tests/test_apigatewaymanagementapi/test_apigatewaymanagementapi.py
+++ b/tests/test_apigatewaymanagementapi/test_apigatewaymanagementapi.py
@@ -1,9 +1,8 @@
-"""Unit tests for apigatewaymanagementapi-supported APIs."""
from unittest import SkipTest
import boto3
-from moto import mock_apigatewaymanagementapi, settings
+from moto import mock_aws, settings
from moto.apigatewaymanagementapi.models import apigatewaymanagementapi_backends
from moto.core.versions import is_werkzeug_2_3_x
from tests import DEFAULT_ACCOUNT_ID
@@ -12,7 +11,7 @@ from tests import DEFAULT_ACCOUNT_ID
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_apigatewaymanagementapi
+@mock_aws
def test_delete_connection():
if settings.TEST_SERVER_MODE and not is_werkzeug_2_3_x():
# URL matching changed between 2.2.x and 2.3.x
@@ -23,7 +22,7 @@ def test_delete_connection():
client.delete_connection(ConnectionId="anything")
-@mock_apigatewaymanagementapi
+@mock_aws
def test_get_connection():
if settings.TEST_SERVER_MODE and not is_werkzeug_2_3_x():
# URL matching changed between 2.2.x and 2.3.x
@@ -37,7 +36,7 @@ def test_get_connection():
assert "LastActiveAt" in conn
-@mock_apigatewaymanagementapi
+@mock_aws
def test_post_to_connection():
if settings.TEST_SERVER_MODE and not is_werkzeug_2_3_x():
# URL matching changed between 2.2.x and 2.3.x
diff --git a/tests/test_apigatewayv2/test_apigatewayv2.py b/tests/test_apigatewayv2/test_apigatewayv2.py
index 94a5ee12f..0726c5f63 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2.py
@@ -3,13 +3,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigatewayv2
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_apigatewayv2
+@mock_aws
def test_create_api_with_unknown_protocol_type():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
@@ -22,7 +22,7 @@ def test_create_api_with_unknown_protocol_type():
)
-@mock_apigatewayv2
+@mock_aws
def test_create_api_minimal():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
resp = client.create_api(Name="test-api", ProtocolType="HTTP")
@@ -40,7 +40,7 @@ def test_create_api_minimal():
assert resp["RouteSelectionExpression"] == "$request.method $request.path"
-@mock_apigatewayv2
+@mock_aws
def test_create_api():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
resp = client.create_api(
@@ -86,7 +86,7 @@ def test_create_api():
assert resp["Version"] == "1.0"
-@mock_apigatewayv2
+@mock_aws
def test_delete_api():
client = boto3.client("apigatewayv2", region_name="us-east-2")
api_id = client.create_api(Name="t", ProtocolType="HTTP")["ApiId"]
@@ -98,7 +98,7 @@ def test_delete_api():
assert exc.value.response["Error"]["Code"] == "NotFoundException"
-@mock_apigatewayv2
+@mock_aws
def test_delete_cors_configuration():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(
@@ -129,7 +129,7 @@ def test_delete_cors_configuration():
assert resp["Name"] == "test-api"
-@mock_apigatewayv2
+@mock_aws
def test_get_api_unknown():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
with pytest.raises(ClientError) as exc:
@@ -140,7 +140,7 @@ def test_get_api_unknown():
assert err["Message"] == "Invalid API identifier specified unknown"
-@mock_apigatewayv2
+@mock_aws
def test_get_api():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-get-api", ProtocolType="WEBSOCKET")["ApiId"]
@@ -160,7 +160,7 @@ def test_get_api():
assert resp["RouteSelectionExpression"] == "$request.method $request.path"
-@mock_apigatewayv2
+@mock_aws
def test_get_apis():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
assert len(client.get_apis()["Items"]) == 0
@@ -174,7 +174,7 @@ def test_get_apis():
assert api_id_2 in api_ids
-@mock_apigatewayv2
+@mock_aws
def test_update_api_minimal():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(
@@ -232,7 +232,7 @@ def test_update_api_minimal():
assert resp["Version"] == "1.0"
-@mock_apigatewayv2
+@mock_aws
def test_update_api_empty_fields():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(
@@ -271,7 +271,7 @@ def test_update_api_empty_fields():
assert resp["Version"] == ""
-@mock_apigatewayv2
+@mock_aws
def test_update_api():
client = boto3.client("apigatewayv2", region_name="us-east-2")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_authorizers.py b/tests/test_apigatewayv2/test_apigatewayv2_authorizers.py
index 36a3eec19..e9e333a40 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_authorizers.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_authorizers.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_create_authorizer_minimum():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -23,7 +23,7 @@ def test_create_authorizer_minimum():
assert resp["Name"] == "auth1"
-@mock_apigatewayv2
+@mock_aws
def test_create_authorizer():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -56,7 +56,7 @@ def test_create_authorizer():
assert resp["AuthorizerPayloadFormatVersion"] == "2.0"
-@mock_apigatewayv2
+@mock_aws
def test_create_authorizer_without_payloadformatversion():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -78,7 +78,7 @@ def test_create_authorizer_without_payloadformatversion():
)
-@mock_apigatewayv2
+@mock_aws
def test_get_authorizer():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -99,7 +99,7 @@ def test_get_authorizer():
assert resp["AuthorizerPayloadFormatVersion"] == "2.0"
-@mock_apigatewayv2
+@mock_aws
def test_delete_authorizer():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="WEBSOCKET")["ApiId"]
@@ -117,7 +117,7 @@ def test_delete_authorizer():
assert err["Code"] == "NotFoundException"
-@mock_apigatewayv2
+@mock_aws
def test_get_authorizer_unknown():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -129,7 +129,7 @@ def test_get_authorizer_unknown():
assert err["Code"] == "NotFoundException"
-@mock_apigatewayv2
+@mock_aws
def test_update_authorizer_single():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -163,7 +163,7 @@ def test_update_authorizer_single():
assert resp["Name"] == "auth2"
-@mock_apigatewayv2
+@mock_aws
def test_update_authorizer_all_attributes():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_domains.py b/tests/test_apigatewayv2/test_apigatewayv2_domains.py
index a92906f4f..01dcfaeba 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_domains.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_domains.py
@@ -2,10 +2,10 @@ import boto3
import botocore.exceptions
import pytest
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_create_domain_name():
client = boto3.client("apigatewayv2", region_name="us-east-1")
domain_name = "dev"
@@ -38,7 +38,7 @@ def test_create_domain_name():
assert post_resp.get("Tags") == tags
-@mock_apigatewayv2
+@mock_aws
def test_create_domain_name_already_exists():
client = boto3.client("apigatewayv2", region_name="us-east-1")
client.create_domain_name(DomainName="exists.io")
@@ -51,7 +51,7 @@ def test_create_domain_name_already_exists():
assert err["Message"] == "The domain name resource already exists."
-@mock_apigatewayv2
+@mock_aws
def test_get_domain_names():
client = boto3.client("apigatewayv2", region_name="us-east-1")
dev_domain = client.create_domain_name(DomainName="dev.service.io")
@@ -71,7 +71,7 @@ def test_get_domain_names():
assert prod_domain in get_resp.get("Items")
-@mock_apigatewayv2
+@mock_aws
def test_delete_domain_name():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
post_resp = client.create_domain_name(DomainName="dev.service.io")
@@ -83,7 +83,7 @@ def test_delete_domain_name():
assert post_resp not in get_resp.get("Items")
-@mock_apigatewayv2
+@mock_aws
def test_delete_domain_name_dne():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
with pytest.raises(botocore.exceptions.ClientError) as exc:
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_integrationresponses.py b/tests/test_apigatewayv2/test_apigatewayv2_integrationresponses.py
index fbc9aad5f..156e0f9b4 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_integrationresponses.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_integrationresponses.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_get_integration_responses_empty():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -17,7 +17,7 @@ def test_get_integration_responses_empty():
assert resp["Items"] == []
-@mock_apigatewayv2
+@mock_aws
def test_create_integration_response():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -44,7 +44,7 @@ def test_create_integration_response():
assert int_res["TemplateSelectionExpression"] == "tse"
-@mock_apigatewayv2
+@mock_aws
def test_get_integration_response():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -74,7 +74,7 @@ def test_get_integration_response():
assert int_res["TemplateSelectionExpression"] == "tse"
-@mock_apigatewayv2
+@mock_aws
def test_get_integration_response_unknown():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -91,7 +91,7 @@ def test_get_integration_response_unknown():
assert err["Message"] == "Invalid IntegrationResponse identifier specified unknown"
-@mock_apigatewayv2
+@mock_aws
def test_delete_integration_response():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -115,7 +115,7 @@ def test_delete_integration_response():
assert err["Code"] == "NotFoundException"
-@mock_apigatewayv2
+@mock_aws
def test_update_integration_response_single_attr():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -139,7 +139,7 @@ def test_update_integration_response_single_attr():
assert res["IntegrationResponseKey"] == "int_res_key"
-@mock_apigatewayv2
+@mock_aws
def test_update_integration_response_multiple_attrs():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_integrations.py b/tests/test_apigatewayv2/test_apigatewayv2_integrations.py
index 1b970ac3a..5633536b2 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_integrations.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_integrations.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_get_integrations_empty():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -14,7 +14,7 @@ def test_get_integrations_empty():
assert resp["Items"] == []
-@mock_apigatewayv2
+@mock_aws
def test_create_integration_minimum():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -25,7 +25,7 @@ def test_create_integration_minimum():
assert resp["IntegrationType"] == "HTTP"
-@mock_apigatewayv2
+@mock_aws
def test_create_integration_for_internet_mock():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -42,7 +42,7 @@ def test_create_integration_for_internet_mock():
)
-@mock_apigatewayv2
+@mock_aws
def test_create_integration_full():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -86,7 +86,7 @@ def test_create_integration_full():
assert resp["TlsConfig"] == {"ServerNameToVerify": "server"}
-@mock_apigatewayv2
+@mock_aws
def test_get_integration():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -101,7 +101,7 @@ def test_get_integration():
assert resp["IntegrationType"] == "HTTP"
-@mock_apigatewayv2
+@mock_aws
def test_get_integration_unknown():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -113,7 +113,7 @@ def test_get_integration_unknown():
assert err["Message"] == "Invalid Integration identifier specified unknown"
-@mock_apigatewayv2
+@mock_aws
def test_get_integrations():
client = boto3.client("apigatewayv2", region_name="us-east-2")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -127,7 +127,7 @@ def test_get_integrations():
assert resp["Items"][0]["IntegrationId"] == integration_id
-@mock_apigatewayv2
+@mock_aws
def test_delete_integration():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -144,7 +144,7 @@ def test_delete_integration():
assert err["Code"] == "NotFoundException"
-@mock_apigatewayv2
+@mock_aws
def test_update_integration_single_attr():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -192,7 +192,7 @@ def test_update_integration_single_attr():
assert resp["TlsConfig"] == {"ServerNameToVerify": "server"}
-@mock_apigatewayv2
+@mock_aws
def test_update_integration_all_attrs():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -247,7 +247,7 @@ def test_update_integration_all_attrs():
assert resp["TlsConfig"] == {"ServerNameToVerify": "server"}
-@mock_apigatewayv2
+@mock_aws
def test_update_integration_request_parameters():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_mappings.py b/tests/test_apigatewayv2/test_apigatewayv2_mappings.py
index 1fa2ee8e7..3a0311df0 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_mappings.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_mappings.py
@@ -2,10 +2,10 @@ import boto3
import botocore.exceptions
import pytest
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_create_api_mapping():
client = boto3.client("apigatewayv2", region_name="us-east-1")
api = client.create_api(Name="test-api", ProtocolType="HTTP")
@@ -42,7 +42,7 @@ def test_create_api_mapping():
assert post_resp.get("Stage") == "$default"
-@mock_apigatewayv2
+@mock_aws
def test_create_api_mapping_missing_api():
client = boto3.client("apigatewayv2", region_name="us-east-1")
dev_domain = client.create_domain_name(DomainName="dev.service.io")
@@ -61,7 +61,7 @@ def test_create_api_mapping_missing_api():
)
-@mock_apigatewayv2
+@mock_aws
def test_create_api_mapping_missing_domain():
client = boto3.client("apigatewayv2", region_name="us-east-1")
api = client.create_api(Name="test-api", ProtocolType="HTTP")
@@ -81,7 +81,7 @@ def test_create_api_mapping_missing_domain():
)
-@mock_apigatewayv2
+@mock_aws
def test_create_api_mapping_bad_mapping_keys():
client = boto3.client("apigatewayv2", region_name="us-east-1")
api = client.create_api(Name="test-api", ProtocolType="HTTP")
@@ -106,7 +106,7 @@ def test_create_api_mapping_bad_mapping_keys():
assert err["Message"] == message
-@mock_apigatewayv2
+@mock_aws
def test_get_api_mappings():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api = client.create_api(Name="test-api", ProtocolType="HTTP")
@@ -151,7 +151,7 @@ def test_get_api_mappings():
assert hr_mapping not in get_resp.get("Items")
-@mock_apigatewayv2
+@mock_aws
def test_delete_api_mapping():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api = client.create_api(Name="test-api", ProtocolType="HTTP")
@@ -179,7 +179,7 @@ def test_delete_api_mapping():
assert v1_mapping not in get_resp.get("Items")
-@mock_apigatewayv2
+@mock_aws
def test_delete_api_mapping_dne():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
client.create_api(Name="test-api", ProtocolType="HTTP")
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_models.py b/tests/test_apigatewayv2/test_apigatewayv2_models.py
index 9346b8fa3..631116d51 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_models.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_models.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_create_model():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -21,7 +21,7 @@ def test_create_model():
assert resp["Schema"] == "cs"
-@mock_apigatewayv2
+@mock_aws
def test_get_model():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -39,7 +39,7 @@ def test_get_model():
assert resp["Schema"] == "cs"
-@mock_apigatewayv2
+@mock_aws
def test_delete_model():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -57,7 +57,7 @@ def test_delete_model():
assert err["Code"] == "NotFoundException"
-@mock_apigatewayv2
+@mock_aws
def test_get_model_unknown():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -69,7 +69,7 @@ def test_get_model_unknown():
assert err["Code"] == "NotFoundException"
-@mock_apigatewayv2
+@mock_aws
def test_update_model_single_attr():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -89,7 +89,7 @@ def test_update_model_single_attr():
assert resp["Schema"] == "cs2"
-@mock_apigatewayv2
+@mock_aws
def test_update_model_all_attrs():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_reimport.py b/tests/test_apigatewayv2/test_apigatewayv2_reimport.py
index e4fd7b3e6..c94bf10b7 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_reimport.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_reimport.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_reimport_api_standard_fields():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -20,7 +20,7 @@ def test_reimport_api_standard_fields():
assert resp["Version"] == "2.0"
-@mock_apigatewayv2
+@mock_aws
def test_reimport_api_failonwarnings():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-import-api", ProtocolType="HTTP")["ApiId"]
@@ -43,7 +43,7 @@ def test_reimport_api_failonwarnings():
assert resp["Name"] == "test-import-api"
-@mock_apigatewayv2
+@mock_aws
def test_reimport_api_do_not_failonwarnings():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-import-api", ProtocolType="HTTP")["ApiId"]
@@ -59,7 +59,7 @@ def test_reimport_api_do_not_failonwarnings():
assert resp["Name"] == "Title test"
-@mock_apigatewayv2
+@mock_aws
def test_reimport_api_routes_and_integrations():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
resp = client.create_api(Name="test-import-api", ProtocolType="HTTP")
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_routes.py b/tests/test_apigatewayv2/test_apigatewayv2_routes.py
index 15cb2487d..63538bddb 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_routes.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_routes.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_get_routes_empty():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -14,7 +14,7 @@ def test_get_routes_empty():
assert resp["Items"] == []
-@mock_apigatewayv2
+@mock_aws
def test_create_route_minimal():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -34,7 +34,7 @@ def test_create_route_minimal():
assert "Target" not in resp
-@mock_apigatewayv2
+@mock_aws
def test_create_route_full():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(
@@ -72,7 +72,7 @@ def test_create_route_full():
assert resp["Target"] == "t"
-@mock_apigatewayv2
+@mock_aws
def test_delete_route():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -84,7 +84,7 @@ def test_delete_route():
assert len(resp["Items"]) == 0
-@mock_apigatewayv2
+@mock_aws
def test_get_route():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -105,7 +105,7 @@ def test_get_route():
assert "Target" not in resp
-@mock_apigatewayv2
+@mock_aws
def test_get_route_unknown():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -117,7 +117,7 @@ def test_get_route_unknown():
assert err["Message"] == "Invalid Route identifier specified unknown"
-@mock_apigatewayv2
+@mock_aws
def test_get_routes():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -127,7 +127,7 @@ def test_get_routes():
assert len(resp["Items"]) == 1
-@mock_apigatewayv2
+@mock_aws
def test_update_route_single_attribute():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -141,7 +141,7 @@ def test_update_route_single_attribute():
assert resp["RouteKey"] == "POST /"
-@mock_apigatewayv2
+@mock_aws
def test_update_route_all_attributes():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -178,7 +178,7 @@ def test_update_route_all_attributes():
assert resp["Target"] == "t"
-@mock_apigatewayv2
+@mock_aws
def test_delete_route_request_parameter():
client = boto3.client("apigatewayv2", region_name="us-east-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -211,7 +211,7 @@ def test_delete_route_request_parameter():
assert "zparam" in request_params
-@mock_apigatewayv2
+@mock_aws
def test_create_route_response_minimal():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -225,7 +225,7 @@ def test_create_route_response_minimal():
assert resp["RouteResponseKey"] == "$default"
-@mock_apigatewayv2
+@mock_aws
def test_create_route_response():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -245,7 +245,7 @@ def test_create_route_response():
assert resp["ResponseModels"] == {"test": "tfacctest5832545056931060873"}
-@mock_apigatewayv2
+@mock_aws
def test_get_route_response():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -263,7 +263,7 @@ def test_get_route_response():
assert resp["RouteResponseKey"] == "$default"
-@mock_apigatewayv2
+@mock_aws
def test_get_route_response_unknown():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -278,7 +278,7 @@ def test_get_route_response_unknown():
assert err["Code"] == "NotFoundException"
-@mock_apigatewayv2
+@mock_aws
def test_delete_route_response_unknown():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_stages.py b/tests/test_apigatewayv2/test_apigatewayv2_stages.py
index b9dd8d4e8..c9af65a57 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_stages.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_stages.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_create_stage__defaults():
client = boto3.client("apigatewayv2", "us-east-2")
@@ -42,7 +42,7 @@ def test_create_stage__defaults():
assert err["Message"] == "Invalid stage identifier specified"
-@mock_apigatewayv2
+@mock_aws
def test_create_stage__defaults_for_websocket_api():
client = boto3.client("apigatewayv2", "us-east-2")
@@ -59,7 +59,7 @@ def test_create_stage__defaults_for_websocket_api():
}
-@mock_apigatewayv2
+@mock_aws
def test_create_stage():
client = boto3.client("apigatewayv2", "us-east-2")
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_tags.py b/tests/test_apigatewayv2/test_apigatewayv2_tags.py
index e468e2ffb..bef4d605a 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_tags.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_tags.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_create_api_with_tags():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
resp = client.create_api(
@@ -13,7 +13,7 @@ def test_create_api_with_tags():
assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
-@mock_apigatewayv2
+@mock_aws
def test_tag_resource():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -28,7 +28,7 @@ def test_tag_resource():
assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
-@mock_apigatewayv2
+@mock_aws
def test_get_tags():
client = boto3.client("apigatewayv2", region_name="eu-west-2")
api_id = client.create_api(Name="test-api", ProtocolType="HTTP")["ApiId"]
@@ -43,7 +43,7 @@ def test_get_tags():
assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
-@mock_apigatewayv2
+@mock_aws
def test_untag_resource():
client = boto3.client("apigatewayv2", region_name="eu-west-2")
api_id = client.create_api(
diff --git a/tests/test_apigatewayv2/test_apigatewayv2_vpclinks.py b/tests/test_apigatewayv2/test_apigatewayv2_vpclinks.py
index 758ce715c..de31ddbc3 100644
--- a/tests/test_apigatewayv2/test_apigatewayv2_vpclinks.py
+++ b/tests/test_apigatewayv2/test_apigatewayv2_vpclinks.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigatewayv2
+from moto import mock_aws
-@mock_apigatewayv2
+@mock_aws
def test_get_vpc_links_empty():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
@@ -13,7 +13,7 @@ def test_get_vpc_links_empty():
assert resp["Items"] == []
-@mock_apigatewayv2
+@mock_aws
def test_create_vpc_links():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
@@ -34,7 +34,7 @@ def test_create_vpc_links():
assert resp["VpcLinkVersion"] == "V2"
-@mock_apigatewayv2
+@mock_aws
def test_get_vpc_link():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
@@ -57,7 +57,7 @@ def test_get_vpc_link():
assert resp["VpcLinkVersion"] == "V2"
-@mock_apigatewayv2
+@mock_aws
def test_get_vpc_link_unknown():
client = boto3.client("apigatewayv2", region_name="ap-southeast-1")
@@ -68,7 +68,7 @@ def test_get_vpc_link_unknown():
assert err["Message"] == "Invalid VpcLink identifier specified unknown"
-@mock_apigatewayv2
+@mock_aws
def test_get_vpc_links():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
@@ -94,7 +94,7 @@ def test_get_vpc_links():
assert len(links) == 2
-@mock_apigatewayv2
+@mock_aws
def test_delete_vpc_link():
client = boto3.client("apigatewayv2", region_name="eu-north-1")
@@ -114,7 +114,7 @@ def test_delete_vpc_link():
assert len(links) == 0
-@mock_apigatewayv2
+@mock_aws
def test_update_vpc_link():
client = boto3.client("apigatewayv2", region_name="eu-north-1")
vpc_link_id = client.create_vpc_link(
@@ -136,7 +136,7 @@ def test_update_vpc_link():
assert resp["VpcLinkVersion"] == "V2"
-@mock_apigatewayv2
+@mock_aws
def test_untag_vpc_link():
client = boto3.client("apigatewayv2", region_name="eu-west-1")
diff --git a/tests/test_appconfig/test_appconfig_applications.py b/tests/test_appconfig/test_appconfig_applications.py
index 7e03ef9a0..92c7192ce 100644
--- a/tests/test_appconfig/test_appconfig_applications.py
+++ b/tests/test_appconfig/test_appconfig_applications.py
@@ -1,15 +1,14 @@
-"""Unit tests for appconfig-supported APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_appconfig
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_appconfig
+@mock_aws
def test_create_application():
client = boto3.client("appconfig", region_name="ap-southeast-1")
post = client.create_application(Name="testapp", Description="blah")
@@ -39,7 +38,7 @@ def test_create_application():
assert err["Code"] == "ResourceNotFoundException"
-@mock_appconfig
+@mock_aws
def test_tag_application():
client = boto3.client("appconfig", region_name="us-east-2")
app_id = client.create_application(Name="testapp")["Id"]
diff --git a/tests/test_appconfig/test_appconfig_config_profiles.py b/tests/test_appconfig/test_appconfig_config_profiles.py
index 91808fa3f..2f463b464 100644
--- a/tests/test_appconfig/test_appconfig_config_profiles.py
+++ b/tests/test_appconfig/test_appconfig_config_profiles.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_appconfig
+from moto import mock_aws
-@mock_appconfig
+@mock_aws
def test_create_configuration_profile():
client = boto3.client("appconfig", region_name="eu-north-1")
app_id = client.create_application(Name="testapp")["Id"]
@@ -79,7 +79,7 @@ def test_create_configuration_profile():
assert err["Code"] == "ResourceNotFoundException"
-@mock_appconfig
+@mock_aws
def test_tag_config_profile():
client = boto3.client("appconfig", region_name="us-east-2")
app_id = client.create_application(Name="testapp")["Id"]
diff --git a/tests/test_appconfig/test_appconfig_hosted_config_versions.py b/tests/test_appconfig/test_appconfig_hosted_config_versions.py
index bdb9bf151..835dea43e 100644
--- a/tests/test_appconfig/test_appconfig_hosted_config_versions.py
+++ b/tests/test_appconfig/test_appconfig_hosted_config_versions.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_appconfig
+from moto import mock_aws
-@mock_appconfig
+@mock_aws
class TestHostedConfigurationVersions:
def setup_method(self, *args): # pylint: disable=unused-argument
self.client = boto3.client("appconfig", region_name="us-west-1")
diff --git a/tests/test_applicationautoscaling/test_applicationautoscaling.py b/tests/test_applicationautoscaling/test_applicationautoscaling.py
index be5f61941..94d6239aa 100644
--- a/tests/test_applicationautoscaling/test_applicationautoscaling.py
+++ b/tests/test_applicationautoscaling/test_applicationautoscaling.py
@@ -3,7 +3,7 @@ import re
import boto3
import pytest
-from moto import mock_applicationautoscaling, mock_ecs
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
DEFAULT_REGION = "us-east-1"
@@ -50,8 +50,7 @@ def _create_ecs_defaults(ecs, create_service=True):
)
-@mock_ecs
-@mock_applicationautoscaling
+@mock_aws
def test_describe_scalable_targets_one_basic_ecs_success():
ecs = boto3.client("ecs", region_name=DEFAULT_REGION)
_create_ecs_defaults(ecs)
@@ -73,8 +72,7 @@ def test_describe_scalable_targets_one_basic_ecs_success():
assert "CreationTime" in t
-@mock_ecs
-@mock_applicationautoscaling
+@mock_aws
def test_describe_scalable_targets_one_full_ecs_success():
ecs = boto3.client("ecs", region_name=DEFAULT_REGION)
_create_ecs_defaults(ecs)
@@ -99,8 +97,7 @@ def test_describe_scalable_targets_one_full_ecs_success():
)
-@mock_ecs
-@mock_applicationautoscaling
+@mock_aws
def test_describe_scalable_targets_only_return_ecs_targets():
ecs = boto3.client("ecs", region_name=DEFAULT_REGION)
_create_ecs_defaults(ecs, create_service=False)
@@ -140,8 +137,7 @@ def test_describe_scalable_targets_only_return_ecs_targets():
assert len(response["ScalableTargets"]) == 2
-@mock_ecs
-@mock_applicationautoscaling
+@mock_aws
def test_describe_scalable_targets_next_token_success():
ecs = boto3.client("ecs", region_name=DEFAULT_REGION)
_create_ecs_defaults(ecs, create_service=False)
@@ -187,8 +183,7 @@ def register_scalable_target(client, **kwargs):
)
-@mock_ecs
-@mock_applicationautoscaling
+@mock_aws
def test_register_scalable_target_resource_id_variations():
# Required to register an ECS target in moto
ecs = boto3.client("ecs", region_name=DEFAULT_REGION)
@@ -266,8 +261,7 @@ def test_register_scalable_target_resource_id_variations():
assert "CreationTime" in t
-@mock_ecs
-@mock_applicationautoscaling
+@mock_aws
def test_register_scalable_target_updates_existing_target():
ecs = boto3.client("ecs", region_name=DEFAULT_REGION)
_create_ecs_defaults(ecs)
@@ -338,7 +332,7 @@ def test_register_scalable_target_updates_existing_target():
],
],
)
-@mock_applicationautoscaling
+@mock_aws
def test_put_scaling_policy(policy_type, policy_body_kwargs):
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
namespace = "sagemaker"
@@ -386,7 +380,7 @@ def test_put_scaling_policy(policy_type, policy_body_kwargs):
)
-@mock_applicationautoscaling
+@mock_aws
def test_describe_scaling_policies():
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
namespace = "sagemaker"
@@ -444,7 +438,7 @@ def test_describe_scaling_policies():
assert "CreationTime" in policy
-@mock_applicationautoscaling
+@mock_aws
def test_delete_scaling_policies():
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
namespace = "sagemaker"
@@ -505,7 +499,7 @@ def test_delete_scaling_policies():
assert len(response["ScalingPolicies"]) == 0
-@mock_applicationautoscaling
+@mock_aws
def test_deregister_scalable_target():
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
namespace = "sagemaker"
@@ -541,7 +535,7 @@ def test_deregister_scalable_target():
assert "No scalable target found" in e.value.response["Error"]["Message"]
-@mock_applicationautoscaling
+@mock_aws
def test_delete_scheduled_action():
client = boto3.client("application-autoscaling", region_name="eu-west-1")
resp = client.describe_scheduled_actions(ServiceNamespace="ecs")
@@ -569,7 +563,7 @@ def test_delete_scheduled_action():
assert len(resp["ScheduledActions"]) == 2
-@mock_applicationautoscaling
+@mock_aws
def test_describe_scheduled_actions():
client = boto3.client("application-autoscaling", region_name="eu-west-1")
resp = client.describe_scheduled_actions(ServiceNamespace="ecs")
@@ -615,7 +609,7 @@ def test_describe_scheduled_actions():
assert len(resp["ScheduledActions"]) == 0
-@mock_applicationautoscaling
+@mock_aws
def test_put_scheduled_action():
client = boto3.client("application-autoscaling", region_name="ap-southeast-1")
client.put_scheduled_action(
@@ -641,7 +635,7 @@ def test_put_scheduled_action():
assert "ScalableTargetAction" not in action
-@mock_applicationautoscaling
+@mock_aws
def test_put_scheduled_action__use_update():
client = boto3.client("application-autoscaling", region_name="ap-southeast-1")
client.put_scheduled_action(
diff --git a/tests/test_applicationautoscaling/test_validation.py b/tests/test_applicationautoscaling/test_validation.py
index 0049937b4..c8ba9d316 100644
--- a/tests/test_applicationautoscaling/test_validation.py
+++ b/tests/test_applicationautoscaling/test_validation.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_applicationautoscaling, mock_ecs
+from moto import mock_aws
from moto.applicationautoscaling import models
from moto.applicationautoscaling.exceptions import AWSValidationException
@@ -20,7 +20,7 @@ DEFAULT_MAX_CAPACITY = 1
DEFAULT_ROLE_ARN = "test:arn"
-@mock_applicationautoscaling
+@mock_aws
def test_describe_scalable_targets_with_invalid_scalable_dimension_should_return_validation_exception():
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
@@ -34,7 +34,7 @@ def test_describe_scalable_targets_with_invalid_scalable_dimension_should_return
assert err["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_applicationautoscaling
+@mock_aws
def test_describe_scalable_targets_with_invalid_service_namespace_should_return_validation_exception():
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
@@ -48,7 +48,7 @@ def test_describe_scalable_targets_with_invalid_service_namespace_should_return_
assert err["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_applicationautoscaling
+@mock_aws
def test_describe_scalable_targets_with_multiple_invalid_parameters_should_return_validation_exception():
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
@@ -62,8 +62,7 @@ def test_describe_scalable_targets_with_multiple_invalid_parameters_should_retur
assert err["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_ecs
-@mock_applicationautoscaling
+@mock_aws
def test_register_scalable_target_ecs_with_non_existent_service_should_return_clusternotfound_exception():
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
resource_id = f"service/{DEFAULT_ECS_CLUSTER}/foo"
diff --git a/tests/test_appsync/test_appsync.py b/tests/test_appsync/test_appsync.py
index 8b9ed0361..67f99bbc7 100644
--- a/tests/test_appsync/test_appsync.py
+++ b/tests/test_appsync/test_appsync.py
@@ -2,14 +2,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_appsync
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_appsync
+@mock_aws
def test_create_graphql_api():
client = boto3.client("appsync", region_name="ap-southeast-1")
resp = client.create_graphql_api(name="api1", authenticationType="API_KEY")
@@ -29,7 +29,7 @@ def test_create_graphql_api():
assert "logConfig" not in api
-@mock_appsync
+@mock_aws
def test_create_graphql_api_advanced():
client = boto3.client("appsync", region_name="ap-southeast-1")
resp = client.create_graphql_api(
@@ -63,7 +63,7 @@ def test_create_graphql_api_advanced():
assert api["xrayEnabled"] is True
-@mock_appsync
+@mock_aws
def test_get_graphql_api():
client = boto3.client("appsync", region_name="ap-southeast-1")
api_id = client.create_graphql_api(name="api1", authenticationType="API_KEY")[
@@ -79,7 +79,7 @@ def test_get_graphql_api():
assert api["authenticationType"] == "API_KEY"
-@mock_appsync
+@mock_aws
def test_update_graphql_api():
client = boto3.client("appsync", region_name="ap-southeast-1")
api_id = client.create_graphql_api(name="api1", authenticationType="API_KEY")[
@@ -122,7 +122,7 @@ def test_update_graphql_api():
assert graphql_api["xrayEnabled"] is True
-@mock_appsync
+@mock_aws
def test_get_graphql_api_unknown():
client = boto3.client("appsync", region_name="ap-southeast-1")
@@ -134,7 +134,7 @@ def test_get_graphql_api_unknown():
assert err["Message"] == "GraphQL API unknown not found."
-@mock_appsync
+@mock_aws
def test_delete_graphql_api():
client = boto3.client("appsync", region_name="eu-west-1")
@@ -151,7 +151,7 @@ def test_delete_graphql_api():
assert len(resp["graphqlApis"]) == 0
-@mock_appsync
+@mock_aws
def test_list_graphql_apis():
client = boto3.client("appsync", region_name="ap-southeast-1")
resp = client.list_graphql_apis()
diff --git a/tests/test_appsync/test_appsync_apikeys.py b/tests/test_appsync/test_appsync_apikeys.py
index d8b60e1be..bde5e922c 100644
--- a/tests/test_appsync/test_appsync_apikeys.py
+++ b/tests/test_appsync/test_appsync_apikeys.py
@@ -2,11 +2,11 @@ from datetime import datetime, timedelta
import boto3
-from moto import mock_appsync
+from moto import mock_aws
from moto.core.utils import unix_time
-@mock_appsync
+@mock_aws
def test_create_api_key_simple():
client = boto3.client("appsync", region_name="eu-west-1")
@@ -24,7 +24,7 @@ def test_create_api_key_simple():
assert "deletes" in api_key
-@mock_appsync
+@mock_aws
def test_create_api_key():
client = boto3.client("appsync", region_name="ap-southeast-1")
tomorrow = datetime.now() + timedelta(days=1)
@@ -46,7 +46,7 @@ def test_create_api_key():
assert api_key["deletes"] == tomorrow_in_secs
-@mock_appsync
+@mock_aws
def test_delete_api_key():
client = boto3.client("appsync", region_name="us-east-1")
@@ -61,14 +61,14 @@ def test_delete_api_key():
assert len(resp["apiKeys"]) == 0
-@mock_appsync
+@mock_aws
def test_list_api_keys_unknown_api():
client = boto3.client("appsync", region_name="ap-southeast-1")
resp = client.list_api_keys(apiId="unknown")
assert resp["apiKeys"] == []
-@mock_appsync
+@mock_aws
def test_list_api_keys_empty():
client = boto3.client("appsync", region_name="ap-southeast-1")
api_id = client.create_graphql_api(name="api1", authenticationType="API_KEY")[
@@ -79,7 +79,7 @@ def test_list_api_keys_empty():
assert resp["apiKeys"] == []
-@mock_appsync
+@mock_aws
def test_list_api_keys():
client = boto3.client("appsync", region_name="ap-southeast-1")
api_id = client.create_graphql_api(name="api1", authenticationType="API_KEY")[
@@ -91,7 +91,7 @@ def test_list_api_keys():
assert len(resp["apiKeys"]) == 2
-@mock_appsync
+@mock_aws
def test_update_api_key():
client = boto3.client("appsync", region_name="eu-west-1")
diff --git a/tests/test_appsync/test_appsync_schema.py b/tests/test_appsync/test_appsync_schema.py
index 462814f7a..5ffc6e972 100644
--- a/tests/test_appsync/test_appsync_schema.py
+++ b/tests/test_appsync/test_appsync_schema.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_appsync
+from moto import mock_aws
schema = """type Mutation {
putPost(id: ID!, title: String!): Post
@@ -54,7 +54,7 @@ type Subscription {
"""
-@mock_appsync
+@mock_aws
def test_start_schema_creation():
client = boto3.client("appsync", region_name="us-east-2")
api_id = client.create_graphql_api(name="api1", authenticationType="API_KEY")[
@@ -66,7 +66,7 @@ def test_start_schema_creation():
assert resp["status"] == "PROCESSING"
-@mock_appsync
+@mock_aws
def test_get_schema_creation_status():
client = boto3.client("appsync", region_name="eu-west-1")
api_id = client.create_graphql_api(name="api1", authenticationType="API_KEY")[
@@ -80,7 +80,7 @@ def test_get_schema_creation_status():
assert "details" not in resp
-@mock_appsync
+@mock_aws
def test_get_schema_creation_status_invalid():
client = boto3.client("appsync", region_name="eu-west-1")
api_id = client.create_graphql_api(name="api1", authenticationType="API_KEY")[
@@ -94,7 +94,7 @@ def test_get_schema_creation_status_invalid():
assert "Syntax Error" in resp["details"]
-@mock_appsync
+@mock_aws
def test_get_type_from_schema():
client = boto3.client("appsync", region_name="us-east-2")
@@ -118,7 +118,7 @@ def test_get_type_from_schema():
assert "description" not in query_type
-@mock_appsync
+@mock_aws
def test_get_introspection_schema_raise_gql_schema_error_if_no_schema():
client = boto3.client("appsync", region_name="us-east-2")
@@ -134,7 +134,7 @@ def test_get_introspection_schema_raise_gql_schema_error_if_no_schema():
assert err["Message"] == "InvalidSyntaxError"
-@mock_appsync
+@mock_aws
def test_get_introspection_schema_sdl():
client = boto3.client("appsync", region_name="us-east-2")
@@ -150,7 +150,7 @@ def test_get_introspection_schema_sdl():
assert "singlePost(id: ID!): Post" in schema_sdl
-@mock_appsync
+@mock_aws
def test_get_introspection_schema_json():
client = boto3.client("appsync", region_name="us-east-2")
@@ -170,7 +170,7 @@ def test_get_introspection_schema_json():
assert "directives" in schema_json["__schema"]
-@mock_appsync
+@mock_aws
def test_get_introspection_schema_bad_format():
client = boto3.client("appsync", region_name="us-east-2")
@@ -188,7 +188,7 @@ def test_get_introspection_schema_bad_format():
assert err["Message"] == "Invalid format NotAFormat given"
-@mock_appsync
+@mock_aws
def test_get_introspection_schema_include_directives_true():
client = boto3.client("appsync", region_name="us-east-2")
@@ -209,7 +209,7 @@ def test_get_introspection_schema_include_directives_true():
assert "@aws_subscribe" in schema_sdl
-@mock_appsync
+@mock_aws
def test_get_introspection_schema_include_directives_false():
client = boto3.client("appsync", region_name="us-east-2")
diff --git a/tests/test_appsync/test_appsync_tags.py b/tests/test_appsync/test_appsync_tags.py
index 3bcc8d64c..b86554be0 100644
--- a/tests/test_appsync/test_appsync_tags.py
+++ b/tests/test_appsync/test_appsync_tags.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_appsync
+from moto import mock_aws
-@mock_appsync
+@mock_aws
def test_create_graphql_api_with_tags():
client = boto3.client("appsync", region_name="ap-southeast-1")
api = client.create_graphql_api(
@@ -17,7 +17,7 @@ def test_create_graphql_api_with_tags():
assert api["tags"] == {"key": "val", "key2": "val2"}
-@mock_appsync
+@mock_aws
def test_tag_resource():
client = boto3.client("appsync", region_name="us-east-2")
api = client.create_graphql_api(name="api1", authenticationType="API_KEY")[
@@ -30,7 +30,7 @@ def test_tag_resource():
assert api["tags"] == {"key1": "val1"}
-@mock_appsync
+@mock_aws
def test_tag_resource_with_existing_tags():
client = boto3.client("appsync", region_name="us-east-2")
api = client.create_graphql_api(
@@ -47,7 +47,7 @@ def test_tag_resource_with_existing_tags():
assert api["tags"] == {"key2": "new value", "key3": "val3"}
-@mock_appsync
+@mock_aws
def test_untag_resource():
client = boto3.client("appsync", region_name="eu-west-1")
api = client.create_graphql_api(
@@ -60,7 +60,7 @@ def test_untag_resource():
assert api["tags"] == {"key2": "val2"}
-@mock_appsync
+@mock_aws
def test_untag_resource_all():
client = boto3.client("appsync", region_name="eu-west-1")
api = client.create_graphql_api(
@@ -73,7 +73,7 @@ def test_untag_resource_all():
assert api["tags"] == {}
-@mock_appsync
+@mock_aws
def test_list_tags_for_resource():
client = boto3.client("appsync", region_name="ap-southeast-1")
api = client.create_graphql_api(
diff --git a/tests/test_athena/test_athena.py b/tests/test_athena/test_athena.py
index a2648e4c2..eb194b927 100644
--- a/tests/test_athena/test_athena.py
+++ b/tests/test_athena/test_athena.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_athena, settings
+from moto import mock_aws, settings
from moto.athena.models import QueryResults, athena_backends
from moto.core import DEFAULT_ACCOUNT_ID
-@mock_athena
+@mock_aws
def test_create_work_group():
client = boto3.client("athena", region_name="us-east-1")
@@ -57,7 +57,7 @@ def test_create_work_group():
assert work_group["State"] == "ENABLED"
-@mock_athena
+@mock_aws
def test_get_primary_workgroup():
client = boto3.client("athena", region_name="us-east-1")
assert len(client.list_work_groups()["WorkGroups"]) == 1
@@ -67,7 +67,7 @@ def test_get_primary_workgroup():
assert primary["Configuration"] == {}
-@mock_athena
+@mock_aws
def test_create_and_get_workgroup():
client = boto3.client("athena", region_name="us-east-1")
@@ -85,7 +85,7 @@ def test_create_and_get_workgroup():
}
-@mock_athena
+@mock_aws
def test_start_query_execution():
client = boto3.client("athena", region_name="us-east-1")
@@ -107,7 +107,7 @@ def test_start_query_execution():
assert response["QueryExecutionId"] != sec_response["QueryExecutionId"]
-@mock_athena
+@mock_aws
def test_start_query_validate_workgroup():
client = boto3.client("athena", region_name="us-east-1")
@@ -122,7 +122,7 @@ def test_start_query_validate_workgroup():
assert err.value.response["Error"]["Message"] == "WorkGroup does not exist"
-@mock_athena
+@mock_aws
def test_get_query_execution():
client = boto3.client("athena", region_name="us-east-1")
@@ -155,7 +155,7 @@ def test_get_query_execution():
assert "WorkGroup" not in details
-@mock_athena
+@mock_aws
def test_stop_query_execution():
client = boto3.client("athena", region_name="us-east-1")
@@ -177,7 +177,7 @@ def test_stop_query_execution():
assert details["Status"]["State"] == "CANCELLED"
-@mock_athena
+@mock_aws
def test_create_named_query():
client = boto3.client("athena", region_name="us-east-1")
@@ -189,7 +189,7 @@ def test_create_named_query():
assert "NamedQueryId" in res
-@mock_athena
+@mock_aws
def test_get_named_query():
client = boto3.client("athena", region_name="us-east-1")
query_name = "query-name"
@@ -224,7 +224,7 @@ def create_basic_workgroup(client, name):
)
-@mock_athena
+@mock_aws
def test_create_data_catalog():
client = boto3.client("athena", region_name="us-east-1")
response = client.create_data_catalog(
@@ -257,7 +257,7 @@ def test_create_data_catalog():
assert data_catalog["Type"] == "GLUE"
-@mock_athena
+@mock_aws
def test_create_and_get_data_catalog():
client = boto3.client("athena", region_name="us-east-1")
@@ -278,7 +278,7 @@ def test_create_and_get_data_catalog():
}
-@mock_athena
+@mock_aws
def test_get_query_results():
client = boto3.client("athena", region_name="us-east-1")
@@ -314,7 +314,7 @@ def test_get_query_results():
assert result["ResultSet"]["ResultSetMetadata"]["ColumnInfo"] == column_info
-@mock_athena
+@mock_aws
def test_get_query_results_queue():
client = boto3.client("athena", region_name="us-east-1")
@@ -360,7 +360,7 @@ def test_get_query_results_queue():
assert result["ResultSet"]["ResultSetMetadata"]["ColumnInfo"] == column_info
-@mock_athena
+@mock_aws
def test_list_query_executions():
client = boto3.client("athena", region_name="us-east-1")
@@ -378,7 +378,7 @@ def test_list_query_executions():
assert executions["QueryExecutionIds"][0] == exec_id
-@mock_athena
+@mock_aws
def test_list_named_queries():
client = boto3.client("athena", region_name="us-east-1")
create_basic_workgroup(client=client, name="athena_workgroup")
@@ -394,7 +394,7 @@ def test_list_named_queries():
assert len(list_primary_wg["NamedQueryIds"]) == 0
-@mock_athena
+@mock_aws
def test_create_prepared_statement():
client = boto3.client("athena", region_name="us-east-1")
create_basic_workgroup(client=client, name="athena_workgroup")
@@ -408,7 +408,7 @@ def test_create_prepared_statement():
assert metadata["RetryAttempts"] == 0
-@mock_athena
+@mock_aws
def test_get_prepared_statement():
client = boto3.client("athena", region_name="us-east-1")
create_basic_workgroup(client=client, name="athena_workgroup")
diff --git a/tests/test_athena/test_athena_server_api.py b/tests/test_athena/test_athena_server_api.py
index 41acf4eb2..95b36b3f1 100644
--- a/tests/test_athena/test_athena_server_api.py
+++ b/tests/test_athena/test_athena_server_api.py
@@ -1,7 +1,7 @@
import boto3
import requests
-from moto import mock_athena, mock_sts, settings
+from moto import mock_aws, settings
DEFAULT_COLUMN_INFO = [
{
@@ -19,7 +19,7 @@ DEFAULT_COLUMN_INFO = [
]
-@mock_athena
+@mock_aws
def test_set_athena_result():
base_url = (
"localhost:5000" if settings.TEST_SERVER_MODE else "motoapi.amazonaws.com"
@@ -55,7 +55,7 @@ def test_set_athena_result():
assert details["Rows"] == []
-@mock_athena
+@mock_aws
def test_set_multiple_athena_result():
base_url = (
"localhost:5000" if settings.TEST_SERVER_MODE else "motoapi.amazonaws.com"
@@ -95,8 +95,7 @@ def test_set_multiple_athena_result():
assert details["Rows"] == []
-@mock_athena
-@mock_sts
+@mock_aws
def test_set_athena_result_with_custom_region_account():
base_url = (
"localhost:5000" if settings.TEST_SERVER_MODE else "motoapi.amazonaws.com"
diff --git a/tests/test_autoscaling/test_autoscaling.py b/tests/test_autoscaling/test_autoscaling.py
index 9a47b1986..8136f2727 100644
--- a/tests/test_autoscaling/test_autoscaling.py
+++ b/tests/test_autoscaling/test_autoscaling.py
@@ -4,15 +4,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_autoscaling, mock_ec2
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
from .utils import setup_instance_with_networking, setup_networking
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_propogate_tags():
mocked_networking = setup_networking()
conn = boto3.client("autoscaling", region_name="us-east-1")
@@ -47,7 +46,7 @@ def test_propogate_tags():
assert {"Value": "TestGroup1", "Key": "aws:autoscaling:groupName"} in tags
-@mock_autoscaling
+@mock_aws
def test_create_autoscaling_group_from_instance():
autoscaling_group_name = "test_asg"
image_id = EXAMPLE_AMI_ID
@@ -76,8 +75,7 @@ def test_create_autoscaling_group_from_instance():
assert config["InstanceType"] == instance_type
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_autoscaling_group_from_instance_with_security_groups():
autoscaling_group_name = "test_asg"
image_id = EXAMPLE_AMI_ID
@@ -107,7 +105,7 @@ def test_create_autoscaling_group_from_instance_with_security_groups():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_autoscaling
+@mock_aws
def test_create_autoscaling_group_from_invalid_instance_id():
invalid_instance_id = "invalid_instance"
@@ -129,8 +127,7 @@ def test_create_autoscaling_group_from_invalid_instance_id():
assert err["Message"] == f"Instance [{invalid_instance_id}] is invalid."
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_autoscaling_group_from_template():
mocked_networking = setup_networking()
@@ -155,8 +152,7 @@ def test_create_autoscaling_group_from_template():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_ec2
-@mock_autoscaling
+@mock_aws
def test_create_auto_scaling_from_template_version__latest():
ec2_client = boto3.client("ec2", region_name="us-west-1")
launch_template_name = "tester"
@@ -185,8 +181,7 @@ def test_create_auto_scaling_from_template_version__latest():
assert response["LaunchTemplate"]["Version"] == "$Latest"
-@mock_ec2
-@mock_autoscaling
+@mock_aws
def test_create_auto_scaling_from_template_version__default():
ec2_client = boto3.client("ec2", region_name="us-west-1")
launch_template_name = "tester"
@@ -220,8 +215,7 @@ def test_create_auto_scaling_from_template_version__default():
assert response["LaunchTemplate"]["Version"] == "$Default"
-@mock_ec2
-@mock_autoscaling
+@mock_aws
def test_create_auto_scaling_from_template_version__no_version():
ec2_client = boto3.client("ec2", region_name="us-west-1")
launch_template_name = "tester"
@@ -247,8 +241,7 @@ def test_create_auto_scaling_from_template_version__no_version():
assert "Version" not in response["LaunchTemplate"]
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_autoscaling_group_no_template_ref():
mocked_networking = setup_networking()
@@ -278,8 +271,7 @@ def test_create_autoscaling_group_no_template_ref():
)
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_autoscaling_group_multiple_template_ref():
mocked_networking = setup_networking()
@@ -313,7 +305,7 @@ def test_create_autoscaling_group_multiple_template_ref():
)
-@mock_autoscaling
+@mock_aws
def test_create_autoscaling_group_no_launch_configuration():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -335,8 +327,7 @@ def test_create_autoscaling_group_no_launch_configuration():
)
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_autoscaling_group_multiple_launch_configurations():
mocked_networking = setup_networking()
@@ -375,8 +366,7 @@ def test_create_autoscaling_group_multiple_launch_configurations():
)
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_describe_autoscaling_groups_launch_template():
mocked_networking = setup_networking()
ec2_client = boto3.client("ec2", region_name="us-east-1")
@@ -417,7 +407,7 @@ def test_describe_autoscaling_groups_launch_template():
assert instance["InstanceType"] == "t2.micro"
-@mock_autoscaling
+@mock_aws
def test_describe_autoscaling_instances_launch_config():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -447,8 +437,7 @@ def test_describe_autoscaling_instances_launch_config():
assert instance["InstanceType"] == "t2.micro"
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_describe_autoscaling_instances_launch_template():
mocked_networking = setup_networking()
ec2_client = boto3.client("ec2", region_name="us-east-1")
@@ -483,7 +472,7 @@ def test_describe_autoscaling_instances_launch_template():
assert instance["InstanceType"] == "t2.micro"
-@mock_autoscaling
+@mock_aws
def test_describe_autoscaling_instances_instanceid_filter():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -518,7 +507,7 @@ def test_describe_autoscaling_instances_instanceid_filter():
assert instance["ProtectedFromScaleIn"] is True
-@mock_autoscaling
+@mock_aws
def test_update_autoscaling_group_launch_config():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -558,8 +547,7 @@ def test_update_autoscaling_group_launch_config():
assert group["NewInstancesProtectedFromScaleIn"] is False
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_update_autoscaling_group_launch_template():
mocked_networking = setup_networking()
ec2_client = boto3.client("ec2", region_name="us-east-1")
@@ -610,7 +598,7 @@ def test_update_autoscaling_group_launch_template():
assert group["NewInstancesProtectedFromScaleIn"] is False
-@mock_autoscaling
+@mock_aws
def test_update_autoscaling_group_min_size_desired_capacity_change():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -636,7 +624,7 @@ def test_update_autoscaling_group_min_size_desired_capacity_change():
assert len(group["Instances"]) == 5
-@mock_autoscaling
+@mock_aws
def test_update_autoscaling_group_max_size_desired_capacity_change():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -662,7 +650,7 @@ def test_update_autoscaling_group_max_size_desired_capacity_change():
assert len(group["Instances"]) == 5
-@mock_autoscaling
+@mock_aws
def test_autoscaling_describe_policies():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -737,8 +725,7 @@ def test_autoscaling_describe_policies():
assert "TargetTrackingConfiguration" not in policy
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_autoscaling_policy_with_policytype__targettrackingscaling():
mocked_networking = setup_networking(region_name="us-west-1")
client = boto3.client("autoscaling", region_name="us-west-1")
@@ -843,8 +830,7 @@ def test_create_autoscaling_policy_with_policytype__targettrackingscaling():
assert "Cooldown" not in policy
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_autoscaling_policy_with_policytype__stepscaling():
mocked_networking = setup_networking(region_name="eu-west-1")
client = boto3.client("autoscaling", region_name="eu-west-1")
@@ -897,8 +883,7 @@ def test_create_autoscaling_policy_with_policytype__stepscaling():
assert "Cooldown" not in policy
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_autoscaling_policy_with_predictive_scaling_config():
mocked_networking = setup_networking(region_name="eu-west-1")
client = boto3.client("autoscaling", region_name="eu-west-1")
@@ -936,8 +921,7 @@ def test_create_autoscaling_policy_with_predictive_scaling_config():
}
-@mock_autoscaling
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("include_instances_distribution", [True, False])
def test_create_auto_scaling_group_with_mixed_instances_policy(
include_instances_distribution,
@@ -996,8 +980,7 @@ def test_create_auto_scaling_group_with_mixed_instances_policy(
}
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_auto_scaling_group_with_mixed_instances_policy_overrides():
mocked_networking = setup_networking(region_name="eu-west-1")
client = boto3.client("autoscaling", region_name="eu-west-1")
@@ -1049,7 +1032,7 @@ def test_create_auto_scaling_group_with_mixed_instances_policy_overrides():
}
-@mock_autoscaling
+@mock_aws
def test_set_instance_protection():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -1086,7 +1069,7 @@ def test_set_instance_protection():
assert instance["ProtectedFromScaleIn"] is (instance["InstanceId"] in protected)
-@mock_autoscaling
+@mock_aws
def test_set_desired_capacity_up():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -1114,7 +1097,7 @@ def test_set_desired_capacity_up():
assert instance["ProtectedFromScaleIn"] is True
-@mock_autoscaling
+@mock_aws
def test_set_desired_capacity_down():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -1157,8 +1140,7 @@ def test_set_desired_capacity_down():
assert x not in instance_ids # only unprotected killed
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_terminate_instance_via_ec2_in_autoscaling_group():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -1192,8 +1174,7 @@ def test_terminate_instance_via_ec2_in_autoscaling_group():
assert replaced_instance_id != original_instance_id
-@mock_ec2
-@mock_autoscaling
+@mock_aws
def test_attach_instances():
asg_client = boto3.client("autoscaling", region_name="us-east-1")
ec2_client = boto3.client("ec2", region_name="us-east-1")
@@ -1233,7 +1214,7 @@ def test_attach_instances():
assert instance["InstanceType"] == "c4.2xlarge"
-@mock_autoscaling
+@mock_aws
def test_autoscaling_lifecyclehook():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -1277,7 +1258,7 @@ def test_autoscaling_lifecyclehook():
@pytest.mark.parametrize("original,new", [(2, 1), (2, 3), (1, 5), (1, 1)])
-@mock_autoscaling
+@mock_aws
def test_set_desired_capacity_without_protection(original, new):
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -1312,8 +1293,7 @@ def test_set_desired_capacity_without_protection(original, new):
assert len(instances) == new
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_template_with_block_device():
ec2_client = boto3.client("ec2", region_name="ap-southeast-2")
ec2_client.create_launch_template(
diff --git a/tests/test_autoscaling/test_autoscaling_cloudformation.py b/tests/test_autoscaling/test_autoscaling_cloudformation.py
index f6004ec89..0f211d23e 100644
--- a/tests/test_autoscaling/test_autoscaling_cloudformation.py
+++ b/tests/test_autoscaling/test_autoscaling_cloudformation.py
@@ -2,14 +2,13 @@ import json
import boto3
-from moto import mock_autoscaling, mock_cloudformation, mock_ec2, mock_elb
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
from .utils import setup_networking
-@mock_autoscaling
-@mock_cloudformation
+@mock_aws
def test_launch_configuration():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -65,8 +64,7 @@ Outputs:
assert lc["InstanceType"] == "m5.large"
-@mock_autoscaling
-@mock_cloudformation
+@mock_aws
def test_autoscaling_group_from_launch_config():
subnet_id = setup_networking()["subnet1"]
@@ -157,9 +155,7 @@ Outputs:
assert asg["LaunchConfigurationName"] == "test_launch_configuration_new"
-@mock_autoscaling
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_autoscaling_group_from_launch_template():
subnet_id = setup_networking()["subnet1"]
@@ -271,10 +267,7 @@ Outputs:
assert lt["Version"] == "1"
-@mock_autoscaling
-@mock_elb
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_autoscaling_group_with_elb():
web_setup_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -425,9 +418,7 @@ def test_autoscaling_group_with_elb():
assert len(response) == 1
-@mock_autoscaling
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_autoscaling_group_update():
asg_template = {
"AWSTemplateFormatVersion": "2010-09-09",
diff --git a/tests/test_autoscaling/test_autoscaling_groups.py b/tests/test_autoscaling/test_autoscaling_groups.py
index e853fe781..680c959a7 100644
--- a/tests/test_autoscaling/test_autoscaling_groups.py
+++ b/tests/test_autoscaling/test_autoscaling_groups.py
@@ -2,14 +2,14 @@ from unittest import TestCase
import boto3
-from moto import mock_autoscaling
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
from .utils import setup_networking
-@mock_autoscaling
+@mock_aws
class TestAutoScalingGroup(TestCase):
def setUp(self) -> None:
self.mocked_networking = setup_networking()
diff --git a/tests/test_autoscaling/test_autoscaling_metrics.py b/tests/test_autoscaling/test_autoscaling_metrics.py
index 5d898b493..e5ad37289 100644
--- a/tests/test_autoscaling/test_autoscaling_metrics.py
+++ b/tests/test_autoscaling/test_autoscaling_metrics.py
@@ -1,14 +1,12 @@
import boto3
-from moto import mock_autoscaling, mock_ec2, mock_elb
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
from .utils import setup_networking
-@mock_autoscaling
-@mock_ec2
-@mock_elb
+@mock_aws
def test_enable_metrics_collection():
mocked_networking = setup_networking()
elb_client = boto3.client("elb", region_name="us-east-1")
diff --git a/tests/test_autoscaling/test_autoscaling_scheduledactions.py b/tests/test_autoscaling/test_autoscaling_scheduledactions.py
index c8f88715d..ddc94891b 100644
--- a/tests/test_autoscaling/test_autoscaling_scheduledactions.py
+++ b/tests/test_autoscaling/test_autoscaling_scheduledactions.py
@@ -2,10 +2,10 @@ from unittest import TestCase
import boto3
-from moto import mock_autoscaling
+from moto import mock_aws
-@mock_autoscaling
+@mock_aws
class TestAutoScalingScheduledActions(TestCase):
def setUp(self) -> None:
self.client = boto3.client("autoscaling", region_name="us-east-1")
diff --git a/tests/test_autoscaling/test_autoscaling_tags.py b/tests/test_autoscaling/test_autoscaling_tags.py
index 016007130..1658342d5 100644
--- a/tests/test_autoscaling/test_autoscaling_tags.py
+++ b/tests/test_autoscaling/test_autoscaling_tags.py
@@ -2,13 +2,13 @@ import copy
import boto3
-from moto import mock_autoscaling, mock_ec2
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
from .utils import setup_networking
-@mock_autoscaling
+@mock_aws
def test_autoscaling_tags_update():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -55,8 +55,7 @@ def test_autoscaling_tags_update():
assert len(response["AutoScalingGroups"][0]["Tags"]) == 2
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_delete_tags_by_key():
mocked_networking = setup_networking()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -107,7 +106,7 @@ def test_delete_tags_by_key():
assert tag_to_delete not in tags
-@mock_autoscaling
+@mock_aws
def test_describe_tags_without_resources():
client = boto3.client("autoscaling", region_name="us-east-2")
resp = client.describe_tags()
@@ -115,7 +114,7 @@ def test_describe_tags_without_resources():
assert "NextToken" not in resp
-@mock_autoscaling
+@mock_aws
def test_describe_tags_no_filter():
subnet = setup_networking()["subnet1"]
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -153,7 +152,7 @@ def test_describe_tags_no_filter():
} in response["Tags"]
-@mock_autoscaling
+@mock_aws
def test_describe_tags_filter_by_name():
subnet = setup_networking()["subnet1"]
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -212,7 +211,7 @@ def test_describe_tags_filter_by_name():
} in response["Tags"]
-@mock_autoscaling
+@mock_aws
def test_describe_tags_filter_by_propgateatlaunch():
subnet = setup_networking()["subnet1"]
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -233,7 +232,7 @@ def test_describe_tags_filter_by_propgateatlaunch():
]
-@mock_autoscaling
+@mock_aws
def test_describe_tags_filter_by_key_or_value():
subnet = setup_networking()["subnet1"]
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -266,7 +265,7 @@ def test_describe_tags_filter_by_key_or_value():
]
-@mock_autoscaling
+@mock_aws
def test_create_20_tags_auto_scaling_group():
"""test to verify that the tag-members are sorted correctly, and there is no regression for
https://github.com/getmoto/moto/issues/6033
diff --git a/tests/test_autoscaling/test_autoscaling_warm_pools.py b/tests/test_autoscaling/test_autoscaling_warm_pools.py
index c1a6a9ae1..0760bb35f 100644
--- a/tests/test_autoscaling/test_autoscaling_warm_pools.py
+++ b/tests/test_autoscaling/test_autoscaling_warm_pools.py
@@ -2,14 +2,13 @@ from unittest import TestCase
import boto3
-from moto import mock_autoscaling, mock_ec2
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
from .utils import setup_networking
-@mock_autoscaling
-@mock_ec2
+@mock_aws
class TestAutoScalingGroup(TestCase):
def setUp(self) -> None:
self.mocked_networking = setup_networking()
diff --git a/tests/test_autoscaling/test_elb.py b/tests/test_autoscaling/test_elb.py
index 8d67cab25..2573b4d0f 100644
--- a/tests/test_autoscaling/test_elb.py
+++ b/tests/test_autoscaling/test_elb.py
@@ -3,15 +3,13 @@ from uuid import uuid4
import boto3
-from moto import mock_autoscaling, mock_ec2, mock_elb
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
from .utils import setup_networking
-@mock_autoscaling
-@mock_ec2
-@mock_elb
+@mock_aws
class TestAutoScalingELB(TestCase):
def setUp(self):
self.mocked_networking = setup_networking()
@@ -266,9 +264,7 @@ class TestAutoScalingELB(TestCase):
assert scheduled_action_1["ScheduledActionName"] == "my-scheduled-action"
-@mock_autoscaling
-@mock_elb
-@mock_ec2
+@mock_aws
class TestAutoScalingInstances(TestCase):
def setUp(self) -> None:
self.mocked_networking = setup_networking()
@@ -809,9 +805,7 @@ class TestAutoScalingInstances(TestCase):
]
-@mock_autoscaling
-@mock_elb
-@mock_ec2
+@mock_aws
class TestAutoScalingInstancesProtected(TestCase):
def setUp(self) -> None:
self.mocked_networking = setup_networking()
@@ -886,9 +880,7 @@ class TestAutoScalingInstancesProtected(TestCase):
assert len(list(response["LoadBalancerDescriptions"][0]["Instances"])) == 3
-@mock_autoscaling
-@mock_ec2
-@mock_elb
+@mock_aws
class TestAutoScalingTerminateInstances(TestCase):
def setUp(self) -> None:
self.mocked_networking = setup_networking()
diff --git a/tests/test_autoscaling/test_elbv2.py b/tests/test_autoscaling/test_elbv2.py
index 3cf6d72b5..9a700fb28 100644
--- a/tests/test_autoscaling/test_elbv2.py
+++ b/tests/test_autoscaling/test_elbv2.py
@@ -3,14 +3,13 @@ from uuid import uuid4
import boto3
-from moto import mock_autoscaling, mock_elbv2
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
from .utils import setup_networking
-@mock_elbv2
-@mock_autoscaling
+@mock_aws
class TestAutoscalignELBv2(unittest.TestCase):
def setUp(self) -> None:
self.mocked_networking = setup_networking()
diff --git a/tests/test_autoscaling/test_launch_configurations.py b/tests/test_autoscaling/test_launch_configurations.py
index cb72b33eb..41966cbb8 100644
--- a/tests/test_autoscaling/test_launch_configurations.py
+++ b/tests/test_autoscaling/test_launch_configurations.py
@@ -6,12 +6,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_autoscaling, mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
-@mock_autoscaling
+@mock_aws
def test_create_launch_configuration():
client = boto3.client("autoscaling", region_name="us-east-1")
client.create_launch_configuration(
@@ -45,7 +45,7 @@ def test_create_launch_configuration():
assert launch_config["BlockDeviceMappings"] == []
-@mock_autoscaling
+@mock_aws
def test_create_launch_configuration_with_block_device_mappings():
client = boto3.client("autoscaling", region_name="us-east-1")
client.create_launch_configuration(
@@ -102,7 +102,7 @@ def test_create_launch_configuration_with_block_device_mappings():
assert "Ebs" not in xvdb
-@mock_autoscaling
+@mock_aws
def test_create_launch_configuration_additional_parameters():
client = boto3.client("autoscaling", region_name="us-east-1")
client.create_launch_configuration(
@@ -135,8 +135,7 @@ def test_create_launch_configuration_additional_parameters():
# The default AMIs are not loaded for our test case, to speed things up
# But we do need it for this specific test (and others in this file..)
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_create_launch_configuration_without_public_ip():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -177,7 +176,7 @@ def test_create_launch_configuration_without_public_ip():
assert "PublicIpAddress" not in instance
-@mock_autoscaling
+@mock_aws
def test_create_launch_configuration_additional_params_default_to_false():
client = boto3.client("autoscaling", region_name="us-east-1")
client.create_launch_configuration(
@@ -191,7 +190,7 @@ def test_create_launch_configuration_additional_params_default_to_false():
assert launch_config["AssociatePublicIpAddress"] is False
-@mock_autoscaling
+@mock_aws
def test_create_launch_configuration_defaults():
"""Test with the minimum inputs and check that all of the proper defaults
are assigned for the other attributes"""
@@ -213,7 +212,7 @@ def test_create_launch_configuration_defaults():
assert "SpotPrice" not in launch_config
-@mock_autoscaling
+@mock_aws
def test_launch_configuration_describe_filter():
client = boto3.client("autoscaling", region_name="us-east-1")
for name in ["tester", "tester2", "tester3"]:
@@ -230,7 +229,7 @@ def test_launch_configuration_describe_filter():
assert len(client.describe_launch_configurations()["LaunchConfigurations"]) == 3
-@mock_autoscaling
+@mock_aws
def test_launch_configuration_describe_paginated():
conn = boto3.client("autoscaling", region_name="us-east-1")
for i in range(51):
@@ -253,7 +252,7 @@ def test_launch_configuration_describe_paginated():
assert "NextToken" not in response2.keys()
-@mock_autoscaling
+@mock_aws
def test_launch_configuration_delete():
client = boto3.client("autoscaling", region_name="us-east-1")
client.create_launch_configuration(
@@ -286,7 +285,7 @@ def test_launch_configuration_delete():
),
],
)
-@mock_autoscaling
+@mock_aws
def test_invalid_launch_configuration_request_raises_error(request_params):
client = boto3.client("autoscaling", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -296,8 +295,7 @@ def test_invalid_launch_configuration_request_raises_error(request_params):
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_autoscaling
-@mock_ec2
+@mock_aws
def test_launch_config_with_block_device_mappings__volumes_are_created():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
diff --git a/tests/test_autoscaling/test_policies.py b/tests/test_autoscaling/test_policies.py
index af040892e..32f7ebcb5 100644
--- a/tests/test_autoscaling/test_policies.py
+++ b/tests/test_autoscaling/test_policies.py
@@ -1,7 +1,7 @@
import boto3
import pytest
-from moto import mock_autoscaling
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
from .utils import setup_networking
@@ -25,7 +25,7 @@ def setup_autoscale_group_boto3():
)
-@mock_autoscaling
+@mock_aws
def test_create_policy_boto3():
setup_autoscale_group_boto3()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -45,7 +45,7 @@ def test_create_policy_boto3():
assert policy["Cooldown"] == 60
-@mock_autoscaling
+@mock_aws
def test_create_policy_default_values_boto3():
setup_autoscale_group_boto3()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -63,7 +63,7 @@ def test_create_policy_default_values_boto3():
assert policy["Cooldown"] == 300
-@mock_autoscaling
+@mock_aws
def test_update_policy_boto3():
setup_autoscale_group_boto3()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -90,7 +90,7 @@ def test_update_policy_boto3():
assert policy["ScalingAdjustment"] == 2
-@mock_autoscaling
+@mock_aws
def test_delete_policy_boto3():
setup_autoscale_group_boto3()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -107,7 +107,7 @@ def test_delete_policy_boto3():
assert len(client.describe_policies()["ScalingPolicies"]) == 0
-@mock_autoscaling
+@mock_aws
def test_execute_policy_exact_capacity_boto3():
setup_autoscale_group_boto3()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -124,7 +124,7 @@ def test_execute_policy_exact_capacity_boto3():
assert len(instances["AutoScalingInstances"]) == 3
-@mock_autoscaling
+@mock_aws
def test_execute_policy_positive_change_in_capacity_boto3():
setup_autoscale_group_boto3()
client = boto3.client("autoscaling", region_name="us-east-1")
@@ -144,7 +144,7 @@ def test_execute_policy_positive_change_in_capacity_boto3():
@pytest.mark.parametrize(
"adjustment,nr_of_instances", [(1, 3), (50, 3), (100, 4), (250, 7)]
)
-@mock_autoscaling
+@mock_aws
def test_execute_policy_percent_change_in_capacity_boto3(adjustment, nr_of_instances):
"""http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/as-scale-based-on-demand.html
If PercentChangeInCapacity returns a value between 0 and 1,
diff --git a/tests/test_autoscaling/utils.py b/tests/test_autoscaling/utils.py
index 412d0959c..b63c7a987 100644
--- a/tests/test_autoscaling/utils.py
+++ b/tests/test_autoscaling/utils.py
@@ -1,9 +1,6 @@
import boto3
-from moto import mock_ec2
-
-@mock_ec2
def setup_networking(region_name="us-east-1"):
ec2 = boto3.resource("ec2", region_name=region_name)
vpc = ec2.create_vpc(CidrBlock="10.11.0.0/16")
@@ -16,7 +13,6 @@ def setup_networking(region_name="us-east-1"):
return {"vpc": vpc.id, "subnet1": subnet1.id, "subnet2": subnet2.id}
-@mock_ec2
def setup_instance_with_networking(image_id, instance_type):
mock_data = setup_networking()
ec2 = boto3.resource("ec2", region_name="us-east-1")
diff --git a/tests/test_awslambda/__init__.py b/tests/test_awslambda/__init__.py
index 89d605282..5e856146e 100644
--- a/tests/test_awslambda/__init__.py
+++ b/tests/test_awslambda/__init__.py
@@ -7,7 +7,7 @@ from uuid import uuid4
import boto3
from botocore.exceptions import ClientError
-from moto import mock_iam, mock_lambda, mock_sts
+from moto import mock_aws
def lambda_aws_verified(func):
@@ -16,7 +16,7 @@ def lambda_aws_verified(func):
Can be run against AWS at any time by setting:
MOTO_TEST_ALLOW_AWS_REQUEST=true
- If this environment variable is not set, the function runs in a `mock_lambda/mock_iam/mock_sts` context.
+ If this environment variable is not set, the function runs in a `mock_aws` context.
This decorator will:
- Create an IAM-role that can be used by AWSLambda functions table
@@ -35,7 +35,7 @@ def lambda_aws_verified(func):
if allow_aws_request:
return create_role_and_test(role_name)
else:
- with mock_lambda(), mock_iam(), mock_sts():
+ with mock_aws():
return create_role_and_test(role_name)
def create_role_and_test(role_name):
diff --git a/tests/test_awslambda/test_awslambda_cloudformation.py b/tests/test_awslambda/test_awslambda_cloudformation.py
index ddff000f3..09e3edf8c 100644
--- a/tests/test_awslambda/test_awslambda_cloudformation.py
+++ b/tests/test_awslambda/test_awslambda_cloudformation.py
@@ -8,7 +8,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudformation, mock_iam, mock_lambda, mock_s3, mock_sqs
+from moto import mock_aws
def random_stack_name():
@@ -72,9 +72,7 @@ event_source_mapping_template = Template(
)
-@mock_cloudformation
-@mock_lambda
-@mock_s3
+@mock_aws
def test_lambda_can_be_updated_by_cloudformation():
s3 = boto3.client("s3", "us-east-1")
cf = boto3.client("cloudformation", region_name="us-east-1")
@@ -101,9 +99,7 @@ def test_lambda_can_be_updated_by_cloudformation():
assert "/test2.zip" in updated_fn["Code"]["Location"]
-@mock_cloudformation
-@mock_lambda
-@mock_s3
+@mock_aws
def test_lambda_can_be_deleted_by_cloudformation():
s3 = boto3.client("s3", "us-east-1")
cf = boto3.client("cloudformation", region_name="us-east-1")
@@ -118,10 +114,7 @@ def test_lambda_can_be_deleted_by_cloudformation():
assert e.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_cloudformation
-@mock_lambda
-@mock_s3
-@mock_sqs
+@mock_aws
def test_event_source_mapping_create_from_cloudformation_json():
sqs = boto3.resource("sqs", region_name="us-east-1")
s3 = boto3.client("s3", "us-east-1")
@@ -156,10 +149,7 @@ def test_event_source_mapping_create_from_cloudformation_json():
assert event_source["FunctionArn"] == created_fn_arn
-@mock_cloudformation
-@mock_lambda
-@mock_s3
-@mock_sqs
+@mock_aws
def test_event_source_mapping_delete_stack():
sqs = boto3.resource("sqs", region_name="us-east-1")
s3 = boto3.client("s3", "us-east-1")
@@ -195,10 +185,7 @@ def test_event_source_mapping_delete_stack():
assert len(event_sources["EventSourceMappings"]) == 0
-@mock_cloudformation
-@mock_lambda
-@mock_s3
-@mock_sqs
+@mock_aws
def test_event_source_mapping_update_from_cloudformation_json():
sqs = boto3.resource("sqs", region_name="us-east-1")
s3 = boto3.client("s3", "us-east-1")
@@ -248,10 +235,7 @@ def test_event_source_mapping_update_from_cloudformation_json():
assert updated_esm["BatchSize"] == 10
-@mock_cloudformation
-@mock_lambda
-@mock_s3
-@mock_sqs
+@mock_aws
def test_event_source_mapping_delete_from_cloudformation_json():
sqs = boto3.resource("sqs", region_name="us-east-1")
s3 = boto3.client("s3", "us-east-1")
@@ -334,15 +318,14 @@ def get_template(bucket_name, version, runtime):
def get_role_arn():
- with mock_iam():
- iam = boto3.client("iam", region_name="us-west-2")
- try:
- iam.create_role(
- RoleName="my-role",
- AssumeRolePolicyDocument="some policy",
- Path="/my-path/",
- )
- except ClientError:
- pass # Will fail second/third time - difficult to execute once with parallel tests
+ iam = boto3.client("iam", region_name="us-west-2")
+ try:
+ iam.create_role(
+ RoleName="my-role",
+ AssumeRolePolicyDocument="some policy",
+ Path="/my-path/",
+ )
+ except ClientError:
+ pass # Will fail second/third time - difficult to execute once with parallel tests
- return iam.get_role(RoleName="my-role")["Role"]["Arn"]
+ return iam.get_role(RoleName="my-role")["Role"]["Arn"]
diff --git a/tests/test_awslambda/test_lambda.py b/tests/test_awslambda/test_lambda.py
index 46f3731cc..21b6345f7 100644
--- a/tests/test_awslambda/test_lambda.py
+++ b/tests/test_awslambda/test_lambda.py
@@ -10,7 +10,7 @@ import pytest
from botocore.exceptions import ClientError, ParamValidationError
from freezegun import freeze_time
-from moto import mock_ecr, mock_lambda, mock_s3, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests.test_ecr.test_ecr_helpers import _create_image_manifest
@@ -27,12 +27,11 @@ from .utilities import (
PYTHON_VERSION = "python3.11"
LAMBDA_FUNC_NAME = "test"
_lambda_region = "us-west-2"
-boto3.setup_default_session(region_name=_lambda_region)
@mock.patch.dict("os.environ", {"MOTO_ENABLE_ISO_REGIONS": "true"})
@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1", "us-isob-east-1"])
-@mock_lambda
+@mock_aws
def test_lambda_regions(region):
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Can only set EnvironVars in DecoratorMode")
@@ -97,7 +96,7 @@ def test_list_functions(iam_role_arn=None):
conn.delete_function(FunctionName=function_name)
-@mock_lambda
+@mock_aws
def test_create_based_on_s3_with_missing_bucket():
conn = boto3.client("lambda", _lambda_region)
function_name = str(uuid4())[0:6]
@@ -125,8 +124,7 @@ def test_create_based_on_s3_with_missing_bucket():
)
-@mock_lambda
-@mock_s3
+@mock_aws
@freeze_time("2015-01-01 00:00:00")
def test_create_function_from_aws_bucket():
bucket_name = str(uuid4())
@@ -168,7 +166,7 @@ def test_create_function_from_aws_bucket():
assert result["State"] == "Active"
-@mock_lambda
+@mock_aws
@freeze_time("2015-01-01 00:00:00")
def test_create_function_from_zipfile():
conn = boto3.client("lambda", _lambda_region)
@@ -217,7 +215,7 @@ def test_create_function_from_zipfile():
}
-@mock_lambda
+@mock_aws
def test_create_function_from_image():
conn = boto3.client("lambda", _lambda_region)
function_name = str(uuid4())[0:6]
@@ -249,7 +247,7 @@ def test_create_function_from_image():
assert result["Configuration"]["ImageConfigResponse"]["ImageConfig"] == image_config
-@mock_lambda
+@mock_aws
def test_create_function_from_image_default_working_directory():
conn = boto3.client("lambda", _lambda_region)
function_name = str(uuid4())[0:6]
@@ -280,7 +278,7 @@ def test_create_function_from_image_default_working_directory():
assert result["Configuration"]["ImageConfigResponse"]["ImageConfig"] == image_config
-@mock_lambda
+@mock_aws
def test_create_function_error_bad_architecture():
conn = boto3.client("lambda", _lambda_region)
function_name = str(uuid4())[0:6]
@@ -309,7 +307,7 @@ def test_create_function_error_bad_architecture():
)
-@mock_lambda
+@mock_aws
def test_create_function_error_ephemeral_too_big():
conn = boto3.client("lambda", _lambda_region)
function_name = str(uuid4())[0:6]
@@ -338,7 +336,7 @@ def test_create_function_error_ephemeral_too_big():
)
-@mock_lambda
+@mock_aws
def test_create_function_error_ephemeral_too_small():
conn = boto3.client("lambda", _lambda_region)
function_name = str(uuid4())[0:6]
@@ -360,7 +358,7 @@ def test_create_function_error_ephemeral_too_small():
assert exc.typename == "ParamValidationError"
-@mock_lambda
+@mock_aws
@pytest.mark.parametrize(
"tracing_mode",
[(None, "PassThrough"), ("PassThrough", "PassThrough"), ("Active", "Active")],
@@ -389,7 +387,7 @@ def test_create_function__with_tracingmode(tracing_mode):
@pytest.fixture(name="with_ecr_mock")
def ecr_repo_fixture():
- with mock_ecr():
+ with mock_aws():
os.environ["MOTO_LAMBDA_STUB_ECR"] = "FALSE"
repo_name = "testlambdaecr"
ecr_client = boto3.client("ecr", "us-east-1")
@@ -404,7 +402,7 @@ def ecr_repo_fixture():
os.environ["MOTO_LAMBDA_STUB_ECR"] = "TRUE"
-@mock_lambda
+@mock_aws
def test_create_function_from_stubbed_ecr():
lambda_client = boto3.client("lambda", "us-east-1")
fn_name = str(uuid4())[0:6]
@@ -437,7 +435,7 @@ def test_create_function_from_stubbed_ecr():
assert code["ResolvedImageUri"] == resolved_image_uri
-@mock_lambda
+@mock_aws
def test_create_function_from_mocked_ecr_image_tag(
with_ecr_mock,
): # pylint: disable=unused-argument
@@ -479,7 +477,7 @@ def test_create_function_from_mocked_ecr_image_tag(
assert code["ResolvedImageUri"] == resolved_image_uri
-@mock_lambda
+@mock_aws
def test_create_function_from_mocked_ecr_image_digest(
with_ecr_mock,
): # pylint: disable=unused-argument
@@ -506,7 +504,7 @@ def test_create_function_from_mocked_ecr_image_digest(
assert resp["PackageType"] == "Image"
-@mock_lambda
+@mock_aws
def test_create_function_from_mocked_ecr_missing_image(
with_ecr_mock,
): # pylint: disable=unused-argument
@@ -539,8 +537,7 @@ def test_create_function_from_mocked_ecr_missing_image(
)
-@mock_lambda
-@mock_s3
+@mock_aws
@freeze_time("2015-01-01 00:00:00")
def test_get_function():
bucket_name = str(uuid4())
@@ -631,8 +628,7 @@ def test_get_function():
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
-@mock_s3
+@mock_aws
@freeze_time("2015-01-01 00:00:00")
def test_get_function_configuration(key):
bucket_name = str(uuid4())
@@ -697,8 +693,7 @@ def test_get_function_configuration(key):
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
-@mock_s3
+@mock_aws
def test_get_function_code_signing_config(key):
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", _lambda_region)
@@ -728,8 +723,7 @@ def test_get_function_code_signing_config(key):
assert result["CodeSigningConfigArn"] == "csc:arn"
-@mock_lambda
-@mock_s3
+@mock_aws
def test_get_function_by_arn():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", "us-east-1")
@@ -775,8 +769,7 @@ def test_get_function_by_arn():
)
-@mock_lambda
-@mock_s3
+@mock_aws
def test_delete_function():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", _lambda_region)
@@ -815,8 +808,7 @@ def test_delete_function():
assert len(our_functions) == 0
-@mock_lambda
-@mock_s3
+@mock_aws
def test_delete_function_by_arn():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", "us-east-1")
@@ -849,7 +841,7 @@ def test_delete_function_by_arn():
assert len(our_functions) == 0
-@mock_lambda
+@mock_aws
def test_delete_unknown_function():
conn = boto3.client("lambda", _lambda_region)
with pytest.raises(ClientError) as exc:
@@ -858,7 +850,7 @@ def test_delete_unknown_function():
assert err["Code"] == "ResourceNotFoundException"
-@mock_lambda
+@mock_aws
@pytest.mark.parametrize(
"name",
[
@@ -878,8 +870,7 @@ def test_publish_version_unknown_function(name):
)
-@mock_lambda
-@mock_s3
+@mock_aws
def test_publish():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", _lambda_region)
@@ -929,8 +920,7 @@ def test_publish():
assert function_name in our_functions[0]["FunctionArn"]
-@mock_lambda
-@mock_s3
+@mock_aws
@freeze_time("2015-01-01 00:00:00")
def test_list_create_list_get_delete_list():
"""
@@ -1049,7 +1039,7 @@ def test_list_create_list_get_delete_list():
assert function_name not in func_names
-@mock_lambda
+@mock_aws
@freeze_time("2015-01-01 00:00:00")
def test_get_function_created_with_zipfile():
conn = boto3.client("lambda", _lambda_region)
@@ -1098,8 +1088,7 @@ def test_get_function_created_with_zipfile():
assert config["LastUpdateStatus"] == "Successful"
-@mock_lambda
-@mock_s3
+@mock_aws
def test_list_versions_by_function():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", _lambda_region)
@@ -1162,8 +1151,7 @@ def test_list_versions_by_function():
)
-@mock_lambda
-@mock_s3
+@mock_aws
def test_list_aliases():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", _lambda_region)
@@ -1263,8 +1251,7 @@ def test_list_aliases():
)
-@mock_lambda
-@mock_s3
+@mock_aws
def test_create_function_with_already_exists():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", _lambda_region)
@@ -1306,8 +1293,7 @@ def test_create_function_with_already_exists():
assert exc.value.response["Error"]["Code"] == "ResourceConflictException"
-@mock_lambda
-@mock_s3
+@mock_aws
def test_list_versions_by_function_for_nonexistent_function():
conn = boto3.client("lambda", _lambda_region)
function_name = str(uuid4())[0:6]
@@ -1317,8 +1303,7 @@ def test_list_versions_by_function_for_nonexistent_function():
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
-@mock_s3
+@mock_aws
def test_update_configuration(key):
bucket_name = str(uuid4())
function_name = str(uuid4())[0:6]
@@ -1379,7 +1364,7 @@ def test_update_configuration(key):
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
+@mock_aws
def test_update_function_zip(key):
conn = boto3.client("lambda", _lambda_region)
@@ -1452,8 +1437,7 @@ def test_update_function_zip(key):
assert new_update["Version"] == "3"
-@mock_lambda
-@mock_s3
+@mock_aws
def test_update_function_s3():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", _lambda_region)
@@ -1514,7 +1498,7 @@ def test_update_function_s3():
assert config["LastUpdateStatus"] == "Successful"
-@mock_lambda
+@mock_aws
def test_update_function_ecr():
conn = boto3.client("lambda", _lambda_region)
function_name = str(uuid4())[0:6]
@@ -1570,7 +1554,7 @@ def test_update_function_ecr():
assert config["LastUpdateStatus"] == "Successful"
-@mock_lambda
+@mock_aws
def test_create_function_with_invalid_arn():
err = create_invalid_lambda("test-iam-role")
assert (
@@ -1579,7 +1563,7 @@ def test_create_function_with_invalid_arn():
)
-@mock_lambda
+@mock_aws
def test_create_function_with_arn_from_different_account():
err = create_invalid_lambda("arn:aws:iam::000000000000:role/example_role")
assert (
@@ -1588,7 +1572,7 @@ def test_create_function_with_arn_from_different_account():
)
-@mock_lambda
+@mock_aws
def test_create_function_with_unknown_arn():
err = create_invalid_lambda(
"arn:aws:iam::" + str(ACCOUNT_ID) + ":role/service-role/unknown_role"
@@ -1599,7 +1583,7 @@ def test_create_function_with_unknown_arn():
)
-@mock_lambda
+@mock_aws
def test_remove_unknown_permission_throws_error():
conn = boto3.client("lambda", _lambda_region)
zip_content = get_test_zip_file1()
@@ -1620,7 +1604,7 @@ def test_remove_unknown_permission_throws_error():
assert err["Message"] == "No policy is associated with the given resource."
-@mock_lambda
+@mock_aws
def test_multiple_qualifiers():
client = boto3.client("lambda", "us-east-1")
@@ -1668,7 +1652,7 @@ def test_multiple_qualifiers():
)
-@mock_lambda
+@mock_aws
def test_delete_non_existent():
client = boto3.client("lambda", "us-east-1")
@@ -1716,7 +1700,7 @@ def test_get_role_name_utility_race_condition():
assert len(errors) == 0
-@mock_lambda
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_LAMBDA_CONCURRENCY_QUOTA": "1000"})
def test_put_function_concurrency_success():
if not settings.TEST_DECORATOR_MODE:
@@ -1744,7 +1728,7 @@ def test_put_function_concurrency_success():
assert response["ReservedConcurrentExecutions"] == 900
-@mock_lambda
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_LAMBDA_CONCURRENCY_QUOTA": "don't care"})
def test_put_function_concurrency_not_enforced():
del os.environ["MOTO_LAMBDA_CONCURRENCY_QUOTA"] # i.e. not set by user
@@ -1770,7 +1754,7 @@ def test_put_function_concurrency_not_enforced():
assert response["ReservedConcurrentExecutions"] == 901
-@mock_lambda
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_LAMBDA_CONCURRENCY_QUOTA": "1000"})
def test_put_function_concurrency_failure():
if not settings.TEST_DECORATOR_MODE:
@@ -1804,7 +1788,7 @@ def test_put_function_concurrency_failure():
assert "ReservedConcurrentExecutions" not in response
-@mock_lambda
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_LAMBDA_CONCURRENCY_QUOTA": "1000"})
def test_put_function_concurrency_i_can_has_math():
if not settings.TEST_DECORATOR_MODE:
@@ -1864,7 +1848,7 @@ def test_put_function_concurrency_i_can_has_math():
assert response["ReservedConcurrentExecutions"] == 100
-@mock_lambda
+@mock_aws
@pytest.mark.parametrize(
"config",
[
@@ -1912,7 +1896,7 @@ def test_put_event_invoke_config(config):
client.delete_function(FunctionName=arn_2)
-@mock_lambda
+@mock_aws
@pytest.mark.parametrize(
"config",
[
@@ -1960,7 +1944,7 @@ def test_update_event_invoke_config(config):
client.delete_function(FunctionName=arn_2)
-@mock_lambda
+@mock_aws
def test_put_event_invoke_config_errors_1():
# Setup
client = boto3.client("lambda", _lambda_region)
@@ -1990,7 +1974,7 @@ def test_put_event_invoke_config_errors_1():
client.delete_function(FunctionName=arn_1)
-@mock_lambda
+@mock_aws
def test_put_event_invoke_config_errors_2():
# Setup
client = boto3.client("lambda", _lambda_region)
@@ -2022,7 +2006,7 @@ def test_put_event_invoke_config_errors_2():
client.delete_function(FunctionName=arn_2)
-@mock_lambda
+@mock_aws
def test_put_event_invoke_config_errors_3():
# Setup
client = boto3.client("lambda", _lambda_region)
@@ -2048,7 +2032,7 @@ def test_put_event_invoke_config_errors_3():
client.delete_function(FunctionName=arn_1)
-@mock_lambda
+@mock_aws
def test_put_event_invoke_config_errors_4():
# Setup
client = boto3.client("lambda", _lambda_region)
@@ -2074,7 +2058,7 @@ def test_put_event_invoke_config_errors_4():
client.delete_function(FunctionName=arn_1)
-@mock_lambda
+@mock_aws
def test_get_event_invoke_config():
# Setup
client = boto3.client("lambda", _lambda_region)
@@ -2101,7 +2085,7 @@ def test_get_event_invoke_config():
client.delete_function(FunctionName=arn_2)
-@mock_lambda
+@mock_aws
def test_list_event_invoke_configs():
# Setup
client = boto3.client("lambda", _lambda_region)
@@ -2134,7 +2118,7 @@ def test_list_event_invoke_configs():
client.delete_function(FunctionName=arn_2)
-@mock_lambda
+@mock_aws
def test_get_event_invoke_config_empty():
# Setup
client = boto3.client("lambda", _lambda_region)
@@ -2157,7 +2141,7 @@ def test_get_event_invoke_config_empty():
client.delete_function(FunctionName=arn_1)
-@mock_lambda
+@mock_aws
def test_delete_event_invoke_config():
# Setup
client = boto3.client("lambda", _lambda_region)
diff --git a/tests/test_awslambda/test_lambda_alias.py b/tests/test_awslambda/test_lambda_alias.py
index 39707f3ac..7c12df8f5 100644
--- a/tests/test_awslambda/test_lambda_alias.py
+++ b/tests/test_awslambda/test_lambda_alias.py
@@ -5,7 +5,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_lambda
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .utilities import (
@@ -19,7 +19,7 @@ from .utilities import (
PYTHON_VERSION = "python3.11"
-@mock_lambda
+@mock_aws
def test_create_alias():
client = boto3.client("lambda", region_name="ap-southeast-1")
function_name = str(uuid4())[0:6]
@@ -47,7 +47,7 @@ def test_create_alias():
assert "RoutingConfig" not in resp
-@mock_lambda
+@mock_aws
def test_create_alias_with_routing_config():
client = boto3.client("lambda", region_name="ap-southeast-1")
function_name = str(uuid4())[0:6]
@@ -73,7 +73,7 @@ def test_create_alias_with_routing_config():
assert resp["RoutingConfig"] == {"AdditionalVersionWeights": {"2": 0.5}}
-@mock_lambda
+@mock_aws
def test_create_alias_using_function_arn():
client = boto3.client("lambda", region_name="ap-southeast-1")
function_name = str(uuid4())[0:6]
@@ -99,7 +99,7 @@ def test_create_alias_using_function_arn():
assert resp["FunctionVersion"] == "$LATEST"
-@mock_lambda
+@mock_aws
def test_delete_alias():
client = boto3.client("lambda", region_name="us-east-2")
function_name = str(uuid4())[0:6]
@@ -124,7 +124,7 @@ def test_delete_alias():
assert err["Code"] == "ResourceNotFoundException"
-@mock_lambda
+@mock_aws
def test_get_alias():
client = boto3.client("lambda", region_name="us-west-1")
function_name = str(uuid4())[0:6]
@@ -153,7 +153,7 @@ def test_get_alias():
assert "RevisionId" in resp
-@mock_lambda
+@mock_aws
def test_aliases_are_unique_per_function():
client = boto3.client("lambda", region_name="us-west-1")
function_name = str(uuid4())[0:6]
@@ -203,7 +203,7 @@ def test_aliases_are_unique_per_function():
)
-@mock_lambda
+@mock_aws
def test_get_alias_using_function_arn():
client = boto3.client("lambda", region_name="us-west-1")
function_name = str(uuid4())[0:6]
@@ -233,7 +233,7 @@ def test_get_alias_using_function_arn():
assert "RevisionId" in resp
-@mock_lambda
+@mock_aws
def test_get_alias_using_alias_arn():
client = boto3.client("lambda", region_name="us-west-1")
function_name = str(uuid4())[0:6]
@@ -263,7 +263,7 @@ def test_get_alias_using_alias_arn():
assert "RevisionId" in resp
-@mock_lambda
+@mock_aws
def test_get_unknown_alias():
client = boto3.client("lambda", region_name="us-west-1")
function_name = str(uuid4())[0:6]
@@ -286,7 +286,7 @@ def test_get_unknown_alias():
)
-@mock_lambda
+@mock_aws
def test_update_alias():
client = boto3.client("lambda", region_name="us-east-2")
function_name = str(uuid4())[0:6]
@@ -326,7 +326,7 @@ def test_update_alias():
assert "RevisionId" in resp
-@mock_lambda
+@mock_aws
def test_update_alias_errors_if_version_doesnt_exist():
client = boto3.client("lambda", region_name="us-east-2")
function_name = str(uuid4())[0:6]
@@ -358,7 +358,7 @@ def test_update_alias_errors_if_version_doesnt_exist():
)
-@mock_lambda
+@mock_aws
def test_update_alias_routingconfig():
client = boto3.client("lambda", region_name="us-east-2")
function_name = str(uuid4())[0:6]
@@ -394,7 +394,7 @@ def test_update_alias_routingconfig():
assert resp["RoutingConfig"] == {"AdditionalVersionWeights": {"2": 0.5}}
-@mock_lambda
+@mock_aws
@pytest.mark.parametrize("qualifierIn", ["NAME", "SEPARATE", "BOTH"])
def test_get_function_using_alias(qualifierIn):
client = boto3.client("lambda", region_name="us-east-2")
diff --git a/tests/test_awslambda/test_lambda_concurrency.py b/tests/test_awslambda/test_lambda_concurrency.py
index 4ad7d861e..3ec01ddc1 100644
--- a/tests/test_awslambda/test_lambda_concurrency.py
+++ b/tests/test_awslambda/test_lambda_concurrency.py
@@ -3,17 +3,16 @@ from uuid import uuid4
import boto3
import pytest
-from moto import mock_lambda
+from moto import mock_aws
from .utilities import get_role_name, get_test_zip_file1
PYTHON_VERSION = "python3.11"
_lambda_region = "us-west-2"
-boto3.setup_default_session(region_name=_lambda_region)
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
+@mock_aws
def test_put_function_concurrency(key):
expected_concurrency = 15
function_name = str(uuid4())[0:6]
@@ -39,7 +38,7 @@ def test_put_function_concurrency(key):
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
+@mock_aws
def test_delete_function_concurrency(key):
function_name = str(uuid4())[0:6]
@@ -67,7 +66,7 @@ def test_delete_function_concurrency(key):
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
+@mock_aws
def test_get_function_concurrency(key):
expected_concurrency = 15
function_name = str(uuid4())[0:6]
diff --git a/tests/test_awslambda/test_lambda_eventsourcemapping.py b/tests/test_awslambda/test_lambda_eventsourcemapping.py
index e643ac493..c441af71d 100644
--- a/tests/test_awslambda/test_lambda_eventsourcemapping.py
+++ b/tests/test_awslambda/test_lambda_eventsourcemapping.py
@@ -1,13 +1,12 @@
import json
import time
import uuid
-from uuid import uuid4
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_dynamodb, mock_lambda, mock_logs, mock_sns, mock_sqs
+from moto import mock_aws
from ..markers import requires_docker
from .utilities import (
@@ -19,14 +18,11 @@ from .utilities import (
PYTHON_VERSION = "python3.11"
_lambda_region = "us-west-2"
-boto3.setup_default_session(region_name=_lambda_region)
-@mock_logs
-@mock_lambda
-@mock_sqs
+@mock_aws
def test_create_event_source_mapping():
- function_name = str(uuid4())[0:6]
+ function_name = str(uuid.uuid4())[0:6]
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=f"{function_name}_queue")
@@ -54,12 +50,10 @@ def test_create_event_source_mapping():
@pytest.mark.network
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_logs
-@mock_lambda
-@mock_sqs
+@mock_aws
@requires_docker
def test_invoke_function_from_sqs(key):
- function_name = str(uuid4())[0:6]
+ function_name = str(uuid.uuid4())[0:6]
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=f"{function_name}_queue")
@@ -99,13 +93,11 @@ def test_invoke_function_from_sqs(key):
@pytest.mark.network
-@mock_logs
-@mock_lambda
-@mock_dynamodb
+@mock_aws
@requires_docker
def test_invoke_function_from_dynamodb_put():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
- table_name = str(uuid4())[0:6] + "_table"
+ table_name = str(uuid.uuid4())[0:6] + "_table"
table = dynamodb.create_table(
TableName=table_name,
KeySchema=[{"AttributeName": "id", "KeyType": "HASH"}],
@@ -118,7 +110,7 @@ def test_invoke_function_from_dynamodb_put():
)
conn = boto3.client("lambda", region_name="us-east-1")
- function_name = str(uuid4())[0:6]
+ function_name = str(uuid.uuid4())[0:6]
func = conn.create_function(
FunctionName=function_name,
Runtime=PYTHON_VERSION,
@@ -155,13 +147,11 @@ def test_invoke_function_from_dynamodb_put():
@pytest.mark.network
-@mock_logs
-@mock_lambda
-@mock_dynamodb
+@mock_aws
@requires_docker
def test_invoke_function_from_dynamodb_update():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
- table_name = str(uuid4())[0:6] + "_table"
+ table_name = str(uuid.uuid4())[0:6] + "_table"
table = dynamodb.create_table(
TableName=table_name,
KeySchema=[{"AttributeName": "id", "KeyType": "HASH"}],
@@ -174,7 +164,7 @@ def test_invoke_function_from_dynamodb_update():
)
conn = boto3.client("lambda", region_name="us-east-1")
- function_name = str(uuid4())[0:6]
+ function_name = str(uuid.uuid4())[0:6]
func = conn.create_function(
FunctionName=function_name,
Runtime=PYTHON_VERSION,
@@ -217,12 +207,10 @@ def test_invoke_function_from_dynamodb_update():
@pytest.mark.network
-@mock_logs
-@mock_lambda
-@mock_sqs
+@mock_aws
@requires_docker
def test_invoke_function_from_sqs_exception():
- function_name = str(uuid4())[0:6]
+ function_name = str(uuid.uuid4())[0:6]
logs_conn = boto3.client("logs", region_name="us-east-1")
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=f"{function_name}_queue")
@@ -282,9 +270,7 @@ def test_invoke_function_from_sqs_exception():
@pytest.mark.network
-@mock_logs
-@mock_sns
-@mock_lambda
+@mock_aws
@requires_docker
def test_invoke_function_from_sns():
logs_conn = boto3.client("logs", region_name=_lambda_region)
@@ -295,7 +281,7 @@ def test_invoke_function_from_sns():
topic_arn = topics[0]["TopicArn"]
conn = boto3.client("lambda", _lambda_region)
- function_name = str(uuid4())[0:6]
+ function_name = str(uuid.uuid4())[0:6]
result = conn.create_function(
FunctionName=function_name,
Runtime=PYTHON_VERSION,
@@ -340,11 +326,9 @@ def test_invoke_function_from_sns():
assert False, "Expected message not found in logs:" + str(events)
-@mock_logs
-@mock_lambda
-@mock_sqs
+@mock_aws
def test_list_event_source_mappings():
- function_name = str(uuid4())[0:6]
+ function_name = str(uuid.uuid4())[0:6]
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=f"{function_name}_queue")
@@ -374,10 +358,9 @@ def test_list_event_source_mappings():
assert mappings["EventSourceMappings"][0]["FunctionArn"] == func["FunctionArn"]
-@mock_lambda
-@mock_sqs
+@mock_aws
def test_get_event_source_mapping():
- function_name = str(uuid4())[0:6]
+ function_name = str(uuid.uuid4())[0:6]
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=f"{function_name}_queue")
@@ -404,10 +387,9 @@ def test_get_event_source_mapping():
conn.get_event_source_mapping(UUID="1")
-@mock_lambda
-@mock_sqs
+@mock_aws
def test_update_event_source_mapping():
- function_name = str(uuid4())[0:6]
+ function_name = str(uuid.uuid4())[0:6]
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=f"{function_name}_queue")
@@ -450,10 +432,9 @@ def test_update_event_source_mapping():
assert mapping["BatchSize"] == 2
-@mock_lambda
-@mock_sqs
+@mock_aws
def test_delete_event_source_mapping():
- function_name = str(uuid4())[0:6]
+ function_name = str(uuid.uuid4())[0:6]
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=f"{function_name}_queue")
diff --git a/tests/test_awslambda/test_lambda_function_urls.py b/tests/test_awslambda/test_lambda_function_urls.py
index c3ad1b9fe..f583332e4 100644
--- a/tests/test_awslambda/test_lambda_function_urls.py
+++ b/tests/test_awslambda/test_lambda_function_urls.py
@@ -4,14 +4,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_lambda
+from moto import mock_aws
from .utilities import get_role_name, get_test_zip_file1
PYTHON_VERSION = "python3.11"
-@mock_lambda
+@mock_aws
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
def test_create_function_url_config(key):
client = boto3.client("lambda", "us-east-2")
@@ -38,7 +38,7 @@ def test_create_function_url_config(key):
assert "FunctionUrl" in resp
-@mock_lambda
+@mock_aws
def test_create_function_url_config_with_cors():
client = boto3.client("lambda", "us-east-2")
function_name = str(uuid4())[0:6]
@@ -73,7 +73,7 @@ def test_create_function_url_config_with_cors():
}
-@mock_lambda
+@mock_aws
def test_update_function_url_config_with_cors():
client = boto3.client("lambda", "us-east-2")
function_name = str(uuid4())[0:6]
@@ -105,7 +105,7 @@ def test_update_function_url_config_with_cors():
assert resp["Cors"] == {"AllowCredentials": False}
-@mock_lambda
+@mock_aws
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
def test_delete_function_url_config(key):
client = boto3.client("lambda", "us-east-2")
diff --git a/tests/test_awslambda/test_lambda_invoke.py b/tests/test_awslambda/test_lambda_invoke.py
index 763be9773..c1e2aadd4 100644
--- a/tests/test_awslambda/test_lambda_invoke.py
+++ b/tests/test_awslambda/test_lambda_invoke.py
@@ -7,7 +7,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_lambda, settings
+from moto import mock_aws, settings
from ..markers import requires_docker
from .utilities import (
@@ -29,7 +29,7 @@ _lambda_region = "us-west-2"
@pytest.mark.network
@requires_docker
class TestLambdaInvocations_Error:
- mock = mock_lambda()
+ mock = mock_aws()
@classmethod
def setup_class(cls):
@@ -79,7 +79,7 @@ class TestLambdaInvocations_Error:
@pytest.mark.network
@requires_docker
class TestLambdaInvocations:
- mock = mock_lambda()
+ mock = mock_aws()
@classmethod
def setup_class(cls):
@@ -186,7 +186,7 @@ class TestLambdaInvocations:
@pytest.mark.network
-@mock_lambda
+@mock_aws
def test_invoke_lambda_using_environment_port():
if not settings.TEST_SERVER_MODE:
raise SkipTest("Can only test environment variables in server mode")
@@ -220,7 +220,7 @@ def test_invoke_lambda_using_environment_port():
@pytest.mark.network
-@mock_lambda
+@mock_aws
def test_invoke_lambda_using_networkmode():
"""
Special use case - verify that Lambda can send a request to 'http://localhost'
@@ -250,7 +250,7 @@ def test_invoke_lambda_using_networkmode():
@pytest.mark.network
-@mock_lambda
+@mock_aws
@requires_docker
def test_invoke_function_with_multiple_files_in_zip():
conn = boto3.client("lambda", _lambda_region)
@@ -278,8 +278,7 @@ def test_invoke_function_with_multiple_files_in_zip():
if settings.TEST_SERVER_MODE:
- @mock_ec2
- @mock_lambda
+ @mock_aws
def test_invoke_function_get_ec2_volume():
conn = boto3.resource("ec2", _lambda_region)
vol = conn.create_volume(Size=99, AvailabilityZone=_lambda_region)
@@ -312,7 +311,7 @@ if settings.TEST_SERVER_MODE:
@pytest.mark.network
-@mock_lambda
+@mock_aws
@requires_docker
@pytest.mark.xfail(message="Fails intermittently - functionality exists though")
def test_invoke_function_large_response():
@@ -344,7 +343,7 @@ def test_invoke_function_large_response():
assert "FunctionError" not in resp
-@mock_lambda
+@mock_aws
def test_invoke_lambda_with_proxy():
if not settings.test_proxy_mode():
raise SkipTest("We only want to test this in ProxyMode")
diff --git a/tests/test_awslambda/test_lambda_layers.py b/tests/test_awslambda/test_lambda_layers.py
index 7541826f9..701adb915 100644
--- a/tests/test_awslambda/test_lambda_layers.py
+++ b/tests/test_awslambda/test_lambda_layers.py
@@ -7,17 +7,16 @@ import pytest
from botocore.exceptions import ClientError
from freezegun import freeze_time
-from moto import mock_lambda, mock_s3, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .utilities import get_role_name, get_test_zip_file1
PYTHON_VERSION = "python3.11"
_lambda_region = "us-west-2"
-boto3.setup_default_session(region_name=_lambda_region)
-@mock_lambda
+@mock_aws
def test_publish_lambda_layers__without_content():
conn = boto3.client("lambda", _lambda_region)
layer_name = str(uuid4())[0:6]
@@ -34,7 +33,7 @@ def test_publish_lambda_layers__without_content():
assert err["Message"] == "Missing Content"
-@mock_lambda
+@mock_aws
@mock.patch.dict(os.environ, {"VALIDATE_LAMBDA_S3": "false"})
def test_publish_layer_with_unknown_s3_file():
if not settings.TEST_DECORATOR_MODE:
@@ -48,8 +47,7 @@ def test_publish_layer_with_unknown_s3_file():
assert content["CodeSize"] == 0
-@mock_lambda
-@mock_s3
+@mock_aws
@freeze_time("2015-01-01 00:00:00")
def test_get_lambda_layers():
bucket_name = str(uuid4())
@@ -152,8 +150,7 @@ def test_get_lambda_layers():
assert err["Code"] == "ResourceNotFoundException"
-@mock_lambda
-@mock_s3
+@mock_aws
def test_get_layer_version():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", _lambda_region)
@@ -184,8 +181,7 @@ def test_get_layer_version():
assert resp["LicenseInfo"] == "MIT"
-@mock_lambda
-@mock_s3
+@mock_aws
def test_get_layer_version__unknown():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", _lambda_region)
@@ -219,8 +215,7 @@ def test_get_layer_version__unknown():
assert err["Code"] == "ResourceNotFoundException"
-@mock_lambda
-@mock_s3
+@mock_aws
@pytest.mark.parametrize("use_arn", [True, False])
def test_delete_layer_version(use_arn):
bucket_name = str(uuid4())
@@ -255,8 +250,7 @@ def test_delete_layer_version(use_arn):
assert result == []
-@mock_lambda
-@mock_s3
+@mock_aws
def test_get_layer_with_no_layer_versions():
def get_layer_by_layer_name_from_list_of_layer_dicts(layer_name, layer_list):
for layer in layer_list:
diff --git a/tests/test_awslambda/test_lambda_layers_invoked.py b/tests/test_awslambda/test_lambda_layers_invoked.py
index 34d5fb1f9..2f7dfdf94 100644
--- a/tests/test_awslambda/test_lambda_layers_invoked.py
+++ b/tests/test_awslambda/test_lambda_layers_invoked.py
@@ -3,14 +3,13 @@ from uuid import uuid4
import boto3
-from moto import mock_lambda
+from moto import mock_aws
from tests.markers import requires_docker
from .utilities import _process_lambda, get_role_name
PYTHON_VERSION = "python3.11"
_lambda_region = "us-west-2"
-boto3.setup_default_session(region_name=_lambda_region)
def get_requests_zip_file():
@@ -23,7 +22,7 @@ def lambda_handler(event, context):
@requires_docker
-@mock_lambda
+@mock_aws
def test_invoke_local_lambda_layers():
conn = boto3.client("lambda", _lambda_region)
lambda_name = str(uuid4())[0:6]
diff --git a/tests/test_awslambda/test_lambda_policy.py b/tests/test_awslambda/test_lambda_policy.py
index b1848d2d9..df038282d 100644
--- a/tests/test_awslambda/test_lambda_policy.py
+++ b/tests/test_awslambda/test_lambda_policy.py
@@ -5,18 +5,17 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_lambda, mock_s3
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .utilities import get_role_name, get_test_zip_file1, get_test_zip_file2
PYTHON_VERSION = "python3.11"
_lambda_region = "us-west-2"
-boto3.setup_default_session(region_name=_lambda_region)
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
+@mock_aws
def test_add_function_permission(key):
"""
Parametrized to ensure that we can add permission by using the FunctionName and the FunctionArn
@@ -50,7 +49,7 @@ def test_add_function_permission(key):
}
-@mock_lambda
+@mock_aws
def test_add_permission_with_principalorgid():
conn = boto3.client("lambda", _lambda_region)
zip_content = get_test_zip_file1()
@@ -81,7 +80,7 @@ def test_add_permission_with_principalorgid():
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
+@mock_aws
def test_get_function_policy(key):
conn = boto3.client("lambda", _lambda_region)
zip_content = get_test_zip_file1()
@@ -119,7 +118,7 @@ def test_get_function_policy(key):
)
-@mock_lambda
+@mock_aws
def test_get_policy_with_qualifier():
# assert that the resource within the statement ends with :qualifier
conn = boto3.client("lambda", _lambda_region)
@@ -164,7 +163,7 @@ def test_get_policy_with_qualifier():
)
-@mock_lambda
+@mock_aws
def test_add_permission_with_unknown_qualifier():
# assert that the resource within the statement ends with :qualifier
conn = boto3.client("lambda", _lambda_region)
@@ -200,7 +199,7 @@ def test_add_permission_with_unknown_qualifier():
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
+@mock_aws
def test_remove_function_permission(key):
conn = boto3.client("lambda", _lambda_region)
zip_content = get_test_zip_file1()
@@ -230,7 +229,7 @@ def test_remove_function_permission(key):
@pytest.mark.parametrize("key", ["FunctionName", "FunctionArn"])
-@mock_lambda
+@mock_aws
def test_remove_function_permission__with_qualifier(key):
conn = boto3.client("lambda", _lambda_region)
zip_content = get_test_zip_file1()
@@ -274,8 +273,7 @@ def test_remove_function_permission__with_qualifier(key):
assert policy["Statement"] == []
-@mock_lambda
-@mock_s3
+@mock_aws
def test_get_unknown_policy():
conn = boto3.client("lambda", _lambda_region)
diff --git a/tests/test_awslambda/test_lambda_tags.py b/tests/test_awslambda/test_lambda_tags.py
index c4c8c07ae..a42e7d98e 100644
--- a/tests/test_awslambda/test_lambda_tags.py
+++ b/tests/test_awslambda/test_lambda_tags.py
@@ -4,18 +4,16 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_lambda, mock_s3
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .utilities import get_role_name, get_test_zip_file2
PYTHON_VERSION = "python3.11"
_lambda_region = "us-east-1"
-boto3.setup_default_session(region_name=_lambda_region)
-@mock_lambda
-@mock_s3
+@mock_aws
def test_tags():
"""
test list_tags -> tag_resource -> list_tags -> tag_resource -> list_tags -> untag_resource -> list_tags integration
@@ -69,8 +67,7 @@ def test_tags():
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 204
-@mock_lambda
-@mock_s3
+@mock_aws
def test_create_function_with_tags():
bucket_name = str(uuid4())
s3_conn = boto3.client("s3", _lambda_region)
@@ -97,7 +94,7 @@ def test_create_function_with_tags():
assert result["Tags"] == {"key1": "val1", "key2": "val2"}
-@mock_lambda
+@mock_aws
def test_tags_not_found():
"""
Test list_tags and tag_resource when the lambda with the given arn does not exist
diff --git a/tests/test_awslambda/utilities.py b/tests/test_awslambda/utilities.py
index f7e78e20a..89778cbd9 100644
--- a/tests/test_awslambda/utilities.py
+++ b/tests/test_awslambda/utilities.py
@@ -7,7 +7,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iam, settings
+from moto import mock_aws, settings
_lambda_region = "us-west-2"
@@ -181,7 +181,7 @@ def create_invalid_lambda(role):
def get_role_name():
- with mock_iam():
+ with mock_aws():
iam = boto3.client("iam", region_name=_lambda_region)
while True:
try:
@@ -198,6 +198,7 @@ def get_role_name():
def wait_for_log_msg(expected_msg, log_group, wait_time=30):
+ expected_msgs = expected_msg if isinstance(expected_msg, list) else [expected_msg]
logs_conn = boto3.client("logs", region_name="us-east-1")
received_messages = []
start = time.time()
@@ -219,7 +220,7 @@ def wait_for_log_msg(expected_msg, log_group, wait_time=30):
[event["message"] for event in result.get("events")]
)
for line in received_messages:
- if expected_msg in line:
+ if any([msg in line for msg in expected_msgs]):
return True, set(received_messages)
time.sleep(1)
return False, set(received_messages)
diff --git a/tests/test_awslambda_simple/test_lambda_simple.py b/tests/test_awslambda_simple/test_lambda_simple.py
index 71ec3e595..3d6d78e86 100644
--- a/tests/test_awslambda_simple/test_lambda_simple.py
+++ b/tests/test_awslambda_simple/test_lambda_simple.py
@@ -3,7 +3,7 @@ from unittest import SkipTest
import boto3
-from moto import mock_iam, mock_lambda_simple, settings
+from moto import mock_aws, settings
from ..test_awslambda.utilities import get_role_name, get_test_zip_file1
@@ -15,8 +15,7 @@ if settings.TEST_SERVER_MODE:
raise SkipTest("No point in testing batch_simple in ServerMode")
-@mock_iam
-@mock_lambda_simple
+@mock_aws(config={"lambda": {"use_docker": False}})
def test_run_function():
# Setup
client = setup_lambda()
@@ -32,8 +31,7 @@ def test_run_function():
assert result["Payload"].read().decode("utf-8") == "Simple Lambda happy path OK"
-@mock_iam
-@mock_lambda_simple
+@mock_aws(config={"lambda": {"use_docker": False}})
def test_run_function_no_log():
# Setup
client = setup_lambda()
diff --git a/tests/test_backup/test_backup.py b/tests/test_backup/test_backup.py
index 030bd9eb9..e5ff7ed19 100644
--- a/tests/test_backup/test_backup.py
+++ b/tests/test_backup/test_backup.py
@@ -3,10 +3,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_backup
+from moto import mock_aws
-@mock_backup
+@mock_aws
def test_create_backup_plan():
client = boto3.client("backup", region_name="eu-west-1")
response = client.create_backup_vault(
@@ -29,7 +29,7 @@ def test_create_backup_plan():
assert "VersionId" in resp
-@mock_backup
+@mock_aws
def test_create_backup_plan_already_exists():
client = boto3.client("backup", region_name="eu-west-1")
backup_plan_name = "backup_plan_foobar"
@@ -51,7 +51,7 @@ def test_create_backup_plan_already_exists():
assert err["Code"] == "AlreadyExistsException"
-@mock_backup
+@mock_aws
def test_get_backup_plan():
client = boto3.client("backup", region_name="eu-west-1")
response = client.create_backup_vault(
@@ -74,7 +74,7 @@ def test_get_backup_plan():
assert "BackupPlan" in resp
-@mock_backup
+@mock_aws
def test_get_backup_plan_invalid_id():
client = boto3.client("backup", region_name="eu-west-1")
@@ -84,7 +84,7 @@ def test_get_backup_plan_invalid_id():
assert err["Code"] == "ResourceNotFoundException"
-@mock_backup
+@mock_aws
def test_get_backup_plan_invalid_version_id():
client = boto3.client("backup", region_name="eu-west-1")
@@ -105,7 +105,7 @@ def test_get_backup_plan_invalid_version_id():
assert err["Code"] == "ResourceNotFoundException"
-@mock_backup
+@mock_aws
def test_get_backup_plan_with_multiple_rules():
client = boto3.client("backup", region_name="eu-west-1")
plan = client.create_backup_plan(
@@ -134,7 +134,7 @@ def test_get_backup_plan_with_multiple_rules():
assert "RuleId" in rule
-@mock_backup
+@mock_aws
def test_delete_backup_plan():
client = boto3.client("backup", region_name="eu-west-1")
response = client.create_backup_vault(
@@ -164,7 +164,7 @@ def test_delete_backup_plan():
assert "DeletionDate" in resp
-@mock_backup
+@mock_aws
def test_delete_backup_plan_invalid_id():
client = boto3.client("backup", region_name="eu-west-1")
@@ -174,7 +174,7 @@ def test_delete_backup_plan_invalid_id():
assert err["Code"] == "ResourceNotFoundException"
-@mock_backup
+@mock_aws
def test_list_backup_plans():
client = boto3.client("backup", region_name="eu-west-1")
for i in range(1, 3):
@@ -197,7 +197,7 @@ def test_list_backup_plans():
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_backup
+@mock_aws
def test_list_backup_plans_without_include_deleted():
client = boto3.client("backup", region_name="eu-west-1")
@@ -221,7 +221,7 @@ def test_list_backup_plans_without_include_deleted():
assert len(backup_plans) == 1
-@mock_backup
+@mock_aws
def test_list_backup_plans_with_include_deleted():
client = boto3.client("backup", region_name="eu-west-1")
for i in range(1, 3):
@@ -245,7 +245,7 @@ def test_list_backup_plans_with_include_deleted():
assert len(backup_plans) == 2
-@mock_backup
+@mock_aws
def test_create_backup_vault():
client = boto3.client("backup", region_name="eu-west-1")
resp = client.create_backup_vault(
@@ -259,7 +259,7 @@ def test_create_backup_vault():
assert "CreationDate" in resp
-@mock_backup
+@mock_aws
def test_create_backup_vault_already_exists():
client = boto3.client("backup", region_name="eu-west-1")
backup_vault_name = "backup_vault_foobar"
@@ -271,7 +271,7 @@ def test_create_backup_vault_already_exists():
assert err["Code"] == "AlreadyExistsException"
-@mock_backup
+@mock_aws
def test_list_backup_vaults():
client = boto3.client("backup", region_name="eu-west-1")
for i in range(1, 3):
@@ -285,7 +285,7 @@ def test_list_backup_vaults():
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_backup
+@mock_aws
def test_list_tags_vault():
client = boto3.client("backup", region_name="eu-west-1")
vault = client.create_backup_vault(
@@ -299,7 +299,7 @@ def test_list_tags_vault():
assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
-@mock_backup
+@mock_aws
def test_list_tags_plan():
client = boto3.client("backup", region_name="eu-west-1")
response = client.create_backup_vault(
@@ -324,7 +324,7 @@ def test_list_tags_plan():
assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
-@mock_backup
+@mock_aws
def test_tag_resource():
client = boto3.client("backup", region_name="eu-west-1")
vault = client.create_backup_vault(
@@ -341,7 +341,7 @@ def test_tag_resource():
assert resp["Tags"] == {"key1": "value1", "key2": "value2", "key3": "value3"}
-@mock_backup
+@mock_aws
def test_untag_resource():
client = boto3.client("backup", region_name="eu-west-1")
vault = client.create_backup_vault(
diff --git a/tests/test_batch/__init__.py b/tests/test_batch/__init__.py
index 35c0c3eae..ee83965c8 100644
--- a/tests/test_batch/__init__.py
+++ b/tests/test_batch/__init__.py
@@ -1,3 +1,4 @@
+from typing import Any, Tuple
from uuid import uuid4
import boto3
@@ -5,7 +6,7 @@ import boto3
DEFAULT_REGION = "eu-central-1"
-def _get_clients():
+def _get_clients() -> Tuple[Any, Any, Any, Any, Any]:
return (
boto3.client("ec2", region_name=DEFAULT_REGION),
boto3.client("iam", region_name=DEFAULT_REGION),
@@ -15,7 +16,7 @@ def _get_clients():
)
-def _setup(ec2_client, iam_client):
+def _setup(ec2_client: Any, iam_client: Any) -> Tuple[str, str, str, str]:
"""
Do prerequisite setup
:return: VPC ID, Subnet ID, Security group ID, IAM Role ARN
diff --git a/tests/test_batch/test_batch.py b/tests/test_batch/test_batch.py
index a1793ab92..8fa83a08a 100644
--- a/tests/test_batch/test_batch.py
+++ b/tests/test_batch/test_batch.py
@@ -1,11 +1,11 @@
import boto3
import pytest
-from moto import mock_batch
+from moto import mock_aws
@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1"])
-@mock_batch
+@mock_aws
def test_batch_regions(region):
client = boto3.client("batch", region_name=region)
resp = client.describe_jobs(jobs=[""])
diff --git a/tests/test_batch/test_batch_cloudformation.py b/tests/test_batch/test_batch_cloudformation.py
index adc2f34f7..96608045a 100644
--- a/tests/test_batch/test_batch_cloudformation.py
+++ b/tests/test_batch/test_batch_cloudformation.py
@@ -3,7 +3,7 @@ from uuid import uuid4
import boto3
-from moto import mock_batch, mock_cloudformation, mock_ec2, mock_ecs, mock_iam
+from moto import mock_aws
DEFAULT_REGION = "eu-central-1"
@@ -48,11 +48,7 @@ def _setup(ec2_client, iam_client):
return vpc_id, subnet_id, sg_id, iam_arn
-@mock_cloudformation()
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_env_cf():
ec2_client, iam_client, _, _, _ = _get_clients()
_, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
@@ -95,11 +91,7 @@ def test_create_env_cf():
assert stack_name in summary["PhysicalResourceId"]
-@mock_cloudformation()
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_job_queue_cf():
ec2_client, iam_client, _, _, _ = _get_clients()
_, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
@@ -162,11 +154,7 @@ def test_create_job_queue_cf():
assert "job-queue/" in job_queue_resource["PhysicalResourceId"]
-@mock_cloudformation()
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_job_def_cf():
ec2_client, iam_client, _, _, _ = _get_clients()
_, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
diff --git a/tests/test_batch/test_batch_compute_envs.py b/tests/test_batch/test_batch_compute_envs.py
index fb5c7a294..7443d73f7 100644
--- a/tests/test_batch/test_batch_compute_envs.py
+++ b/tests/test_batch/test_batch_compute_envs.py
@@ -3,16 +3,12 @@ from uuid import uuid4
import pytest
from botocore.exceptions import ClientError
-from moto import mock_batch, mock_ec2, mock_ecs, mock_iam, settings
+from moto import mock_aws, settings
from . import _get_clients, _setup
-# Yes, yes it talks to all the things
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_managed_compute_environment():
ec2_client, iam_client, ecs_client, _, batch_client = _get_clients()
_, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
@@ -58,10 +54,7 @@ def test_create_managed_compute_environment():
assert our_env["ecsClusterArn"] in all_clusters
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_managed_compute_environment_with_instance_family():
"""
The InstanceType parameter can have multiple values:
@@ -102,10 +95,7 @@ def test_create_managed_compute_environment_with_instance_family():
assert our_env["computeResources"]["instanceTypes"] == ["t2"]
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_managed_compute_environment_with_unknown_instance_type():
"""
The InstanceType parameter can have multiple values:
@@ -145,10 +135,7 @@ def test_create_managed_compute_environment_with_unknown_instance_type():
assert err["Message"] == "Instance type unknown does not exist"
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_unmanaged_compute_environment():
ec2_client, iam_client, ecs_client, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -183,10 +170,7 @@ def test_create_unmanaged_compute_environment():
# TODO create 1000s of tests to test complex option combinations of create environment
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_describe_compute_environment():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -216,10 +200,7 @@ def test_describe_compute_environment():
assert len(resp["computeEnvironments"]) == 0
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_delete_unmanaged_compute_environment():
ec2_client, iam_client, ecs_client, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -248,10 +229,7 @@ def test_delete_unmanaged_compute_environment():
assert cluster["status"] == "INACTIVE"
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_delete_managed_compute_environment():
ec2_client, iam_client, ecs_client, _, batch_client = _get_clients()
_, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
@@ -303,10 +281,7 @@ def test_delete_managed_compute_environment():
assert cluster["status"] == "INACTIVE"
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_update_unmanaged_compute_environment_state():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -329,10 +304,7 @@ def test_update_unmanaged_compute_environment_state():
assert our_envs[0]["state"] == "DISABLED"
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_update_iam_role():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -366,10 +338,7 @@ def test_update_iam_role():
@pytest.mark.parametrize("compute_env_type", ["FARGATE", "FARGATE_SPOT"])
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_fargate_managed_compute_environment(compute_env_type):
ec2_client, iam_client, ecs_client, _, batch_client = _get_clients()
_, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
@@ -400,10 +369,7 @@ def test_create_fargate_managed_compute_environment(compute_env_type):
assert our_env["ecsClusterArn"] in all_clusters
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_ec2_managed_compute_environment__without_required_params():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, subnet_id, _, iam_arn = _setup(ec2_client, iam_client)
diff --git a/tests/test_batch/test_batch_job_queue.py b/tests/test_batch/test_batch_job_queue.py
index 139f48f92..8584fd9ea 100644
--- a/tests/test_batch/test_batch_job_queue.py
+++ b/tests/test_batch/test_batch_job_queue.py
@@ -4,15 +4,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_batch, mock_ec2, mock_ecs, mock_iam
+from moto import mock_aws
from . import _get_clients, _setup
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_job_queue():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -45,7 +42,7 @@ def test_create_job_queue():
assert our_queues[0]["schedulingPolicyArn"] == "policy_arn"
-@mock_batch
+@mock_aws
def test_describe_job_queue_unknown_value():
batch_client = boto3.client("batch", "us-east-1")
@@ -53,10 +50,7 @@ def test_describe_job_queue_unknown_value():
assert len(resp["jobQueues"]) == 0
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_job_queue_twice():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -92,10 +86,7 @@ def test_create_job_queue_twice():
assert err["Message"] == f"Job queue {jq_name} already exists"
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_job_queue_incorrect_state():
_, _, _, _, batch_client = _get_clients()
@@ -111,10 +102,7 @@ def test_create_job_queue_incorrect_state():
assert err["Message"] == "state JUNK must be one of ENABLED | DISABLED"
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_job_queue_without_compute_environment():
_, _, _, _, batch_client = _get_clients()
@@ -130,10 +118,7 @@ def test_create_job_queue_without_compute_environment():
assert err["Message"] == "At least 1 compute environment must be provided"
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_job_queue_bad_arn():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -161,10 +146,7 @@ def test_job_queue_bad_arn():
assert err["Message"] == "computeEnvironmentOrder is malformed"
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_update_job_queue():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -201,10 +183,7 @@ def test_update_job_queue():
assert our_queues[0]["priority"] == 15
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_delete_job_queue():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
diff --git a/tests/test_batch/test_batch_jobs.py b/tests/test_batch/test_batch_jobs.py
index 1174e59a3..cc50b170d 100644
--- a/tests/test_batch/test_batch_jobs.py
+++ b/tests/test_batch/test_batch_jobs.py
@@ -6,18 +6,14 @@ from uuid import uuid4
import botocore.exceptions
import pytest
-from moto import mock_batch, mock_ec2, mock_ecs, mock_iam, mock_logs, settings
+from moto import mock_aws, settings
from tests import DEFAULT_ACCOUNT_ID
from ..markers import requires_docker
from . import DEFAULT_REGION, _get_clients, _setup
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_submit_job_by_name():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -92,10 +88,7 @@ def test_submit_job_by_name():
# SLOW TESTS
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@pytest.mark.network
@requires_docker
def test_submit_job_array_size():
@@ -138,10 +131,7 @@ def test_submit_job_array_size():
assert len(child_job_1["attempts"]) == 1
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@pytest.mark.network
@requires_docker
def test_submit_job_array_size__reset_while_job_is_running():
@@ -171,11 +161,7 @@ def test_submit_job_array_size__reset_while_job_is_running():
batch_backends[DEFAULT_ACCOUNT_ID][DEFAULT_REGION].reset()
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@pytest.mark.network
@requires_docker
def test_submit_job():
@@ -234,11 +220,7 @@ def test_submit_job():
assert attempt["stoppedAt"] == stopped_at
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@pytest.mark.network
@requires_docker
def test_submit_job_multinode():
@@ -299,11 +281,7 @@ def test_submit_job_multinode():
assert attempt["stoppedAt"] == stopped_at
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@pytest.mark.network
@requires_docker
def test_list_jobs():
@@ -370,11 +348,7 @@ def test_list_jobs():
assert filtered_jobs[0]["jobName"] == "test2"
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@requires_docker
def test_terminate_job():
ec2_client, iam_client, _, logs_client, batch_client = _get_clients()
@@ -412,7 +386,7 @@ def test_terminate_job():
assert resp["events"][0]["message"] == "start"
-@mock_batch
+@mock_aws
def test_terminate_nonexisting_job():
"""
Test verifies that you get a 200 HTTP status code when terminating a non-existing job.
@@ -424,7 +398,7 @@ def test_terminate_nonexisting_job():
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_batch
+@mock_aws
def test_terminate_job_empty_argument_strings():
"""
Test verifies that a `ClientException` is raised if `jobId` or `reason` is a empty string when terminating a job.
@@ -439,11 +413,8 @@ def test_terminate_job_empty_argument_strings():
assert exc.match("ClientException")
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@requires_docker
+@mock_aws
@requires_docker
def test_cancel_pending_job():
ec2_client, iam_client, _, _, batch_client = _get_clients()
@@ -478,11 +449,7 @@ def test_cancel_pending_job():
assert "logStreamName" not in resp["jobs"][0]["container"]
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@requires_docker
def test_cancel_running_job():
"""
@@ -513,7 +480,7 @@ def test_cancel_running_job():
assert "logStreamName" in resp["jobs"][0]["container"]
-@mock_batch
+@mock_aws
def test_cancel_nonexisting_job():
"""
Test verifies that you get a 200 HTTP status code when cancelling a non-existing job.
@@ -525,7 +492,7 @@ def test_cancel_nonexisting_job():
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_batch
+@mock_aws
def test_cancel_job_empty_argument_strings():
"""
Test verifies that a `ClientException` is raised if `jobId` or `reason` is a empty string when cancelling a job.
@@ -559,11 +526,7 @@ def _wait_for_job_statuses(client, job_id, statuses, seconds_to_wait=30):
)
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@requires_docker
def test_failed_job():
ec2_client, iam_client, _, _, batch_client = _get_clients()
@@ -593,11 +556,7 @@ def test_failed_job():
raise RuntimeError("Batch job timed out")
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@requires_docker
def test_dependencies():
ec2_client, iam_client, _, logs_client, batch_client = _get_clients()
@@ -680,11 +639,7 @@ def retrieve_all_streams(log_stream_name, logs_client):
return all_streams
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@requires_docker
def test_failed_dependencies():
ec2_client, iam_client, _, _, batch_client = _get_clients()
@@ -780,11 +735,7 @@ def test_failed_dependencies():
raise RuntimeError("Batch job timed out")
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@requires_docker
def test_container_overrides():
"""
@@ -981,7 +932,7 @@ def prepare_multinode_job(batch_client, commands, iam_arn, job_def_name):
return job_def_arn, queue_arn
-@mock_batch
+@mock_aws
def test_update_job_definition():
_, _, _, _, batch_client = _get_clients()
@@ -1027,7 +978,7 @@ def test_update_job_definition():
assert job_defs[1]["tags"] == tags[1]
-@mock_batch
+@mock_aws
def test_register_job_definition_with_timeout():
_, _, _, _, batch_client = _get_clients()
@@ -1051,9 +1002,7 @@ def test_register_job_definition_with_timeout():
assert job_def["timeout"] == {"attemptDurationSeconds": 3}
-@mock_batch
-@mock_ec2
-@mock_iam
+@mock_aws
@requires_docker
def test_submit_job_with_timeout():
ec2_client, iam_client, _, _, batch_client = _get_clients()
@@ -1081,9 +1030,7 @@ def test_submit_job_with_timeout():
_wait_for_job_status(batch_client, job_id, "FAILED")
-@mock_batch
-@mock_ec2
-@mock_iam
+@mock_aws
@requires_docker
def test_submit_job_with_timeout_set_at_definition():
ec2_client, iam_client, _, _, batch_client = _get_clients()
@@ -1114,7 +1061,7 @@ def test_submit_job_with_timeout_set_at_definition():
_wait_for_job_status(batch_client, job_id, "FAILED")
-@mock_batch
+@mock_aws
def test_submit_job_invalid_name():
"""
Test verifies that a `ClientException` is raised if `jobName` isn't valid
diff --git a/tests/test_batch/test_batch_scheduling_policy.py b/tests/test_batch/test_batch_scheduling_policy.py
index c20866131..5a589f84e 100644
--- a/tests/test_batch/test_batch_scheduling_policy.py
+++ b/tests/test_batch/test_batch_scheduling_policy.py
@@ -1,10 +1,10 @@
import boto3
-from moto import mock_batch
+from moto import mock_aws
from tests import DEFAULT_ACCOUNT_ID
-@mock_batch
+@mock_aws
def test_create_scheduling_policy():
client = boto3.client("batch", "us-east-2")
resp = client.create_scheduling_policy(name="test")
@@ -15,7 +15,7 @@ def test_create_scheduling_policy():
)
-@mock_batch
+@mock_aws
def test_describe_default_scheduling_policy():
client = boto3.client("batch", "us-east-2")
arn = client.create_scheduling_policy(name="test")["arn"]
@@ -33,7 +33,7 @@ def test_describe_default_scheduling_policy():
assert policy["tags"] == {}
-@mock_batch
+@mock_aws
def test_describe_scheduling_policy():
client = boto3.client("batch", "us-east-2")
arn = client.create_scheduling_policy(
@@ -63,7 +63,7 @@ def test_describe_scheduling_policy():
assert policy["tags"] == {}
-@mock_batch
+@mock_aws
def test_delete_scheduling_policy():
client = boto3.client("batch", "us-east-2")
arn = client.create_scheduling_policy(name="test")["arn"]
@@ -74,7 +74,7 @@ def test_delete_scheduling_policy():
assert len(resp["schedulingPolicies"]) == 0
-@mock_batch
+@mock_aws
def test_update_scheduling_policy():
client = boto3.client("batch", "us-east-2")
arn = client.create_scheduling_policy(name="test")["arn"]
diff --git a/tests/test_batch/test_batch_tags_job_definition.py b/tests/test_batch/test_batch_tags_job_definition.py
index f8ab03923..73ec0b101 100644
--- a/tests/test_batch/test_batch_tags_job_definition.py
+++ b/tests/test_batch/test_batch_tags_job_definition.py
@@ -1,6 +1,6 @@
from uuid import uuid4
-from moto import mock_batch
+from moto import mock_aws
from . import _get_clients
@@ -12,7 +12,7 @@ container_properties = {
}
-@mock_batch
+@mock_aws
def test_list_tags_with_job_definition():
_, _, _, _, batch_client = _get_clients()
@@ -29,7 +29,7 @@ def test_list_tags_with_job_definition():
assert my_queue["tags"] == {"foo": "123", "bar": "456"}
-@mock_batch
+@mock_aws
def test_tag_job_definition():
_, _, _, _, batch_client = _get_clients()
@@ -47,7 +47,7 @@ def test_tag_job_definition():
assert my_queue["tags"] == {"k1": "v1", "k2": "v2"}
-@mock_batch
+@mock_aws
def test_untag_job_queue():
_, _, _, _, batch_client = _get_clients()
diff --git a/tests/test_batch/test_batch_tags_job_queue.py b/tests/test_batch/test_batch_tags_job_queue.py
index d4df887aa..c3d624f8b 100644
--- a/tests/test_batch/test_batch_tags_job_queue.py
+++ b/tests/test_batch/test_batch_tags_job_queue.py
@@ -1,14 +1,11 @@
from uuid import uuid4
-from moto import mock_batch, mock_ec2, mock_ecs, mock_iam
+from moto import mock_aws
from . import _get_clients, _setup
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_create_job_queue_with_tags():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -38,10 +35,7 @@ def test_create_job_queue_with_tags():
assert my_queue["tags"] == {"k1": "v1", "k2": "v2"}
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_list_tags():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -71,10 +65,7 @@ def test_list_tags():
assert my_queue["tags"] == {"k1": "v1", "k2": "v2"}
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_tag_job_queue():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
@@ -103,10 +94,7 @@ def test_tag_job_queue():
assert my_queue["tags"] == {"k1": "v1", "k2": "v2"}
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
def test_untag_job_queue():
ec2_client, iam_client, _, _, batch_client = _get_clients()
_, _, _, iam_arn = _setup(ec2_client, iam_client)
diff --git a/tests/test_batch/test_batch_tags_scheduling_policy.py b/tests/test_batch/test_batch_tags_scheduling_policy.py
index b1b540598..43056868e 100644
--- a/tests/test_batch/test_batch_tags_scheduling_policy.py
+++ b/tests/test_batch/test_batch_tags_scheduling_policy.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_batch
+from moto import mock_aws
-@mock_batch
+@mock_aws
def test_create_with_tags():
client = boto3.client("batch", "us-east-2")
arn = client.create_scheduling_policy(name="test", tags={"key": "val"})["arn"]
diff --git a/tests/test_batch/test_batch_task_definition.py b/tests/test_batch/test_batch_task_definition.py
index e6bf114f0..d4643bd90 100644
--- a/tests/test_batch/test_batch_task_definition.py
+++ b/tests/test_batch/test_batch_task_definition.py
@@ -3,12 +3,12 @@ from uuid import uuid4
import pytest
-from moto import mock_batch
+from moto import mock_aws
from . import _get_clients
-@mock_batch
+@mock_aws
@pytest.mark.parametrize("use_resource_reqs", [True, False])
def test_register_task_definition(use_resource_reqs):
_, _, _, _, batch_client = _get_clients()
@@ -22,7 +22,7 @@ def test_register_task_definition(use_resource_reqs):
assert f"{resp['jobDefinitionName']}:{resp['revision']}" in resp["jobDefinitionArn"]
-@mock_batch
+@mock_aws
@pytest.mark.parametrize("propagate_tags", [None, True, False])
def test_register_task_definition_with_tags(propagate_tags):
_, _, _, _, batch_client = _get_clients()
@@ -38,7 +38,7 @@ def test_register_task_definition_with_tags(propagate_tags):
assert job_def["propagateTags"] == propagate_tags
-@mock_batch
+@mock_aws
@pytest.mark.parametrize("platform_capability", ["EC2", "FARGATE"])
def test_register_task_definition_with_platform_capability(platform_capability):
_, _, _, _, batch_client = _get_clients()
@@ -72,7 +72,7 @@ def test_register_task_definition_with_platform_capability(platform_capability):
assert "fargatePlatformConfiguration" not in container_props
-@mock_batch
+@mock_aws
def test_register_task_definition_without_command():
_, _, _, _, batch_client = _get_clients()
@@ -95,7 +95,7 @@ def test_register_task_definition_without_command():
assert container_props["command"] == []
-@mock_batch
+@mock_aws
def test_register_task_definition_with_retry_strategies():
_, _, _, _, batch_client = _get_clients()
@@ -128,7 +128,7 @@ def test_register_task_definition_with_retry_strategies():
}
-@mock_batch
+@mock_aws
@pytest.mark.parametrize("use_resource_reqs", [True, False])
def test_reregister_task_definition(use_resource_reqs):
# Reregistering task with the same name bumps the revision number
@@ -173,7 +173,7 @@ def test_reregister_task_definition(use_resource_reqs):
assert resp4["jobDefinitionArn"] != resp3["jobDefinitionArn"]
-@mock_batch
+@mock_aws
def test_reregister_task_definition_should_not_reuse_parameters_from_inactive_definition():
# Reregistering task with the same name bumps the revision number
_, _, _, _, batch_client = _get_clients()
@@ -226,7 +226,7 @@ def test_reregister_task_definition_should_not_reuse_parameters_from_inactive_de
assert (2, "ACTIVE", {}) in actual
-@mock_batch
+@mock_aws
@pytest.mark.parametrize("use_resource_reqs", [True, False])
def test_delete_task_definition(use_resource_reqs):
_, _, _, _, batch_client = _get_clients()
@@ -250,7 +250,7 @@ def test_delete_task_definition(use_resource_reqs):
assert definitions[0]["status"] == "INACTIVE"
-@mock_batch
+@mock_aws
@pytest.mark.parametrize("use_resource_reqs", [True, False])
def test_delete_task_definition_by_name(use_resource_reqs):
_, _, _, _, batch_client = _get_clients()
@@ -284,7 +284,7 @@ def test_delete_task_definition_by_name(use_resource_reqs):
assert {"revision": 2, "status": "ACTIVE"} in revision_status
-@mock_batch
+@mock_aws
@pytest.mark.parametrize("use_resource_reqs", [True, False])
def test_describe_task_definition(use_resource_reqs):
_, _, _, _, batch_client = _get_clients()
diff --git a/tests/test_batch/test_server.py b/tests/test_batch/test_server.py
index 969cf5115..ea1d5909b 100644
--- a/tests/test_batch/test_server.py
+++ b/tests/test_batch/test_server.py
@@ -1,12 +1,12 @@
import moto.server as server
-from moto import mock_batch
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_batch
+@mock_aws
def test_batch_list():
backend = server.create_backend_app("batch")
test_client = backend.test_client()
diff --git a/tests/test_batch_simple/test_batch_cloudformation.py b/tests/test_batch_simple/test_batch_cloudformation.py
index 981ea7097..143a58677 100644
--- a/tests/test_batch_simple/test_batch_cloudformation.py
+++ b/tests/test_batch_simple/test_batch_cloudformation.py
@@ -3,8 +3,9 @@ from uuid import uuid4
import boto3
-from moto import mock_batch_simple as mock_batch_without_docker
-from moto import mock_cloudformation, mock_ec2, mock_ecs, mock_iam
+from moto import mock_aws
+
+from .test_batch_jobs import _get_clients, _setup
# Copy of test_batch/test_batch_cloudformation
# Except that we verify this behaviour still works without docker
@@ -13,52 +14,8 @@ from moto import mock_cloudformation, mock_ec2, mock_ecs, mock_iam
DEFAULT_REGION = "eu-central-1"
-def _get_clients():
- return (
- boto3.client("ec2", region_name=DEFAULT_REGION),
- boto3.client("iam", region_name=DEFAULT_REGION),
- boto3.client("ecs", region_name=DEFAULT_REGION),
- boto3.client("logs", region_name=DEFAULT_REGION),
- boto3.client("batch", region_name=DEFAULT_REGION),
- )
-
-
-def _setup(ec2_client, iam_client):
- """
- Do prerequisite setup
- :return: VPC ID, Subnet ID, Security group ID, IAM Role ARN
- :rtype: tuple
- """
- resp = ec2_client.create_vpc(CidrBlock="172.30.0.0/24")
- vpc_id = resp["Vpc"]["VpcId"]
- resp = ec2_client.create_subnet(
- AvailabilityZone="eu-central-1a", CidrBlock="172.30.0.0/25", VpcId=vpc_id
- )
- subnet_id = resp["Subnet"]["SubnetId"]
- resp = ec2_client.create_security_group(
- Description="test_sg_desc", GroupName=str(uuid4())[0:6], VpcId=vpc_id
- )
- sg_id = resp["GroupId"]
-
- role_name = str(uuid4())[0:6]
- resp = iam_client.create_role(
- RoleName=role_name, AssumeRolePolicyDocument="some_policy"
- )
- iam_arn = resp["Role"]["Arn"]
- iam_client.create_instance_profile(InstanceProfileName=role_name)
- iam_client.add_role_to_instance_profile(
- InstanceProfileName=role_name, RoleName=role_name
- )
-
- return vpc_id, subnet_id, sg_id, iam_arn
-
-
-@mock_cloudformation()
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_without_docker
-def test_create_env_cf():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_create_env_cf() -> None:
ec2_client, iam_client, _, _, _ = _get_clients()
_, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
@@ -100,12 +57,8 @@ def test_create_env_cf():
assert stack_name in summary["PhysicalResourceId"]
-@mock_cloudformation()
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_without_docker
-def test_create_job_queue_cf():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_create_job_queue_cf() -> None:
ec2_client, iam_client, _, _, _ = _get_clients()
_, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
@@ -167,12 +120,8 @@ def test_create_job_queue_cf():
assert "job-queue/" in job_queue_resource["PhysicalResourceId"]
-@mock_cloudformation
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_without_docker
-def test_create_job_def_cf():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_create_job_def_cf() -> None:
ec2_client, iam_client, _, _, _ = _get_clients()
_, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
diff --git a/tests/test_batch_simple/test_batch_compute_envs.py b/tests/test_batch_simple/test_batch_compute_envs.py
index 8eb359d2e..1f5791161 100644
--- a/tests/test_batch_simple/test_batch_compute_envs.py
+++ b/tests/test_batch_simple/test_batch_compute_envs.py
@@ -1,6 +1,6 @@
from uuid import uuid4
-from moto import mock_batch_simple, mock_ec2, mock_ecs, mock_iam, settings
+from moto import mock_aws, settings
from ..test_batch import _get_clients, _setup
@@ -8,11 +8,8 @@ from ..test_batch import _get_clients, _setup
# Except that we verify this behaviour still works without docker
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_simple
-def test_create_managed_compute_environment():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_create_managed_compute_environment() -> None:
ec2_client, iam_client, ecs_client, _, batch_client = _get_clients()
_, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
@@ -57,11 +54,8 @@ def test_create_managed_compute_environment():
assert our_env["ecsClusterArn"] in all_clusters
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_simple
-def test_create_managed_compute_environment_with_instance_family():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_create_managed_compute_environment_with_instance_family() -> None:
"""
The InstanceType parameter can have multiple values:
instance_type t2.small
diff --git a/tests/test_batch_simple/test_batch_jobs.py b/tests/test_batch_simple/test_batch_jobs.py
index ae09d1399..4168f48cc 100644
--- a/tests/test_batch_simple/test_batch_jobs.py
+++ b/tests/test_batch_simple/test_batch_jobs.py
@@ -1,8 +1,9 @@
import os
+from typing import Any, Tuple
from unittest import SkipTest, mock
from uuid import uuid4
-from moto import mock_batch_simple, mock_ec2, mock_ecs, mock_iam, mock_logs, settings
+from moto import mock_aws, settings
from ..test_batch import _get_clients, _setup
@@ -10,12 +11,8 @@ from ..test_batch import _get_clients, _setup
# Except that we verify this behaviour still works without docker
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_simple
-def test_submit_job_by_name():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_submit_job_by_name() -> None:
job_definition_name = f"sleep10_{str(uuid4())[0:6]}"
batch_client, job_definition_arn, queue_arn = setup_common_batch_simple(
job_definition_name
@@ -42,11 +39,8 @@ def test_submit_job_by_name():
assert "logStreamName" in job["container"]
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_simple
-def test_submit_job_array_size():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_submit_job_array_size() -> None:
# Setup
job_definition_name = f"sleep10_{str(uuid4())[0:6]}"
batch_client, _, queue_arn = setup_common_batch_simple(job_definition_name)
@@ -80,8 +74,8 @@ def test_submit_job_array_size():
assert len(child_job_1["attempts"]) == 1
-@mock_batch_simple
-def test_update_job_definition():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_update_job_definition() -> None:
_, _, _, _, batch_client = _get_clients()
tags = [
@@ -126,12 +120,8 @@ def test_update_job_definition():
assert job_defs[1]["tags"] == tags[1]
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_simple
-def test_submit_job_fail():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_submit_job_fail() -> None:
job_definition_name = "test_job_moto_fail"
with mock.patch.dict(os.environ, {"MOTO_SIMPLE_BATCH_FAIL_AFTER": "0"}):
@@ -153,12 +143,8 @@ def test_submit_job_fail():
assert job["status"] == "FAILED"
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_simple
-def test_submit_job_fail_after_1_secs():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_submit_job_fail_after_1_secs() -> None:
job_definition_name = "test_job_moto_fail"
with mock.patch.dict(os.environ, {"MOTO_SIMPLE_BATCH_FAIL_AFTER": "1"}):
@@ -180,12 +166,8 @@ def test_submit_job_fail_after_1_secs():
assert job["status"] == "FAILED"
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_simple
-def test_submit_job_fail_bad_int():
+@mock_aws(config={"batch": {"use_docker": False}})
+def test_submit_job_fail_bad_int() -> None:
job_definition_name = "test_job_moto_fail"
with mock.patch.dict(
@@ -209,12 +191,7 @@ def test_submit_job_fail_bad_int():
assert job["status"] == "FAILED"
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch_simple
-def setup_common_batch_simple(job_definition_name):
+def setup_common_batch_simple(job_definition_name: str) -> Tuple[Any, str, str]:
if settings.TEST_SERVER_MODE:
raise SkipTest("No point in testing batch_simple in ServerMode")
diff --git a/tests/test_budgets/test_budgets.py b/tests/test_budgets/test_budgets.py
index e7e4ea0a3..6e2825227 100644
--- a/tests/test_budgets/test_budgets.py
+++ b/tests/test_budgets/test_budgets.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_budgets
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_budgets
+@mock_aws
def test_create_and_describe_budget_minimal_params():
client = boto3.client("budgets", region_name="us-east-1")
resp = client.create_budget(
@@ -63,7 +63,7 @@ def test_create_and_describe_budget_minimal_params():
assert budget["TimeUnit"] == "DAILY"
-@mock_budgets
+@mock_aws
def test_create_existing_budget():
client = boto3.client("budgets", region_name="us-east-1")
client.create_budget(
@@ -91,7 +91,7 @@ def test_create_existing_budget():
assert err["Message"] == "Error creating budget: testb - the budget already exists."
-@mock_budgets
+@mock_aws
def test_create_budget_without_limit_param():
client = boto3.client("budgets", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -107,7 +107,7 @@ def test_create_budget_without_limit_param():
)
-@mock_budgets
+@mock_aws
def test_describe_unknown_budget():
client = boto3.client("budgets", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -117,14 +117,14 @@ def test_describe_unknown_budget():
assert err["Message"] == "Unable to get budget: unknown - the budget doesn't exist."
-@mock_budgets
+@mock_aws
def test_describe_no_budgets():
client = boto3.client("budgets", region_name="us-east-1")
resp = client.describe_budgets(AccountId=ACCOUNT_ID)
assert resp["Budgets"] == []
-@mock_budgets
+@mock_aws
def test_create_and_describe_all_budgets():
client = boto3.client("budgets", region_name="us-east-1")
client.create_budget(
@@ -144,7 +144,7 @@ def test_create_and_describe_all_budgets():
assert len(res["Budgets"]) == 1
-@mock_budgets
+@mock_aws
def test_delete_budget():
client = boto3.client("budgets", region_name="us-east-1")
client.create_budget(
@@ -164,7 +164,7 @@ def test_delete_budget():
assert len(res["Budgets"]) == 0
-@mock_budgets
+@mock_aws
def test_delete_unknown_budget():
client = boto3.client("budgets", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
diff --git a/tests/test_budgets/test_notifications.py b/tests/test_budgets/test_notifications.py
index 580f19f7a..15260d0a5 100644
--- a/tests/test_budgets/test_notifications.py
+++ b/tests/test_budgets/test_notifications.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_budgets
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_budgets
+@mock_aws
def test_create_and_describe_notification():
client = boto3.client("budgets", region_name="us-east-1")
client.create_budget(
@@ -45,7 +45,7 @@ def test_create_and_describe_notification():
assert notification["NotificationState"] == "ALARM"
-@mock_budgets
+@mock_aws
def test_create_notification():
client = boto3.client("budgets", region_name="us-east-1")
client.create_budget(
@@ -104,7 +104,7 @@ def test_create_notification():
assert n_2["NotificationState"] == "OK"
-@mock_budgets
+@mock_aws
def test_create_notification_unknown_budget():
client = boto3.client("budgets", region_name="us-east-1")
@@ -126,7 +126,7 @@ def test_create_notification_unknown_budget():
assert err["Message"] == "Unable to create notification - the budget doesn't exist."
-@mock_budgets
+@mock_aws
def test_delete_notification():
client = boto3.client("budgets", region_name="us-east-1")
client.create_budget(
@@ -171,7 +171,7 @@ def test_delete_notification():
assert len(res["Notifications"]) == 0
-@mock_budgets
+@mock_aws
def test_delete_notification_unknown_budget():
client = boto3.client("budgets", region_name="us-east-1")
diff --git a/tests/test_budgets/test_server.py b/tests/test_budgets/test_server.py
index 3f7333939..bdbffbb51 100644
--- a/tests/test_budgets/test_server.py
+++ b/tests/test_budgets/test_server.py
@@ -1,10 +1,10 @@
import json
import moto.server as server
-from moto import mock_budgets
+from moto import mock_aws
-@mock_budgets
+@mock_aws
def test_budgets_describe_budgets():
backend = server.create_backend_app("budgets")
test_client = backend.test_client()
diff --git a/tests/test_ce/test_ce.py b/tests/test_ce/test_ce.py
index c234d1b62..8989b605a 100644
--- a/tests/test_ce/test_ce.py
+++ b/tests/test_ce/test_ce.py
@@ -1,16 +1,15 @@
-"""Unit tests for ce-supported APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ce
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_ce
+@mock_aws
def test_create_cost_category_definition():
client = boto3.client("ce", region_name="ap-southeast-1")
resp = client.create_cost_category_definition(
@@ -24,7 +23,7 @@ def test_create_cost_category_definition():
assert "EffectiveStart" in resp
-@mock_ce
+@mock_aws
def test_create_cost_category_definition_with_effective_start():
client = boto3.client("ce", region_name="ap-southeast-1")
resp = client.create_cost_category_definition(
@@ -39,7 +38,7 @@ def test_create_cost_category_definition_with_effective_start():
assert resp["EffectiveStart"] == "2022-11-01T00:00:00Z"
-@mock_ce
+@mock_aws
def test_describe_cost_category_definition():
client = boto3.client("ce", region_name="us-east-2")
ccd_arn = client.create_cost_category_definition(
@@ -63,7 +62,7 @@ def test_describe_cost_category_definition():
}
-@mock_ce
+@mock_aws
def test_delete_cost_category_definition():
client = boto3.client("ce", region_name="ap-southeast-1")
ccd_arn = client.create_cost_category_definition(
@@ -84,7 +83,7 @@ def test_delete_cost_category_definition():
assert err["Message"] == f"No Cost Categories found with ID {ccd_id}"
-@mock_ce
+@mock_aws
def test_update_cost_category_definition():
client = boto3.client("ce", region_name="us-east-2")
ccd_arn = client.create_cost_category_definition(
diff --git a/tests/test_ce/test_ce_tags.py b/tests/test_ce/test_ce_tags.py
index ce01b9b01..df8e46c9e 100644
--- a/tests/test_ce/test_ce_tags.py
+++ b/tests/test_ce/test_ce_tags.py
@@ -1,12 +1,12 @@
import boto3
-from moto import mock_ce
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_ce
+@mock_aws
def test_list_tags_if_none_exist():
client = boto3.client("ce", region_name="ap-southeast-1")
arn = client.create_cost_category_definition(
@@ -26,7 +26,7 @@ def test_list_tags_if_none_exist():
assert resp["ResourceTags"] == [{"Key": "t1", "Value": "v1"}]
-@mock_ce
+@mock_aws
def test_cost_category_tags_workflow():
client = boto3.client("ce", region_name="ap-southeast-1")
arn = client.create_cost_category_definition(
diff --git a/tests/test_cloudformation/test_cloudformation_custom_resources.py b/tests/test_cloudformation/test_cloudformation_custom_resources.py
index 2fbef1f7b..97e1d8e9b 100644
--- a/tests/test_cloudformation/test_cloudformation_custom_resources.py
+++ b/tests/test_cloudformation/test_cloudformation_custom_resources.py
@@ -8,7 +8,7 @@ import pytest
import requests
from botocore.exceptions import ClientError
-from moto import mock_cloudformation, mock_lambda, mock_logs, mock_s3, settings
+from moto import mock_aws, settings
from tests.test_awslambda.utilities import wait_for_log_msg
from ..markers import requires_docker
@@ -35,10 +35,7 @@ def lambda_handler(event, context):
"""
-@mock_cloudformation
-@mock_lambda
-@mock_logs
-@mock_s3
+@mock_aws
def test_create_custom_lambda_resource():
#########
# Integration test using a Custom Resource
@@ -75,10 +72,7 @@ def test_create_custom_lambda_resource():
assert outputs[0]["OutputValue"] == "special value"
-@mock_cloudformation
-@mock_lambda
-@mock_logs
-@mock_s3
+@mock_aws
@requires_docker
def test_create_custom_lambda_resource__verify_cfnresponse_failed():
#########
@@ -102,10 +96,13 @@ def test_create_custom_lambda_resource__verify_cfnresponse_failed():
)
# Verify CloudWatch contains the correct logs
log_group_name = get_log_group_name(cf, stack_name)
+ # urllib< 2 will emit the `failed executing http.request` message
+ # urllib>=2 will emit the StatusCode=400 message
execution_failed, logs = wait_for_log_msg(
- expected_msg="failed executing http.request", log_group=log_group_name
+ expected_msg=["failed executing http.request", "Status code: 400"],
+ log_group=log_group_name,
)
- assert execution_failed is True
+ assert execution_failed is True, logs
printed_events = [
line for line in logs if line.startswith("{'RequestType': 'Create'")
@@ -126,10 +123,7 @@ def test_create_custom_lambda_resource__verify_cfnresponse_failed():
assert original_event["ResourceProperties"]["MyProperty"] == "stuff"
-@mock_cloudformation
-@mock_lambda
-@mock_logs
-@mock_s3
+@mock_aws
def test_create_custom_lambda_resource__verify_manual_request():
#########
# Integration test using a Custom Resource
@@ -174,8 +168,16 @@ def test_create_custom_lambda_resource__verify_manual_request():
{"OutputKey": "infokey", "OutputValue": "resultfromthirdpartysystem"}
]
+ # AWSlambda will not have logged anything
+ log_group_name = get_log_group_name(cf=cf, stack_name=stack_name)
+ success, logs = wait_for_log_msg(
+ expected_msg="Status code: 200", log_group=log_group_name, wait_time=5
+ )
+ assert success is False
+ assert len(logs) == 0
-@mock_cloudformation
+
+@mock_aws
def test_create_custom_lambda_resource__unknown_arn():
# Try to create a Lambda with an unknown ARN
# Verify that this fails in a predictable manner
diff --git a/tests/test_cloudformation/test_cloudformation_depends_on.py b/tests/test_cloudformation/test_cloudformation_depends_on.py
index ed2d2f81b..dfff59d78 100644
--- a/tests/test_cloudformation/test_cloudformation_depends_on.py
+++ b/tests/test_cloudformation/test_cloudformation_depends_on.py
@@ -2,7 +2,7 @@ import json
import boto3
-from moto import mock_autoscaling, mock_cloudformation, mock_ecs, mock_s3
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
@@ -88,9 +88,7 @@ depends_on_template_list_json = json.dumps(depends_on_template_list)
depends_on_template_string_json = json.dumps(depends_on_template_string)
-@mock_cloudformation
-@mock_autoscaling
-@mock_ecs
+@mock_aws
def test_create_stack_with_depends_on():
boto3.client("cloudformation", region_name="us-east-1").create_stack(
StackName="depends_on_test", TemplateBody=depends_on_template_list_json
@@ -116,8 +114,7 @@ def test_create_stack_with_depends_on():
assert cluster_arn == f"arn:aws:ecs:us-east-1:{ACCOUNT_ID}:cluster/test-cluster"
-@mock_cloudformation
-@mock_autoscaling
+@mock_aws
def test_create_stack_with_depends_on_string():
boto3.client("cloudformation", region_name="us-east-1").create_stack(
StackName="depends_on_string_test", TemplateBody=depends_on_template_string_json
@@ -139,8 +136,7 @@ def test_create_stack_with_depends_on_string():
assert launch_configuration["LaunchConfigurationName"] == "test-launch-config"
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_create_chained_depends_on_stack():
boto3.client("cloudformation", region_name="us-east-1").create_stack(
StackName="linked_depends_on_test",
diff --git a/tests/test_cloudformation/test_cloudformation_multi_accounts.py b/tests/test_cloudformation/test_cloudformation_multi_accounts.py
index 633bc42c9..56f5b6349 100644
--- a/tests/test_cloudformation/test_cloudformation_multi_accounts.py
+++ b/tests/test_cloudformation/test_cloudformation_multi_accounts.py
@@ -6,7 +6,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudformation, mock_organizations, mock_sqs, settings
+from moto import mock_aws, settings
from moto.cloudformation import cloudformation_backends as cf_backends
from moto.core import DEFAULT_ACCOUNT_ID
from moto.sqs import sqs_backends
@@ -103,9 +103,7 @@ class TestStackSetMultipleAccounts(TestCase):
)
-@mock_cloudformation
-@mock_organizations
-@mock_sqs
+@mock_aws
class TestServiceManagedStacks(TestStackSetMultipleAccounts):
def setUp(self) -> None:
super().setUp()
@@ -191,9 +189,7 @@ class TestServiceManagedStacks(TestStackSetMultipleAccounts):
self._verify_queues(self.acct22, ["testqueue"])
-@mock_cloudformation
-@mock_organizations
-@mock_sqs
+@mock_aws
class TestSelfManagedStacks(TestStackSetMultipleAccounts):
def setUp(self) -> None:
super().setUp()
diff --git a/tests/test_cloudformation/test_cloudformation_nested_stacks.py b/tests/test_cloudformation/test_cloudformation_nested_stacks.py
index 6095e7b22..563e7d605 100644
--- a/tests/test_cloudformation/test_cloudformation_nested_stacks.py
+++ b/tests/test_cloudformation/test_cloudformation_nested_stacks.py
@@ -3,11 +3,10 @@ from uuid import uuid4
import boto3
-from moto import mock_cloudformation, mock_s3
+from moto import mock_aws
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_create_basic_stack():
# Create inner template
cf = boto3.client("cloudformation", "us-east-1")
@@ -43,8 +42,7 @@ def test_create_basic_stack():
assert len(stacks) == 2
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_create_stack_with_params():
# Create inner template
cf = boto3.client("cloudformation", "us-east-1")
@@ -67,8 +65,7 @@ def test_create_stack_with_params():
assert bucket_names == sorted([cf_storage_bucket, bucket_created_by_cf])
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_update_stack_with_params():
# Create inner template
cf = boto3.client("cloudformation", "us-east-1")
@@ -100,8 +97,7 @@ def test_update_stack_with_params():
assert bucket_names == sorted([cf_storage_bucket, second_bucket])
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_delete_basic_stack():
# Create inner template
cf = boto3.client("cloudformation", "us-east-1")
diff --git a/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py b/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py
index 9e3002b5d..d6c37aa67 100644
--- a/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py
+++ b/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py
@@ -9,17 +9,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import (
- mock_cloudformation,
- mock_dynamodb,
- mock_ec2,
- mock_iam,
- mock_lambda,
- mock_s3,
- mock_sns,
- mock_sqs,
- settings,
-)
+from moto import mock_aws, settings
from moto.cloudformation import cloudformation_backends
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
@@ -325,8 +315,7 @@ dummy_template_json4 = json.dumps(dummy_template4)
dummy_unknown_template_json = json.dumps(dummy_unknown_template)
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_create_stack():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -338,7 +327,7 @@ def test_create_stack():
assert template == dummy_template
-@mock_cloudformation
+@mock_aws
def test_create_stack_with_additional_properties():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(
@@ -353,8 +342,7 @@ def test_create_stack_with_additional_properties():
assert stack["TimeoutInMinutes"] == 25
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_describe_stack_instances():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="teststackset", TemplateBody=dummy_template_json)
@@ -382,7 +370,7 @@ def test_describe_stack_instances():
assert instance["StackInstanceStatus"] == {"DetailedStatus": "SUCCEEDED"}
-@mock_cloudformation
+@mock_aws
def test_list_stacksets_length():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="teststackset", TemplateBody=dummy_template_json)
@@ -391,7 +379,7 @@ def test_list_stacksets_length():
assert len(stacksets) == 2
-@mock_cloudformation
+@mock_aws
def test_filter_stacks():
conn = boto3.client("cloudformation", region_name=REGION_NAME)
conn.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -404,7 +392,7 @@ def test_filter_stacks():
assert len(stacks.get("StackSummaries")) == 1
-@mock_cloudformation
+@mock_aws
def test_list_stacksets_contents():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="teststackset", TemplateBody=dummy_template_json)
@@ -413,7 +401,7 @@ def test_list_stacksets_contents():
assert stacksets["Summaries"][0]["Status"] == "ACTIVE"
-@mock_cloudformation
+@mock_aws
def test_stop_stack_set_operation():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="teststackset", TemplateBody=dummy_template_json)
@@ -430,7 +418,7 @@ def test_stop_stack_set_operation():
assert list_operation["Summaries"][-1]["Status"] == "STOPPED"
-@mock_cloudformation
+@mock_aws
def test_describe_stack_set_operation():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="name", TemplateBody=dummy_template_json)
@@ -459,7 +447,7 @@ def test_describe_stack_set_operation():
assert exp_metadata.get("HTTPStatusCode") == 400
-@mock_cloudformation
+@mock_aws
def test_list_stack_set_operation_results():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="teststackset", TemplateBody=dummy_template_json)
@@ -482,7 +470,7 @@ def test_list_stack_set_operation_results():
assert response["Summaries"][1]["Status"] == "STOPPED"
-@mock_cloudformation
+@mock_aws
def test_update_stack_instances():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
param = [
@@ -540,7 +528,7 @@ def test_update_stack_instances():
assert use1_instance["StackInstance"]["ParameterOverrides"] == []
-@mock_cloudformation
+@mock_aws
def test_delete_stack_instances():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
tss = "teststackset"
@@ -581,7 +569,7 @@ def test_delete_stack_instances():
assert len(remaining_stacks) == 0
-@mock_cloudformation
+@mock_aws
def test_create_stack_instances():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="teststackset", TemplateBody=dummy_template_json)
@@ -596,7 +584,7 @@ def test_create_stack_instances():
assert summaries[0]["Account"] == ACCOUNT_ID
-@mock_cloudformation
+@mock_aws
def test_create_stack_instances_with_param_overrides():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
param = [
@@ -631,7 +619,7 @@ def test_create_stack_instances_with_param_overrides():
assert usw2_overrides[1]["ParameterValue"] == param_overrides[1]["ParameterValue"]
-@mock_cloudformation
+@mock_aws
def test_update_stack_set():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
param = [
@@ -661,7 +649,7 @@ def test_update_stack_set():
assert stack_params[1]["ParameterKey"] == param_overrides[1]["ParameterKey"]
-@mock_cloudformation
+@mock_aws
def test_update_stack_set_with_previous_value():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
param = [
@@ -691,7 +679,7 @@ def test_update_stack_set_with_previous_value():
assert stack_params[1]["ParameterKey"] == param_overrides[1]["ParameterKey"]
-@mock_cloudformation
+@mock_aws
def test_list_stack_set_operations():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="teststackset", TemplateBody=dummy_template_json)
@@ -711,7 +699,7 @@ def test_list_stack_set_operations():
assert list_operation["Summaries"][-1]["Action"] == "UPDATE"
-@mock_cloudformation
+@mock_aws
def test_bad_list_stack_resources():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
@@ -719,7 +707,7 @@ def test_bad_list_stack_resources():
cf.list_stack_resources(StackName="teststackset")
-@mock_cloudformation
+@mock_aws
def test_delete_stack_set_by_name():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="teststackset", TemplateBody=dummy_template_json)
@@ -737,7 +725,7 @@ def test_delete_stack_set_by_name():
assert err["Message"] == "StackSet teststackset not found"
-@mock_cloudformation
+@mock_aws
def test_delete_stack_set_by_id():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
response = cf.create_stack_set(
@@ -752,7 +740,7 @@ def test_delete_stack_set_by_id():
assert stacks[0]["Status"] == "DELETED"
-@mock_cloudformation
+@mock_aws
def test_delete_stack_set__while_instances_are_running():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="a", TemplateBody=json.dumps(dummy_template3))
@@ -778,7 +766,7 @@ def test_delete_stack_set__while_instances_are_running():
cf.delete_stack_set(StackSetName="a")
-@mock_cloudformation
+@mock_aws
def test_create_stack_set():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
response = cf.create_stack_set(
@@ -795,7 +783,7 @@ def test_create_stack_set():
assert stack_set["Description"] == "desc"
-@mock_cloudformation
+@mock_aws
@pytest.mark.parametrize("name", ["1234", "stack_set", "-set"])
def test_create_stack_set__invalid_name(name):
client = boto3.client("cloudformation", region_name=REGION_NAME)
@@ -809,7 +797,7 @@ def test_create_stack_set__invalid_name(name):
)
-@mock_cloudformation
+@mock_aws
def test_create_stack_set_with_yaml():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack_set(StackSetName="tss", TemplateBody=dummy_template_yaml)
@@ -818,8 +806,7 @@ def test_create_stack_set_with_yaml():
assert tmplt == dummy_template_yaml
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_create_stack_set_from_s3_url():
s3 = boto3.client("s3", region_name=REGION_NAME)
s3_conn = boto3.resource("s3", region_name=REGION_NAME)
@@ -836,7 +823,7 @@ def test_create_stack_set_from_s3_url():
assert tmplt == dummy_template_json
-@mock_cloudformation
+@mock_aws
def test_create_stack_set_with_ref_yaml():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
params = [
@@ -853,7 +840,7 @@ def test_create_stack_set_with_ref_yaml():
assert tmplt == dummy_template_yaml_with_ref
-@mock_cloudformation
+@mock_aws
def test_describe_stack_set_params():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
params = [
@@ -870,7 +857,7 @@ def test_describe_stack_set_params():
assert stack_set["Parameters"] == params
-@mock_cloudformation
+@mock_aws
def test_describe_stack_set_by_id():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
ss_id = cf.create_stack_set(StackSetName="s", TemplateBody=dummy_template_json)[
@@ -881,7 +868,7 @@ def test_describe_stack_set_by_id():
assert stack_set["TemplateBody"] == dummy_template_json
-@mock_cloudformation
+@mock_aws
def test_create_stack_fail_missing_parameter():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
@@ -889,7 +876,7 @@ def test_create_stack_fail_missing_parameter():
cf.create_stack(StackName="ts", TemplateBody=dummy_parametrized_template_json)
-@mock_cloudformation
+@mock_aws
def test_create_stack_s3_long_name():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
@@ -913,7 +900,7 @@ def test_create_stack_s3_long_name():
assert bucket_name_stack_name_prefix in stack_name.lower()
-@mock_cloudformation
+@mock_aws
def test_create_stack_with_yaml():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName="ts", TemplateBody=dummy_template_yaml)
@@ -921,7 +908,7 @@ def test_create_stack_with_yaml():
assert cf.get_template(StackName="ts")["TemplateBody"] == dummy_template_yaml
-@mock_cloudformation
+@mock_aws
def test_create_stack_with_short_form_func_yaml():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(
@@ -932,8 +919,7 @@ def test_create_stack_with_short_form_func_yaml():
assert template_body == dummy_template_yaml_with_short_form_func
-@mock_s3
-@mock_cloudformation
+@mock_aws
def test_get_template_summary():
s3 = boto3.client("s3", region_name=REGION_NAME)
s3_conn = boto3.resource("s3", region_name=REGION_NAME)
@@ -976,7 +962,7 @@ def test_get_template_summary():
assert result["Description"] == "Stack1 with yaml template"
-@mock_cloudformation
+@mock_aws
def test_get_template_summary_for_stack_created_by_changeset_execution():
conn = boto3.client("cloudformation", region_name=REGION_NAME)
conn.create_change_set(
@@ -997,8 +983,7 @@ def test_get_template_summary_for_stack_created_by_changeset_execution():
assert result["Description"] == "Stack 3"
-@mock_s3
-@mock_cloudformation
+@mock_aws
def test_get_template_summary_for_template_containing_parameters():
conn = boto3.client("cloudformation", region_name=REGION_NAME)
conn.create_stack(
@@ -1040,7 +1025,7 @@ def test_get_template_summary_for_template_containing_parameters():
}
-@mock_cloudformation
+@mock_aws
def test_create_stack_with_ref_yaml():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
params = [
@@ -1057,7 +1042,7 @@ def test_create_stack_with_ref_yaml():
assert template_body == dummy_template_yaml_with_ref
-@mock_cloudformation
+@mock_aws
def test_creating_stacks_across_regions():
west1_cf = boto3.resource("cloudformation", region_name="us-west-1")
west2_cf = boto3.resource("cloudformation", region_name="us-west-2")
@@ -1077,9 +1062,7 @@ def test_creating_stacks_across_regions():
)
-@mock_cloudformation
-@mock_sns
-@mock_sqs
+@mock_aws
def test_create_stack_with_notification_arn():
sqs = boto3.resource("sqs", region_name=REGION_NAME)
queue = sqs.create_queue(QueueName="fake-queue")
@@ -1139,7 +1122,7 @@ def test_create_stack_with_notification_arn():
assert "UnsubscribeURL" in msg
-@mock_cloudformation
+@mock_aws
def test_create_stack_with_role_arn():
cf = boto3.resource("cloudformation", region_name=REGION_NAME)
cf.create_stack(
@@ -1151,8 +1134,7 @@ def test_create_stack_with_role_arn():
assert stack.role_arn == f"arn:aws:iam::{ACCOUNT_ID}:role/moto"
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_create_stack_from_s3_url():
s3 = boto3.client("s3", region_name=REGION_NAME)
s3_conn = boto3.resource("s3", region_name=REGION_NAME)
@@ -1169,7 +1151,7 @@ def test_create_stack_from_s3_url():
assert tmplt == json.loads(dummy_template_json, object_pairs_hook=OrderedDict)
-@mock_cloudformation
+@mock_aws
def test_update_stack_fail_missing_new_parameter():
name = "update_stack_fail_missing_new_parameter"
@@ -1181,7 +1163,7 @@ def test_update_stack_fail_missing_new_parameter():
cf.update_stack(StackName=name, TemplateBody=dummy_parametrized_template_json)
-@mock_cloudformation
+@mock_aws
def test_update_stack_fail_update_same_template_body():
name = "update_stack_with_previous_value"
cf = boto3.client("cloudformation", region_name=REGION_NAME)
@@ -1215,7 +1197,7 @@ def test_update_stack_fail_update_same_template_body():
)
-@mock_cloudformation
+@mock_aws
def test_update_stack_deleted_resources_can_reference_deleted_parameters():
name = "update_stack_deleted_resources_can_reference_deleted_parameters"
@@ -1245,7 +1227,7 @@ def test_update_stack_deleted_resources_can_reference_deleted_parameters():
assert len(response["StackResources"]) == 0
-@mock_cloudformation
+@mock_aws
def test_update_stack_deleted_resources_can_reference_deleted_resources():
name = "update_stack_deleted_resources_can_reference_deleted_resources"
@@ -1279,7 +1261,7 @@ def test_update_stack_deleted_resources_can_reference_deleted_resources():
assert len(response["StackResources"]) == 0
-@mock_cloudformation
+@mock_aws
def test_update_stack_with_previous_value():
name = "update_stack_with_previous_value"
cf = boto3.client("cloudformation", region_name=REGION_NAME)
@@ -1314,9 +1296,7 @@ def test_update_stack_with_previous_value():
assert tag_desc == "not bar"
-@mock_cloudformation
-@mock_s3
-@mock_ec2
+@mock_aws
def test_update_stack_from_s3_url():
s3 = boto3.client("s3", region_name=REGION_NAME)
s3_conn = boto3.resource("s3", region_name=REGION_NAME)
@@ -1347,8 +1327,7 @@ def test_update_stack_from_s3_url():
)
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_create_change_set_from_s3_url():
s3 = boto3.client("s3", region_name=REGION_NAME)
s3_conn = boto3.resource("s3", region_name=REGION_NAME)
@@ -1384,8 +1363,7 @@ def test_create_change_set_from_s3_url():
pytest.param(dummy_template_yaml, dummy_update_template_yaml),
],
)
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_describe_change_set(stack_template, change_template):
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_change_set(
@@ -1451,8 +1429,7 @@ def test_describe_change_set(stack_template, change_template):
assert stack["StackStatus"] == "UPDATE_COMPLETE"
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_execute_change_set_w_arn():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
ec2 = boto3.client("ec2", region_name=REGION_NAME)
@@ -1474,7 +1451,7 @@ def test_execute_change_set_w_arn():
assert len(ec2.describe_instances()["Reservations"]) == 1
-@mock_cloudformation
+@mock_aws
def test_execute_change_set_w_name():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_change_set(
@@ -1486,7 +1463,7 @@ def test_execute_change_set_w_name():
cf.execute_change_set(ChangeSetName="NewChangeSet", StackName="NewStack")
-@mock_cloudformation
+@mock_aws
def test_describe_stack_pagination():
conn = boto3.client("cloudformation", region_name=REGION_NAME)
for i in range(100):
@@ -1503,7 +1480,7 @@ def test_describe_stack_pagination():
assert "NextToken" not in resp2.keys()
-@mock_cloudformation
+@mock_aws
def test_describe_stack_resource():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -1521,7 +1498,7 @@ def test_describe_stack_resource():
assert resource["StackId"] == stack["StackId"]
-@mock_cloudformation
+@mock_aws
def test_describe_stack_resource_when_resource_does_not_exist():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -1534,7 +1511,7 @@ def test_describe_stack_resource_when_resource_does_not_exist():
)
-@mock_cloudformation
+@mock_aws
def test_describe_stack_resources():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -1549,7 +1526,7 @@ def test_describe_stack_resources():
assert resource["StackId"] == stack["StackId"]
-@mock_cloudformation
+@mock_aws
def test_describe_stack_by_name():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -1562,7 +1539,7 @@ def test_describe_stack_by_name():
), "Stack should have been created recently"
-@mock_cloudformation
+@mock_aws
def test_describe_stack_by_stack_id():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -1574,7 +1551,7 @@ def test_describe_stack_by_stack_id():
assert stack_by_id["StackName"] == TEST_STACK_NAME
-@mock_cloudformation
+@mock_aws
def test_list_change_sets():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_change_set(
@@ -1588,7 +1565,7 @@ def test_list_change_sets():
assert change_set["ChangeSetName"] == "NewChangeSet2"
-@mock_cloudformation
+@mock_aws
def test_list_stacks():
cf = boto3.resource("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -1601,7 +1578,7 @@ def test_list_stacks():
assert "test_stack2" in stack_names
-@mock_cloudformation
+@mock_aws
def test_delete_stack_from_resource():
cf = boto3.resource("cloudformation", region_name=REGION_NAME)
stack = cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -1611,8 +1588,7 @@ def test_delete_stack_from_resource():
assert len(list(cf.stacks.all())) == 0
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_delete_change_set():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_change_set(
@@ -1637,8 +1613,7 @@ def test_delete_change_set():
assert len(cf.list_change_sets(StackName="NewStack")["Summaries"]) == 0
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_create_change_set_twice__no_changes():
cf_client = boto3.client("cloudformation", region_name=REGION_NAME)
@@ -1669,9 +1644,7 @@ def test_create_change_set_twice__no_changes():
)
-@mock_cloudformation
-@mock_ec2
-@mock_s3
+@mock_aws
def test_create_change_set_twice__using_s3__no_changes():
cf_client = boto3.client("cloudformation", region_name=REGION_NAME)
s3 = boto3.client("s3", region_name=REGION_NAME)
@@ -1716,8 +1689,7 @@ def test_create_change_set_twice__using_s3__no_changes():
)
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_delete_stack_by_name():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -1727,8 +1699,7 @@ def test_delete_stack_by_name():
assert len(cf.describe_stacks()["Stacks"]) == 0
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_delete_stack():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
ec2 = boto3.client("ec2", region_name=REGION_NAME)
@@ -1742,8 +1713,7 @@ def test_delete_stack():
assert ec2.describe_instances()["Reservations"][0]["Instances"][0]["State"] != state
-@mock_cloudformation
-@mock_ec2
+@mock_aws
@pytest.mark.skipif(
settings.TEST_SERVER_MODE,
reason="Can't patch model delete attributes in server mode.",
@@ -1768,7 +1738,7 @@ def test_delete_stack_delete_not_implemented(monkeypatch):
assert ec2.describe_instances()["Reservations"][0]["Instances"][0]["State"] == state
-@mock_cloudformation
+@mock_aws
def test_describe_deleted_stack():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -1782,7 +1752,7 @@ def test_describe_deleted_stack():
assert stack_by_id["StackStatus"] == "DELETE_COMPLETE"
-@mock_cloudformation
+@mock_aws
def test_describe_stack_with_special_chars():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(
@@ -1795,8 +1765,7 @@ def test_describe_stack_with_special_chars():
assert stack.get("Description") == "Stack 1 "
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_describe_updated_stack():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(
@@ -1827,7 +1796,7 @@ def test_describe_updated_stack():
assert template == dummy_update_template
-@mock_cloudformation
+@mock_aws
def test_update_stack_with_previous_template():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -1842,7 +1811,7 @@ def test_update_stack_with_previous_template():
assert template == dummy_template
-@mock_cloudformation
+@mock_aws
def test_bad_describe_stack():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
with pytest.raises(ClientError) as exc:
@@ -1852,7 +1821,7 @@ def test_bad_describe_stack():
assert err["Message"] == "Stack with id non_existent_stack does not exist"
-@mock_cloudformation
+@mock_aws
def test_cloudformation_params():
dummy_template_with_params = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1881,8 +1850,7 @@ def test_cloudformation_params():
assert param["ParameterValue"] == "testing123"
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_update_stack_with_parameters():
template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1916,8 +1884,7 @@ def test_update_stack_with_parameters():
}
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_update_stack_replace_tags():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(
@@ -1936,7 +1903,7 @@ def test_update_stack_replace_tags():
assert stack["Tags"] == [{"Key": "foo", "Value": "baz"}]
-@mock_cloudformation
+@mock_aws
def test_update_stack_when_rolled_back():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cant manipulate backend in server mode")
@@ -1956,8 +1923,7 @@ def test_update_stack_when_rolled_back():
assert "is in ROLLBACK_COMPLETE state and can not be updated." in err["Message"]
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_cloudformation_params_conditions_and_resources_are_distinct():
template_with_conditions = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1994,8 +1960,7 @@ def test_cloudformation_params_conditions_and_resources_are_distinct():
]
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_cloudformation_conditions_yaml_equals():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(
@@ -2011,8 +1976,7 @@ def test_cloudformation_conditions_yaml_equals():
]
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_cloudformation_conditions_yaml_equals_shortform():
_template = dummy_yaml_template_with_equals
_template = _template.replace("Fn::Equals:", "!Equals")
@@ -2030,7 +1994,7 @@ def test_cloudformation_conditions_yaml_equals_shortform():
]
-@mock_cloudformation
+@mock_aws
def test_stack_tags():
tags = [{"Key": "foo", "Value": "bar"}, {"Key": "baz", "Value": "bleh"}]
cf = boto3.resource("cloudformation", region_name=REGION_NAME)
@@ -2046,8 +2010,7 @@ def test_stack_tags():
assert observed_tag_items == expected_tag_items
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_stack_events():
cf = boto3.resource("cloudformation", region_name=REGION_NAME)
stack = cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -2105,7 +2068,7 @@ def test_stack_events():
assert exp_metadata.get("HTTPStatusCode") == 400
-@mock_cloudformation
+@mock_aws
def test_list_exports():
cf_client = boto3.client("cloudformation", region_name=REGION_NAME)
cf_resource = boto3.resource("cloudformation", region_name=REGION_NAME)
@@ -2124,7 +2087,7 @@ def test_list_exports():
assert exports[0]["Value"] == output_value
-@mock_cloudformation
+@mock_aws
def test_list_exports_with_token():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
for i in range(101):
@@ -2143,7 +2106,7 @@ def test_list_exports_with_token():
assert more_exports.get("NextToken") is None
-@mock_cloudformation
+@mock_aws
def test_delete_stack_with_export():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
stack = cf.create_stack(
@@ -2158,7 +2121,7 @@ def test_delete_stack_with_export():
assert len(cf.list_exports()["Exports"]) == 0
-@mock_cloudformation
+@mock_aws
def test_export_names_must_be_unique():
cf = boto3.resource("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_output_template_json)
@@ -2168,8 +2131,7 @@ def test_export_names_must_be_unique():
)
-@mock_sqs
-@mock_cloudformation
+@mock_aws
def test_stack_with_imports():
cf = boto3.resource("cloudformation", region_name=REGION_NAME)
ec2_resource = boto3.resource("sqs", region_name=REGION_NAME)
@@ -2184,8 +2146,7 @@ def test_stack_with_imports():
assert ec2_resource.get_queue_by_name(QueueName=output)
-@mock_sqs
-@mock_cloudformation
+@mock_aws
def test_non_json_redrive_policy():
cf = boto3.resource("cloudformation", region_name=REGION_NAME)
@@ -2197,7 +2158,7 @@ def test_non_json_redrive_policy():
assert stack.Resource("DeadLetterQueue").resource_status == "CREATE_COMPLETE"
-@mock_cloudformation
+@mock_aws
def test_create_duplicate_stack():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
@@ -2206,8 +2167,7 @@ def test_create_duplicate_stack():
cf.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json)
-@mock_dynamodb
-@mock_cloudformation
+@mock_aws
def test_delete_stack_dynamo_template():
conn = boto3.client("cloudformation", region_name=REGION_NAME)
dynamodb_client = boto3.client("dynamodb", region_name=REGION_NAME)
@@ -2220,9 +2180,7 @@ def test_delete_stack_dynamo_template():
conn.create_stack(StackName=TEST_STACK_NAME, TemplateBody=dummy_template_json4)
-@mock_dynamodb
-@mock_cloudformation
-@mock_lambda
+@mock_aws
def test_create_stack_lambda_and_dynamodb():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cant set environment variables in server mode")
@@ -2295,8 +2253,7 @@ def test_create_stack_lambda_and_dynamodb():
assert "AWS::Lambda::EventSourceMapping" in resource_types
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_create_and_update_stack_with_unknown_resource():
cf = boto3.client("cloudformation", region_name=REGION_NAME)
# Creating a stack with an unknown resource should throw a warning
@@ -2332,7 +2289,7 @@ def test_create_and_update_stack_with_unknown_resource():
def get_role_name():
- with mock_iam():
+ with mock_aws():
iam = boto3.client("iam", region_name=REGION_NAME)
try:
return iam.get_role(RoleName="my-role")["Role"]["Arn"]
diff --git a/tests/test_cloudformation/test_cloudformation_stack_integration.py b/tests/test_cloudformation/test_cloudformation_stack_integration.py
index 9d605c6fb..534ec31f7 100644
--- a/tests/test_cloudformation/test_cloudformation_stack_integration.py
+++ b/tests/test_cloudformation/test_cloudformation_stack_integration.py
@@ -8,27 +8,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import (
- mock_autoscaling,
- mock_cloudformation,
- mock_dynamodb,
- mock_ec2,
- mock_elbv2,
- mock_events,
- mock_kms,
- mock_lambda,
- mock_logs,
- mock_s3,
- mock_sqs,
- mock_ssm,
-)
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID, EXAMPLE_AMI_ID2
from tests.markers import requires_docker
from tests.test_cloudformation.fixtures import fn_join, single_instance_with_ebs_volume
-@mock_cloudformation
+@mock_aws
def test_create_template_without_required_param_boto3():
template_json = json.dumps(single_instance_with_ebs_volume.template)
cf = boto3.client("cloudformation", region_name="us-west-1")
@@ -39,8 +26,7 @@ def test_create_template_without_required_param_boto3():
assert err["Message"] == "Missing parameter KeyName"
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_fn_join_boto3():
template_json = json.dumps(fn_join.template)
cf = boto3.client("cloudformation", region_name="us-west-1")
@@ -53,8 +39,7 @@ def test_fn_join_boto3():
assert fn_join_output["OutputValue"] == f"test eip:{eip['PublicIp']}"
-@mock_cloudformation
-@mock_sqs
+@mock_aws
def test_conditional_resources_boto3():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -89,8 +74,7 @@ def test_conditional_resources_boto3():
assert len(sqs.list_queues()["QueueUrls"]) == 1
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_conditional_if_handling_boto3():
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -133,8 +117,7 @@ def test_conditional_if_handling_boto3():
assert ec2_instance["ImageId"] == EXAMPLE_AMI_ID
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_cloudformation_mapping_boto3():
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -175,8 +158,7 @@ def test_cloudformation_mapping_boto3():
assert ec2_instance["ImageId"] == EXAMPLE_AMI_ID2
-@mock_cloudformation
-@mock_lambda
+@mock_aws
@requires_docker
def test_lambda_function():
# switch this to python as backend lambda only supports python execution.
@@ -254,9 +236,7 @@ def _make_zipfile(func_str):
return zip_output.read()
-@mock_cloudformation
-@mock_s3
-@mock_lambda
+@mock_aws
def test_lambda_layer():
# switch this to python as backend lambda only supports python execution.
layer_code = """
@@ -308,8 +288,7 @@ def lambda_handler(event, context):
]
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_nat_gateway():
ec2_conn = boto3.client("ec2", "us-east-1")
vpc_id = ec2_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]["VpcId"]
@@ -371,8 +350,7 @@ def test_nat_gateway():
assert "rtb-" in route_resource["PhysicalResourceId"]
-@mock_cloudformation()
-@mock_kms()
+@mock_aws
def test_stack_kms():
kms_key_template = {
"Resources": {
@@ -401,8 +379,7 @@ def test_stack_kms():
assert result["KeyMetadata"]["KeyUsage"] == "ENCRYPT_DECRYPT"
-@mock_cloudformation()
-@mock_ec2()
+@mock_aws
def test_stack_spot_fleet():
conn = boto3.client("ec2", "us-east-1")
@@ -486,8 +463,7 @@ def test_stack_spot_fleet():
assert launch_spec["WeightedCapacity"] == 2.0
-@mock_cloudformation()
-@mock_ec2()
+@mock_aws
def test_stack_spot_fleet_should_figure_out_default_price():
conn = boto3.client("ec2", "us-east-1")
@@ -560,9 +536,7 @@ def test_stack_spot_fleet_should_figure_out_default_price():
assert "SpotPrice" not in launch_spec2
-@mock_ec2
-@mock_elbv2
-@mock_cloudformation
+@mock_aws
def test_invalid_action_type_listener_rule():
invalid_listener_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -628,10 +602,7 @@ def test_invalid_action_type_listener_rule():
assert err["Code"] == "ValidationError"
-@mock_ec2
-@mock_elbv2
-@mock_cloudformation
-@mock_events
+@mock_aws
def test_update_stack_listener_and_rule():
initial_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -726,9 +697,7 @@ def test_update_stack_listener_and_rule():
assert l_rule[0]["Conditions"] == [{"Field": "host-header", "Values": ["*"]}]
-@mock_ec2
-@mock_elbv2
-@mock_cloudformation
+@mock_aws
def test_stack_elbv2_resources_integration():
alb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -965,8 +934,7 @@ def test_stack_elbv2_resources_integration():
assert name["OutputValue"] == lbs[0]["LoadBalancerName"]
-@mock_dynamodb
-@mock_cloudformation
+@mock_aws
def test_stack_dynamodb_resources_integration():
dynamodb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1070,9 +1038,7 @@ def test_stack_dynamodb_resources_integration():
assert response["Item"]["Album"] == "myAlbum"
-@mock_cloudformation
-@mock_logs
-@mock_s3
+@mock_aws
def test_create_log_group_using_fntransform():
s3_resource = boto3.resource("s3")
s3_resource.create_bucket(
@@ -1113,8 +1079,7 @@ def test_create_log_group_using_fntransform():
assert log_group["logGroupName"] == "some-log-group"
-@mock_cloudformation
-@mock_logs
+@mock_aws
def test_create_cloudwatch_logs_resource_policy():
policy_document = json.dumps(
{
@@ -1191,8 +1156,7 @@ def test_create_cloudwatch_logs_resource_policy():
assert policies[0]["policyDocument"] == policy_document
-@mock_cloudformation
-@mock_logs
+@mock_aws
def test_delete_stack_containing_cloudwatch_logs_resource_policy():
template1 = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1219,8 +1183,7 @@ def test_delete_stack_containing_cloudwatch_logs_resource_policy():
assert len(policies) == 0
-@mock_cloudformation
-@mock_sqs
+@mock_aws
def test_delete_stack_with_deletion_policy_boto3():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1247,8 +1210,7 @@ def test_delete_stack_with_deletion_policy_boto3():
assert len(sqs.list_queues()["QueueUrls"]) == 1
-@mock_cloudformation
-@mock_events
+@mock_aws
def test_stack_events_create_rule_integration():
events_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1275,8 +1237,7 @@ def test_stack_events_create_rule_integration():
assert rules["Rules"][0]["ScheduleExpression"] == "rate(5 minutes)"
-@mock_cloudformation
-@mock_events
+@mock_aws
def test_stack_events_delete_rule_integration():
events_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1305,8 +1266,7 @@ def test_stack_events_delete_rule_integration():
assert len(rules["Rules"]) == 0
-@mock_cloudformation
-@mock_events
+@mock_aws
def test_stack_events_create_rule_without_name_integration():
events_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1329,9 +1289,7 @@ def test_stack_events_create_rule_without_name_integration():
assert "test_stack-Event-" in rules["Rules"][0]["Name"]
-@mock_cloudformation
-@mock_events
-@mock_logs
+@mock_aws
def test_stack_events_create_rule_as_target():
events_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1366,8 +1324,7 @@ def test_stack_events_create_rule_as_target():
assert log_groups["logGroups"][0]["retentionInDays"] == 3
-@mock_cloudformation
-@mock_events
+@mock_aws
def test_stack_events_update_rule_integration():
events_template = Template(
"""{
@@ -1405,8 +1362,7 @@ def test_stack_events_update_rule_integration():
assert rules["Rules"][0]["State"] == "DISABLED"
-@mock_cloudformation
-@mock_autoscaling
+@mock_aws
def test_autoscaling_propagate_tags():
autoscaling_group_with_tags = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1475,8 +1431,7 @@ def test_autoscaling_propagate_tags():
assert not propagation_dict["test-key-no-propagate"]
-@mock_cloudformation
-@mock_events
+@mock_aws
def test_stack_eventbus_create_from_cfn_integration():
eventbus_template = """{
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1501,8 +1456,7 @@ def test_stack_eventbus_create_from_cfn_integration():
assert event_buses["EventBuses"][0]["Name"] == "MyCustomEventBus"
-@mock_cloudformation
-@mock_events
+@mock_aws
def test_stack_events_delete_eventbus_integration():
eventbus_template = """{
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1531,8 +1485,7 @@ def test_stack_events_delete_eventbus_integration():
assert len(event_buses["EventBuses"]) == 0
-@mock_cloudformation
-@mock_events
+@mock_aws
def test_stack_events_delete_from_cfn_integration():
eventbus_template = Template(
"""{
@@ -1574,8 +1527,7 @@ def test_stack_events_delete_from_cfn_integration():
assert update_event_buses["EventBuses"][0]["Arn"] != original_eventbus["Arn"]
-@mock_cloudformation
-@mock_events
+@mock_aws
def test_stack_events_update_from_cfn_integration():
eventbus_template = Template(
"""{
@@ -1614,8 +1566,7 @@ def test_stack_events_update_from_cfn_integration():
assert update_event_buses["EventBuses"][0]["Arn"] != original_eventbus["Arn"]
-@mock_cloudformation
-@mock_events
+@mock_aws
def test_stack_events_get_attribute_integration():
eventbus_template = """{
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1650,8 +1601,7 @@ def test_stack_events_get_attribute_integration():
assert output_name["OutputValue"] == event_bus["Name"]
-@mock_cloudformation
-@mock_dynamodb
+@mock_aws
def test_dynamodb_table_creation():
CFN_TEMPLATE = {
"Outputs": {"MyTableName": {"Value": {"Ref": "MyTable"}}},
@@ -1686,8 +1636,7 @@ def test_dynamodb_table_creation():
assert table_names == [outputs[0]["OutputValue"]]
-@mock_cloudformation
-@mock_ssm
+@mock_aws
def test_ssm_parameter():
parameter_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1724,8 +1673,7 @@ def test_ssm_parameter():
assert parameters[0]["Value"] == "Test SSM Parameter"
-@mock_cloudformation
-@mock_ssm
+@mock_aws
def test_ssm_parameter_update_stack():
parameter_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1771,8 +1719,7 @@ def test_ssm_parameter_update_stack():
assert parameters[0]["Value"] == "Test SSM Parameter Updated"
-@mock_cloudformation
-@mock_ssm
+@mock_aws
def test_ssm_parameter_update_stack_and_remove_resource():
parameter_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -1814,8 +1761,7 @@ def test_ssm_parameter_update_stack_and_remove_resource():
assert len(parameters) == 0
-@mock_cloudformation
-@mock_ssm
+@mock_aws
def test_ssm_parameter_update_stack_and_add_resource():
parameter_template = {"AWSTemplateFormatVersion": "2010-09-09", "Resources": {}}
stack_name = "test_stack"
diff --git a/tests/test_cloudformation/test_cloudformation_stack_policies.py b/tests/test_cloudformation/test_cloudformation_stack_policies.py
index fa124eef1..fbe15f52b 100644
--- a/tests/test_cloudformation/test_cloudformation_stack_policies.py
+++ b/tests/test_cloudformation/test_cloudformation_stack_policies.py
@@ -4,12 +4,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudformation, mock_s3
+from moto import mock_aws
from .test_cloudformation_stack_crud_boto3 import dummy_template_json
-@mock_cloudformation
+@mock_aws
def test_set_stack_policy_on_nonexisting_stack():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
@@ -21,7 +21,7 @@ def test_set_stack_policy_on_nonexisting_stack():
assert err["Type"] == "Sender"
-@mock_cloudformation
+@mock_aws
def test_get_stack_policy_on_nonexisting_stack():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
@@ -33,7 +33,7 @@ def test_get_stack_policy_on_nonexisting_stack():
assert err["Type"] == "Sender"
-@mock_cloudformation
+@mock_aws
def test_get_stack_policy_on_stack_without_policy():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
cf_conn.create_stack(StackName="test_stack", TemplateBody=dummy_template_json)
@@ -42,7 +42,7 @@ def test_get_stack_policy_on_stack_without_policy():
assert "StackPolicyBody" not in resp
-@mock_cloudformation
+@mock_aws
def test_set_stack_policy_with_both_body_and_url():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
cf_conn.create_stack(StackName="test_stack", TemplateBody=dummy_template_json)
@@ -59,7 +59,7 @@ def test_set_stack_policy_with_both_body_and_url():
assert err["Type"] == "Sender"
-@mock_cloudformation
+@mock_aws
def test_set_stack_policy_with_body():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
cf_conn.create_stack(StackName="test_stack", TemplateBody=dummy_template_json)
@@ -72,7 +72,7 @@ def test_set_stack_policy_with_body():
assert resp["StackPolicyBody"] == policy
-@mock_cloudformation
+@mock_aws
def test_set_stack_policy_on_create():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
cf_conn.create_stack(
@@ -85,8 +85,7 @@ def test_set_stack_policy_on_create():
assert resp["StackPolicyBody"] == "stack_policy_body"
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_set_stack_policy_with_url():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
cf_conn.create_stack(StackName="test_stack", TemplateBody=dummy_template_json)
@@ -105,8 +104,7 @@ def test_set_stack_policy_with_url():
assert resp["StackPolicyBody"] == policy
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_set_stack_policy_with_url_pointing_to_unknown_key():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
cf_conn.create_stack(StackName="test_stack", TemplateBody=dummy_template_json)
diff --git a/tests/test_cloudformation/test_import_value.py b/tests/test_cloudformation/test_import_value.py
index 6675373a2..0182ea0ee 100644
--- a/tests/test_cloudformation/test_import_value.py
+++ b/tests/test_cloudformation/test_import_value.py
@@ -6,7 +6,7 @@ import boto3
from botocore.exceptions import ClientError
# Package modules
-from moto import mock_cloudformation
+from moto import mock_aws
AWS_REGION = "us-west-1"
@@ -61,7 +61,7 @@ Resources:
class TestSimpleInstance(unittest.TestCase):
def test_simple_instance(self):
"""Test that we can create a simple CloudFormation stack that imports values from an existing CloudFormation stack"""
- with mock_cloudformation():
+ with mock_aws():
client = boto3.client("cloudformation", region_name=AWS_REGION)
client.create_stack(StackName=SG_STACK_NAME, TemplateBody=SG_TEMPLATE)
response = client.create_stack(
@@ -77,7 +77,7 @@ class TestSimpleInstance(unittest.TestCase):
def test_simple_instance_missing_export(self):
"""Test that we get an exception if a CloudFormation stack tries to imports a non-existent export value"""
- with mock_cloudformation():
+ with mock_aws():
client = boto3.client("cloudformation", region_name=AWS_REGION)
with self.assertRaises(ClientError) as e:
client.create_stack(StackName=EC2_STACK_NAME, TemplateBody=EC2_TEMPLATE)
diff --git a/tests/test_cloudformation/test_stack_parsing.py b/tests/test_cloudformation/test_stack_parsing.py
index 505d8eb9f..5585d5c8e 100644
--- a/tests/test_cloudformation/test_stack_parsing.py
+++ b/tests/test_cloudformation/test_stack_parsing.py
@@ -6,7 +6,7 @@ import pytest
import yaml
from botocore.exceptions import ClientError
-from moto import mock_cloudformation, mock_sqs, mock_ssm, settings
+from moto import mock_aws, settings
from moto.cloudformation.exceptions import ValidationError
from moto.cloudformation.models import FakeStack
from moto.cloudformation.parsing import (
@@ -392,8 +392,7 @@ def test_parse_stack_with_get_availability_zones():
assert output.value == ["us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d"]
-@mock_sqs
-@mock_cloudformation
+@mock_aws
def test_parse_stack_with_bad_get_attribute_outputs_using_boto3():
conn = boto3.client("cloudformation", region_name="us-west-1")
with pytest.raises(ClientError) as exc:
@@ -702,7 +701,7 @@ def test_short_form_func_in_yaml_teamplate():
assert template_dict[k] == v
-@mock_ssm
+@mock_aws
def test_ssm_parameter_parsing():
client = boto3.client("ssm", region_name="us-west-1")
client.put_parameter(Name="/path/to/single/param", Value="string", Type="String")
diff --git a/tests/test_cloudformation/test_validate.py b/tests/test_cloudformation/test_validate.py
index 58bedc030..ffdde144b 100644
--- a/tests/test_cloudformation/test_validate.py
+++ b/tests/test_cloudformation/test_validate.py
@@ -4,7 +4,7 @@ import boto3
import botocore
import pytest
-from moto import mock_cloudformation, mock_s3
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
json_template = {
@@ -43,7 +43,7 @@ dummy_template_json = json.dumps(json_template)
dummy_bad_template_json = json.dumps(json_bad_template)
-@mock_cloudformation
+@mock_aws
def test_boto3_json_validate_successful():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
response = cf_conn.validate_template(TemplateBody=dummy_template_json)
@@ -52,7 +52,7 @@ def test_boto3_json_validate_successful():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_cloudformation
+@mock_aws
def test_boto3_json_with_tabs_validate_successful():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
response = cf_conn.validate_template(TemplateBody=json_valid_template_with_tabs)
@@ -61,7 +61,7 @@ def test_boto3_json_with_tabs_validate_successful():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_cloudformation
+@mock_aws
def test_boto3_json_invalid_missing_resource():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
with pytest.raises(botocore.exceptions.ClientError) as exc:
@@ -89,7 +89,7 @@ yaml_bad_template = """
"""
-@mock_cloudformation
+@mock_aws
def test_boto3_yaml_validate_successful():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
response = cf_conn.validate_template(TemplateBody=yaml_template)
@@ -98,8 +98,7 @@ def test_boto3_yaml_validate_successful():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_cloudformation
-@mock_s3
+@mock_aws
def test_boto3_yaml_validate_template_url_successful():
s3 = boto3.client("s3", region_name="us-east-1")
s3_conn = boto3.resource("s3", region_name="us-east-1")
@@ -117,7 +116,7 @@ def test_boto3_yaml_validate_template_url_successful():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_cloudformation
+@mock_aws
def test_boto3_yaml_invalid_missing_resource():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
with pytest.raises(botocore.exceptions.ClientError) as exc:
diff --git a/tests/test_cloudfront/test_cloudfront.py b/tests/test_cloudfront/test_cloudfront.py
index 04884d7a1..178ea583d 100644
--- a/tests/test_cloudfront/test_cloudfront.py
+++ b/tests/test_cloudfront/test_cloudfront.py
@@ -1,9 +1,8 @@
-"""Unit tests for cloudfront-supported APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError, ParamValidationError
-from moto import mock_cloudfront
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from . import cloudfront_test_scaffolding as scaffold
@@ -12,7 +11,7 @@ from . import cloudfront_test_scaffolding as scaffold
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_cloudfront
+@mock_aws
def test_update_distribution():
client = boto3.client("cloudfront", region_name="us-east-1")
@@ -123,7 +122,7 @@ def test_update_distribution():
assert restriction["Quantity"] == 0
-@mock_cloudfront
+@mock_aws
def test_update_distribution_no_such_distId():
client = boto3.client("cloudfront", region_name="us-east-1")
@@ -151,7 +150,7 @@ def test_update_distribution_no_such_distId():
assert err["Message"] == "The specified distribution does not exist."
-@mock_cloudfront
+@mock_aws
def test_update_distribution_distId_is_None():
client = boto3.client("cloudfront", region_name="us-east-1")
@@ -178,7 +177,7 @@ def test_update_distribution_distId_is_None():
assert error.exconly() == error_str
-@mock_cloudfront
+@mock_aws
def test_update_distribution_IfMatch_not_set():
client = boto3.client("cloudfront", region_name="us-east-1")
@@ -206,7 +205,7 @@ def test_update_distribution_IfMatch_not_set():
assert err["Message"] == msg
-@mock_cloudfront
+@mock_aws
def test_update_distribution_dist_config_not_set():
client = boto3.client("cloudfront", region_name="us-east-1")
@@ -227,7 +226,7 @@ def test_update_distribution_dist_config_not_set():
assert error.exconly() == error_str
-@mock_cloudfront
+@mock_aws
def test_update_default_root_object():
client = boto3.client("cloudfront", region_name="us-east-1")
diff --git a/tests/test_cloudfront/test_cloudfront_dist_tags.py b/tests/test_cloudfront/test_cloudfront_dist_tags.py
index 5d1906ccd..def254631 100644
--- a/tests/test_cloudfront/test_cloudfront_dist_tags.py
+++ b/tests/test_cloudfront/test_cloudfront_dist_tags.py
@@ -1,11 +1,11 @@
import boto3
-from moto import mock_cloudfront
+from moto import mock_aws
from . import cloudfront_test_scaffolding as scaffold
-@mock_cloudfront
+@mock_aws
def test_create_distribution_with_tags():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -20,7 +20,7 @@ def test_create_distribution_with_tags():
assert {"Key": "k2", "Value": "v2"} in resp["Tags"]["Items"]
-@mock_cloudfront
+@mock_aws
def test_create_distribution_with_tags_only_one_tag():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
diff --git a/tests/test_cloudfront/test_cloudfront_distributions.py b/tests/test_cloudfront/test_cloudfront_distributions.py
index 45fc528f9..1ad6d5b7a 100644
--- a/tests/test_cloudfront/test_cloudfront_distributions.py
+++ b/tests/test_cloudfront/test_cloudfront_distributions.py
@@ -2,13 +2,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudfront
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from . import cloudfront_test_scaffolding as scaffold
-@mock_cloudfront
+@mock_aws
def test_create_distribution_s3_minimum():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -119,7 +119,7 @@ def test_create_distribution_s3_minimum():
assert config["WebACLId"] == ""
-@mock_cloudfront
+@mock_aws
def test_create_distribution_with_logging():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -141,7 +141,7 @@ def test_create_distribution_with_logging():
}
-@mock_cloudfront
+@mock_aws
def test_create_distribution_with_web_acl():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -153,7 +153,7 @@ def test_create_distribution_with_web_acl():
assert config["WebACLId"] == "test-web-acl"
-@mock_cloudfront
+@mock_aws
def test_create_distribution_with_field_level_encryption_and_real_time_log_config_arn():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -170,7 +170,7 @@ def test_create_distribution_with_field_level_encryption_and_real_time_log_confi
assert default_cache["RealtimeLogConfigArn"] == real_time_log_config_arn
-@mock_cloudfront
+@mock_aws
def test_create_distribution_with_georestriction():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -192,7 +192,7 @@ def test_create_distribution_with_georestriction():
assert "GB" in restriction["Items"]
-@mock_cloudfront
+@mock_aws
def test_create_distribution_with_allowed_methods():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -219,7 +219,7 @@ def test_create_distribution_with_allowed_methods():
}
-@mock_cloudfront
+@mock_aws
def test_create_distribution_with_origins():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -238,7 +238,7 @@ def test_create_distribution_with_origins():
assert origin["OriginShield"] == {"Enabled": True, "OriginShieldRegion": "east"}
-@mock_cloudfront
+@mock_aws
@pytest.mark.parametrize("compress", [True, False])
@pytest.mark.parametrize("qs", [True, False])
@pytest.mark.parametrize("smooth", [True, False])
@@ -280,7 +280,7 @@ def test_create_distribution_with_additional_fields(
assert forwarded["Cookies"]["WhitelistedNames"]["Items"] == ["x-amz-header"]
-@mock_cloudfront
+@mock_aws
def test_create_distribution_returns_etag():
client = boto3.client("cloudfront", region_name="us-east-1")
@@ -296,7 +296,7 @@ def test_create_distribution_returns_etag():
)
-@mock_cloudfront
+@mock_aws
def test_create_distribution_needs_unique_caller_reference():
client = boto3.client("cloudfront", region_name="us-east-1")
@@ -325,7 +325,7 @@ def test_create_distribution_needs_unique_caller_reference():
assert len(resp["Items"]) == 2
-@mock_cloudfront
+@mock_aws
def test_get_distribution_config_with_unknown_distribution_id():
client = boto3.client("cloudfront", region_name="us-west-1")
@@ -339,7 +339,7 @@ def test_get_distribution_config_with_unknown_distribution_id():
assert err["Message"] == "The specified distribution does not exist."
-@mock_cloudfront
+@mock_aws
def test_get_distribution_config_with_mismatched_originid():
client = boto3.client("cloudfront", region_name="us-west-1")
@@ -368,7 +368,7 @@ def test_get_distribution_config_with_mismatched_originid():
)
-@mock_cloudfront
+@mock_aws
def test_create_origin_without_origin_config():
client = boto3.client("cloudfront", region_name="us-west-1")
@@ -398,7 +398,7 @@ def test_create_origin_without_origin_config():
)
-@mock_cloudfront
+@mock_aws
def test_create_distribution_with_invalid_s3_bucket():
client = boto3.client("cloudfront", region_name="us-west-1")
@@ -435,7 +435,7 @@ def test_create_distribution_with_invalid_s3_bucket():
)
-@mock_cloudfront
+@mock_aws
@pytest.mark.parametrize("ssl_protocols", (["TLSv1"], ["TLSv1", "SSLv3"]))
def test_create_distribution_custom_config(ssl_protocols):
client = boto3.client("cloudfront", region_name="us-west-1")
@@ -458,7 +458,7 @@ def test_create_distribution_custom_config(ssl_protocols):
}
-@mock_cloudfront
+@mock_aws
def test_create_distribution_minimal_custom_config():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.minimal_dist_custom_config("ref")
@@ -480,7 +480,7 @@ def test_create_distribution_minimal_custom_config():
assert custom_config == get_custom_config
-@mock_cloudfront
+@mock_aws
def test_list_distributions_without_any():
client = boto3.client("cloudfront", region_name="us-east-1")
@@ -492,7 +492,7 @@ def test_list_distributions_without_any():
assert "Items" not in dlist
-@mock_cloudfront
+@mock_aws
def test_list_distributions():
client = boto3.client("cloudfront", region_name="us-east-1")
@@ -516,7 +516,7 @@ def test_list_distributions():
assert item2["Status"] == "Deployed"
-@mock_cloudfront
+@mock_aws
def test_get_distribution():
client = boto3.client("cloudfront", region_name="us-east-1")
@@ -538,7 +538,7 @@ def test_get_distribution():
assert config["CallerReference"] == "ref"
-@mock_cloudfront
+@mock_aws
def test_get_unknown_distribution():
client = boto3.client("cloudfront", region_name="us-west-1")
@@ -553,7 +553,7 @@ def test_get_unknown_distribution():
assert err["Message"] == "The specified distribution does not exist."
-@mock_cloudfront
+@mock_aws
def test_delete_unknown_distribution():
client = boto3.client("cloudfront", region_name="us-west-1")
@@ -567,7 +567,7 @@ def test_delete_unknown_distribution():
assert err["Message"] == "The specified distribution does not exist."
-@mock_cloudfront
+@mock_aws
def test_delete_distribution_without_ifmatch():
client = boto3.client("cloudfront", region_name="us-west-1")
@@ -585,7 +585,7 @@ def test_delete_distribution_without_ifmatch():
)
-@mock_cloudfront
+@mock_aws
def test_delete_distribution_random_etag():
"""
Etag validation is not implemented yet
@@ -606,7 +606,7 @@ def test_delete_distribution_random_etag():
assert err["Code"] == "NoSuchDistribution"
-@mock_cloudfront
+@mock_aws
def test_get_distribution_config():
client = boto3.client("cloudfront", region_name="us-east-1")
diff --git a/tests/test_cloudfront/test_cloudfront_invalidation.py b/tests/test_cloudfront/test_cloudfront_invalidation.py
index 3f92de7eb..655dbcb37 100644
--- a/tests/test_cloudfront/test_cloudfront_invalidation.py
+++ b/tests/test_cloudfront/test_cloudfront_invalidation.py
@@ -1,11 +1,11 @@
import boto3
-from moto import mock_cloudfront
+from moto import mock_aws
from . import cloudfront_test_scaffolding as scaffold
-@mock_cloudfront
+@mock_aws
def test_create_invalidation_with_single_path():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -32,7 +32,7 @@ def test_create_invalidation_with_single_path():
}
-@mock_cloudfront
+@mock_aws
def test_create_invalidation_with_multiple_paths():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -59,7 +59,7 @@ def test_create_invalidation_with_multiple_paths():
}
-@mock_cloudfront
+@mock_aws
def test_list_invalidations():
client = boto3.client("cloudfront", region_name="us-west-1")
config = scaffold.example_distribution_config("ref")
@@ -86,7 +86,7 @@ def test_list_invalidations():
assert resp["InvalidationList"]["Items"][0]["Status"] == "COMPLETED"
-@mock_cloudfront
+@mock_aws
def test_list_invalidations__no_entries():
client = boto3.client("cloudfront", region_name="us-west-1")
diff --git a/tests/test_cloudfront/test_cloudfront_oac.py b/tests/test_cloudfront/test_cloudfront_oac.py
index 073d57c75..a796c27b5 100644
--- a/tests/test_cloudfront/test_cloudfront_oac.py
+++ b/tests/test_cloudfront/test_cloudfront_oac.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudfront
+from moto import mock_aws
-@mock_cloudfront
+@mock_aws
def test_create_origin_access_control():
cf = boto3.client("cloudfront", "us-east-1")
@@ -46,7 +46,7 @@ def test_create_origin_access_control():
assert err["Message"] == "The specified origin access control does not exist."
-@mock_cloudfront
+@mock_aws
def test_update_origin_access_control():
# http://localhost:5000/2020-05-31/origin-access-control/DE53MREVCPIFL/config
cf = boto3.client("cloudfront", "us-east-1")
diff --git a/tests/test_cloudfront/test_server.py b/tests/test_cloudfront/test_server.py
index 09c7d7ed0..3337258dc 100644
--- a/tests/test_cloudfront/test_server.py
+++ b/tests/test_cloudfront/test_server.py
@@ -1,10 +1,10 @@
import xmltodict
import moto.server as server
-from moto import mock_cloudfront
+from moto import mock_aws
-@mock_cloudfront
+@mock_aws
def test_cloudfront_list():
backend = server.create_backend_app("cloudfront")
test_client = backend.test_client()
diff --git a/tests/test_cloudtrail/test_cloudtrail.py b/tests/test_cloudtrail/test_cloudtrail.py
index 7f25610c8..aa933f7e4 100644
--- a/tests/test_cloudtrail/test_cloudtrail.py
+++ b/tests/test_cloudtrail/test_cloudtrail.py
@@ -1,4 +1,3 @@
-"""Unit tests for cloudtrail-supported APIs."""
from datetime import datetime
from uuid import uuid4
@@ -6,12 +5,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudtrail, mock_s3, mock_sns
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_s3
-@mock_cloudtrail
+@mock_aws
def test_create_trail_without_bucket():
client = boto3.client("cloudtrail", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -49,7 +47,7 @@ def test_create_trail_without_bucket():
("-trail", "Trail name must starts with a letter or number."),
],
)
-@mock_cloudtrail
+@mock_aws
def test_create_trail_invalid_name(name, message):
client = boto3.client("cloudtrail", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -61,8 +59,7 @@ def test_create_trail_invalid_name(name, message):
assert err["Message"] == message
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_create_trail_simple():
bucket_name, resp, trail_name = create_trail_simple()
assert resp["Name"] == trail_name
@@ -90,7 +87,7 @@ def create_trail_simple(region_name="us-east-1"):
return bucket_name, resp, trail_name
-@mock_cloudtrail
+@mock_aws
def test_create_trail_multi_but_not_global():
client = boto3.client("cloudtrail", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -106,9 +103,7 @@ def test_create_trail_multi_but_not_global():
assert err["Message"] == "Multi-Region trail must include global service events."
-@mock_cloudtrail
-@mock_s3
-@mock_sns
+@mock_aws
def test_create_trail_with_nonexisting_topic():
client = boto3.client("cloudtrail", region_name="us-east-1")
s3 = boto3.client("s3", region_name="us-east-1")
@@ -127,9 +122,7 @@ def test_create_trail_with_nonexisting_topic():
)
-@mock_cloudtrail
-@mock_s3
-@mock_sns
+@mock_aws
def test_create_trail_advanced():
bucket_name, resp, sns_topic_name, trail_name = create_trail_advanced()
assert resp["Name"] == trail_name
@@ -176,7 +169,7 @@ def create_trail_advanced(region_name="us-east-1"):
return bucket_name, resp, sns_topic_name, trail_name
-@mock_cloudtrail
+@mock_aws
def test_get_trail_with_one_char():
client = boto3.client("cloudtrail", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -189,7 +182,7 @@ def test_get_trail_with_one_char():
)
-@mock_cloudtrail
+@mock_aws
def test_get_trail_unknown():
client = boto3.client("cloudtrail", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -199,8 +192,7 @@ def test_get_trail_unknown():
assert err["Message"] == f"Unknown trail: unknowntrail for the user: {ACCOUNT_ID}"
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_get_trail():
create_trail_simple()
client = boto3.client("cloudtrail", region_name="us-east-1")
@@ -214,7 +206,7 @@ def test_get_trail():
)
-@mock_cloudtrail
+@mock_aws
def test_get_trail_status_with_one_char():
client = boto3.client("cloudtrail", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -227,7 +219,7 @@ def test_get_trail_status_with_one_char():
)
-@mock_cloudtrail
+@mock_aws
def test_get_trail_status_unknown_trail():
client = boto3.client("cloudtrail", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -240,8 +232,7 @@ def test_get_trail_status_unknown_trail():
)
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_get_trail_status_inactive():
client = boto3.client("cloudtrail", region_name="us-east-1")
_, _, trail_name = create_trail_simple()
@@ -256,8 +247,7 @@ def test_get_trail_status_inactive():
assert "StartLoggingTime" not in status
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_get_trail_status_arn_inactive():
client = boto3.client("cloudtrail", region_name="us-east-1")
_, resp, _ = create_trail_simple()
@@ -272,8 +262,7 @@ def test_get_trail_status_arn_inactive():
assert "StartLoggingTime" not in status
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_get_trail_status_after_starting():
client = boto3.client("cloudtrail", region_name="eu-west-3")
_, _, trail_name = create_trail_simple(region_name="eu-west-3")
@@ -295,8 +284,7 @@ def test_get_trail_status_after_starting():
assert "StopLoggingTime" not in status
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_get_trail_status_after_starting_and_stopping():
client = boto3.client("cloudtrail", region_name="eu-west-3")
_, _, trail_name = create_trail_simple(region_name="eu-west-3")
@@ -320,9 +308,7 @@ def test_get_trail_status_after_starting_and_stopping():
assert "TimeLoggingStopped" in status # .equal("2021-10-13T15:03:21Z")
-@mock_cloudtrail
-@mock_s3
-@mock_sns
+@mock_aws
def test_get_trail_status_multi_region_not_from_the_home_region():
# CloudTrail client
client_us_east_1 = boto3.client("cloudtrail", region_name="us-east-1")
@@ -352,9 +338,7 @@ def test_get_trail_status_multi_region_not_from_the_home_region():
assert trail_status_us_east_1["IsLogging"]
-@mock_cloudtrail
-@mock_s3
-@mock_sns
+@mock_aws
def test_list_trails_different_home_region_one_multiregion():
client = boto3.client("cloudtrail", region_name="eu-west-3")
@@ -374,9 +358,7 @@ def test_list_trails_different_home_region_one_multiregion():
]
-@mock_cloudtrail
-@mock_s3
-@mock_sns
+@mock_aws
def test_list_trails_different_home_region_no_multiregion():
client = boto3.client("cloudtrail", region_name="eu-west-3")
@@ -390,9 +372,7 @@ def test_list_trails_different_home_region_no_multiregion():
assert len(all_trails) == 0
-@mock_cloudtrail
-@mock_s3
-@mock_sns
+@mock_aws
def test_describe_trails_without_shadowtrails():
client = boto3.client("cloudtrail", region_name="us-east-1")
_, trail1, _ = create_trail_simple()
@@ -433,9 +413,7 @@ def test_describe_trails_without_shadowtrails():
assert second_trail["IsOrganizationTrail"] is True
-@mock_cloudtrail
-@mock_s3
-@mock_sns
+@mock_aws
def test_describe_trails_with_shadowtrails_true():
# Same behaviour as if shadowtrails-parameter was not supplied
client = boto3.client("cloudtrail", region_name="us-east-1")
@@ -456,9 +434,7 @@ def test_describe_trails_with_shadowtrails_true():
assert len(trails) == 2
-@mock_cloudtrail
-@mock_s3
-@mock_sns
+@mock_aws
def test_describe_trails_with_shadowtrails_false():
# Only trails for the current region should now be returned
client = boto3.client("cloudtrail", region_name="us-east-1")
@@ -476,8 +452,7 @@ def test_describe_trails_with_shadowtrails_false():
assert [t["Name"] for t in trails] == [name3]
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_delete_trail():
client = boto3.client("cloudtrail", region_name="us-east-1")
_, _, name = create_trail_simple()
@@ -491,8 +466,7 @@ def test_delete_trail():
assert len(trails) == 0
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_update_trail_simple():
client = boto3.client("cloudtrail", region_name="ap-southeast-2")
bucket_name, trail, name = create_trail_simple(region_name="ap-southeast-2")
@@ -519,8 +493,7 @@ def test_update_trail_simple():
assert "SnsTopicARN" not in trail
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_update_trail_full():
client = boto3.client("cloudtrail", region_name="ap-southeast-1")
_, trail, name = create_trail_simple(region_name="ap-southeast-1")
diff --git a/tests/test_cloudtrail/test_cloudtrail_eventselectors.py b/tests/test_cloudtrail/test_cloudtrail_eventselectors.py
index ce1a55487..734ab185b 100644
--- a/tests/test_cloudtrail/test_cloudtrail_eventselectors.py
+++ b/tests/test_cloudtrail/test_cloudtrail_eventselectors.py
@@ -1,14 +1,13 @@
import boto3
import pytest
-from moto import mock_cloudtrail, mock_s3
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .test_cloudtrail import create_trail_simple
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_put_event_selectors():
client = boto3.client("cloudtrail", region_name="eu-west-1")
_, _, trail_name = create_trail_simple(region_name="eu-west-1")
@@ -39,8 +38,7 @@ def test_put_event_selectors():
assert "AdvancedEventSelectors" not in resp
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_put_event_selectors_advanced():
client = boto3.client("cloudtrail", region_name="eu-west-1")
_, _, trail_name = create_trail_simple(region_name="eu-west-1")
@@ -76,8 +74,7 @@ def test_put_event_selectors_advanced():
]
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_get_event_selectors_empty():
client = boto3.client("cloudtrail", region_name="ap-southeast-1")
_, _, trail_name = create_trail_simple(region_name="ap-southeast-1")
@@ -92,8 +89,7 @@ def test_get_event_selectors_empty():
assert resp["AdvancedEventSelectors"] == []
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_get_event_selectors():
client = boto3.client("cloudtrail", region_name="ap-southeast-2")
_, _, trail_name = create_trail_simple(region_name="ap-southeast-2")
@@ -128,8 +124,7 @@ def test_get_event_selectors():
]
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_get_event_selectors_multiple():
client = boto3.client("cloudtrail", region_name="ap-southeast-1")
_, _, trail_name = create_trail_simple(region_name="ap-southeast-1")
@@ -164,8 +159,7 @@ def test_get_event_selectors_multiple():
]
-@mock_cloudtrail
-@mock_s3
+@mock_aws
@pytest.mark.parametrize("using_arn", [True, False])
def test_put_insight_selectors(using_arn):
client = boto3.client("cloudtrail", region_name="us-east-2")
@@ -188,8 +182,7 @@ def test_put_insight_selectors(using_arn):
assert resp["InsightSelectors"] == [{"InsightType": "ApiCallRateInsight"}]
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_get_insight_selectors():
client = boto3.client("cloudtrail", region_name="eu-west-1")
_, resp, trail_name = create_trail_simple(region_name="eu-west-1")
diff --git a/tests/test_cloudtrail/test_cloudtrail_tags.py b/tests/test_cloudtrail/test_cloudtrail_tags.py
index d61f4f926..2492754b9 100644
--- a/tests/test_cloudtrail/test_cloudtrail_tags.py
+++ b/tests/test_cloudtrail/test_cloudtrail_tags.py
@@ -1,12 +1,11 @@
import boto3
-from moto import mock_cloudtrail, mock_s3, mock_sns
+from moto import mock_aws
from .test_cloudtrail import create_trail_advanced, create_trail_simple
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_add_tags():
client = boto3.client("cloudtrail", region_name="ap-southeast-1")
_, resp, _ = create_trail_simple(region_name="ap-southeast-1")
@@ -22,9 +21,7 @@ def test_add_tags():
}
-@mock_cloudtrail
-@mock_s3
-@mock_sns
+@mock_aws
def test_remove_tags():
client = boto3.client("cloudtrail", region_name="ap-southeast-1")
# Start with two tags
@@ -46,8 +43,7 @@ def test_remove_tags():
}
-@mock_cloudtrail
-@mock_s3
+@mock_aws
def test_create_trail_without_tags_and_list_tags():
client = boto3.client("cloudtrail", region_name="us-east-2")
_, resp, _ = create_trail_simple(region_name="us-east-2")
@@ -58,9 +54,7 @@ def test_create_trail_without_tags_and_list_tags():
assert resp["ResourceTagList"][0] == {"ResourceId": trail_arn, "TagsList": []}
-@mock_cloudtrail
-@mock_s3
-@mock_sns
+@mock_aws
def test_create_trail_with_tags_and_list_tags():
client = boto3.client("cloudtrail", region_name="us-east-2")
_, resp, _, _ = create_trail_advanced(region_name="us-east-2")
diff --git a/tests/test_cloudtrail/test_server.py b/tests/test_cloudtrail/test_server.py
index df0af5d70..5cb1b6dd7 100644
--- a/tests/test_cloudtrail/test_server.py
+++ b/tests/test_cloudtrail/test_server.py
@@ -2,10 +2,10 @@
import json
import moto.server as server
-from moto import mock_cloudtrail
+from moto import mock_aws
-@mock_cloudtrail
+@mock_aws
def test_cloudtrail_list():
backend = server.create_backend_app("cloudtrail")
test_client = backend.test_client()
diff --git a/tests/test_cloudwatch/test_cloudwatch_alarms.py b/tests/test_cloudwatch/test_cloudwatch_alarms.py
index 82ef5283e..172b6360a 100644
--- a/tests/test_cloudwatch/test_cloudwatch_alarms.py
+++ b/tests/test_cloudwatch/test_cloudwatch_alarms.py
@@ -1,10 +1,10 @@
import boto3
-from moto import mock_cloudwatch
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_cloudwatch
+@mock_aws
def test_create_alarm():
region = "eu-west-1"
cloudwatch = boto3.client("cloudwatch", region)
@@ -49,7 +49,7 @@ def test_create_alarm():
assert alarm["ActionsEnabled"] is True
-@mock_cloudwatch
+@mock_aws
def test_delete_alarm():
cloudwatch = boto3.client("cloudwatch", region_name="eu-central-1")
@@ -83,7 +83,7 @@ def test_delete_alarm():
assert len(alarms) == 0
-@mock_cloudwatch
+@mock_aws
def test_delete_alarms_without_error():
# given
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
@@ -92,7 +92,7 @@ def test_delete_alarms_without_error():
cloudwatch.delete_alarms(AlarmNames=["not-exists"])
-@mock_cloudwatch
+@mock_aws
def test_describe_alarms_for_metric():
conn = boto3.client("cloudwatch", region_name="eu-central-1")
conn.put_metric_alarm(
@@ -113,7 +113,7 @@ def test_describe_alarms_for_metric():
assert alarm["ActionsEnabled"] is True
-@mock_cloudwatch
+@mock_aws
def test_describe_alarms():
conn = boto3.client("cloudwatch", region_name="eu-central-1")
conn.put_metric_alarm(
@@ -199,7 +199,7 @@ def test_describe_alarms():
assert multiple_metric_alarm["ActionsEnabled"] is True
-@mock_cloudwatch
+@mock_aws
def test_alarm_state():
client = boto3.client("cloudwatch", region_name="eu-central-1")
diff --git a/tests/test_cloudwatch/test_cloudwatch_boto3.py b/tests/test_cloudwatch/test_cloudwatch_boto3.py
index 769ad1b25..a5d881ac5 100644
--- a/tests/test_cloudwatch/test_cloudwatch_boto3.py
+++ b/tests/test_cloudwatch/test_cloudwatch_boto3.py
@@ -10,12 +10,12 @@ from botocore.exceptions import ClientError
from dateutil.tz import tzutc
from freezegun import freeze_time
-from moto import mock_cloudwatch, mock_s3
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core.utils import utcnow
-@mock_cloudwatch
+@mock_aws
def test_put_metric_data_no_dimensions():
conn = boto3.client("cloudwatch", region_name="us-east-1")
@@ -27,7 +27,7 @@ def test_put_metric_data_no_dimensions():
assert {"Namespace": "tester", "MetricName": "metric", "Dimensions": []} in metrics
-@mock_cloudwatch
+@mock_aws
def test_put_metric_data_can_not_have_nan():
client = boto3.client("cloudwatch", region_name="us-west-2")
utc_now = datetime.now(tz=timezone.utc)
@@ -51,7 +51,7 @@ def test_put_metric_data_can_not_have_nan():
)
-@mock_cloudwatch
+@mock_aws
def test_put_metric_data_can_not_have_value_and_values():
client = boto3.client("cloudwatch", region_name="us-west-2")
utc_now = datetime.now(tz=timezone.utc)
@@ -76,7 +76,7 @@ def test_put_metric_data_can_not_have_value_and_values():
)
-@mock_cloudwatch
+@mock_aws
def test_put_metric_data_can_not_have_and_values_mismatched_counts():
client = boto3.client("cloudwatch", region_name="us-west-2")
utc_now = datetime.now(tz=timezone.utc)
@@ -101,7 +101,7 @@ def test_put_metric_data_can_not_have_and_values_mismatched_counts():
)
-@mock_cloudwatch
+@mock_aws
def test_put_metric_data_values_and_counts():
client = boto3.client("cloudwatch", region_name="us-west-2")
utc_now = datetime.now(tz=timezone.utc)
@@ -132,7 +132,7 @@ def test_put_metric_data_values_and_counts():
assert datapoint["Maximum"] == 10.0
-@mock_cloudwatch
+@mock_aws
def test_put_metric_data_values_without_counts():
client = boto3.client("cloudwatch", region_name="us-west-2")
utc_now = datetime.now(tz=timezone.utc)
@@ -162,7 +162,7 @@ def test_put_metric_data_values_without_counts():
assert datapoint["Maximum"] == 23.45
-@mock_cloudwatch
+@mock_aws
def test_put_metric_data_value_and_statistics():
conn = boto3.client("cloudwatch", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -186,7 +186,7 @@ def test_put_metric_data_value_and_statistics():
)
-@mock_cloudwatch
+@mock_aws
def test_put_metric_data_with_statistics():
conn = boto3.client("cloudwatch", region_name="us-east-1")
utc_now = datetime.now(tz=timezone.utc)
@@ -262,7 +262,7 @@ def test_put_metric_data_with_statistics():
assert datapoint["Average"] == 56.0
-@mock_cloudwatch
+@mock_aws
def test_get_metric_statistics():
conn = boto3.client("cloudwatch", region_name="us-east-1")
utc_now = datetime.now(tz=timezone.utc)
@@ -287,7 +287,7 @@ def test_get_metric_statistics():
assert datapoint["Sum"] == 1.5
-@mock_cloudwatch
+@mock_aws
def test_get_metric_invalid_parameter_combination():
conn = boto3.client("cloudwatch", region_name="us-east-1")
utc_now = datetime.now(tz=timezone.utc)
@@ -312,7 +312,7 @@ def test_get_metric_invalid_parameter_combination():
assert err["Message"] == "Must specify either Statistics or ExtendedStatistics"
-@mock_cloudwatch
+@mock_aws
def test_get_metric_statistics_dimensions():
conn = boto3.client("cloudwatch", region_name="us-east-1")
utc_now = datetime.now(tz=timezone.utc)
@@ -381,7 +381,7 @@ def test_get_metric_statistics_dimensions():
assert datapoint["Average"] == params[2]
-@mock_cloudwatch
+@mock_aws
def test_get_metric_statistics_endtime_sooner_than_starttime():
# given
utc_now = datetime.now(tz=timezone.utc)
@@ -410,7 +410,7 @@ def test_get_metric_statistics_endtime_sooner_than_starttime():
)
-@mock_cloudwatch
+@mock_aws
def test_get_metric_statistics_starttime_endtime_equals():
# given
utc_now = datetime.now(tz=timezone.utc)
@@ -439,7 +439,7 @@ def test_get_metric_statistics_starttime_endtime_equals():
)
-@mock_cloudwatch
+@mock_aws
def test_get_metric_statistics_starttime_endtime_within_1_second():
# given
utc_now = datetime.now(tz=timezone.utc)
@@ -468,7 +468,7 @@ def test_get_metric_statistics_starttime_endtime_within_1_second():
)
-@mock_cloudwatch
+@mock_aws
def test_get_metric_statistics_starttime_endtime_ignore_miliseconds():
cloudwatch = boto3.client("cloudwatch", region_name="us-east-1")
utc_now = datetime.now(tz=timezone.utc)
@@ -499,7 +499,7 @@ def test_get_metric_statistics_starttime_endtime_ignore_miliseconds():
assert datapoint["Sum"] == 1.5
-@mock_cloudwatch
+@mock_aws
def test_duplicate_put_metric_data():
conn = boto3.client("cloudwatch", region_name="us-east-1")
utc_now = datetime.now(tz=timezone.utc)
@@ -594,7 +594,7 @@ def test_duplicate_put_metric_data():
]
-@mock_cloudwatch
+@mock_aws
@freeze_time("2020-02-10 18:44:05")
def test_custom_timestamp():
utc_now = datetime.now(tz=timezone.utc)
@@ -624,7 +624,7 @@ def test_custom_timestamp():
assert resp["Datapoints"] == []
-@mock_cloudwatch
+@mock_aws
def test_list_metrics():
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
# Verify namespace has to exist
@@ -653,7 +653,7 @@ def test_list_metrics():
assert res == []
-@mock_cloudwatch
+@mock_aws
def test_list_metrics_paginated():
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
# Verify that only a single page of metrics is returned
@@ -702,7 +702,7 @@ def test_list_metrics_paginated():
)
-@mock_cloudwatch
+@mock_aws
def test_list_metrics_without_value():
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
# Create some metrics to filter on
@@ -721,7 +721,7 @@ def test_list_metrics_without_value():
assert results[0]["Dimensions"] == [{"Name": "D1", "Value": "V1"}]
-@mock_cloudwatch
+@mock_aws
def test_list_metrics_with_same_dimensions_different_metric_name():
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
@@ -792,7 +792,7 @@ def create_metrics_with_dimensions(cloudwatch, namespace, data_points=5):
)
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_for_multiple_metrics_w_same_dimensions():
utc_now = datetime.now(tz=timezone.utc)
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
@@ -864,7 +864,7 @@ def test_get_metric_data_for_multiple_metrics_w_same_dimensions():
assert res2["Values"] == [25.0]
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_within_timeframe():
utc_now = datetime.now(tz=timezone.utc)
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
@@ -925,7 +925,7 @@ def test_get_metric_data_within_timeframe():
assert [int(val) for val in max_["Values"]] == [100]
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_partially_within_timeframe():
utc_now = datetime.now(tz=timezone.utc)
yesterday = utc_now - timedelta(days=1)
@@ -1049,7 +1049,7 @@ def test_get_metric_data_partially_within_timeframe():
assert response["MetricDataResults"][0]["Values"] == [10.0, 20.0, 10.0]
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_outside_timeframe():
utc_now = datetime.now(tz=timezone.utc)
last_week = utc_now - timedelta(days=7)
@@ -1090,7 +1090,7 @@ def test_get_metric_data_outside_timeframe():
assert response["MetricDataResults"][0]["Values"] == []
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_for_multiple_metrics():
utc_now = datetime.now(tz=timezone.utc)
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
@@ -1151,7 +1151,7 @@ def test_get_metric_data_for_multiple_metrics():
assert res2["Values"] == [25.0]
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_for_dimensions():
utc_now = datetime.now(tz=timezone.utc)
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
@@ -1259,7 +1259,7 @@ def test_get_metric_data_for_dimensions():
assert res4["Values"] == [75.0]
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_for_unit():
utc_now = datetime.now(tz=timezone.utc)
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
@@ -1331,7 +1331,7 @@ def test_get_metric_data_for_unit():
assert metric_result_data[0]["Values"][0] == expected_value
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_endtime_sooner_than_starttime():
# given
utc_now = datetime.now(tz=timezone.utc)
@@ -1367,7 +1367,7 @@ def test_get_metric_data_endtime_sooner_than_starttime():
assert err["Message"] == "The parameter EndTime must be greater than StartTime."
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_starttime_endtime_equals():
# given
utc_now = datetime.now(tz=timezone.utc)
@@ -1403,7 +1403,7 @@ def test_get_metric_data_starttime_endtime_equals():
assert err["Message"] == "The parameter StartTime must not equal parameter EndTime."
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_starttime_endtime_within_1_second():
# given
utc_now = datetime.now(tz=timezone.utc)
@@ -1441,7 +1441,7 @@ def test_get_metric_data_starttime_endtime_within_1_second():
)
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_starttime_endtime_ignore_miliseconds():
utc_now = datetime.now(tz=timezone.utc).replace(microsecond=200 * 1000)
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
@@ -1482,8 +1482,7 @@ def test_get_metric_data_starttime_endtime_ignore_miliseconds():
assert response["MetricDataResults"][0]["Values"][0] == 1.0
-@mock_cloudwatch
-@mock_s3
+@mock_aws
def test_cloudwatch_return_s3_metrics():
utc_now = datetime.now(tz=timezone.utc)
bucket_name = "examplebucket"
@@ -1567,7 +1566,7 @@ def test_cloudwatch_return_s3_metrics():
s3_client.delete_bucket(Bucket=bucket_name)
-@mock_cloudwatch
+@mock_aws
def test_put_metric_alarm():
# given
region_name = "eu-central-1"
@@ -1635,7 +1634,7 @@ def test_put_metric_alarm():
assert alarm["TreatMissingData"] == "notBreaching"
-@mock_cloudwatch
+@mock_aws
def test_put_metric_alarm_with_percentile():
# given
region_name = "eu-central-1"
@@ -1697,7 +1696,7 @@ def test_put_metric_alarm_with_percentile():
assert alarm["EvaluateLowSampleCountPercentile"] == "ignore"
-@mock_cloudwatch
+@mock_aws
def test_put_metric_alarm_with_anomaly_detection():
# given
region_name = "eu-central-1"
@@ -1756,7 +1755,7 @@ def test_put_metric_alarm_with_anomaly_detection():
assert alarm["ThresholdMetricId"] == "t1"
-@mock_cloudwatch
+@mock_aws
def test_put_metric_alarm_error_extended_statistic():
# given
region_name = "eu-central-1"
@@ -1795,7 +1794,7 @@ def test_put_metric_alarm_error_extended_statistic():
)
-@mock_cloudwatch
+@mock_aws
def test_put_metric_alarm_error_evaluate_low_sample_count_percentile():
# given
region_name = "eu-central-1"
@@ -1836,7 +1835,7 @@ def test_put_metric_alarm_error_evaluate_low_sample_count_percentile():
)
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_with_custom_label():
utc_now = datetime.now(tz=timezone.utc)
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
@@ -1907,7 +1906,7 @@ def test_get_metric_data_with_custom_label():
assert metric_result_data[0]["Label"] == expected_value
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_queries():
"""
verify that >= 10 queries can still be parsed
diff --git a/tests/test_cloudwatch/test_cloudwatch_dashboards.py b/tests/test_cloudwatch/test_cloudwatch_dashboards.py
index 6f107ffc1..80d3f79ca 100644
--- a/tests/test_cloudwatch/test_cloudwatch_dashboards.py
+++ b/tests/test_cloudwatch/test_cloudwatch_dashboards.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudwatch
+from moto import mock_aws
-@mock_cloudwatch
+@mock_aws
def test_put_list_dashboard():
client = boto3.client("cloudwatch", region_name="eu-central-1")
widget = '{"widgets": [{"type": "text", "x": 0, "y": 7, "width": 3, "height": 3, "properties": {"markdown": "Hello world"}}]}'
@@ -16,7 +16,7 @@ def test_put_list_dashboard():
assert len(resp["DashboardEntries"]) == 1
-@mock_cloudwatch
+@mock_aws
def test_put_list_prefix_nomatch_dashboard():
client = boto3.client("cloudwatch", region_name="eu-central-1")
widget = '{"widgets": [{"type": "text", "x": 0, "y": 7, "width": 3, "height": 3, "properties": {"markdown": "Hello world"}}]}'
@@ -27,7 +27,7 @@ def test_put_list_prefix_nomatch_dashboard():
assert len(resp["DashboardEntries"]) == 0
-@mock_cloudwatch
+@mock_aws
def test_delete_dashboard():
client = boto3.client("cloudwatch", region_name="eu-central-1")
widget = '{"widgets": [{"type": "text", "x": 0, "y": 7, "width": 3, "height": 3, "properties": {"markdown": "Hello world"}}]}'
@@ -41,7 +41,7 @@ def test_delete_dashboard():
assert len(resp["DashboardEntries"]) == 1
-@mock_cloudwatch
+@mock_aws
def test_delete_dashboard_fail():
client = boto3.client("cloudwatch", region_name="eu-central-1")
widget = '{"widgets": [{"type": "text", "x": 0, "y": 7, "width": 3, "height": 3, "properties": {"markdown": "Hello world"}}]}'
@@ -58,7 +58,7 @@ def test_delete_dashboard_fail():
assert len(resp["DashboardEntries"]) == 3
-@mock_cloudwatch
+@mock_aws
def test_get_dashboard():
client = boto3.client("cloudwatch", region_name="eu-central-1")
widget = '{"widgets": [{"type": "text", "x": 0, "y": 7, "width": 3, "height": 3, "properties": {"markdown": "Hello world"}}]}'
@@ -70,7 +70,7 @@ def test_get_dashboard():
assert resp["DashboardName"] == "test1"
-@mock_cloudwatch
+@mock_aws
def test_get_dashboard_fail():
client = boto3.client("cloudwatch", region_name="eu-central-1")
diff --git a/tests/test_cloudwatch/test_cloudwatch_expressions.py b/tests/test_cloudwatch/test_cloudwatch_expressions.py
index 16dfdbaaa..d2f9bce68 100644
--- a/tests/test_cloudwatch/test_cloudwatch_expressions.py
+++ b/tests/test_cloudwatch/test_cloudwatch_expressions.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudwatch
+from moto import mock_aws
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data__no_metric_data_or_expression():
utc_now = datetime.now(tz=timezone.utc)
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
@@ -26,7 +26,7 @@ def test_get_metric_data__no_metric_data_or_expression():
)
-@mock_cloudwatch
+@mock_aws
def test_get_metric_data_with_simple_expression():
utc_now = datetime.now(tz=timezone.utc)
cloudwatch = boto3.client("cloudwatch", "eu-west-1")
diff --git a/tests/test_cloudwatch/test_cloudwatch_tags.py b/tests/test_cloudwatch/test_cloudwatch_tags.py
index b3c9445df..4eac59820 100644
--- a/tests/test_cloudwatch/test_cloudwatch_tags.py
+++ b/tests/test_cloudwatch/test_cloudwatch_tags.py
@@ -4,12 +4,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudwatch
+from moto import mock_aws
from moto.cloudwatch.utils import make_arn_for_alarm
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_cloudwatch
+@mock_aws
def test_list_tags_for_resource():
# given
client = boto3.client("cloudwatch", region_name="eu-central-1")
@@ -42,7 +42,7 @@ def test_list_tags_for_resource():
assert response["Tags"] == [{"Key": "key-1", "Value": "value-1"}]
-@mock_cloudwatch
+@mock_aws
def test_list_tags_for_resource_with_unknown_resource():
# given
region_name = "eu-central-1"
@@ -59,7 +59,7 @@ def test_list_tags_for_resource_with_unknown_resource():
assert response["Tags"] == []
-@mock_cloudwatch
+@mock_aws
def test_tag_resource():
# given
client = boto3.client("cloudwatch", region_name="eu-central-1")
@@ -96,7 +96,7 @@ def test_tag_resource():
]
-@mock_cloudwatch
+@mock_aws
def test_tag_resource_on_resource_without_tags():
cw = boto3.client("cloudwatch", region_name="eu-central-1")
cw.put_metric_alarm(
@@ -118,7 +118,7 @@ def test_tag_resource_on_resource_without_tags():
assert len(cw.list_tags_for_resource(ResourceARN=alarm_arn)["Tags"]) == 1
-@mock_cloudwatch
+@mock_aws
def test_tag_resource_error_not_exists():
# given
region_name = "eu-central-1"
@@ -141,7 +141,7 @@ def test_tag_resource_error_not_exists():
assert ex.response["Error"]["Message"] == "Unknown"
-@mock_cloudwatch
+@mock_aws
def test_untag_resource():
# given
client = boto3.client("cloudwatch", region_name="eu-central-1")
@@ -178,7 +178,7 @@ def test_untag_resource():
assert response["Tags"] == [{"Key": "key-1", "Value": "value-1"}]
-@mock_cloudwatch
+@mock_aws
def test_untag_resource_error_not_exists():
# given
region_name = "eu-central-1"
diff --git a/tests/test_codebuild/test_codebuild.py b/tests/test_codebuild/test_codebuild.py
index a966099c2..057218eb1 100644
--- a/tests/test_codebuild/test_codebuild.py
+++ b/tests/test_codebuild/test_codebuild.py
@@ -4,11 +4,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError, ParamValidationError
-from moto import mock_codebuild
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_codebuild
+@mock_aws
def test_codebuild_create_project_s3_artifacts():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -52,7 +52,7 @@ def test_codebuild_create_project_s3_artifacts():
assert project["artifacts"] == {"location": "bucketname", "type": "S3"}
-@mock_codebuild
+@mock_aws
def test_codebuild_create_project_no_artifacts():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -94,7 +94,7 @@ def test_codebuild_create_project_no_artifacts():
assert project["artifacts"] == {"type": "NO_ARTIFACTS"}
-@mock_codebuild
+@mock_aws
def test_codebuild_create_project_with_invalid_inputs():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -126,7 +126,7 @@ def test_codebuild_create_project_with_invalid_inputs():
assert err.value.response["Error"]["Code"] == "InvalidInputException"
-@mock_codebuild
+@mock_aws
def test_codebuild_create_project_when_exists():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -164,7 +164,7 @@ def test_codebuild_create_project_when_exists():
assert err.value.response["Error"]["Code"] == "ResourceAlreadyExistsException"
-@mock_codebuild
+@mock_aws
def test_codebuild_list_projects():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -205,7 +205,7 @@ def test_codebuild_list_projects():
assert projects["projects"] == ["project1", "project2"]
-@mock_codebuild
+@mock_aws
def test_codebuild_list_builds_for_project_no_history():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -237,7 +237,7 @@ def test_codebuild_list_builds_for_project_no_history():
assert history["ids"] == []
-@mock_codebuild
+@mock_aws
def test_codebuild_list_builds_for_project_with_history():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -270,7 +270,7 @@ def test_codebuild_list_builds_for_project_with_history():
# project never started
-@mock_codebuild
+@mock_aws
def test_codebuild_get_batch_builds_for_project_no_history():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -305,7 +305,7 @@ def test_codebuild_get_batch_builds_for_project_no_history():
assert err.typename == "ParamValidationError"
-@mock_codebuild
+@mock_aws
def test_codebuild_start_build_no_project():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -316,7 +316,7 @@ def test_codebuild_start_build_no_project():
assert err.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_codebuild
+@mock_aws
def test_codebuild_start_build_no_overrides():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -347,7 +347,7 @@ def test_codebuild_start_build_no_overrides():
assert response["build"]["sourceVersion"] == "refs/heads/main"
-@mock_codebuild
+@mock_aws
def test_codebuild_start_build_multiple_times():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -381,7 +381,7 @@ def test_codebuild_start_build_multiple_times():
assert len(client.list_builds()["ids"]) == 3
-@mock_codebuild
+@mock_aws
def test_codebuild_start_build_with_overrides():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -419,7 +419,7 @@ def test_codebuild_start_build_with_overrides():
assert response["build"]["sourceVersion"] == "fix/testing"
-@mock_codebuild
+@mock_aws
def test_codebuild_batch_get_builds_1_project():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -457,7 +457,7 @@ def test_codebuild_batch_get_builds_1_project():
assert len(response["builds"][0]["phases"]) == 11
-@mock_codebuild
+@mock_aws
def test_codebuild_batch_get_builds_2_projects():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -506,7 +506,7 @@ def test_codebuild_batch_get_builds_2_projects():
assert "project-2" in metadata[1]["id"]
-@mock_codebuild
+@mock_aws
def test_codebuild_batch_get_builds_invalid_build_id():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -515,7 +515,7 @@ def test_codebuild_batch_get_builds_invalid_build_id():
assert err.value.response["Error"]["Code"] == "InvalidInputException"
-@mock_codebuild
+@mock_aws
def test_codebuild_batch_get_builds_empty_build_id():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -524,7 +524,7 @@ def test_codebuild_batch_get_builds_empty_build_id():
assert err.typename == "ParamValidationError"
-@mock_codebuild
+@mock_aws
def test_codebuild_delete_project():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -562,7 +562,7 @@ def test_codebuild_delete_project():
assert err.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_codebuild
+@mock_aws
def test_codebuild_stop_build():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -596,7 +596,7 @@ def test_codebuild_stop_build():
assert response["build"]["buildStatus"] == "STOPPED"
-@mock_codebuild
+@mock_aws
def test_codebuild_stop_build_no_build():
client = boto3.client("codebuild", region_name="eu-central-1")
@@ -605,7 +605,7 @@ def test_codebuild_stop_build_no_build():
assert err.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_codebuild
+@mock_aws
def test_codebuild_stop_build_bad_uid():
client = boto3.client("codebuild", region_name="eu-central-1")
diff --git a/tests/test_codecommit/test_codecommit.py b/tests/test_codecommit/test_codecommit.py
index 24c6a23ad..1d90d0ab3 100644
--- a/tests/test_codecommit/test_codecommit.py
+++ b/tests/test_codecommit/test_codecommit.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_codecommit
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_codecommit
+@mock_aws
def test_create_repository():
client = boto3.client("codecommit", region_name="eu-central-1")
metadata = client.create_repository(
@@ -33,7 +33,7 @@ def test_create_repository():
assert metadata["accountId"] == ACCOUNT_ID
-@mock_codecommit
+@mock_aws
def test_create_repository_without_description():
client = boto3.client("codecommit", region_name="eu-central-1")
@@ -62,7 +62,7 @@ def test_create_repository_without_description():
assert metadata["accountId"] == ACCOUNT_ID
-@mock_codecommit
+@mock_aws
def test_create_repository_repository_name_exists():
client = boto3.client("codecommit", region_name="eu-central-1")
@@ -83,7 +83,7 @@ def test_create_repository_repository_name_exists():
)
-@mock_codecommit
+@mock_aws
def test_create_repository_invalid_repository_name():
client = boto3.client("codecommit", region_name="eu-central-1")
@@ -99,7 +99,7 @@ def test_create_repository_invalid_repository_name():
)
-@mock_codecommit
+@mock_aws
def test_get_repository():
client = boto3.client("codecommit", region_name="eu-central-1")
@@ -143,7 +143,7 @@ def test_get_repository():
assert ex.response["Error"]["Message"] == f"{repository_name} does not exist"
-@mock_codecommit
+@mock_aws
def test_get_repository_invalid_repository_name():
client = boto3.client("codecommit", region_name="eu-central-1")
@@ -158,7 +158,7 @@ def test_get_repository_invalid_repository_name():
)
-@mock_codecommit
+@mock_aws
def test_delete_repository():
client = boto3.client("codecommit", region_name="us-east-1")
@@ -176,7 +176,7 @@ def test_delete_repository():
assert response.get("repositoryId") is None
-@mock_codecommit
+@mock_aws
def test_delete_repository_invalid_repository_name():
client = boto3.client("codecommit", region_name="us-east-1")
diff --git a/tests/test_codepipeline/test_codepipeline.py b/tests/test_codepipeline/test_codepipeline.py
index 7b1b8a12f..7e14935c6 100644
--- a/tests/test_codepipeline/test_codepipeline.py
+++ b/tests/test_codepipeline/test_codepipeline.py
@@ -6,7 +6,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_codepipeline, mock_iam
+from moto import mock_aws
expected_pipeline_details = {
"name": "test-pipeline",
@@ -60,7 +60,7 @@ expected_pipeline_details = {
}
-@mock_codepipeline
+@mock_aws
def test_create_pipeline():
client = boto3.client("codepipeline", region_name="us-east-1")
@@ -70,8 +70,7 @@ def test_create_pipeline():
assert response["tags"] == [{"key": "key", "value": "value"}]
-@mock_codepipeline
-@mock_iam
+@mock_aws
def test_create_pipeline_errors():
client = boto3.client("codepipeline", region_name="us-east-1")
client_iam = boto3.client("iam", region_name="us-east-1")
@@ -216,7 +215,7 @@ def test_create_pipeline_errors():
)
-@mock_codepipeline
+@mock_aws
def test_get_pipeline():
client = boto3.client("codepipeline", region_name="us-east-1")
create_basic_codepipeline(client, "test-pipeline")
@@ -232,7 +231,7 @@ def test_get_pipeline():
assert isinstance(response["metadata"]["updated"], datetime)
-@mock_codepipeline
+@mock_aws
def test_get_pipeline_errors():
client = boto3.client("codepipeline", region_name="us-east-1")
@@ -248,7 +247,7 @@ def test_get_pipeline_errors():
)
-@mock_codepipeline
+@mock_aws
def test_update_pipeline():
client = boto3.client("codepipeline", region_name="us-east-1")
create_basic_codepipeline(client, "test-pipeline")
@@ -359,7 +358,7 @@ def test_update_pipeline():
assert metadata["updated"] > updated_time
-@mock_codepipeline
+@mock_aws
def test_update_pipeline_errors():
client = boto3.client("codepipeline", region_name="us-east-1")
@@ -419,7 +418,7 @@ def test_update_pipeline_errors():
)
-@mock_codepipeline
+@mock_aws
def test_list_pipelines():
client = boto3.client("codepipeline", region_name="us-east-1")
name_1 = "test-pipeline-1"
@@ -440,7 +439,7 @@ def test_list_pipelines():
assert isinstance(response["pipelines"][1]["updated"], datetime)
-@mock_codepipeline
+@mock_aws
def test_delete_pipeline():
client = boto3.client("codepipeline", region_name="us-east-1")
name = "test-pipeline"
@@ -455,7 +454,7 @@ def test_delete_pipeline():
client.delete_pipeline(name=name)
-@mock_codepipeline
+@mock_aws
def test_list_tags_for_resource():
client = boto3.client("codepipeline", region_name="us-east-1")
name = "test-pipeline"
@@ -467,7 +466,7 @@ def test_list_tags_for_resource():
assert response["tags"] == [{"key": "key", "value": "value"}]
-@mock_codepipeline
+@mock_aws
def test_list_tags_for_resource_errors():
client = boto3.client("codepipeline", region_name="us-east-1")
@@ -485,7 +484,7 @@ def test_list_tags_for_resource_errors():
)
-@mock_codepipeline
+@mock_aws
def test_tag_resource():
client = boto3.client("codepipeline", region_name="us-east-1")
name = "test-pipeline"
@@ -505,7 +504,7 @@ def test_tag_resource():
]
-@mock_codepipeline
+@mock_aws
def test_tag_resource_errors():
client = boto3.client("codepipeline", region_name="us-east-1")
name = "test-pipeline"
@@ -554,7 +553,7 @@ def test_tag_resource_errors():
)
-@mock_codepipeline
+@mock_aws
def test_untag_resource():
client = boto3.client("codepipeline", region_name="us-east-1")
name = "test-pipeline"
@@ -582,7 +581,7 @@ def test_untag_resource():
)
-@mock_codepipeline
+@mock_aws
def test_untag_resource_errors():
client = boto3.client("codepipeline", region_name="us-east-1")
@@ -613,7 +612,6 @@ simple_trust_policy = {
}
-@mock_iam
def get_role_arn(name="test-role", trust_policy=None):
client = boto3.client("iam", region_name="us-east-1")
try:
@@ -697,7 +695,7 @@ extended_trust_policy = {
}
-@mock_codepipeline
+@mock_aws
def test_create_pipeline_with_extended_trust_policy():
client = boto3.client("codepipeline", region_name="us-east-1")
@@ -713,7 +711,7 @@ def test_create_pipeline_with_extended_trust_policy():
assert response["tags"] == [{"key": "key", "value": "value"}]
-@mock_codepipeline
+@mock_aws
def test_create_pipeline_without_tags():
client = boto3.client("codepipeline", region_name="us-east-1")
diff --git a/tests/test_cognitoidentity/test_cognitoidentity.py b/tests/test_cognitoidentity/test_cognitoidentity.py
index 7646e8cd9..093b36a6f 100644
--- a/tests/test_cognitoidentity/test_cognitoidentity.py
+++ b/tests/test_cognitoidentity/test_cognitoidentity.py
@@ -7,12 +7,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cognitoidentity, settings
+from moto import mock_aws, settings
from moto.cognitoidentity.utils import get_random_identity_id
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_cognitoidentity
+@mock_aws
@pytest.mark.parametrize("name", ["pool#name", "with!excl", "with?quest"])
def test_create_identity_pool_invalid_name(name):
conn = boto3.client("cognito-identity", "us-west-2")
@@ -29,7 +29,7 @@ def test_create_identity_pool_invalid_name(name):
)
-@mock_cognitoidentity
+@mock_aws
@pytest.mark.parametrize("name", ["x", "pool-", "pool_name", "with space"])
def test_create_identity_pool_valid_name(name):
conn = boto3.client("cognito-identity", "us-west-2")
@@ -39,7 +39,7 @@ def test_create_identity_pool_valid_name(name):
)
-@mock_cognitoidentity
+@mock_aws
def test_create_identity_pool():
conn = boto3.client("cognito-identity", "us-west-2")
@@ -61,7 +61,7 @@ def test_create_identity_pool():
assert result["IdentityPoolId"] != ""
-@mock_cognitoidentity
+@mock_aws
def test_describe_identity_pool():
conn = boto3.client("cognito-identity", "us-west-2")
@@ -107,7 +107,7 @@ def test_describe_identity_pool():
("DeveloperProviderName", "dev1", "dev2"),
],
)
-@mock_cognitoidentity
+@mock_aws
def test_update_identity_pool(key, initial_value, updated_value):
conn = boto3.client("cognito-identity", "us-west-2")
@@ -132,7 +132,7 @@ def test_update_identity_pool(key, initial_value, updated_value):
assert second[key] == response[key]
-@mock_cognitoidentity
+@mock_aws
def test_describe_identity_pool_with_invalid_id_raises_error():
conn = boto3.client("cognito-identity", "us-west-2")
with pytest.raises(ClientError) as cm:
@@ -152,7 +152,7 @@ def test_get_random_identity_id():
UUID(identity_id, version=4) # Will throw an error if it's not a valid UUID
-@mock_cognitoidentity
+@mock_aws
def test_get_id():
conn = boto3.client("cognito-identity", "us-west-2")
identity_pool_data = conn.create_identity_pool(
@@ -166,7 +166,7 @@ def test_get_id():
assert result.get("IdentityId").startswith("us-west-2")
-@mock_cognitoidentity
+@mock_aws
@mock.patch.dict(os.environ, {"AWS_DEFAULT_REGION": "any-region"})
@mock.patch.dict(os.environ, {"MOTO_ALLOW_NONEXISTENT_REGION": "trUe"})
def test_get_id__unknown_region():
@@ -184,7 +184,7 @@ def test_get_id__unknown_region():
assert result.get("IdentityId").startswith("any-region")
-@mock_cognitoidentity
+@mock_aws
def test_get_credentials_for_identity():
conn = boto3.client("cognito-identity", "us-west-2")
result = conn.get_credentials_for_identity(IdentityId="12345")
@@ -193,7 +193,7 @@ def test_get_credentials_for_identity():
assert result.get("IdentityId") == "12345"
-@mock_cognitoidentity
+@mock_aws
def test_get_open_id_token_for_developer_identity():
conn = boto3.client("cognito-identity", "us-west-2")
result = conn.get_open_id_token_for_developer_identity(
@@ -206,7 +206,7 @@ def test_get_open_id_token_for_developer_identity():
assert result["IdentityId"] == "12345"
-@mock_cognitoidentity
+@mock_aws
def test_get_open_id_token_for_developer_identity_when_no_explicit_identity_id():
conn = boto3.client("cognito-identity", "us-west-2")
result = conn.get_open_id_token_for_developer_identity(
@@ -216,7 +216,7 @@ def test_get_open_id_token_for_developer_identity_when_no_explicit_identity_id()
assert len(result["IdentityId"]) > 0
-@mock_cognitoidentity
+@mock_aws
def test_get_open_id_token():
conn = boto3.client("cognito-identity", "us-west-2")
result = conn.get_open_id_token(IdentityId="12345", Logins={"someurl": "12345"})
@@ -224,7 +224,7 @@ def test_get_open_id_token():
assert result["IdentityId"] == "12345"
-@mock_cognitoidentity
+@mock_aws
def test_list_identities():
conn = boto3.client("cognito-identity", "us-west-2")
identity_pool_data = conn.create_identity_pool(
@@ -242,7 +242,7 @@ def test_list_identities():
assert identity_id in [x["IdentityId"] for x in identities["Identities"]]
-@mock_cognitoidentity
+@mock_aws
def test_list_identity_pools():
conn = boto3.client("cognito-identity", "us-west-2")
identity_pool_data = conn.create_identity_pool(
diff --git a/tests/test_cognitoidentity/test_server.py b/tests/test_cognitoidentity/test_server.py
index 6ac6d9020..07742274e 100644
--- a/tests/test_cognitoidentity/test_server.py
+++ b/tests/test_cognitoidentity/test_server.py
@@ -1,14 +1,14 @@
import json
import moto.server as server
-from moto import mock_cognitoidentity
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_cognitoidentity
+@mock_aws
def test_create_identity_pool():
backend = server.create_backend_app("cognito-identity")
@@ -26,7 +26,7 @@ def test_create_identity_pool():
assert json_data["IdentityPoolName"] == "test"
-@mock_cognitoidentity
+@mock_aws
def test_get_id():
backend = server.create_backend_app("cognito-identity")
test_client = backend.test_client()
@@ -58,7 +58,7 @@ def test_get_id():
assert ":" in json_data["IdentityId"]
-@mock_cognitoidentity
+@mock_aws
def test_list_identities():
backend = server.create_backend_app("cognito-identity")
test_client = backend.test_client()
diff --git a/tests/test_cognitoidp/test_cognitoidp.py b/tests/test_cognitoidp/test_cognitoidp.py
index 6df344398..31fc3842a 100644
--- a/tests/test_cognitoidp/test_cognitoidp.py
+++ b/tests/test_cognitoidp/test_cognitoidp.py
@@ -16,12 +16,12 @@ from botocore.exceptions import ClientError, ParamValidationError
from jose import jws, jwt
import moto.cognitoidp.models
-from moto import mock_cognitoidp, settings
+from moto import mock_aws, settings
from moto.cognitoidp.utils import create_id
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -37,7 +37,7 @@ def test_create_user_pool():
assert result["UserPool"]["LambdaConfig"]["PreSignUp"] == value
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool__overwrite_template_messages():
client = boto3.client("cognito-idp", "us-east-2")
resp = client.create_user_pool(
@@ -57,7 +57,7 @@ def test_create_user_pool__overwrite_template_messages():
assert pool["EmailVerificationMessage"] == "foo {####} bar"
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_should_have_all_default_attributes_in_schema():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -90,7 +90,7 @@ def test_create_user_pool_should_have_all_default_attributes_in_schema():
assert attribute["DeveloperOnlyAttribute"] is False
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_unknown_attribute_data_type():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -111,7 +111,7 @@ def test_create_user_pool_unknown_attribute_data_type():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_custom_attribute_without_data_type():
conn = boto3.client("cognito-idp", "us-west-2")
with pytest.raises(ClientError) as ex:
@@ -125,7 +125,7 @@ def test_create_user_pool_custom_attribute_without_data_type():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_custom_attribute_defaults():
conn = boto3.client("cognito-idp", "us-west-2")
res = conn.create_user_pool(
@@ -153,7 +153,7 @@ def test_create_user_pool_custom_attribute_defaults():
assert "NumberAttributeConstraints" not in number_attribute
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_custom_attribute_developer_only():
conn = boto3.client("cognito-idp", "us-west-2")
res = conn.create_user_pool(
@@ -175,7 +175,7 @@ def test_create_user_pool_custom_attribute_developer_only():
assert attribute["DeveloperOnlyAttribute"] is True
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_custom_attribute_required():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -194,7 +194,7 @@ def test_create_user_pool_custom_attribute_required():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
@pytest.mark.parametrize(
"attribute",
[
@@ -217,7 +217,7 @@ def test_create_user_pool_standard_attribute_with_changed_data_type_or_developer
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_attribute_with_schema():
conn = boto3.client("cognito-idp", "us-west-2")
res = conn.create_user_pool(
@@ -274,7 +274,7 @@ def test_create_user_pool_attribute_with_schema():
assert "StringAttributeConstraints" not in boolean_attribute
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_attribute_partial_schema():
conn = boto3.client("cognito-idp", "us-west-2")
res = conn.create_user_pool(
@@ -333,7 +333,7 @@ def test_create_user_pool_attribute_partial_schema():
assert "MaxValue" not in number_no_max["NumberAttributeConstraints"]
-@mock_cognitoidp
+@mock_aws
@pytest.mark.parametrize(
("constraint_type", "attribute"),
[
@@ -389,7 +389,7 @@ def test_create_user_pool_invalid_schema_values(constraint_type, attribute):
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
@pytest.mark.parametrize(
"attribute",
[
@@ -418,7 +418,7 @@ def test_create_user_pool_string_schema_max_length_over_2048(attribute):
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_string_schema_min_bigger_than_max():
conn = boto3.client("cognito-idp", "us-west-2")
with pytest.raises(ClientError) as ex:
@@ -440,7 +440,7 @@ def test_create_user_pool_string_schema_min_bigger_than_max():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_number_schema_min_bigger_than_max():
conn = boto3.client("cognito-idp", "us-west-2")
with pytest.raises(ClientError) as ex:
@@ -462,7 +462,7 @@ def test_create_user_pool_number_schema_min_bigger_than_max():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_add_custom_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -484,7 +484,7 @@ def test_add_custom_attributes():
assert described_attribute is not None
-@mock_cognitoidp
+@mock_aws
def test_add_custom_attributes_existing_attribute():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -510,7 +510,7 @@ def test_add_custom_attributes_existing_attribute():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_default_id_strategy():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -520,7 +520,7 @@ def test_create_user_pool_default_id_strategy():
assert first_pool["UserPool"]["Id"] != second_pool["UserPool"]["Id"]
-@mock_cognitoidp
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_COGNITO_IDP_USER_POOL_ID_STRATEGY": "HASH"})
def test_create_user_pool_hash_id_strategy_with_equal_pool_name():
if settings.TEST_SERVER_MODE:
@@ -534,7 +534,7 @@ def test_create_user_pool_hash_id_strategy_with_equal_pool_name():
assert first_pool["UserPool"]["Id"] == second_pool["UserPool"]["Id"]
-@mock_cognitoidp
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_COGNITO_IDP_USER_POOL_ID_STRATEGY": "HASH"})
def test_create_user_pool_hash_id_strategy_with_different_pool_name():
if settings.TEST_SERVER_MODE:
@@ -548,7 +548,7 @@ def test_create_user_pool_hash_id_strategy_with_different_pool_name():
assert first_pool["UserPool"]["Id"] != second_pool["UserPool"]["Id"]
-@mock_cognitoidp
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_COGNITO_IDP_USER_POOL_ID_STRATEGY": "HASH"})
def test_create_user_pool_hash_id_strategy_with_different_attributes():
if settings.TEST_SERVER_MODE:
@@ -578,7 +578,7 @@ def test_create_user_pool_hash_id_strategy_with_different_attributes():
assert first_pool["UserPool"]["Id"] != second_pool["UserPool"]["Id"]
-@mock_cognitoidp
+@mock_aws
def test_list_user_pools():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -589,7 +589,7 @@ def test_list_user_pools():
assert result["UserPools"][0]["Name"] == name
-@mock_cognitoidp
+@mock_aws
def test_authorize_user_with_force_password_change_status():
conn = boto3.client("cognito-idp", "us-west-2")
pool_id = conn.create_user_pool(PoolName="TestUserPool")["UserPool"]["Id"]
@@ -649,7 +649,7 @@ def test_authorize_user_with_force_password_change_status():
assert result["AuthenticationResult"]["AccessToken"] is not None
-@mock_cognitoidp
+@mock_aws
def test_set_user_pool_mfa_config():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -746,7 +746,7 @@ def test_set_user_pool_mfa_config():
assert mfa_config["MfaConfiguration"] == "ON"
-@mock_cognitoidp
+@mock_aws
def test_list_user_pools_returns_max_items():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -761,7 +761,7 @@ def test_list_user_pools_returns_max_items():
assert "NextToken" in result
-@mock_cognitoidp
+@mock_aws
def test_list_user_pools_returns_next_tokens():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -781,7 +781,7 @@ def test_list_user_pools_returns_next_tokens():
assert "NextToken" not in result_2
-@mock_cognitoidp
+@mock_aws
def test_list_user_pools_when_max_items_more_than_total_items():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -796,7 +796,7 @@ def test_list_user_pools_when_max_items_more_than_total_items():
assert "NextToken" not in result
-@mock_cognitoidp
+@mock_aws
def test_describe_user_pool():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -817,7 +817,7 @@ def test_describe_user_pool():
)
-@mock_cognitoidp
+@mock_aws
def test_describe_user_pool_estimated_number_of_users():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -833,7 +833,7 @@ def test_describe_user_pool_estimated_number_of_users():
assert result["UserPool"]["EstimatedNumberOfUsers"] == users_count
-@mock_cognitoidp
+@mock_aws
def test_describe_user_pool_resource_not_found():
conn = boto3.client("cognito-idp", "us-east-1")
@@ -846,7 +846,7 @@ def test_describe_user_pool_resource_not_found():
assert err["Message"] == f"User pool {user_pool_id} does not exist."
-@mock_cognitoidp
+@mock_aws
def test_update_user_pool():
conn = boto3.client("cognito-idp", "us-east-1")
@@ -889,7 +889,7 @@ def test_update_user_pool():
assert updated_user_pool_details["UserPool"]["AccountRecoverySetting"] is not None
-@mock_cognitoidp
+@mock_aws
def test_delete_user_pool():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -899,7 +899,7 @@ def test_delete_user_pool():
assert len(conn.list_user_pools(MaxResults=10)["UserPools"]) == 0
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_domain():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -910,7 +910,7 @@ def test_create_user_pool_domain():
assert result["CloudFrontDomain"] is not None
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_domain_custom_domain_config():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -926,7 +926,7 @@ def test_create_user_pool_domain_custom_domain_config():
assert result["CloudFrontDomain"] == "e2c343b3293ee505.cloudfront.net"
-@mock_cognitoidp
+@mock_aws
def test_describe_user_pool_domain():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -941,7 +941,7 @@ def test_describe_user_pool_domain():
assert result["UserPool"]["Domain"] == domain
-@mock_cognitoidp
+@mock_aws
def test_delete_user_pool_domain():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -957,7 +957,7 @@ def test_delete_user_pool_domain():
assert len(result["DomainDescription"].keys()) == 0
-@mock_cognitoidp
+@mock_aws
def test_update_user_pool_domain():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -974,7 +974,7 @@ def test_update_user_pool_domain():
assert result["CloudFrontDomain"] == "e2c343b3293ee505.cloudfront.net"
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_client():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -993,7 +993,7 @@ def test_create_user_pool_client():
assert result["UserPoolClient"]["CallbackURLs"][0] == value
-@mock_cognitoidp
+@mock_aws
def test_create_user_pool_client_returns_secret():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1015,7 +1015,7 @@ def test_create_user_pool_client_returns_secret():
assert result["UserPoolClient"]["CallbackURLs"][0] == value
-@mock_cognitoidp
+@mock_aws
def test_list_user_pool_clients():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1027,7 +1027,7 @@ def test_list_user_pool_clients():
assert result["UserPoolClients"][0]["ClientName"] == client_name
-@mock_cognitoidp
+@mock_aws
def test_list_user_pool_clients_returns_max_items():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -1045,7 +1045,7 @@ def test_list_user_pool_clients_returns_max_items():
assert "NextToken" in result
-@mock_cognitoidp
+@mock_aws
def test_list_user_pool_clients_returns_next_tokens():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -1070,7 +1070,7 @@ def test_list_user_pool_clients_returns_next_tokens():
assert "NextToken" not in result_2
-@mock_cognitoidp
+@mock_aws
def test_list_user_pool_clients_when_max_items_more_than_total_items():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -1088,7 +1088,7 @@ def test_list_user_pool_clients_when_max_items_more_than_total_items():
assert "NextToken" not in result
-@mock_cognitoidp
+@mock_aws
def test_describe_user_pool_client():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1108,7 +1108,7 @@ def test_describe_user_pool_client():
assert result["UserPoolClient"]["CallbackURLs"][0] == value
-@mock_cognitoidp
+@mock_aws
def test_update_user_pool_client():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1134,7 +1134,7 @@ def test_update_user_pool_client():
assert result["UserPoolClient"]["CallbackURLs"][0] == new_value
-@mock_cognitoidp
+@mock_aws
def test_update_user_pool_client_returns_secret():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1164,7 +1164,7 @@ def test_update_user_pool_client_returns_secret():
assert result["UserPoolClient"]["CallbackURLs"][0] == new_value
-@mock_cognitoidp
+@mock_aws
def test_delete_user_pool_client():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1186,7 +1186,7 @@ def test_delete_user_pool_client():
assert err["Code"] == "ResourceNotFoundException"
-@mock_cognitoidp
+@mock_aws
def test_create_identity_provider():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1207,7 +1207,7 @@ def test_create_identity_provider():
assert result["IdentityProvider"]["ProviderDetails"]["thing"] == value
-@mock_cognitoidp
+@mock_aws
def test_list_identity_providers():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1228,7 +1228,7 @@ def test_list_identity_providers():
assert result["Providers"][0]["ProviderType"] == provider_type
-@mock_cognitoidp
+@mock_aws
def test_list_identity_providers_returns_max_items():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -1253,7 +1253,7 @@ def test_list_identity_providers_returns_max_items():
assert "NextToken" in result
-@mock_cognitoidp
+@mock_aws
def test_list_identity_providers_returns_next_tokens():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -1285,7 +1285,7 @@ def test_list_identity_providers_returns_next_tokens():
assert "NextToken" not in result_2
-@mock_cognitoidp
+@mock_aws
def test_list_identity_providers_when_max_items_more_than_total_items():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -1310,7 +1310,7 @@ def test_list_identity_providers_when_max_items_more_than_total_items():
assert "NextToken" not in result
-@mock_cognitoidp
+@mock_aws
def test_describe_identity_providers():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1335,7 +1335,7 @@ def test_describe_identity_providers():
assert result["IdentityProvider"]["ProviderDetails"]["thing"] == value
-@mock_cognitoidp
+@mock_aws
def test_update_identity_provider():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1365,7 +1365,7 @@ def test_update_identity_provider():
assert result["AttributeMapping"] == {"email": "email", "username": "sub"}
-@mock_cognitoidp
+@mock_aws
def test_update_identity_provider_no_user_pool():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1381,7 +1381,7 @@ def test_update_identity_provider_no_user_pool():
assert cm.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_update_identity_provider_no_identity_provider():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1400,7 +1400,7 @@ def test_update_identity_provider_no_identity_provider():
assert cm.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_delete_identity_providers():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1425,7 +1425,7 @@ def test_delete_identity_providers():
assert err["Code"] == "ResourceNotFoundException"
-@mock_cognitoidp
+@mock_aws
def test_create_group():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1452,7 +1452,7 @@ def test_create_group():
assert isinstance(result["Group"]["CreationDate"], datetime.datetime)
-@mock_cognitoidp
+@mock_aws
def test_update_group():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1490,7 +1490,7 @@ def test_update_group():
assert isinstance(result["Group"]["CreationDate"], datetime.datetime)
-@mock_cognitoidp
+@mock_aws
def test_group_in_access_token():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1544,7 +1544,7 @@ def test_group_in_access_token():
assert claims["cognito:groups"] == [group_name]
-@mock_cognitoidp
+@mock_aws
def test_other_attributes_in_id_token():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1606,7 +1606,7 @@ def test_other_attributes_in_id_token():
assert claims["custom:myattr"] == "some val"
-@mock_cognitoidp
+@mock_aws
def test_create_group_with_duplicate_name_raises_error():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1622,7 +1622,7 @@ def test_create_group_with_duplicate_name_raises_error():
assert cm.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_get_group():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1638,7 +1638,7 @@ def test_get_group():
assert isinstance(result["Group"]["CreationDate"], datetime.datetime)
-@mock_cognitoidp
+@mock_aws
def test_list_groups():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1652,7 +1652,7 @@ def test_list_groups():
assert result["Groups"][0]["GroupName"] == group_name
-@mock_cognitoidp
+@mock_aws
def test_list_groups_returns_pagination_tokens():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -1675,7 +1675,7 @@ def test_list_groups_returns_pagination_tokens():
assert "NextToken" not in result_2
-@mock_cognitoidp
+@mock_aws
def test_list_groups_when_limit_more_than_total_items():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -1691,7 +1691,7 @@ def test_list_groups_when_limit_more_than_total_items():
assert "NextToken" not in result
-@mock_cognitoidp
+@mock_aws
def test_delete_group():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1707,7 +1707,7 @@ def test_delete_group():
assert cm.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_cognitoidp
+@mock_aws
def test_admin_add_user_to_group():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1724,7 +1724,7 @@ def test_admin_add_user_to_group():
assert list(result.keys()) == ["ResponseMetadata"] # No response expected
-@mock_cognitoidp
+@mock_aws
def test_admin_add_user_to_group_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1743,7 +1743,7 @@ def test_admin_add_user_to_group_with_username_attributes():
assert list(result.keys()) == ["ResponseMetadata"] # No response expected
-@mock_cognitoidp
+@mock_aws
def test_admin_add_user_to_group_again_is_noop():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1762,7 +1762,7 @@ def test_admin_add_user_to_group_again_is_noop():
)
-@mock_cognitoidp
+@mock_aws
def test_list_users_in_group():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1783,7 +1783,7 @@ def test_list_users_in_group():
assert result["Users"][0]["Username"] == username
-@mock_cognitoidp
+@mock_aws
def test_list_users_in_group_ignores_deleted_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1810,7 +1810,7 @@ def test_list_users_in_group_ignores_deleted_user():
assert result["Users"][0]["Username"] == username2
-@mock_cognitoidp
+@mock_aws
def test_list_users_in_group_returns_pagination_tokens():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1844,7 +1844,7 @@ def test_list_users_in_group_returns_pagination_tokens():
assert "NextToken" not in result_2
-@mock_cognitoidp
+@mock_aws
def test_list_users_in_group_when_limit_more_than_total_items():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1868,7 +1868,7 @@ def test_list_users_in_group_when_limit_more_than_total_items():
assert "NextToken" not in result
-@mock_cognitoidp
+@mock_aws
def test_admin_list_groups_for_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1889,7 +1889,7 @@ def test_admin_list_groups_for_user():
assert result["Groups"][0]["GroupName"] == group_name
-@mock_cognitoidp
+@mock_aws
def test_admin_list_groups_for_user_with_username_attribute():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1912,7 +1912,7 @@ def test_admin_list_groups_for_user_with_username_attribute():
assert result["Groups"][0]["GroupName"] == group_name
-@mock_cognitoidp
+@mock_aws
def test_admin_list_groups_for_user_ignores_deleted_group():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1939,7 +1939,7 @@ def test_admin_list_groups_for_user_ignores_deleted_group():
assert result["Groups"][0]["GroupName"] == group_name2
-@mock_cognitoidp
+@mock_aws
def test_admin_remove_user_from_group():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1965,7 +1965,7 @@ def test_admin_remove_user_from_group():
assert resp["Groups"] == []
-@mock_cognitoidp
+@mock_aws
def test_admin_remove_user_from_group_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -1993,7 +1993,7 @@ def test_admin_remove_user_from_group_with_username_attributes():
assert resp["Groups"] == []
-@mock_cognitoidp
+@mock_aws
def test_admin_remove_user_from_group_again_is_noop():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2012,7 +2012,7 @@ def test_admin_remove_user_from_group_again_is_noop():
)
-@mock_cognitoidp
+@mock_aws
def test_admin_create_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2038,7 +2038,7 @@ def test_admin_create_user():
assert result["User"]["Enabled"] is True
-@mock_cognitoidp
+@mock_aws
def test_admin_create_user_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2067,7 +2067,7 @@ def test_admin_create_user_with_username_attributes():
assert result["User"]["Enabled"] is True
-@mock_cognitoidp
+@mock_aws
def test_admin_create_user_with_incorrect_username_attribute_type_fails():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2088,7 +2088,7 @@ def test_admin_create_user_with_incorrect_username_attribute_type_fails():
assert err["Message"] == "Username should be either an email or a phone number."
-@mock_cognitoidp
+@mock_aws
def test_admin_create_user_with_existing_username_attribute_fails():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2116,7 +2116,7 @@ def test_admin_create_user_with_existing_username_attribute_fails():
assert err["Message"] == "test@example.com"
-@mock_cognitoidp
+@mock_aws
def test_admin_create_existing_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2139,7 +2139,7 @@ def test_admin_create_existing_user():
assert err["Code"] == "UsernameExistsException"
-@mock_cognitoidp
+@mock_aws
def test_admin_confirm_sign_up():
conn = boto3.client("cognito-idp", "us-east-1")
@@ -2162,7 +2162,7 @@ def test_admin_confirm_sign_up():
assert user["UserStatus"] == "CONFIRMED"
-@mock_cognitoidp
+@mock_aws
def test_admin_confirm_sign_up_non_existing_user():
conn = boto3.client("cognito-idp", "us-east-1")
@@ -2179,7 +2179,7 @@ def test_admin_confirm_sign_up_non_existing_user():
assert err["Message"] == "User does not exist."
-@mock_cognitoidp
+@mock_aws
def test_admin_confirm_sign_up_non_existing_pool():
conn = boto3.client("cognito-idp", "us-east-1")
@@ -2192,7 +2192,7 @@ def test_admin_confirm_sign_up_non_existing_pool():
assert err["Message"] == f"User pool {user_pool_id} does not exist."
-@mock_cognitoidp
+@mock_aws
def test_admin_resend_invitation_existing_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2214,7 +2214,7 @@ def test_admin_resend_invitation_existing_user():
)
-@mock_cognitoidp
+@mock_aws
def test_admin_resend_invitation_missing_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2234,7 +2234,7 @@ def test_admin_resend_invitation_missing_user():
assert err["Message"] == "User does not exist."
-@mock_cognitoidp
+@mock_aws
def test_admin_get_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2252,7 +2252,7 @@ def test_admin_get_user():
assert len(result["UserAttributes"]) == 2
-@mock_cognitoidp
+@mock_aws
def test_admin_get_user_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2305,7 +2305,7 @@ def test_admin_get_user_with_username_attributes():
_verify_attribute("email", "test@example.com")
-@mock_cognitoidp
+@mock_aws
def test_admin_get_missing_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2320,7 +2320,7 @@ def test_admin_get_missing_user():
assert err["Message"] == "User does not exist."
-@mock_cognitoidp
+@mock_aws
def test_admin_get_missing_user_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2337,7 +2337,7 @@ def test_admin_get_missing_user_with_username_attributes():
assert err["Message"] == "User does not exist."
-@mock_cognitoidp
+@mock_aws
def test_get_user():
conn = boto3.client("cognito-idp", "us-west-2")
outputs = authentication_flow(conn, "ADMIN_NO_SRP_AUTH")
@@ -2354,7 +2354,7 @@ def test_get_user():
_verify_attribute(key, value)
-@mock_cognitoidp
+@mock_aws
def test_get_user_unknown_accesstoken():
conn = boto3.client("cognito-idp", "us-west-2")
with pytest.raises(ClientError) as ex:
@@ -2364,7 +2364,7 @@ def test_get_user_unknown_accesstoken():
assert err["Message"] == "Invalid token"
-@mock_cognitoidp
+@mock_aws
def test_list_users():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2411,7 +2411,7 @@ def test_list_users():
assert len(result["Users"]) == 0
-@mock_cognitoidp
+@mock_aws
def test_list_users_incorrect_filter():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2432,7 +2432,7 @@ def _assert_filter_parsing_error(exc):
assert err["Message"] == "Error while parsing filter"
-@mock_cognitoidp
+@mock_aws
def test_list_users_invalid_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2445,7 +2445,7 @@ def test_list_users_invalid_attributes():
assert err["Message"] == "Invalid search attribute: custom:foo"
-@mock_cognitoidp
+@mock_aws
def test_list_users_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2489,7 +2489,7 @@ def test_list_users_with_username_attributes():
_verify_attribute("email", username_bis)
-@mock_cognitoidp
+@mock_aws
def test_list_users_inherent_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2526,7 +2526,7 @@ def test_list_users_inherent_attributes():
assert result["Users"][0][response_field] == response_field_expected_value
-@mock_cognitoidp
+@mock_aws
def test_get_user_unconfirmed():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cant patch attributes in server mode.")
@@ -2544,7 +2544,7 @@ def test_get_user_unconfirmed():
assert err["Message"] == "username"
-@mock_cognitoidp
+@mock_aws
def test_list_users_returns_limit_items():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -2559,7 +2559,7 @@ def test_list_users_returns_limit_items():
assert "PaginationToken" in result
-@mock_cognitoidp
+@mock_aws
def test_list_users_returns_pagination_tokens():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -2582,7 +2582,7 @@ def test_list_users_returns_pagination_tokens():
assert "PaginationToken" not in result_2
-@mock_cognitoidp
+@mock_aws
def test_list_users_when_limit_more_than_total_items():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -2598,7 +2598,7 @@ def test_list_users_when_limit_more_than_total_items():
assert "PaginationToken" not in result
-@mock_cognitoidp
+@mock_aws
def test_list_users_with_attributes_to_get():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -2625,7 +2625,7 @@ def test_list_users_with_attributes_to_get():
assert {"Name": "custom:foo", "Value": "bar"} in user["Attributes"]
-@mock_cognitoidp
+@mock_aws
def test_admin_disable_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2642,7 +2642,7 @@ def test_admin_disable_user():
)
-@mock_cognitoidp
+@mock_aws
def test_admin_disable_user_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2661,7 +2661,7 @@ def test_admin_disable_user_with_username_attributes():
)
-@mock_cognitoidp
+@mock_aws
def test_admin_enable_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2676,7 +2676,7 @@ def test_admin_enable_user():
assert conn.admin_get_user(UserPoolId=user_pool_id, Username=username)["Enabled"]
-@mock_cognitoidp
+@mock_aws
def test_admin_enable_user_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2693,7 +2693,7 @@ def test_admin_enable_user_with_username_attributes():
assert conn.admin_get_user(UserPoolId=user_pool_id, Username=username)["Enabled"]
-@mock_cognitoidp
+@mock_aws
def test_admin_delete_user():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2709,7 +2709,7 @@ def test_admin_delete_user():
assert err["Code"] == "UserNotFoundException"
-@mock_cognitoidp
+@mock_aws
def test_admin_delete_user_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2781,7 +2781,7 @@ def authentication_flow(conn, auth_flow):
}
-@mock_cognitoidp
+@mock_aws
def test_authentication_flow():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2789,7 +2789,7 @@ def test_authentication_flow():
authentication_flow(conn, auth_flow)
-@mock_cognitoidp
+@mock_aws
def test_authentication_flow_invalid_flow():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2804,7 +2804,7 @@ def test_authentication_flow_invalid_flow():
)
-@mock_cognitoidp
+@mock_aws
def test_authentication_flow_invalid_user_flow():
"""Pass a user authFlow to admin_initiate_auth"""
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2940,14 +2940,14 @@ def user_authentication_flow(conn):
}
-@mock_cognitoidp
+@mock_aws
def test_user_authentication_flow():
conn = boto3.client("cognito-idp", "us-west-2")
user_authentication_flow(conn)
-@mock_cognitoidp
+@mock_aws
def test_token_legitimacy():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -2978,7 +2978,7 @@ def test_token_legitimacy():
assert access_claims["username"] == username
-@mock_cognitoidp
+@mock_aws
def test_change_password():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -3008,7 +3008,7 @@ def test_change_password():
assert result["AuthenticationResult"] is not None
-@mock_cognitoidp
+@mock_aws
def test_change_password__using_custom_user_agent_header():
# https://github.com/getmoto/moto/issues/3098
# As the admin_initiate_auth-method is unauthenticated, we use the user-agent header to pass in the region
@@ -3044,7 +3044,7 @@ def test_change_password__using_custom_user_agent_header():
assert result["AuthenticationResult"] is not None
-@mock_cognitoidp
+@mock_aws
def test_forgot_password():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -3057,7 +3057,7 @@ def test_forgot_password():
assert result["CodeDeliveryDetails"]["AttributeName"] == "email"
-@mock_cognitoidp
+@mock_aws
def test_forgot_password_nonexistent_client_id():
conn = boto3.client("cognito-idp", "us-west-2")
with pytest.raises(ClientError) as ex:
@@ -3068,7 +3068,7 @@ def test_forgot_password_nonexistent_client_id():
assert err["Message"] == "Username/client id combination not found."
-@mock_cognitoidp
+@mock_aws
def test_forgot_password_admin_only_recovery():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(
@@ -3089,7 +3089,7 @@ def test_forgot_password_admin_only_recovery():
assert err["Message"] == "Contact administrator to reset password."
-@mock_cognitoidp
+@mock_aws
def test_forgot_password_user_with_all_recovery_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(
@@ -3131,7 +3131,7 @@ def test_forgot_password_user_with_all_recovery_attributes():
assert result["CodeDeliveryDetails"]["AttributeName"] == "phone_number"
-@mock_cognitoidp
+@mock_aws
def test_forgot_password_nonexistent_user_or_user_without_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(
@@ -3168,7 +3168,7 @@ def test_forgot_password_nonexistent_user_or_user_without_attributes():
assert result["CodeDeliveryDetails"]["AttributeName"] == "phone_number"
-@mock_cognitoidp
+@mock_aws
def test_confirm_forgot_password_legacy():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -3193,7 +3193,7 @@ def test_confirm_forgot_password_legacy():
assert res["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_cognitoidp
+@mock_aws
def test_confirm_forgot_password_opt_in_verification():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -3223,7 +3223,7 @@ def test_confirm_forgot_password_opt_in_verification():
assert res["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_cognitoidp
+@mock_aws
def test_confirm_forgot_password_opt_in_verification_invalid_confirmation_code():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -3248,7 +3248,7 @@ def test_confirm_forgot_password_opt_in_verification_invalid_confirmation_code()
assert err["Message"] == "Invalid code provided, please request a code again."
-@mock_cognitoidp
+@mock_aws
def test_admin_user_global_sign_out():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -3271,7 +3271,7 @@ def test_admin_user_global_sign_out():
assert err["Message"] == "Refresh Token has been revoked"
-@mock_cognitoidp
+@mock_aws
def test_admin_user_global_sign_out_twice():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -3298,7 +3298,7 @@ def test_admin_user_global_sign_out_twice():
assert err["Message"] == "Refresh Token has been revoked"
-@mock_cognitoidp
+@mock_aws
def test_admin_user_global_sign_out_unknown_userpool():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -3308,7 +3308,7 @@ def test_admin_user_global_sign_out_unknown_userpool():
assert err["Code"] == "ResourceNotFoundException"
-@mock_cognitoidp
+@mock_aws
def test_admin_user_global_sign_out_unknown_user():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -3321,7 +3321,7 @@ def test_admin_user_global_sign_out_unknown_user():
assert err["Message"] == "User does not exist."
-@mock_cognitoidp
+@mock_aws
def test_global_sign_out():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -3348,7 +3348,7 @@ def test_global_sign_out():
assert err["Code"] == "NotAuthorizedException"
-@mock_cognitoidp
+@mock_aws
def test_global_sign_out_unknown_accesstoken():
conn = boto3.client("cognito-idp", "us-east-2")
with pytest.raises(ClientError) as ex:
@@ -3357,7 +3357,7 @@ def test_global_sign_out_unknown_accesstoken():
assert err["Code"] == "NotAuthorizedException"
-@mock_cognitoidp
+@mock_aws
def test_admin_update_user_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -3392,7 +3392,7 @@ def test_admin_update_user_attributes():
assert val == "Jane"
-@mock_cognitoidp
+@mock_aws
def test_admin_delete_user_attributes():
conn = boto3.client("cognito-idp", "us-east-1")
@@ -3435,7 +3435,7 @@ def test_admin_delete_user_attributes():
assert {"Name": "custom:foo", "Value": "bar"} not in user["UserAttributes"]
-@mock_cognitoidp
+@mock_aws
def test_admin_delete_user_attributes_non_existing_attribute():
conn = boto3.client("cognito-idp", "us-east-1")
@@ -3479,7 +3479,7 @@ def test_admin_delete_user_attributes_non_existing_attribute():
)
-@mock_cognitoidp
+@mock_aws
def test_admin_delete_user_attributes_non_existing_user():
conn = boto3.client("cognito-idp", "us-east-1")
@@ -3497,7 +3497,7 @@ def test_admin_delete_user_attributes_non_existing_user():
assert err["Message"] == "User does not exist."
-@mock_cognitoidp
+@mock_aws
def test_admin_delete_user_attributes_non_existing_pool():
conn = boto3.client("cognito-idp", "us-east-1")
@@ -3514,7 +3514,7 @@ def test_admin_delete_user_attributes_non_existing_pool():
assert err["Message"] == f"User pool {user_pool_id} does not exist."
-@mock_cognitoidp
+@mock_aws
def test_update_user_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -3538,7 +3538,7 @@ def test_update_user_attributes():
assert {"Name": "given_name", "Value": "Jane"} in attributes
-@mock_cognitoidp
+@mock_aws
def test_update_user_attributes_unknown_accesstoken():
conn = boto3.client("cognito-idp", "us-east-2")
with pytest.raises(ClientError) as ex:
@@ -3549,7 +3549,7 @@ def test_update_user_attributes_unknown_accesstoken():
assert err["Code"] == "NotAuthorizedException"
-@mock_cognitoidp
+@mock_aws
def test_create_resource_server():
client = boto3.client("cognito-idp", "us-west-2")
name = str(uuid.uuid4())
@@ -3586,7 +3586,7 @@ def test_create_resource_server():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_create_resource_server_with_no_scopes():
client = boto3.client("cognito-idp", "us-west-2")
name = str(uuid.uuid4())
@@ -3606,7 +3606,7 @@ def test_create_resource_server_with_no_scopes():
assert "Scopes" not in res["ResourceServer"]
-@mock_cognitoidp
+@mock_aws
def test_describe_resource_server():
# Create a user pool to attach a resource server to
@@ -3663,7 +3663,7 @@ def test_describe_resource_server():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_cognitoidp
+@mock_aws
def test_list_resource_servers_empty_set():
# Create a user pool to attach a resource server to
@@ -3689,7 +3689,7 @@ def test_list_resource_servers_empty_set():
assert len(servers["ResourceServers"]) == 0
-@mock_cognitoidp
+@mock_aws
def test_list_resource_servers_single_page():
# Create a user pool to attach a resource server to
@@ -3745,7 +3745,7 @@ def test_list_resource_servers_single_page():
)
-@mock_cognitoidp
+@mock_aws
def test_list_resource_servers_multi_page():
# Create a user pool to attach a resource server to
@@ -3824,7 +3824,7 @@ def test_list_resource_servers_multi_page():
)
-@mock_cognitoidp
+@mock_aws
def test_sign_up():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -3838,7 +3838,7 @@ def test_sign_up():
assert result["UserSub"] is not None
-@mock_cognitoidp
+@mock_aws
@pytest.mark.parametrize("password", ["p2$$word", "P2$s"])
def test_sign_up_with_invalid_password(password):
conn = boto3.client("cognito-idp", "us-west-2")
@@ -3854,7 +3854,7 @@ def test_sign_up_with_invalid_password(password):
assert err["Code"] == "InvalidPasswordException"
-@mock_cognitoidp
+@mock_aws
def test_sign_up_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(
@@ -3882,7 +3882,7 @@ def test_sign_up_with_username_attributes():
assert result["UserSub"] is not None
-@mock_cognitoidp
+@mock_aws
def test_sign_up_existing_user():
conn = boto3.client("cognito-idp", "us-west-2")
user_pool_id = conn.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"]
@@ -3902,7 +3902,7 @@ def test_sign_up_existing_user():
assert err.value.response["Error"]["Code"] == "UsernameExistsException"
-@mock_cognitoidp
+@mock_aws
def test_confirm_sign_up():
conn = boto3.client("cognito-idp", "us-west-2")
username = str(uuid.uuid4())
@@ -3921,7 +3921,7 @@ def test_confirm_sign_up():
assert result["UserStatus"] == "CONFIRMED"
-@mock_cognitoidp
+@mock_aws
def test_confirm_sign_up_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
username = "test@example.com"
@@ -3942,7 +3942,7 @@ def test_confirm_sign_up_with_username_attributes():
assert result["UserStatus"] == "CONFIRMED"
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_USER_SRP_AUTH():
conn = boto3.client("cognito-idp", "us-west-2")
username = str(uuid.uuid4())
@@ -3978,7 +3978,7 @@ def test_initiate_auth_USER_SRP_AUTH():
assert result["ChallengeParameters"]["USERNAME"] == username
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_USER_SRP_AUTH_with_username_attributes():
conn = boto3.client("cognito-idp", "us-west-2")
username = "test@example.com"
@@ -4015,7 +4015,7 @@ def test_initiate_auth_USER_SRP_AUTH_with_username_attributes():
assert result["ChallengeName"] == "PASSWORD_VERIFIER"
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_REFRESH_TOKEN():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -4031,7 +4031,7 @@ def test_initiate_auth_REFRESH_TOKEN():
assert result["AuthenticationResult"]["AccessToken"] is not None
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_USER_PASSWORD_AUTH():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -4047,7 +4047,7 @@ def test_initiate_auth_USER_PASSWORD_AUTH():
assert result["AuthenticationResult"]["TokenType"] == "Bearer"
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_invalid_auth_flow():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -4072,7 +4072,7 @@ def test_initiate_auth_invalid_auth_flow():
)
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_invalid_admin_auth_flow():
"""Pass an admin auth_flow to the regular initiate_auth"""
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4095,7 +4095,7 @@ def test_initiate_auth_invalid_admin_auth_flow():
assert err["Message"] == "Initiate Auth method not supported"
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_USER_PASSWORD_AUTH_with_FORCE_CHANGE_PASSWORD_status():
# Test flow:
# 1. Create user with FORCE_CHANGE_PASSWORD status
@@ -4146,7 +4146,7 @@ def test_initiate_auth_USER_PASSWORD_AUTH_with_FORCE_CHANGE_PASSWORD_status():
assert result["AuthenticationResult"]["AccessToken"] != ""
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_USER_PASSWORD_AUTH_user_not_found():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -4160,7 +4160,7 @@ def test_initiate_auth_USER_PASSWORD_AUTH_user_not_found():
assert err["Code"] == "UserNotFoundException"
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_USER_PASSWORD_AUTH_user_incorrect_password():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -4177,7 +4177,7 @@ def test_initiate_auth_USER_PASSWORD_AUTH_user_incorrect_password():
assert err["Code"] == "NotAuthorizedException"
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_USER_PASSWORD_AUTH_unconfirmed_user():
conn = boto3.client("cognito-idp", "us-west-2")
username = str(uuid.uuid4())
@@ -4198,7 +4198,7 @@ def test_initiate_auth_USER_PASSWORD_AUTH_unconfirmed_user():
assert err["Code"] == "UserNotConfirmedException"
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_for_unconfirmed_user():
conn = boto3.client("cognito-idp", "us-west-2")
username = str(uuid.uuid4())
@@ -4231,7 +4231,7 @@ def test_initiate_auth_for_unconfirmed_user():
assert err["Code"] == "UserNotConfirmedException"
-@mock_cognitoidp
+@mock_aws
def test_initiate_auth_with_invalid_secret_hash():
conn = boto3.client("cognito-idp", "us-west-2")
username = str(uuid.uuid4())
@@ -4262,7 +4262,7 @@ def test_initiate_auth_with_invalid_secret_hash():
assert err["Code"] == "NotAuthorizedException"
-@mock_cognitoidp
+@mock_aws
def test_setting_mfa():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4298,7 +4298,7 @@ def test_setting_mfa():
assert user["PreferredMfaSetting"] == ""
-@mock_cognitoidp
+@mock_aws
def test_setting_mfa_when_token_not_verified():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4315,7 +4315,7 @@ def test_setting_mfa_when_token_not_verified():
assert err["Code"] == "InvalidParameterException"
-@mock_cognitoidp
+@mock_aws
def test_admin_setting_single_mfa():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4346,7 +4346,7 @@ def test_admin_setting_single_mfa():
assert result["PreferredMfaSetting"] == ""
-@mock_cognitoidp
+@mock_aws
def test_admin_setting_mfa_totp_and_sms():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4380,7 +4380,7 @@ def test_admin_setting_mfa_totp_and_sms():
assert result["PreferredMfaSetting"] == ""
-@mock_cognitoidp
+@mock_aws
def test_admin_initiate_auth_when_token_totp_enabled():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4436,7 +4436,7 @@ def test_admin_initiate_auth_when_token_totp_enabled():
assert result["AuthenticationResult"]["TokenType"] == "Bearer"
-@mock_cognitoidp
+@mock_aws
def test_admin_setting_mfa_when_token_not_verified():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4454,7 +4454,7 @@ def test_admin_setting_mfa_when_token_not_verified():
)
-@mock_cognitoidp
+@mock_aws
def test_respond_to_auth_challenge_with_invalid_secret_hash():
conn = boto3.client("cognito-idp", "us-west-2")
result = user_authentication_flow(conn)
@@ -4498,7 +4498,7 @@ def test_respond_to_auth_challenge_with_invalid_secret_hash():
assert err["Code"] == "NotAuthorizedException"
-@mock_cognitoidp
+@mock_aws
def test_admin_set_user_password():
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4526,7 +4526,7 @@ def test_admin_set_user_password():
_verify_attribute("thing", value)
-@mock_cognitoidp
+@mock_aws
@pytest.mark.parametrize("password", ["pa$$word", "Password", "p2ssword", "P2$S"])
def test_admin_set_invalid_user_password(password):
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4550,7 +4550,7 @@ def test_admin_set_invalid_user_password(password):
assert err["Code"] == "InvalidPasswordException"
-@mock_cognitoidp
+@mock_aws
@pytest.mark.parametrize("password", ["password", "P2$$word"])
def test_admin_set_invalid_user_password__custom_policy_provided(password):
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4593,7 +4593,7 @@ def test_admin_set_invalid_user_password__custom_policy_provided(password):
)
-@mock_cognitoidp
+@mock_aws
def test_change_password_with_invalid_token_raises_error():
client = boto3.client("cognito-idp", "us-west-2")
with pytest.raises(ClientError) as ex:
@@ -4605,7 +4605,7 @@ def test_change_password_with_invalid_token_raises_error():
assert ex.value.response["Error"]["Code"] == "NotAuthorizedException"
-@mock_cognitoidp
+@mock_aws
def test_confirm_forgot_password_with_non_existent_client_id_raises_error():
client = boto3.client("cognito-idp", "us-west-2")
with pytest.raises(ClientError) as ex:
@@ -4618,7 +4618,7 @@ def test_confirm_forgot_password_with_non_existent_client_id_raises_error():
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_cognitoidp
+@mock_aws
def test_admin_reset_password_and_change_password():
client = boto3.client("cognito-idp", "us-west-2")
username = str(uuid.uuid4())
@@ -4674,7 +4674,7 @@ def test_admin_reset_password_and_change_password():
assert result["UserStatus"] == "CONFIRMED"
-@mock_cognitoidp
+@mock_aws
def test_admin_initiate_auth__use_access_token():
client = boto3.client("cognito-idp", "us-west-2")
un = str(uuid.uuid4())
@@ -4709,7 +4709,7 @@ def test_admin_initiate_auth__use_access_token():
client.global_sign_out(AccessToken=access_token)
-@mock_cognitoidp
+@mock_aws
def test_admin_reset_password_disabled_user():
client = boto3.client("cognito-idp", "us-west-2")
username = str(uuid.uuid4())
@@ -4728,7 +4728,7 @@ def test_admin_reset_password_disabled_user():
assert err["Message"] == "User is disabled"
-@mock_cognitoidp
+@mock_aws
def test_admin_reset_password_unconfirmed_user():
client = boto3.client("cognito-idp", "us-west-2")
username = str(uuid.uuid4())
@@ -4746,7 +4746,7 @@ def test_admin_reset_password_unconfirmed_user():
assert err["Message"] == "User password cannot be reset in the current state."
-@mock_cognitoidp
+@mock_aws
def test_admin_reset_password_no_verified_notification_channel():
client = boto3.client("cognito-idp", "us-west-2")
username = str(uuid.uuid4())
@@ -4773,7 +4773,7 @@ def test_admin_reset_password_no_verified_notification_channel():
)
-@mock_cognitoidp
+@mock_aws
def test_admin_reset_password_multiple_invocations():
client = boto3.client("cognito-idp", "us-west-2")
username = str(uuid.uuid4())
@@ -4801,7 +4801,7 @@ def test_admin_reset_password_multiple_invocations():
assert user["UserStatus"] == "RESET_REQUIRED"
-@mock_cognitoidp
+@mock_aws
def test_login_denied_if_account_disabled():
"""Make sure a disabled account is denied login"""
conn = boto3.client("cognito-idp", "us-west-2")
@@ -4859,7 +4859,7 @@ def test_login_denied_if_account_disabled():
# which isnt mocked in ServerMode
if not settings.TEST_SERVER_MODE:
- @mock_cognitoidp
+ @mock_aws
def test_idtoken_contains_kid_header():
# https://github.com/getmoto/moto/issues/3078
# Setup
diff --git a/tests/test_cognitoidp/test_cognitoidp_exceptions.py b/tests/test_cognitoidp/test_cognitoidp_exceptions.py
index e010ba3e6..76dbf2f31 100644
--- a/tests/test_cognitoidp/test_cognitoidp_exceptions.py
+++ b/tests/test_cognitoidp/test_cognitoidp_exceptions.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cognitoidp
+from moto import mock_aws
-@mock_cognitoidp
+@mock_aws
class TestCognitoUserDeleter(TestCase):
def setUp(self) -> None:
self.client = boto3.client("cognito-idp", "us-east-1")
@@ -53,7 +53,7 @@ class TestCognitoUserDeleter(TestCase):
assert exc.exception.response["Error"]["Code"] == "NotAuthorizedException"
-@mock_cognitoidp
+@mock_aws
class TestCognitoUserPoolDuplidateEmails(TestCase):
def setUp(self) -> None:
self.client = boto3.client("cognito-idp", "us-east-1")
diff --git a/tests/test_cognitoidp/test_cognitoidp_replay.py b/tests/test_cognitoidp/test_cognitoidp_replay.py
index fea72f865..0fa576f28 100644
--- a/tests/test_cognitoidp/test_cognitoidp_replay.py
+++ b/tests/test_cognitoidp/test_cognitoidp_replay.py
@@ -7,11 +7,11 @@ import pytest
import requests
from botocore.exceptions import ClientError
-from moto import mock_cognitoidp, settings
+from moto import mock_aws, settings
from moto.moto_api import recorder
-@mock_cognitoidp
+@mock_aws
class TestCreateUserPoolWithPredeterminedID(TestCase):
def _reset_recording(self):
if settings.TEST_SERVER_MODE:
diff --git a/tests/test_comprehend/test_comprehend.py b/tests/test_comprehend/test_comprehend.py
index a26afcf45..890797087 100644
--- a/tests/test_comprehend/test_comprehend.py
+++ b/tests/test_comprehend/test_comprehend.py
@@ -1,9 +1,8 @@
-"""Unit tests for comprehend-supported APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_comprehend
+from moto import mock_aws
from moto.comprehend.models import (
CANNED_DETECT_RESPONSE,
CANNED_PHRASES_RESPONSE,
@@ -25,7 +24,7 @@ INPUT_DATA_CONFIG = {
}
-@mock_comprehend
+@mock_aws
def test_list_entity_recognizers():
client = boto3.client("comprehend", region_name="us-east-2")
@@ -58,7 +57,7 @@ def test_list_entity_recognizers():
assert len(resp["EntityRecognizerPropertiesList"]) == 2
-@mock_comprehend
+@mock_aws
def test_create_entity_recognizer():
client = boto3.client("comprehend", region_name="ap-southeast-1")
resp = client.create_entity_recognizer(
@@ -72,7 +71,7 @@ def test_create_entity_recognizer():
assert "EntityRecognizerArn" in resp
-@mock_comprehend
+@mock_aws
def test_create_entity_recognizer_without_version():
client = boto3.client("comprehend", region_name="ap-southeast-1")
resp = client.create_entity_recognizer(
@@ -89,7 +88,7 @@ def test_create_entity_recognizer_without_version():
)
-@mock_comprehend
+@mock_aws
def test_create_entity_recognizer_with_tags():
client = boto3.client("comprehend", region_name="ap-southeast-1")
arn = client.create_entity_recognizer(
@@ -105,7 +104,7 @@ def test_create_entity_recognizer_with_tags():
assert resp["Tags"] == [{"Key": "k1", "Value": "v1"}]
-@mock_comprehend
+@mock_aws
def test_describe_entity_recognizer():
client = boto3.client("comprehend", region_name="eu-west-1")
arn = client.create_entity_recognizer(
@@ -128,7 +127,7 @@ def test_describe_entity_recognizer():
assert props["VersionName"] == "terraform-20221003201727469000000002"
-@mock_comprehend
+@mock_aws
def test_describe_unknown_recognizer():
client = boto3.client("comprehend", region_name="eu-west-1")
@@ -139,7 +138,7 @@ def test_describe_unknown_recognizer():
assert err["Message"] == "RESOURCE_NOT_FOUND: Could not find specified resource."
-@mock_comprehend
+@mock_aws
def test_stop_training_entity_recognizer():
client = boto3.client("comprehend", region_name="eu-west-1")
arn = client.create_entity_recognizer(
@@ -157,7 +156,7 @@ def test_stop_training_entity_recognizer():
assert props["Status"] == "TRAINED"
-@mock_comprehend
+@mock_aws
def test_list_tags_for_resource():
client = boto3.client("comprehend", region_name="us-east-2")
arn = client.create_entity_recognizer(
@@ -182,7 +181,7 @@ def test_list_tags_for_resource():
assert resp["Tags"] == []
-@mock_comprehend
+@mock_aws
def test_delete_entity_recognizer():
client = boto3.client("comprehend", region_name="ap-southeast-1")
arn = client.create_entity_recognizer(
@@ -202,7 +201,7 @@ def test_delete_entity_recognizer():
assert err["Message"] == "RESOURCE_NOT_FOUND: Could not find specified resource."
-@mock_comprehend
+@mock_aws
def test_detect_pii_entities():
# Setup
client = boto3.client("comprehend", region_name="eu-west-1")
@@ -216,7 +215,7 @@ def test_detect_pii_entities():
assert result["Entities"] == CANNED_DETECT_RESPONSE
-@mock_comprehend
+@mock_aws
def test_detect_pii_entities_invalid_languages():
# Setup
client = boto3.client("comprehend", region_name="eu-west-1")
@@ -237,7 +236,7 @@ def test_detect_pii_entities_invalid_languages():
)
-@mock_comprehend
+@mock_aws
def test_detect_pii_entities_text_too_large():
# Setup
client = boto3.client("comprehend", region_name="eu-west-1")
@@ -259,7 +258,7 @@ def test_detect_pii_entities_text_too_large():
)
-@mock_comprehend
+@mock_aws
def test_detect_key_phrases():
# Setup
client = boto3.client("comprehend", region_name="eu-west-1")
@@ -273,7 +272,7 @@ def test_detect_key_phrases():
assert result["KeyPhrases"] == CANNED_PHRASES_RESPONSE
-@mock_comprehend
+@mock_aws
def test_detect_key_phrases_invalid_languages():
# Setup
client = boto3.client("comprehend", region_name="eu-west-1")
@@ -294,7 +293,7 @@ def test_detect_key_phrases_invalid_languages():
)
-@mock_comprehend
+@mock_aws
def test_detect_detect_key_phrases_text_too_large():
# Setup
client = boto3.client("comprehend", region_name="eu-west-1")
@@ -316,7 +315,7 @@ def test_detect_detect_key_phrases_text_too_large():
)
-@mock_comprehend
+@mock_aws
def test_detect_sentiment():
# Setup
client = boto3.client("comprehend", region_name="eu-west-1")
@@ -330,7 +329,7 @@ def test_detect_sentiment():
assert result == CANNED_SENTIMENT_RESPONSE
-@mock_comprehend
+@mock_aws
def test_detect_sentiment_invalid_languages():
# Setup
client = boto3.client("comprehend", region_name="eu-west-1")
@@ -351,7 +350,7 @@ def test_detect_sentiment_invalid_languages():
)
-@mock_comprehend
+@mock_aws
def test_detect_sentiment_text_too_large():
# Setup
client = boto3.client("comprehend", region_name="eu-west-1")
diff --git a/tests/test_config/test_config.py b/tests/test_config/test_config.py
index c15b62a14..ad738b966 100644
--- a/tests/test_config/test_config.py
+++ b/tests/test_config/test_config.py
@@ -9,13 +9,12 @@ import pytest
from botocore.config import Config
from botocore.exceptions import ClientError
-from moto import mock_s3
-from moto.config import mock_config
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core.utils import utcnow
-@mock_config
+@mock_aws
def test_put_configuration_recorder():
client = boto3.client("config", region_name="us-west-2")
@@ -341,7 +340,7 @@ def test_put_configuration_recorder():
)
-@mock_config
+@mock_aws
def test_put_configuration_aggregator():
client = boto3.client("config", region_name="us-west-2")
@@ -597,7 +596,7 @@ def test_put_configuration_aggregator():
}
-@mock_config
+@mock_aws
def test_describe_configuration_aggregators():
client = boto3.client("config", region_name="us-west-2")
@@ -703,7 +702,7 @@ def test_describe_configuration_aggregators():
assert ce.value.response["Error"]["Code"] == "InvalidNextTokenException"
-@mock_config
+@mock_aws
def test_put_aggregation_authorization():
client = boto3.client("config", region_name="us-west-2")
@@ -799,7 +798,7 @@ def test_put_aggregation_authorization():
assert result["AggregationAuthorization"]["CreationTime"] == creation_date
-@mock_config
+@mock_aws
def test_describe_aggregation_authorizations():
client = boto3.client("config", region_name="us-west-2")
@@ -854,7 +853,7 @@ def test_describe_aggregation_authorizations():
assert ce.value.response["Error"]["Code"] == "InvalidNextTokenException"
-@mock_config
+@mock_aws
def test_delete_aggregation_authorization():
client = boto3.client("config", region_name="us-west-2")
@@ -876,7 +875,7 @@ def test_delete_aggregation_authorization():
)
-@mock_config
+@mock_aws
def test_delete_configuration_aggregator():
client = boto3.client("config", region_name="us-west-2")
client.put_configuration_aggregator(
@@ -900,7 +899,7 @@ def test_delete_configuration_aggregator():
)
-@mock_config
+@mock_aws
def test_describe_configurations():
client = boto3.client("config", region_name="us-west-2")
@@ -947,7 +946,7 @@ def test_describe_configurations():
assert "wrong" in ce.value.response["Error"]["Message"]
-@mock_config
+@mock_aws
def test_delivery_channels():
client = boto3.client("config", region_name="us-west-2")
@@ -1110,7 +1109,7 @@ def test_delivery_channels():
)
-@mock_config
+@mock_aws
def test_describe_delivery_channels():
client = boto3.client("config", region_name="us-west-2")
client.put_configuration_recorder(
@@ -1175,7 +1174,7 @@ def test_describe_delivery_channels():
assert "wrong" in ce.value.response["Error"]["Message"]
-@mock_config
+@mock_aws
def test_start_configuration_recorder():
client = boto3.client("config", region_name="us-west-2")
@@ -1223,7 +1222,7 @@ def test_start_configuration_recorder():
)
-@mock_config
+@mock_aws
def test_stop_configuration_recorder():
client = boto3.client("config", region_name="us-west-2")
@@ -1268,7 +1267,7 @@ def test_stop_configuration_recorder():
)
-@mock_config
+@mock_aws
def test_describe_configuration_recorder_status():
client = boto3.client("config", region_name="us-west-2")
@@ -1314,7 +1313,7 @@ def test_describe_configuration_recorder_status():
assert "wrong" in ce.value.response["Error"]["Message"]
-@mock_config
+@mock_aws
def test_delete_configuration_recorder():
client = boto3.client("config", region_name="us-west-2")
@@ -1340,7 +1339,7 @@ def test_delete_configuration_recorder():
assert ce.value.response["Error"]["Code"] == "NoSuchConfigurationRecorderException"
-@mock_config
+@mock_aws
def test_delete_delivery_channel():
client = boto3.client("config", region_name="us-west-2")
@@ -1384,8 +1383,7 @@ def test_delete_delivery_channel():
assert ce.value.response["Error"]["Code"] == "NoSuchDeliveryChannelException"
-@mock_config
-@mock_s3
+@mock_aws
def test_list_discovered_resource():
"""NOTE: We are only really testing the Config part. For each individual service, please add tests
for that individual service's "list_config_service_resources" function.
@@ -1490,8 +1488,7 @@ def test_list_discovered_resource():
)
-@mock_config
-@mock_s3
+@mock_aws
def test_list_aggregate_discovered_resource():
"""NOTE: We are only really testing the Config part. For each individual service, please add tests
for that individual service's "list_config_service_resources" function.
@@ -1634,8 +1631,7 @@ def test_list_aggregate_discovered_resource():
assert "101" in ce.value.response["Error"]["Message"]
-@mock_config
-@mock_s3
+@mock_aws
def test_get_resource_config_history():
"""NOTE: We are only really testing the Config part. For each individual service, please add tests
for that individual service's "get_config_resource" function.
@@ -1693,8 +1689,7 @@ def test_get_resource_config_history():
assert ce.value.response["Error"]["Code"] == "ResourceNotDiscoveredException"
-@mock_config
-@mock_s3
+@mock_aws
def test_batch_get_resource_config():
"""NOTE: We are only really testing the Config part. For each individual service, please add tests
for that individual service's "get_config_resource" function.
@@ -1757,8 +1752,7 @@ def test_batch_get_resource_config():
assert not result["baseConfigurationItems"]
-@mock_config
-@mock_s3
+@mock_aws
def test_batch_get_aggregate_resource_config():
"""NOTE: We are only really testing the Config part. For each individual service, please add tests
for that individual service's "get_config_resource" function.
@@ -1928,7 +1922,7 @@ def test_batch_get_aggregate_resource_config():
)
-@mock_config
+@mock_aws
def test_put_evaluations():
client = boto3.client("config", region_name="us-west-2")
@@ -1997,7 +1991,7 @@ def test_put_evaluations():
}
-@mock_config
+@mock_aws
def test_put_organization_conformance_pack():
# given
client = boto3.client("config", region_name="us-east-1")
@@ -2027,7 +2021,7 @@ def test_put_organization_conformance_pack():
assert response["OrganizationConformancePackArn"] == arn
-@mock_config
+@mock_aws
def test_put_organization_conformance_pack_errors():
# given
client = boto3.client("config", region_name="us-east-1")
@@ -2065,7 +2059,7 @@ def test_put_organization_conformance_pack_errors():
)
-@mock_config
+@mock_aws
def test_describe_organization_conformance_packs():
# given
client = boto3.client("config", region_name="us-east-1")
@@ -2091,7 +2085,7 @@ def test_describe_organization_conformance_packs():
assert isinstance(pack["LastUpdateTime"], datetime)
-@mock_config
+@mock_aws
def test_describe_organization_conformance_packs_errors():
# given
client = boto3.client("config", region_name="us-east-1")
@@ -2113,7 +2107,7 @@ def test_describe_organization_conformance_packs_errors():
)
-@mock_config
+@mock_aws
def test_describe_organization_conformance_pack_statuses():
# given
client = boto3.client("config", region_name="us-east-1")
@@ -2165,7 +2159,7 @@ def test_describe_organization_conformance_pack_statuses():
assert status["LastUpdateTime"] > update_time
-@mock_config
+@mock_aws
def test_describe_organization_conformance_pack_statuses_errors():
# given
client = boto3.client("config", region_name="us-east-1")
@@ -2187,7 +2181,7 @@ def test_describe_organization_conformance_pack_statuses_errors():
)
-@mock_config
+@mock_aws
def test_get_organization_conformance_pack_detailed_status():
# given
client = boto3.client("config", region_name="us-east-1")
@@ -2235,7 +2229,7 @@ def test_get_organization_conformance_pack_detailed_status():
assert status["LastUpdateTime"] > update_time
-@mock_config
+@mock_aws
def test_get_organization_conformance_pack_detailed_status_errors():
# given
client = boto3.client("config", region_name="us-east-1")
@@ -2257,7 +2251,7 @@ def test_get_organization_conformance_pack_detailed_status_errors():
)
-@mock_config
+@mock_aws
def test_delete_organization_conformance_pack():
# given
client = boto3.client("config", region_name="us-east-1")
@@ -2277,7 +2271,7 @@ def test_delete_organization_conformance_pack():
assert len(response["OrganizationConformancePackStatuses"]) == 0
-@mock_config
+@mock_aws
def test_delete_organization_conformance_pack_errors():
# given
client = boto3.client("config", region_name="us-east-1")
@@ -2299,7 +2293,7 @@ def test_delete_organization_conformance_pack_errors():
)
-@mock_config
+@mock_aws
def test_put_retention_configuration():
# Test with parameter validation being False to test the retention days check:
client = boto3.client(
@@ -2332,7 +2326,7 @@ def test_put_retention_configuration():
}
-@mock_config
+@mock_aws
def test_describe_retention_configurations():
client = boto3.client("config", region_name="us-west-2")
@@ -2377,7 +2371,7 @@ def test_describe_retention_configurations():
)
-@mock_config
+@mock_aws
def test_delete_retention_configuration():
client = boto3.client("config", region_name="us-west-2")
diff --git a/tests/test_config/test_config_rules.py b/tests/test_config/test_config_rules.py
index 4a8bb0bc7..b91d7f23a 100644
--- a/tests/test_config/test_config_rules.py
+++ b/tests/test_config/test_config_rules.py
@@ -12,8 +12,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import settings
-from moto.config import mock_config
+from moto import mock_aws, settings
from moto.config.models import CONFIG_RULE_PAGE_SIZE, ConfigRule
from moto.moto_api._internal import mock_random
@@ -34,7 +33,7 @@ def managed_config_rule():
}
-@mock_config
+@mock_aws
def test_put_config_rule_errors():
"""Test various error conditions in put_config_rule API call."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -68,7 +67,7 @@ def test_put_config_rule_errors():
assert "Member must have length less than or equal to 128" in err["Message"]
-@mock_config
+@mock_aws
def test_put_config_rule_update_errors():
"""Test various error conditions when updating ConfigRule."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -111,7 +110,7 @@ def test_put_config_rule_update_errors():
)
-@mock_config
+@mock_aws
def test_config_rule_errors(): # pylint: disable=too-many-statements
"""Test various error conditions in ConfigRule instantiation."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -188,7 +187,7 @@ def test_config_rule_errors(): # pylint: disable=too-many-statements
)
-@mock_config
+@mock_aws
def test_aws_managed_rule_errors():
"""Test various error conditions in ConfigRule instantiation."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -236,7 +235,7 @@ def test_aws_managed_rule_errors():
# assert new_config_rule["MaximumExecutionFrequency"] == "TwentyFour_Hours"
-@mock_config
+@mock_aws
def test_config_rules_scope_errors(): # pylint: disable=too-many-statements
"""Test various error conditions in ConfigRule.Scope instantiation."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -309,7 +308,7 @@ def test_config_rules_scope_errors(): # pylint: disable=too-many-statements
assert "Scope cannot be applied to both resource and tag" in err["Message"]
-@mock_config
+@mock_aws
def test_valid_put_config_managed_rule():
"""Test valid put_config_rule API calls for managed rules."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -366,7 +365,7 @@ def test_valid_put_config_managed_rule():
assert managed_rule_json == rsp_json
-@mock_config
+@mock_aws
def test_describe_config_rules():
"""Test the describe_config_rules API."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -433,7 +432,7 @@ def test_describe_config_rules():
idx += 1
-@mock_config
+@mock_aws
def test_delete_config_rules():
"""Test the delete_config_rule API."""
client = boto3.client("config", region_name=TEST_REGION)
diff --git a/tests/test_config/test_config_rules_integration.py b/tests/test_config/test_config_rules_integration.py
index e409f5a18..bccb05fa0 100644
--- a/tests/test_config/test_config_rules_integration.py
+++ b/tests/test_config/test_config_rules_integration.py
@@ -7,7 +7,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_config, mock_iam, mock_lambda
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .test_config_rules import TEST_REGION, managed_config_rule
@@ -49,19 +49,17 @@ def lambda_handler(event, context):
return zip_output.read()
-@mock_lambda
def create_lambda_for_config_rule():
"""Return the ARN of a lambda that can be used by a custom rule."""
role_name = "test-role"
lambda_role = None
- with mock_iam():
- iam_client = boto3.client("iam", region_name=TEST_REGION)
- try:
- lambda_role = iam_client.get_role(RoleName=role_name)["Role"]["Arn"]
- except ClientError:
- lambda_role = iam_client.create_role(
- RoleName=role_name, AssumeRolePolicyDocument="test policy", Path="/"
- )["Role"]["Arn"]
+ iam_client = boto3.client("iam", region_name=TEST_REGION)
+ try:
+ lambda_role = iam_client.get_role(RoleName=role_name)["Role"]["Arn"]
+ except ClientError:
+ lambda_role = iam_client.create_role(
+ RoleName=role_name, AssumeRolePolicyDocument="test policy", Path="/"
+ )["Role"]["Arn"]
# Create the lambda function and identify its location.
lambda_client = boto3.client("lambda", region_name=TEST_REGION)
@@ -78,7 +76,7 @@ def create_lambda_for_config_rule():
)
-@mock_config
+@mock_aws
def test_config_rules_source_details_errors():
"""Test error conditions with ConfigRule.Source_Details instantiation."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -159,7 +157,7 @@ def test_config_rules_source_details_errors():
)
-@mock_config
+@mock_aws
def test_valid_put_config_custom_rule():
"""Test valid put_config_rule API calls for custom rules."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -227,7 +225,7 @@ def test_valid_put_config_custom_rule():
assert updated_rule["MaximumExecutionFrequency"] == "Six_Hours"
-@mock_config
+@mock_aws
def test_config_rules_source_errors(): # pylint: disable=too-many-statements
"""Test various error conditions in ConfigRule.Source instantiation."""
client = boto3.client("config", region_name=TEST_REGION)
diff --git a/tests/test_config/test_config_tags.py b/tests/test_config/test_config_tags.py
index 856100df6..6320b5086 100644
--- a/tests/test_config/test_config_tags.py
+++ b/tests/test_config/test_config_tags.py
@@ -10,7 +10,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError, ParamValidationError
-from moto.config import mock_config
+from moto import mock_aws
from moto.config.models import MAX_TAGS_IN_ARG
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.moto_api._internal import mock_random
@@ -43,7 +43,7 @@ def config_aggregators_info(client):
return config_aggs
-@mock_config
+@mock_aws
def test_tag_resource():
"""Test the ConfigSource API tag_resource()."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -148,7 +148,7 @@ def test_tag_resource():
assert tags == updated_rsp["Tags"]
-@mock_config
+@mock_aws
def test_untag_resource():
"""Test the ConfigSource API untag_resource()."""
client = boto3.client("config", region_name=TEST_REGION)
@@ -269,7 +269,7 @@ def test_untag_resource():
assert tags == updated_rsp["Tags"]
-@mock_config
+@mock_aws
def test_list_tags_for_resource():
"""Test the ConfigSource API list_tags_for_resource()."""
client = boto3.client("config", region_name=TEST_REGION)
diff --git a/tests/test_core/test_auth.py b/tests/test_core/test_auth.py
index 3376d94d5..4813fb420 100644
--- a/tests/test_core/test_auth.py
+++ b/tests/test_core/test_auth.py
@@ -6,19 +6,19 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_elbv2, mock_iam, mock_rds, mock_s3, mock_ssm, mock_sts
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core import set_initial_no_auth_action_count
-@mock_iam
+@mock_aws
def create_user_with_access_key(user_name: str = "test-user") -> Dict[str, str]:
client = boto3.client("iam", region_name="us-east-1")
client.create_user(UserName=user_name)
return client.create_access_key(UserName=user_name)["AccessKey"]
-@mock_iam
+@mock_aws
def create_user_with_access_key_and_inline_policy( # type: ignore[misc]
user_name: str, policy_document: Dict[str, Any], policy_name: str = "policy1"
) -> Dict[str, str]:
@@ -32,7 +32,7 @@ def create_user_with_access_key_and_inline_policy( # type: ignore[misc]
return client.create_access_key(UserName=user_name)["AccessKey"]
-@mock_iam
+@mock_aws
def create_user_with_access_key_and_attached_policy( # type: ignore[misc]
user_name: str, policy_document: Dict[str, Any], policy_name: str = "policy1"
) -> Dict[str, str]:
@@ -45,7 +45,7 @@ def create_user_with_access_key_and_attached_policy( # type: ignore[misc]
return client.create_access_key(UserName=user_name)["AccessKey"]
-@mock_iam
+@mock_aws
def create_user_with_access_key_and_multiple_policies( # type: ignore[misc]
user_name: str,
inline_policy_document: Dict[str, Any],
@@ -126,8 +126,7 @@ def create_group_with_multiple_policies_and_add_user(
client.add_user_to_group(GroupName=group_name, UserName=user_name)
-@mock_iam
-@mock_sts
+@mock_aws
def create_role_with_attached_policy_and_assume_it( # type: ignore[misc]
role_name: str,
trust_policy_document: Dict[str, Any],
@@ -149,8 +148,7 @@ def create_role_with_attached_policy_and_assume_it( # type: ignore[misc]
]
-@mock_iam
-@mock_sts
+@mock_aws
def create_role_with_inline_policy_and_assume_it( # type: ignore[misc]
role_name: str,
trust_policy_document: Dict[str, Any],
@@ -174,7 +172,7 @@ def create_role_with_inline_policy_and_assume_it( # type: ignore[misc]
@set_initial_no_auth_action_count(0)
-@mock_iam
+@mock_aws
def test_invalid_client_token_id() -> None:
client = boto3.client(
"iam",
@@ -191,7 +189,7 @@ def test_invalid_client_token_id() -> None:
@set_initial_no_auth_action_count(0)
-@mock_ec2
+@mock_aws
def test_auth_failure() -> None:
client = boto3.client(
"ec2",
@@ -210,7 +208,7 @@ def test_auth_failure() -> None:
@set_initial_no_auth_action_count(2)
-@mock_iam
+@mock_aws
def test_signature_does_not_match() -> None:
access_key = create_user_with_access_key()
client = boto3.client(
@@ -230,7 +228,7 @@ def test_signature_does_not_match() -> None:
@set_initial_no_auth_action_count(2)
-@mock_ec2
+@mock_aws
def test_auth_failure_with_valid_access_key_id() -> None:
access_key = create_user_with_access_key()
client = boto3.client(
@@ -250,7 +248,7 @@ def test_auth_failure_with_valid_access_key_id() -> None:
@set_initial_no_auth_action_count(2)
-@mock_ec2
+@mock_aws
def test_access_denied_with_no_policy() -> None:
user_name = "test-user"
access_key = create_user_with_access_key(user_name)
@@ -271,7 +269,7 @@ def test_access_denied_with_no_policy() -> None:
@set_initial_no_auth_action_count(3)
-@mock_ec2
+@mock_aws
def test_access_denied_with_not_allowing_policy() -> None:
user_name = "test-user"
inline_policy_document = {
@@ -298,7 +296,7 @@ def test_access_denied_with_not_allowing_policy() -> None:
@set_initial_no_auth_action_count(3)
-@mock_sts
+@mock_aws
def test_access_denied_explicitly_on_specific_resource() -> None:
user_name = "test-user"
forbidden_role_arn = f"arn:aws:iam::{ACCOUNT_ID}:role/forbidden_explicitly"
@@ -339,7 +337,7 @@ def test_access_denied_explicitly_on_specific_resource() -> None:
@set_initial_no_auth_action_count(3)
-@mock_ec2
+@mock_aws
def test_access_denied_for_run_instances() -> None:
# https://github.com/getmoto/moto/issues/2774
# The run-instances method was broken between botocore versions 1.15.8 and 1.15.12
@@ -372,7 +370,7 @@ def test_access_denied_for_run_instances() -> None:
@set_initial_no_auth_action_count(3)
-@mock_ec2
+@mock_aws
def test_access_denied_with_denying_policy() -> None:
user_name = "test-user"
inline_policy_document = {
@@ -402,7 +400,7 @@ def test_access_denied_with_denying_policy() -> None:
@set_initial_no_auth_action_count(3)
-@mock_sts
+@mock_aws
def test_get_caller_identity_allowed_with_denying_policy() -> None:
user_name = "test-user"
inline_policy_document = {
@@ -427,7 +425,7 @@ def test_get_caller_identity_allowed_with_denying_policy() -> None:
@set_initial_no_auth_action_count(3)
-@mock_ec2
+@mock_aws
def test_allowed_with_wildcard_action() -> None:
user_name = "test-user"
inline_policy_document = {
@@ -447,7 +445,7 @@ def test_allowed_with_wildcard_action() -> None:
@set_initial_no_auth_action_count(4)
-@mock_iam
+@mock_aws
def test_allowed_with_explicit_action_in_attached_policy() -> None:
user_name = "test-user"
attached_policy_document = {
@@ -467,8 +465,7 @@ def test_allowed_with_explicit_action_in_attached_policy() -> None:
@set_initial_no_auth_action_count(8)
-@mock_s3
-@mock_iam
+@mock_aws
def test_s3_access_denied_with_denying_attached_group_policy() -> None:
user_name = "test-user"
attached_policy_document = {
@@ -501,8 +498,7 @@ def test_s3_access_denied_with_denying_attached_group_policy() -> None:
@set_initial_no_auth_action_count(6)
-@mock_s3
-@mock_iam
+@mock_aws
def test_s3_access_denied_with_denying_inline_group_policy() -> None:
user_name = "test-user"
bucket_name = "test-bucket"
@@ -535,8 +531,7 @@ def test_s3_access_denied_with_denying_inline_group_policy() -> None:
@set_initial_no_auth_action_count(10)
-@mock_iam
-@mock_ec2
+@mock_aws
def test_access_denied_with_many_irrelevant_policies() -> None:
user_name = "test-user"
inline_policy_document = {
@@ -584,10 +579,7 @@ def test_access_denied_with_many_irrelevant_policies() -> None:
@set_initial_no_auth_action_count(4)
-@mock_iam
-@mock_sts
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_allowed_with_temporary_credentials() -> None:
role_name = "test-role"
trust_policy_document = {
@@ -636,9 +628,7 @@ def test_allowed_with_temporary_credentials() -> None:
@set_initial_no_auth_action_count(3)
-@mock_iam
-@mock_sts
-@mock_rds
+@mock_aws
def test_access_denied_with_temporary_credentials() -> None:
role_name = "test-role"
session_name = "test-session"
@@ -681,7 +671,7 @@ def test_access_denied_with_temporary_credentials() -> None:
@set_initial_no_auth_action_count(3)
-@mock_iam
+@mock_aws
def test_get_user_from_credentials() -> None:
user_name = "new-test-user"
inline_policy_document = {
@@ -701,7 +691,7 @@ def test_get_user_from_credentials() -> None:
@set_initial_no_auth_action_count(0)
-@mock_s3
+@mock_aws
def test_s3_invalid_access_key_id() -> None:
client = boto3.client(
"s3",
@@ -720,8 +710,7 @@ def test_s3_invalid_access_key_id() -> None:
@set_initial_no_auth_action_count(3)
-@mock_s3
-@mock_iam
+@mock_aws
def test_s3_signature_does_not_match() -> None:
bucket_name = "test-bucket"
access_key = create_user_with_access_key()
@@ -743,8 +732,7 @@ def test_s3_signature_does_not_match() -> None:
@set_initial_no_auth_action_count(7)
-@mock_s3
-@mock_iam
+@mock_aws
def test_s3_access_denied_not_action() -> None:
user_name = "test-user"
bucket_name = "test-bucket"
@@ -777,9 +765,7 @@ def test_s3_access_denied_not_action() -> None:
@set_initial_no_auth_action_count(4)
-@mock_iam
-@mock_sts
-@mock_s3
+@mock_aws
def test_s3_invalid_token_with_temporary_credentials() -> None:
role_name = "test-role"
session_name = "test-session"
@@ -816,8 +802,7 @@ def test_s3_invalid_token_with_temporary_credentials() -> None:
@set_initial_no_auth_action_count(3)
-@mock_s3
-@mock_iam
+@mock_aws
def test_allow_bucket_access_using_resource_arn() -> None:
user_name = "test-user"
policy_doc = {
@@ -850,8 +835,7 @@ def test_allow_bucket_access_using_resource_arn() -> None:
@set_initial_no_auth_action_count(3)
-@mock_s3
-@mock_iam
+@mock_aws
def test_allow_key_access_using_resource_arn() -> None:
user_name = "test-user"
policy_doc = {
@@ -881,8 +865,7 @@ def test_allow_key_access_using_resource_arn() -> None:
@set_initial_no_auth_action_count(3)
-@mock_ssm
-@mock_iam
+@mock_aws
def test_ssm_service() -> None:
user_name = "test-user"
policy_doc = {
diff --git a/tests/test_core/test_backenddict.py b/tests/test_core/test_backenddict.py
index 1044ff9cb..0d1ed0984 100644
--- a/tests/test_core/test_backenddict.py
+++ b/tests/test_core/test_backenddict.py
@@ -176,86 +176,3 @@ def test_multiple_backends_cache_behaviour() -> None:
as_1 = autoscaling[DEFAULT_ACCOUNT_ID]["us-east-1"]
assert type(as_1) == AutoScalingBackend
-
-
-def test_backenddict_cache_hits_and_misses() -> None:
- backend = BackendDict(ExampleBackend, "ebs")
- backend.__getitem__.cache_clear()
-
- assert backend.__getitem__.cache_info().hits == 0
- assert backend.__getitem__.cache_info().misses == 0
- assert backend.__getitem__.cache_info().currsize == 0
-
- # Create + Retrieve an account - verify it is stored in cache
- accnt_1 = backend["accnt1"]
- assert accnt_1.account_id == "accnt1"
-
- assert backend.__getitem__.cache_info().hits == 0
- assert backend.__getitem__.cache_info().misses == 1
- assert backend.__getitem__.cache_info().currsize == 1
-
- # Creating + Retrieving a second account
- accnt_2 = backend["accnt2"]
- assert accnt_2.account_id == "accnt2"
-
- assert backend.__getitem__.cache_info().hits == 0
- assert backend.__getitem__.cache_info().misses == 2
- assert backend.__getitem__.cache_info().currsize == 2
-
- # Retrieving the first account from cache
- accnt_1_again = backend["accnt1"]
- assert accnt_1_again.account_id == "accnt1"
-
- assert backend.__getitem__.cache_info().hits == 1
- assert backend.__getitem__.cache_info().misses == 2
- assert backend.__getitem__.cache_info().currsize == 2
-
- # Retrieving the second account from cache
- accnt_2_again = backend["accnt2"]
- assert accnt_2_again.account_id == "accnt2"
-
- assert backend.__getitem__.cache_info().hits == 2
- assert backend.__getitem__.cache_info().misses == 2
- assert backend.__getitem__.cache_info().currsize == 2
-
-
-def test_asb_cache_hits_and_misses() -> None:
- backend = BackendDict(ExampleBackend, "ebs")
- acb = backend["accnt_id"]
- acb.__getitem__.cache_clear()
-
- assert acb.__getitem__.cache_info().hits == 0
- assert acb.__getitem__.cache_info().misses == 0
- assert acb.__getitem__.cache_info().currsize == 0
-
- # Create + Retrieve an account - verify it is stored in cache
- region_1 = acb["us-east-1"]
- assert region_1.region_name == "us-east-1"
-
- assert acb.__getitem__.cache_info().hits == 0
- assert acb.__getitem__.cache_info().misses == 1
- assert acb.__getitem__.cache_info().currsize == 1
-
- # Creating + Retrieving a second account
- region_2 = acb["us-east-2"]
- assert region_2.region_name == "us-east-2"
-
- assert acb.__getitem__.cache_info().hits == 0
- assert acb.__getitem__.cache_info().misses == 2
- assert acb.__getitem__.cache_info().currsize == 2
-
- # Retrieving the first account from cache
- region_1_again = acb["us-east-1"]
- assert region_1_again.region_name == "us-east-1"
-
- assert acb.__getitem__.cache_info().hits == 1
- assert acb.__getitem__.cache_info().misses == 2
- assert acb.__getitem__.cache_info().currsize == 2
-
- # Retrieving the second account from cache
- region_2_again = acb["us-east-2"]
- assert region_2_again.region_name == "us-east-2"
-
- assert acb.__getitem__.cache_info().hits == 2
- assert acb.__getitem__.cache_info().misses == 2
- assert acb.__getitem__.cache_info().currsize == 2
diff --git a/tests/test_core/test_context_manager.py b/tests/test_core/test_context_manager.py
deleted file mode 100644
index 8e7592ca9..000000000
--- a/tests/test_core/test_context_manager.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import boto3
-
-from moto import mock_sqs, settings
-from tests import DEFAULT_ACCOUNT_ID
-
-
-def test_context_manager_returns_mock() -> None:
- with mock_sqs() as sqs_mock:
- conn = boto3.client("sqs", region_name="us-west-1")
- conn.create_queue(QueueName="queue1")
-
- if not settings.TEST_SERVER_MODE:
- backend = sqs_mock.backends[DEFAULT_ACCOUNT_ID]["us-west-1"]
- assert list(backend.queues.keys()) == ["queue1"] # type: ignore[attr-defined]
diff --git a/tests/test_core/test_decorator_calls.py b/tests/test_core/test_decorator_calls.py
index 30a0c6479..efa7ed6ab 100644
--- a/tests/test_core/test_decorator_calls.py
+++ b/tests/test_core/test_decorator_calls.py
@@ -6,14 +6,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_kinesis, mock_s3, settings
+from moto import mock_aws, settings
"""
Test the different ways that the decorator can be used
"""
-@mock_ec2
+@mock_aws
def test_basic_decorator() -> None:
client = boto3.client("ec2", region_name="us-west-1")
assert client.describe_addresses()["Addresses"] == []
@@ -39,7 +39,7 @@ def test_context_manager(aws_credentials: Any) -> None: # type: ignore[misc] #
err["Message"] == "AWS was not able to validate the provided access credentials"
)
- with mock_ec2():
+ with mock_aws():
client = boto3.client("ec2", region_name="us-west-1")
assert client.describe_addresses()["Addresses"] == []
@@ -48,7 +48,7 @@ def test_context_manager(aws_credentials: Any) -> None: # type: ignore[misc] #
def test_decorator_start_and_stop() -> None:
if settings.TEST_SERVER_MODE:
raise SkipTest("Authentication always works in ServerMode")
- mock = mock_ec2()
+ mock = mock_aws()
mock.start()
client = boto3.client("ec2", region_name="us-west-1")
assert client.describe_addresses()["Addresses"] == []
@@ -63,7 +63,7 @@ def test_decorator_start_and_stop() -> None:
)
-@mock_ec2
+@mock_aws
def test_decorater_wrapped_gets_set() -> None:
"""
Moto decorator's __wrapped__ should get set to the tests function
@@ -71,7 +71,7 @@ def test_decorater_wrapped_gets_set() -> None:
assert test_decorater_wrapped_gets_set.__wrapped__.__name__ == "test_decorater_wrapped_gets_set" # type: ignore
-@mock_ec2
+@mock_aws
class Tester:
def test_the_class(self) -> None:
client = boto3.client("ec2", region_name="us-west-1")
@@ -82,7 +82,7 @@ class Tester:
assert client.describe_addresses()["Addresses"] == []
-@mock_s3
+@mock_aws
class TesterWithSetup(unittest.TestCase):
def setUp(self) -> None:
self.client = boto3.client("s3", region_name="us-east-1")
@@ -96,7 +96,7 @@ class TesterWithSetup(unittest.TestCase):
assert "mybucket" in bucket_names
-@mock_s3
+@mock_aws
class TesterWithStaticmethod:
@staticmethod
def static(*args: Any) -> None: # type: ignore[misc]
@@ -106,7 +106,7 @@ class TesterWithStaticmethod:
self.static()
-@mock_s3
+@mock_aws
class TestWithSetup_UppercaseU(unittest.TestCase):
def setUp(self) -> None:
# This method will be executed automatically, provided we extend the TestCase-class
@@ -123,7 +123,7 @@ class TestWithSetup_UppercaseU(unittest.TestCase):
s3.head_bucket(Bucket="unknown_bucket")
-@mock_s3
+@mock_aws
class TestWithSetup_LowercaseU:
def setup_method(self, *args: Any) -> None: # pylint: disable=unused-argument
# This method will be executed automatically using pytest
@@ -140,7 +140,7 @@ class TestWithSetup_LowercaseU:
s3.head_bucket(Bucket="unknown_bucket")
-@mock_s3
+@mock_aws
class TestWithSetupMethod:
def setup_method(self, *args: Any) -> None: # pylint: disable=unused-argument
# This method will be executed automatically using pytest
@@ -157,7 +157,7 @@ class TestWithSetupMethod:
s3.head_bucket(Bucket="unknown_bucket")
-@mock_kinesis
+@mock_aws
class TestKinesisUsingSetupMethod:
def setup_method(self, *args: Any) -> None: # pylint: disable=unused-argument
self.stream_name = "test_stream"
@@ -176,7 +176,7 @@ class TestKinesisUsingSetupMethod:
pass
-@mock_s3
+@mock_aws
class TestWithInvalidSetupMethod:
def setupmethod(self) -> None:
s3 = boto3.client("s3", region_name="us-east-1")
@@ -189,7 +189,7 @@ class TestWithInvalidSetupMethod:
s3.head_bucket(Bucket="mybucket")
-@mock_s3
+@mock_aws
class TestWithPublicMethod(unittest.TestCase):
def ensure_bucket_exists(self) -> None:
s3 = boto3.client("s3", region_name="us-east-1")
@@ -207,7 +207,7 @@ class TestWithPublicMethod(unittest.TestCase):
s3.head_bucket(Bucket="mybucket")
-@mock_s3
+@mock_aws
class TestWithPseudoPrivateMethod(unittest.TestCase):
def _ensure_bucket_exists(self) -> None:
s3 = boto3.client("s3", region_name="us-east-1")
@@ -224,7 +224,7 @@ class TestWithPseudoPrivateMethod(unittest.TestCase):
s3.head_bucket(Bucket="mybucket")
-@mock_s3
+@mock_aws
class Baseclass(unittest.TestCase):
def setUp(self) -> None:
self.s3 = boto3.resource("s3", region_name="us-east-1")
@@ -237,14 +237,14 @@ class Baseclass(unittest.TestCase):
self.test_bucket.delete()
-@mock_s3
+@mock_aws
class TestSetUpInBaseClass(Baseclass):
def test_a_thing(self) -> None:
# Verify that we can 'see' the setUp-method in the parent class
assert self.client.head_bucket(Bucket="testbucket") is not None
-@mock_s3
+@mock_aws
class TestWithNestedClasses:
class NestedClass(unittest.TestCase):
def _ensure_bucket_exists(self) -> None:
diff --git a/tests/test_core/test_ec2_vpc_endpoint_services.py b/tests/test_core/test_ec2_vpc_endpoint_services.py
index 2f58d5d77..b804da1f1 100644
--- a/tests/test_core/test_ec2_vpc_endpoint_services.py
+++ b/tests/test_core/test_ec2_vpc_endpoint_services.py
@@ -7,10 +7,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
-@mock_ec2
+@mock_aws
def test_describe_vpc_endpoint_services_bad_args() -> None:
"""Verify exceptions are raised for bad arguments."""
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -46,7 +46,7 @@ def test_describe_vpc_endpoint_services_bad_args() -> None:
assert "The token 'foo' is invalid" in err["Message"]
-@mock_ec2
+@mock_aws
def test_describe_vpc_default_endpoint_services() -> None:
"""Test successfull calls as well as the next_token arg."""
ec2 = boto3.client("ec2", region_name="us-west-1")
diff --git a/tests/test_core/test_environ_patching.py b/tests/test_core/test_environ_patching.py
index a0bbc7261..0d36dcbcc 100644
--- a/tests/test_core/test_environ_patching.py
+++ b/tests/test_core/test_environ_patching.py
@@ -1,12 +1,12 @@
import os
-from moto import mock_ec2, mock_s3
+from moto import mock_aws
KEY = "AWS_ACCESS_KEY_ID"
def test_aws_keys_are_patched() -> None:
- with mock_ec2():
+ with mock_aws():
patched_value = os.environ[KEY]
assert patched_value == "FOOBARKEY"
@@ -24,7 +24,7 @@ def test_aws_keys_can_be_none() -> None:
pass # Value might not be set on this system in the first place
try:
# Verify that the os.environ[KEY] is patched
- with mock_s3():
+ with mock_aws():
patched_value = os.environ[KEY]
assert patched_value == "FOOBARKEY"
# Verify that the os.environ[KEY] is unpatched, and reverts to None
diff --git a/tests/test_core/test_importorder.py b/tests/test_core/test_importorder.py
index 0f649b5a8..e235f553a 100644
--- a/tests/test_core/test_importorder.py
+++ b/tests/test_core/test_importorder.py
@@ -4,7 +4,7 @@ from unittest import SkipTest
import boto3
import pytest
-from moto import mock_s3, settings
+from moto import mock_aws, settings
@pytest.fixture(scope="function", name="aws_credentials")
@@ -21,7 +21,7 @@ def fixture_aws_credentials(monkeypatch: Any) -> None: # type: ignore[misc]
def test_mock_works_with_client_created_inside(
aws_credentials: Any, # pylint: disable=unused-argument
) -> None:
- m = mock_s3()
+ m = mock_aws()
m.start()
client = boto3.client("s3", region_name="us-east-1")
@@ -37,7 +37,7 @@ def test_mock_works_with_client_created_outside(
outside_client = boto3.client("s3", region_name="us-east-1")
# Start the mock afterwards - which does not mock an already created client
- m = mock_s3()
+ m = mock_aws()
m.start()
# So remind us to mock this client
@@ -57,7 +57,7 @@ def test_mock_works_with_resource_created_outside(
outside_resource = boto3.resource("s3", region_name="us-east-1")
# Start the mock afterwards - which does not mock an already created resource
- m = mock_s3()
+ m = mock_aws()
m.start()
# So remind us to mock this resource
@@ -71,7 +71,7 @@ def test_mock_works_with_resource_created_outside(
def test_patch_can_be_called_on_a_mocked_client() -> None:
# start S3 after the mock, ensuring that the client contains our event-handler
- m = mock_s3()
+ m = mock_aws()
m.start()
client = boto3.client("s3", region_name="us-east-1")
@@ -80,7 +80,7 @@ def test_patch_can_be_called_on_a_mocked_client() -> None:
patch_client(client)
patch_client(client)
- # At this point, our event-handler should only be registered once, by `mock_s3`
+ # At this point, our event-handler should only be registered once, by `mock_aws`
# `patch_client` should not re-register the event-handler
test_object = b"test_object_text"
client.create_bucket(Bucket="buck")
@@ -120,7 +120,7 @@ def test_mock_works_when_replacing_client(
) -> None:
logic = ImportantBusinessLogic()
- m = mock_s3()
+ m = mock_aws()
m.start()
# This will fail, as the S3 client was created before the mock was initialized
diff --git a/tests/test_core/test_instance_metadata.py b/tests/test_core/test_instance_metadata.py
index 0fcb4a47d..94170e32d 100644
--- a/tests/test_core/test_instance_metadata.py
+++ b/tests/test_core/test_instance_metadata.py
@@ -1,6 +1,6 @@
import requests
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
if settings.TEST_SERVER_MODE:
BASE_URL = "http://localhost:5000"
@@ -8,13 +8,13 @@ else:
BASE_URL = "http://169.254.169.254"
-@mock_ec2
+@mock_aws
def test_latest_meta_data() -> None:
res = requests.get(f"{BASE_URL}/latest/meta-data/")
assert res.content == b"iam"
-@mock_ec2
+@mock_aws
def test_meta_data_iam() -> None:
res = requests.get(f"{BASE_URL}/latest/meta-data/iam")
json_response = res.json()
@@ -25,13 +25,13 @@ def test_meta_data_iam() -> None:
assert "Expiration" in default_role
-@mock_ec2
+@mock_aws
def test_meta_data_security_credentials() -> None:
res = requests.get(f"{BASE_URL}/latest/meta-data/iam/security-credentials/")
assert res.content == b"default-role"
-@mock_ec2
+@mock_aws
def test_meta_data_default_role() -> None:
res = requests.get(
f"{BASE_URL}/latest/meta-data/iam/security-credentials/default-role"
diff --git a/tests/test_core/test_mock_all.py b/tests/test_core/test_mock_all.py
deleted file mode 100644
index a91d87295..000000000
--- a/tests/test_core/test_mock_all.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import boto3
-import pytest
-
-from moto import mock_all
-
-
-@mock_all()
-def test_decorator() -> None:
- rgn = "us-east-1"
- sqs = boto3.client("sqs", region_name=rgn)
- r = sqs.list_queues()
- assert r["ResponseMetadata"]["HTTPStatusCode"] == 200
-
- lmbda = boto3.client("lambda", region_name=rgn)
- r = lmbda.list_event_source_mappings()
- assert r["ResponseMetadata"]["HTTPStatusCode"] == 200
-
- ddb = boto3.client("dynamodb", region_name=rgn)
- r = ddb.list_tables()
- assert r["ResponseMetadata"]["HTTPStatusCode"] == 200
-
-
-def test_context_manager() -> None:
- rgn = "us-east-1"
-
- with mock_all():
- sqs = boto3.client("sqs", region_name=rgn)
- r = sqs.list_queues()
- assert r["ResponseMetadata"]["HTTPStatusCode"] == 200
-
- unpatched_sqs = boto3.Session().client("sqs", region_name=rgn)
-
- with pytest.raises(Exception):
- unpatched_sqs.list_queues()
diff --git a/tests/test_core/test_mock_regions.py b/tests/test_core/test_mock_regions.py
index 5b7f89840..2475e0122 100644
--- a/tests/test_core/test_mock_regions.py
+++ b/tests/test_core/test_mock_regions.py
@@ -4,10 +4,10 @@ from unittest import SkipTest, mock
import boto3
import pytest
-from moto import mock_dynamodb, mock_sns, settings
+from moto import mock_aws, settings
-@mock_sns
+@mock_aws
def test_use_invalid_region() -> None:
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode will throw different errors")
@@ -17,25 +17,25 @@ def test_use_invalid_region() -> None:
assert "any-region" in str(exc.value)
-@mock_sns
+@mock_aws
@mock.patch.dict(os.environ, {"AWS_DEFAULT_REGION": "us-east-2"})
def test_use_region_from_env() -> None: # type: ignore[misc]
client = boto3.client("sns")
assert client.list_platform_applications()["PlatformApplications"] == []
-@mock_sns
+@mock_aws
@mock.patch.dict(os.environ, {"AWS_DEFAULT_REGION": "any-region"})
def test_use_unknown_region_from_env() -> None: # type: ignore[misc]
if settings.TEST_SERVER_MODE:
- raise SkipTest("Cannot set environemnt variables in ServerMode")
+ raise SkipTest("Cannot set environment variables in ServerMode")
client = boto3.client("sns")
with pytest.raises(KeyError) as exc:
client.list_platform_applications()
assert "any-region" in str(exc.value)
-@mock_sns
+@mock_aws
@mock.patch.dict(os.environ, {"AWS_DEFAULT_REGION": "any-region"})
@mock.patch.dict(os.environ, {"MOTO_ALLOW_NONEXISTENT_REGION": "trUe"})
def test_use_unknown_region_from_env_but_allow_it() -> None: # type: ignore[misc]
@@ -45,7 +45,7 @@ def test_use_unknown_region_from_env_but_allow_it() -> None: # type: ignore[mis
assert client.list_platform_applications()["PlatformApplications"] == []
-@mock_dynamodb
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_ALLOW_NONEXISTENT_REGION": "trUe"})
def test_use_unknown_region_from_env_but_allow_it__dynamo() -> None: # type: ignore[misc]
if settings.TEST_SERVER_MODE:
diff --git a/tests/test_core/test_moto_api.py b/tests/test_core/test_moto_api.py
index 695801d02..6b2b3c101 100644
--- a/tests/test_core/test_moto_api.py
+++ b/tests/test_core/test_moto_api.py
@@ -6,7 +6,7 @@ import pytest
import requests
from botocore.exceptions import ClientError
-from moto import mock_autoscaling, mock_s3, mock_sqs, settings
+from moto import mock_aws, settings
from moto.core.model_instances import model_data, reset_model_data
base_url = (
@@ -17,7 +17,7 @@ base_url = (
data_url = f"{base_url}/moto-api/data.json"
-@mock_sqs
+@mock_aws
def test_reset_api() -> None:
conn = boto3.client("sqs", region_name="us-west-1")
conn.create_queue(QueueName="queue1")
@@ -29,7 +29,7 @@ def test_reset_api() -> None:
assert "QueueUrls" not in conn.list_queues() # No more queues
-@mock_sqs
+@mock_aws
def test_data_api() -> None:
conn = boto3.client("sqs", region_name="us-west-1")
conn.create_queue(QueueName="queue1")
@@ -40,7 +40,7 @@ def test_data_api() -> None:
assert queue["name"] == "queue1"
-@mock_s3
+@mock_aws
def test_overwriting_s3_object_still_returns_data() -> None:
if settings.TEST_SERVER_MODE:
raise SkipTest("No point in testing this behaves the same in ServerMode")
@@ -52,7 +52,7 @@ def test_overwriting_s3_object_still_returns_data() -> None:
assert len(requests.post(data_url).json()["s3"]["FakeKey"]) == 2
-@mock_autoscaling
+@mock_aws
def test_creation_error__data_api_still_returns_thing() -> None:
if settings.TEST_SERVER_MODE:
raise SkipTest("No point in testing this behaves the same in ServerMode")
@@ -99,7 +99,9 @@ def test_model_data_is_emptied_as_necessary() -> None:
for _class in classes_per_service.values():
assert _class.instances == [] # type: ignore[attr-defined]
- with mock_sqs():
+ # TODO: ensure that iam is not loaded, and IAM policies are not created
+ # with mock_aws(load_static_data=False) ?
+ with mock_aws():
# When just starting a mock, it is empty
for classes_per_service in model_data.values():
for _class in classes_per_service.values():
@@ -117,17 +119,17 @@ def test_model_data_is_emptied_as_necessary() -> None:
assert _class.instances == [] # type: ignore[attr-defined]
# When we have multiple/nested mocks, the data should still be present after the first mock ends
- with mock_sqs():
+ with mock_aws():
conn = boto3.client("sqs", region_name="us-west-1")
conn.create_queue(QueueName="queue1")
- with mock_s3():
+ with mock_aws():
# The data should still be here - instances should not reset if another mock is still active
assert len(model_data["sqs"]["Queue"].instances) == 1 # type: ignore[attr-defined]
# The data should still be here - the inner mock has exited, but the outer mock is still active
assert len(model_data["sqs"]["Queue"].instances) == 1 # type: ignore[attr-defined]
-@mock_sqs
+@mock_aws
class TestModelDataResetForClassDecorator(TestCase):
def setUp(self) -> None:
if settings.TEST_SERVER_MODE:
diff --git a/tests/test_core/test_mypy.py b/tests/test_core/test_mypy.py
index 593e1a8da..25f596232 100644
--- a/tests/test_core/test_mypy.py
+++ b/tests/test_core/test_mypy.py
@@ -1,35 +1,34 @@
import boto3
-from moto import mock_s3
-from moto.core.models import BaseMockAWS
+from moto import MockAWS, mock_aws
-@mock_s3
+@mock_aws
def test_without_parentheses() -> int:
assert boto3.client("s3").list_buckets()["Buckets"] == []
return 123
-@mock_s3()
+@mock_aws()
def test_with_parentheses() -> int:
assert boto3.client("s3").list_buckets()["Buckets"] == []
return 456
-@mock_s3
+@mock_aws
def test_no_return() -> None:
assert boto3.client("s3").list_buckets()["Buckets"] == []
def test_with_context_manager() -> None:
- with mock_s3():
+ with mock_aws():
assert boto3.client("s3").list_buckets()["Buckets"] == []
def test_manual() -> None:
# this has the explicit type not because it's necessary but so that mypy will
# complain if it's wrong
- m: BaseMockAWS = mock_s3()
+ m: MockAWS = mock_aws()
m.start()
assert boto3.client("s3").list_buckets()["Buckets"] == []
m.stop()
diff --git a/tests/test_core/test_nested.py b/tests/test_core/test_nested.py
index 7a79beea7..de290e504 100644
--- a/tests/test_core/test_nested.py
+++ b/tests/test_core/test_nested.py
@@ -2,12 +2,12 @@ import unittest
import boto3
-from moto import mock_ec2, mock_sqs
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
class TestNestedDecoratorsBoto3(unittest.TestCase):
- @mock_sqs
+ @mock_aws
def setup_sqs_queue(self) -> None:
conn = boto3.resource("sqs", region_name="us-east-1")
queue = conn.create_queue(QueueName="some-queue")
@@ -17,9 +17,22 @@ class TestNestedDecoratorsBoto3(unittest.TestCase):
queue.reload()
assert queue.attributes["ApproximateNumberOfMessages"] == "1"
- @mock_ec2
+ @mock_aws
def test_nested(self) -> None:
self.setup_sqs_queue()
conn = boto3.client("ec2", region_name="us-west-2")
conn.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
+
+
+def test_multiple_mocks() -> None:
+ with mock_aws():
+ client = boto3.client("sqs", region_name="us-east-1")
+ client.create_queue(QueueName="some-queue")
+
+ # Starting another (inner) mock does not reset the data
+ with mock_aws():
+ assert len(client.list_queues()["QueueUrls"]) == 1
+
+ # Ending an inner mock does not reset the data
+ assert len(client.list_queues()["QueueUrls"]) == 1
diff --git a/tests/test_core/test_request_mocking.py b/tests/test_core/test_request_mocking.py
index 40a47f45e..3865ba679 100644
--- a/tests/test_core/test_request_mocking.py
+++ b/tests/test_core/test_request_mocking.py
@@ -2,10 +2,10 @@ import boto3
import pytest
import requests
-from moto import mock_s3, mock_sqs, mock_sts, settings
+from moto import mock_aws, settings
-@mock_sqs
+@mock_aws
@pytest.mark.network
def test_passthrough_requests() -> None:
conn = boto3.client("sqs", region_name="us-west-1")
@@ -17,15 +17,14 @@ def test_passthrough_requests() -> None:
if not settings.TEST_SERVER_MODE:
- @mock_sqs
+ @mock_aws
def test_requests_to_amazon_subdomains_dont_work() -> None:
res = requests.get("https://fakeservice.amazonaws.com/foo/bar")
assert res.content == b"The method is not implemented"
assert res.status_code == 400
-@mock_sts
-@mock_s3
+@mock_aws
def test_decorator_ordering() -> None:
"""
https://github.com/getmoto/moto/issues/3790#issuecomment-803979809
@@ -48,4 +47,4 @@ def test_decorator_ordering() -> None:
)
resp = requests.get(presigned_url)
- assert resp.status_code == 200 # type: ignore[attr-defined]
+ assert resp.status_code == 200
diff --git a/tests/test_core/test_responses_module.py b/tests/test_core/test_responses_module.py
index eb89dea48..eb119c1ff 100644
--- a/tests/test_core/test_responses_module.py
+++ b/tests/test_core/test_responses_module.py
@@ -8,7 +8,7 @@ import boto3
import requests
import responses
-from moto import mock_dynamodb, mock_s3, settings
+from moto import mock_aws, settings
from moto.core.models import override_responses_real_send
from moto.core.versions import RESPONSES_VERSION
from moto.utilities.distutils_version import LooseVersion
@@ -19,16 +19,16 @@ class TestResponsesModule(TestCase):
if settings.TEST_SERVER_MODE:
raise SkipTest("No point in testing responses-decorator in ServerMode")
- @mock_s3
+ @mock_aws
@responses.activate
- def test_moto_first(self) -> None: # type: ignore
+ def test_moto_first(self) -> None: # type: ignore[misc]
"""
Verify we can activate a user-defined `responses` on top of our Moto mocks
"""
self.moto_responses_compatibility()
@responses.activate
- @mock_s3
+ @mock_aws
def test_moto_second(self) -> None:
"""
Verify we can load Moto after activating a `responses`-mock
@@ -54,7 +54,7 @@ class TestResponsesModule(TestCase):
responses.add(
responses.GET, url="http://127.0.0.1/lkdsfjlkdsa", json={"a": "4"}
)
- with mock_s3():
+ with mock_aws():
s3 = boto3.client("s3", region_name="us-east-1")
s3.create_bucket(Bucket="mybucket")
s3.put_object(Bucket="mybucket", Key="name", Body="value")
@@ -67,7 +67,7 @@ class TestResponsesModule(TestCase):
assert r.json() == {"a": "4"}
-@mock_dynamodb
+@mock_aws
class TestResponsesMockWithPassThru(TestCase):
"""
https://github.com/getmoto/moto/issues/6417
diff --git a/tests/test_core/test_server.py b/tests/test_core/test_server.py
index c67111afe..eadc0f576 100644
--- a/tests/test_core/test_server.py
+++ b/tests/test_core/test_server.py
@@ -1,5 +1,4 @@
-from typing import Any
-from unittest.mock import patch
+from unittest.mock import Mock, patch
from moto.server import DomainDispatcherApplication, create_backend_app, main
@@ -16,7 +15,7 @@ def test_wrong_arguments() -> None:
@patch("moto.server.run_simple")
-def test_right_arguments(run_simple: Any) -> None: # type: ignore[misc]
+def test_right_arguments(run_simple: Mock) -> None: # type: ignore[misc]
main(["s3"])
func_call = run_simple.call_args[0]
assert func_call[0] == "127.0.0.1"
@@ -24,7 +23,7 @@ def test_right_arguments(run_simple: Any) -> None: # type: ignore[misc]
@patch("moto.server.run_simple")
-def test_port_argument(run_simple: Any) -> None: # type: ignore[misc]
+def test_port_argument(run_simple: Mock) -> None: # type: ignore[misc]
main(["s3", "--port", "8080"])
func_call = run_simple.call_args[0]
assert func_call[0] == "127.0.0.1"
diff --git a/tests/test_core/test_socket.py b/tests/test_core/test_socket.py
deleted file mode 100644
index 97c341430..000000000
--- a/tests/test_core/test_socket.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import socket
-import unittest
-
-from moto import mock_dynamodb
-
-
-class TestSocketPair(unittest.TestCase):
- @mock_dynamodb
- def test_socket_pair(self) -> None:
- a, b = socket.socketpair()
- self.assertIsNotNone(a)
- self.assertIsNotNone(b)
- if a:
- a.close()
- if b:
- b.close()
diff --git a/tests/test_core/test_url_base_regex.py b/tests/test_core/test_url_base_regex.py
index b0bc2c632..c08de229a 100644
--- a/tests/test_core/test_url_base_regex.py
+++ b/tests/test_core/test_url_base_regex.py
@@ -1,14 +1,8 @@
import boto3
import pytest
-import moto
-from moto import mock_s3
-
-service_names = [
- d[5:]
- for d in dir(moto)
- if d.startswith("mock_") and not d == "mock_xray_client" and not d == "mock_all"
-]
+from moto import mock_aws
+from moto.backends import list_of_moto_modules
class TestMockBucketStartingWithServiceName:
@@ -16,15 +10,13 @@ class TestMockBucketStartingWithServiceName:
https://github.com/getmoto/moto/issues/4099
"""
- @pytest.mark.parametrize("service_name", service_names)
+ @pytest.mark.parametrize("service_name", list(list_of_moto_modules()))
def test_bucketname_starting_with_service_name(self, service_name: str) -> None:
- decorator = getattr(moto, f"mock_{service_name}")
- with decorator():
- with mock_s3():
- s3_client = boto3.client("s3", "eu-west-1")
- bucket_name = f"{service_name}-bucket"
- s3_client.create_bucket(
- ACL="private",
- Bucket=bucket_name,
- CreateBucketConfiguration={"LocationConstraint": "eu-west-1"},
- )
+ with mock_aws():
+ s3_client = boto3.client("s3", "eu-west-1")
+ bucket_name = f"{service_name}-bucket"
+ s3_client.create_bucket(
+ ACL="private",
+ Bucket=bucket_name,
+ CreateBucketConfiguration={"LocationConstraint": "eu-west-1"},
+ )
diff --git a/tests/test_databrew/test_databrew_datasets.py b/tests/test_databrew/test_databrew_datasets.py
index daf959043..5bdbe075c 100644
--- a/tests/test_databrew/test_databrew_datasets.py
+++ b/tests/test_databrew/test_databrew_datasets.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_databrew
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
@@ -94,7 +94,7 @@ def _create_test_datasets(client, count):
_create_test_dataset(client)
-@mock_databrew
+@mock_aws
def test_dataset_list_when_empty():
client = _create_databrew_client()
@@ -103,7 +103,7 @@ def test_dataset_list_when_empty():
assert len(response["Datasets"]) == 0
-@mock_databrew
+@mock_aws
def test_list_datasets_with_max_results():
client = _create_databrew_client()
@@ -114,7 +114,7 @@ def test_list_datasets_with_max_results():
assert "NextToken" in response
-@mock_databrew
+@mock_aws
def test_list_datasets_from_next_token():
client = _create_databrew_client()
_create_test_datasets(client, 10)
@@ -123,7 +123,7 @@ def test_list_datasets_from_next_token():
assert len(response["Datasets"]) == 7
-@mock_databrew
+@mock_aws
def test_list_datasets_with_max_results_greater_than_actual_results():
client = _create_databrew_client()
_create_test_datasets(client, 4)
@@ -131,7 +131,7 @@ def test_list_datasets_with_max_results_greater_than_actual_results():
assert len(response["Datasets"]) == 4
-@mock_databrew
+@mock_aws
def test_describe_dataset():
client = _create_databrew_client()
@@ -152,7 +152,7 @@ def test_describe_dataset():
# endregion
-@mock_databrew
+@mock_aws
def test_describe_dataset_that_does_not_exist():
client = _create_databrew_client()
@@ -163,7 +163,7 @@ def test_describe_dataset_that_does_not_exist():
assert err["Message"] == "One or more resources can't be found."
-@mock_databrew
+@mock_aws
def test_create_dataset_that_already_exists():
client = _create_databrew_client()
@@ -176,7 +176,7 @@ def test_create_dataset_that_already_exists():
assert err["Message"] == f"{response['Name']} already exists."
-@mock_databrew
+@mock_aws
@pytest.mark.parametrize("name", ["name", "name with space"])
def test_delete_dataset(name):
client = _create_databrew_client()
@@ -206,7 +206,7 @@ def test_delete_dataset(name):
assert err["Message"] == "One or more resources can't be found."
-@mock_databrew
+@mock_aws
@pytest.mark.parametrize("name", ["name", "name with space"])
def test_update_dataset(name):
client = _create_databrew_client()
@@ -247,7 +247,7 @@ def test_update_dataset(name):
)
-@mock_databrew
+@mock_aws
def test_update_dataset_that_does_not_exist():
client = _create_databrew_client()
diff --git a/tests/test_databrew/test_databrew_jobs.py b/tests/test_databrew/test_databrew_jobs.py
index d9241f494..464b05054 100644
--- a/tests/test_databrew/test_databrew_jobs.py
+++ b/tests/test_databrew/test_databrew_jobs.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_databrew
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
@@ -69,7 +69,7 @@ def _create_test_profile_jobs(client, count, **kwargs):
_create_test_profile_job(client, **kwargs)
-@mock_databrew
+@mock_aws
def test_create_profile_job_that_already_exists():
client = _create_databrew_client()
@@ -83,7 +83,7 @@ def test_create_profile_job_that_already_exists():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 409
-@mock_databrew
+@mock_aws
def test_create_recipe_job_that_already_exists():
client = _create_databrew_client()
@@ -97,7 +97,7 @@ def test_create_recipe_job_that_already_exists():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 409
-@mock_databrew
+@mock_aws
def test_create_recipe_job_with_invalid_encryption_mode():
client = _create_databrew_client()
@@ -112,7 +112,7 @@ def test_create_recipe_job_with_invalid_encryption_mode():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
def test_create_recipe_job_with_invalid_log_subscription_value():
client = _create_databrew_client()
@@ -127,7 +127,7 @@ def test_create_recipe_job_with_invalid_log_subscription_value():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
def test_create_recipe_job_with_same_name_as_profile_job():
client = _create_databrew_client()
@@ -141,7 +141,7 @@ def test_create_recipe_job_with_same_name_as_profile_job():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 409
-@mock_databrew
+@mock_aws
def test_describe_recipe_job():
client = _create_databrew_client()
@@ -156,7 +156,7 @@ def test_describe_recipe_job():
assert job["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_databrew
+@mock_aws
def test_describe_job_that_does_not_exist():
client = _create_databrew_client()
@@ -168,7 +168,7 @@ def test_describe_job_that_does_not_exist():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_databrew
+@mock_aws
def test_describe_job_with_long_name():
client = _create_databrew_client()
name = "a" * 241
@@ -183,7 +183,7 @@ def test_describe_job_with_long_name():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
@pytest.mark.parametrize("job_name", ["name", "name with space"])
def test_update_profile_job(job_name):
client = _create_databrew_client()
@@ -204,7 +204,7 @@ def test_update_profile_job(job_name):
assert job["RoleArn"] == "a" * 20
-@mock_databrew
+@mock_aws
@pytest.mark.parametrize("job_name", ["name", "name with space"])
def test_update_recipe_job(job_name):
client = _create_databrew_client()
@@ -223,7 +223,7 @@ def test_update_recipe_job(job_name):
assert job["RoleArn"] == "a" * 20
-@mock_databrew
+@mock_aws
def test_update_profile_job_does_not_exist():
client = _create_databrew_client()
@@ -237,7 +237,7 @@ def test_update_profile_job_does_not_exist():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_databrew
+@mock_aws
def test_update_recipe_job_does_not_exist():
client = _create_databrew_client()
@@ -249,7 +249,7 @@ def test_update_recipe_job_does_not_exist():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_databrew
+@mock_aws
@pytest.mark.parametrize("job_name", ["name", "name with space"])
def test_delete_job(job_name):
client = _create_databrew_client()
@@ -271,7 +271,7 @@ def test_delete_job(job_name):
assert err["Message"] == f"Job {job_name} wasn't found."
-@mock_databrew
+@mock_aws
def test_delete_job_does_not_exist():
client = _create_databrew_client()
@@ -285,7 +285,7 @@ def test_delete_job_does_not_exist():
assert err["Message"] == "The job DoesNotExist wasn't found."
-@mock_databrew
+@mock_aws
def test_delete_job_with_long_name():
client = _create_databrew_client()
name = "a" * 241
@@ -300,7 +300,7 @@ def test_delete_job_with_long_name():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
def test_job_list_when_empty():
client = _create_databrew_client()
@@ -309,7 +309,7 @@ def test_job_list_when_empty():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_databrew
+@mock_aws
def test_list_jobs_with_max_results():
client = _create_databrew_client()
@@ -320,7 +320,7 @@ def test_list_jobs_with_max_results():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_databrew
+@mock_aws
def test_list_jobs_from_next_token():
client = _create_databrew_client()
_create_test_recipe_jobs(client, 10)
@@ -330,7 +330,7 @@ def test_list_jobs_from_next_token():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_databrew
+@mock_aws
def test_list_jobs_with_max_results_greater_than_actual_results():
client = _create_databrew_client()
_create_test_recipe_jobs(client, 4)
@@ -339,7 +339,7 @@ def test_list_jobs_with_max_results_greater_than_actual_results():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_databrew
+@mock_aws
def test_list_jobs_recipe_and_profile():
client = _create_databrew_client()
@@ -350,7 +350,7 @@ def test_list_jobs_recipe_and_profile():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_databrew
+@mock_aws
def test_list_jobs_dataset_name_filter():
client = _create_databrew_client()
@@ -364,7 +364,7 @@ def test_list_jobs_dataset_name_filter():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_databrew
+@mock_aws
def test_list_jobs_project_name_filter():
client = _create_databrew_client()
@@ -377,7 +377,7 @@ def test_list_jobs_project_name_filter():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_databrew
+@mock_aws
def test_list_jobs_dataset_name_and_project_name_filter():
client = _create_databrew_client()
diff --git a/tests/test_databrew/test_databrew_recipes.py b/tests/test_databrew/test_databrew_recipes.py
index ba22b46ce..3de39fb10 100644
--- a/tests/test_databrew/test_databrew_recipes.py
+++ b/tests/test_databrew/test_databrew_recipes.py
@@ -5,7 +5,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_databrew
+from moto import mock_aws
def _create_databrew_client():
@@ -50,7 +50,7 @@ def _create_test_recipes(client, count):
_create_test_recipe(client)
-@mock_databrew
+@mock_aws
def test_recipe_list_when_empty():
client = _create_databrew_client()
@@ -59,7 +59,7 @@ def test_recipe_list_when_empty():
assert len(response["Recipes"]) == 0
-@mock_databrew
+@mock_aws
def test_recipe_list_with_invalid_version():
client = _create_databrew_client()
@@ -77,7 +77,7 @@ def test_recipe_list_with_invalid_version():
assert err["Code"] == "ValidationException"
-@mock_databrew
+@mock_aws
def test_list_recipes_with_max_results():
client = _create_databrew_client()
@@ -87,7 +87,7 @@ def test_list_recipes_with_max_results():
assert "NextToken" in response
-@mock_databrew
+@mock_aws
def test_list_recipes_from_next_token():
client = _create_databrew_client()
_create_test_recipes(client, 10)
@@ -98,7 +98,7 @@ def test_list_recipes_from_next_token():
assert len(response["Recipes"]) == 7
-@mock_databrew
+@mock_aws
def test_list_recipes_with_max_results_greater_than_actual_results():
client = _create_databrew_client()
_create_test_recipes(client, 4)
@@ -106,7 +106,7 @@ def test_list_recipes_with_max_results_greater_than_actual_results():
assert len(response["Recipes"]) == 4
-@mock_databrew
+@mock_aws
def test_list_recipe_versions_no_recipe():
client = _create_databrew_client()
recipe_name = "NotExist"
@@ -114,7 +114,7 @@ def test_list_recipe_versions_no_recipe():
assert len(response["Recipes"]) == 0
-@mock_databrew
+@mock_aws
def test_list_recipe_versions_none_published():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -123,7 +123,7 @@ def test_list_recipe_versions_none_published():
assert len(response["Recipes"]) == 0
-@mock_databrew
+@mock_aws
def test_list_recipe_versions_one_published():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -134,7 +134,7 @@ def test_list_recipe_versions_one_published():
assert response["Recipes"][0]["RecipeVersion"] == "1.0"
-@mock_databrew
+@mock_aws
def test_list_recipe_versions_two_published():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -147,7 +147,7 @@ def test_list_recipe_versions_two_published():
assert response["Recipes"][1]["RecipeVersion"] == "2.0"
-@mock_databrew
+@mock_aws
def test_describe_recipe_latest_working():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -161,7 +161,7 @@ def test_describe_recipe_latest_working():
assert recipe["RecipeVersion"] == "0.1"
-@mock_databrew
+@mock_aws
@pytest.mark.parametrize("name", ["name", "name with space"])
def test_describe_recipe_with_version(name):
client = _create_databrew_client()
@@ -174,7 +174,7 @@ def test_describe_recipe_with_version(name):
assert recipe["RecipeVersion"] == "0.1"
-@mock_databrew
+@mock_aws
def test_describe_recipe_latest_published():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -189,7 +189,7 @@ def test_describe_recipe_latest_published():
assert recipe["RecipeVersion"] == "1.0"
-@mock_databrew
+@mock_aws
def test_describe_recipe_implicit_latest_published():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -202,7 +202,7 @@ def test_describe_recipe_implicit_latest_published():
assert recipe["RecipeVersion"] == "1.0"
-@mock_databrew
+@mock_aws
def test_describe_recipe_that_does_not_exist():
client = _create_databrew_client()
@@ -217,7 +217,7 @@ def test_describe_recipe_that_does_not_exist():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_databrew
+@mock_aws
def test_describe_recipe_with_long_name():
client = _create_databrew_client()
name = "a" * 256
@@ -232,7 +232,7 @@ def test_describe_recipe_with_long_name():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
def test_describe_recipe_with_long_version():
client = _create_databrew_client()
version = "1" * 17
@@ -247,7 +247,7 @@ def test_describe_recipe_with_long_version():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
def test_describe_recipe_with_invalid_version():
client = _create_databrew_client()
name = "AnyName"
@@ -260,7 +260,7 @@ def test_describe_recipe_with_invalid_version():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
@pytest.mark.parametrize("name", ["name", "name with space"])
def test_update_recipe(name):
client = _create_databrew_client()
@@ -301,7 +301,7 @@ def test_update_recipe(name):
assert recipe["Steps"][0]["Action"]["Parameters"]["removeCustomValue"] == "true"
-@mock_databrew
+@mock_aws
def test_update_recipe_description():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -321,7 +321,7 @@ def test_update_recipe_description():
assert recipe["Description"] == description
-@mock_databrew
+@mock_aws
def test_update_recipe_invalid():
client = _create_databrew_client()
@@ -334,7 +334,7 @@ def test_update_recipe_invalid():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_databrew
+@mock_aws
def test_create_recipe_that_already_exists():
client = _create_databrew_client()
@@ -348,7 +348,7 @@ def test_create_recipe_that_already_exists():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 409
-@mock_databrew
+@mock_aws
@pytest.mark.parametrize("recipe_name", ["name", "name with space"])
def test_publish_recipe(recipe_name):
client = _create_databrew_client()
@@ -384,7 +384,7 @@ def test_publish_recipe(recipe_name):
assert recipe["PublishedDate"] >= first_published_date
-@mock_databrew
+@mock_aws
def test_publish_recipe_that_does_not_exist():
client = _create_databrew_client()
with pytest.raises(ClientError) as exc:
@@ -394,7 +394,7 @@ def test_publish_recipe_that_does_not_exist():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_databrew
+@mock_aws
def test_publish_long_recipe_name():
client = _create_databrew_client()
name = "a" * 256
@@ -411,7 +411,7 @@ def test_publish_long_recipe_name():
assert err["Code"] == "ValidationException"
-@mock_databrew
+@mock_aws
@pytest.mark.parametrize("recipe_name", ["name", "name with space"])
def test_delete_recipe_version(recipe_name):
client = _create_databrew_client()
@@ -425,7 +425,7 @@ def test_delete_recipe_version(recipe_name):
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_databrew
+@mock_aws
def test_delete_recipe_version_published():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -441,7 +441,7 @@ def test_delete_recipe_version_published():
assert recipe["RecipeVersion"] == "1.1"
-@mock_databrew
+@mock_aws
def test_delete_recipe_version_latest_working_after_publish():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -457,7 +457,7 @@ def test_delete_recipe_version_latest_working_after_publish():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
def test_delete_recipe_version_latest_working_numeric_after_publish():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -471,7 +471,7 @@ def test_delete_recipe_version_latest_working_numeric_after_publish():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
def test_delete_recipe_version_invalid_version_string():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -488,7 +488,7 @@ def test_delete_recipe_version_invalid_version_string():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
def test_delete_recipe_version_invalid_version_length():
client = _create_databrew_client()
response = _create_test_recipe(client)
@@ -505,7 +505,7 @@ def test_delete_recipe_version_invalid_version_length():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_databrew
+@mock_aws
def test_delete_recipe_version_unknown_recipe():
client = _create_databrew_client()
recipe_name = "Unknown"
@@ -517,7 +517,7 @@ def test_delete_recipe_version_unknown_recipe():
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 404
-@mock_databrew
+@mock_aws
def test_delete_recipe_version_unknown_version():
client = _create_databrew_client()
response = _create_test_recipe(client)
diff --git a/tests/test_databrew/test_databrew_rulesets.py b/tests/test_databrew/test_databrew_rulesets.py
index 6c0dea100..ab878000e 100644
--- a/tests/test_databrew/test_databrew_rulesets.py
+++ b/tests/test_databrew/test_databrew_rulesets.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_databrew
+from moto import mock_aws
def _create_databrew_client():
@@ -40,7 +40,7 @@ def _create_test_rulesets(client, count):
_create_test_ruleset(client)
-@mock_databrew
+@mock_aws
def test_ruleset_list_when_empty():
client = _create_databrew_client()
@@ -49,7 +49,7 @@ def test_ruleset_list_when_empty():
assert len(response["Rulesets"]) == 0
-@mock_databrew
+@mock_aws
def test_list_ruleset_with_max_results():
client = _create_databrew_client()
@@ -59,7 +59,7 @@ def test_list_ruleset_with_max_results():
assert "NextToken" in response
-@mock_databrew
+@mock_aws
def test_list_rulesets_from_next_token():
client = _create_databrew_client()
_create_test_rulesets(client, 10)
@@ -68,7 +68,7 @@ def test_list_rulesets_from_next_token():
assert len(response["Rulesets"]) == 7
-@mock_databrew
+@mock_aws
def test_list_rulesets_with_max_results_greater_than_actual_results():
client = _create_databrew_client()
_create_test_rulesets(client, 4)
@@ -76,7 +76,7 @@ def test_list_rulesets_with_max_results_greater_than_actual_results():
assert len(response["Rulesets"]) == 4
-@mock_databrew
+@mock_aws
def test_describe_ruleset():
client = _create_databrew_client()
response = _create_test_ruleset(client)
@@ -88,7 +88,7 @@ def test_describe_ruleset():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_databrew
+@mock_aws
def test_describe_ruleset_that_does_not_exist():
client = _create_databrew_client()
@@ -99,7 +99,7 @@ def test_describe_ruleset_that_does_not_exist():
assert err["Message"] == "Ruleset DoseNotExist not found."
-@mock_databrew
+@mock_aws
def test_create_ruleset_that_already_exists():
client = _create_databrew_client()
@@ -112,7 +112,7 @@ def test_create_ruleset_that_already_exists():
assert err["Message"] == "Ruleset already exists."
-@mock_databrew
+@mock_aws
def test_delete_ruleset():
client = _create_databrew_client()
response = _create_test_ruleset(client)
@@ -143,7 +143,7 @@ def test_delete_ruleset():
assert err["Message"] == f"Ruleset {ruleset_name} not found."
-@mock_databrew
+@mock_aws
@pytest.mark.parametrize("name", ["name", "name with space"])
def test_update_ruleset(name):
client = _create_databrew_client()
diff --git a/tests/test_datapipeline/test_datapipeline.py b/tests/test_datapipeline/test_datapipeline.py
index 1ea8eb3b9..5c43a7b5d 100644
--- a/tests/test_datapipeline/test_datapipeline.py
+++ b/tests/test_datapipeline/test_datapipeline.py
@@ -1,6 +1,6 @@
import boto3
-from moto import mock_datapipeline
+from moto import mock_aws
from moto.datapipeline.utils import remove_capitalization_of_dict_keys
@@ -10,7 +10,7 @@ def get_value_from_fields(key, fields):
return field["stringValue"]
-@mock_datapipeline
+@mock_aws
def test_create_pipeline_boto3():
conn = boto3.client("datapipeline", region_name="us-west-2")
@@ -60,7 +60,7 @@ PIPELINE_OBJECTS = [
]
-@mock_datapipeline
+@mock_aws
def test_creating_pipeline_definition_boto3():
conn = boto3.client("datapipeline", region_name="us-west-2")
res = conn.create_pipeline(name="mypipeline", uniqueId="some-unique-id")
@@ -80,7 +80,7 @@ def test_creating_pipeline_definition_boto3():
]
-@mock_datapipeline
+@mock_aws
def test_describing_pipeline_objects_boto3():
conn = boto3.client("datapipeline", region_name="us-west-2")
res = conn.create_pipeline(name="mypipeline", uniqueId="some-unique-id")
@@ -102,7 +102,7 @@ def test_describing_pipeline_objects_boto3():
]
-@mock_datapipeline
+@mock_aws
def test_activate_pipeline_boto3():
conn = boto3.client("datapipeline", region_name="us-west-2")
res = conn.create_pipeline(name="mypipeline", uniqueId="some-unique-id")
@@ -120,7 +120,7 @@ def test_activate_pipeline_boto3():
assert get_value_from_fields("@pipelineState", fields) == "SCHEDULED"
-@mock_datapipeline
+@mock_aws
def test_delete_pipeline_boto3():
conn = boto3.client("datapipeline", region_name="us-west-2")
res = conn.create_pipeline(name="mypipeline", uniqueId="some-unique-id")
@@ -133,7 +133,7 @@ def test_delete_pipeline_boto3():
assert len(response["pipelineIdList"]) == 0
-@mock_datapipeline
+@mock_aws
def test_listing_pipelines_boto3():
conn = boto3.client("datapipeline", region_name="us-west-2")
res1 = conn.create_pipeline(name="mypipeline1", uniqueId="some-unique-id1")
@@ -149,7 +149,7 @@ def test_listing_pipelines_boto3():
assert {"id": res2["pipelineId"], "name": "mypipeline2"} in objects
-@mock_datapipeline
+@mock_aws
def test_listing_paginated_pipelines_boto3():
conn = boto3.client("datapipeline", region_name="us-west-2")
for i in range(100):
diff --git a/tests/test_datapipeline/test_datapipeline_cloudformation.py b/tests/test_datapipeline/test_datapipeline_cloudformation.py
index 7af5b6fd6..33ce57e6e 100644
--- a/tests/test_datapipeline/test_datapipeline_cloudformation.py
+++ b/tests/test_datapipeline/test_datapipeline_cloudformation.py
@@ -2,11 +2,10 @@ import json
import boto3
-from moto import mock_cloudformation, mock_datapipeline
+from moto import mock_aws
-@mock_cloudformation
-@mock_datapipeline
+@mock_aws
def test_datapipeline():
dp_template = {
"AWSTemplateFormatVersion": "2010-09-09",
diff --git a/tests/test_datapipeline/test_server.py b/tests/test_datapipeline/test_server.py
index 44c3879c1..3bb207c35 100644
--- a/tests/test_datapipeline/test_server.py
+++ b/tests/test_datapipeline/test_server.py
@@ -1,14 +1,14 @@
import json
import moto.server as server
-from moto import mock_datapipeline
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_datapipeline
+@mock_aws
def test_list_streams():
backend = server.create_backend_app("datapipeline")
test_client = backend.test_client()
diff --git a/tests/test_datasync/test_datasync.py b/tests/test_datasync/test_datasync.py
index 8dbaabca8..a8ef1c8c9 100644
--- a/tests/test_datasync/test_datasync.py
+++ b/tests/test_datasync/test_datasync.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_datasync
+from moto import mock_aws
def create_locations(client, create_smb=False, create_s3=False):
@@ -31,7 +31,7 @@ def create_locations(client, create_smb=False, create_s3=False):
return {"smb_arn": smb_arn, "s3_arn": s3_arn}
-@mock_datasync
+@mock_aws
def test_create_location_smb():
client = boto3.client("datasync", region_name="us-east-1")
response = client.create_location_smb(
@@ -44,7 +44,7 @@ def test_create_location_smb():
assert "LocationArn" in response
-@mock_datasync
+@mock_aws
def test_describe_location_smb():
client = boto3.client("datasync", region_name="us-east-1")
agent_arns = ["stuff"]
@@ -63,7 +63,7 @@ def test_describe_location_smb():
assert response["AgentArns"] == agent_arns
-@mock_datasync
+@mock_aws
def test_create_location_s3():
client = boto3.client("datasync", region_name="us-east-1")
response = client.create_location_s3(
@@ -74,7 +74,7 @@ def test_create_location_s3():
assert "LocationArn" in response
-@mock_datasync
+@mock_aws
def test_describe_location_s3():
client = boto3.client("datasync", region_name="us-east-1")
s3_config = {"BucketAccessRoleArn": "role"}
@@ -87,7 +87,7 @@ def test_describe_location_s3():
assert response["S3Config"] == s3_config
-@mock_datasync
+@mock_aws
def test_describe_location_wrong():
client = boto3.client("datasync", region_name="us-east-1")
agent_arns = ["stuff"]
@@ -106,7 +106,7 @@ def test_describe_location_wrong():
assert err["Message"] == "Invalid Location type: SMB"
-@mock_datasync
+@mock_aws
def test_list_locations():
client = boto3.client("datasync", region_name="us-east-1")
response = client.list_locations()
@@ -128,7 +128,7 @@ def test_list_locations():
assert response["Locations"][2]["LocationUri"] == "s3://my_bucket/dir"
-@mock_datasync
+@mock_aws
def test_delete_location():
client = boto3.client("datasync", region_name="us-east-1")
locations = create_locations(client, create_smb=True)
@@ -144,7 +144,7 @@ def test_delete_location():
client.delete_location(LocationArn=location_arn)
-@mock_datasync
+@mock_aws
def test_create_task():
client = boto3.client("datasync", region_name="us-east-1")
locations = create_locations(client, create_smb=True, create_s3=True)
@@ -155,7 +155,7 @@ def test_create_task():
assert "TaskArn" in response
-@mock_datasync
+@mock_aws
def test_create_task_fail():
"""Test that Locations must exist before a Task can be created"""
client = boto3.client("datasync", region_name="us-east-1")
@@ -177,7 +177,7 @@ def test_create_task_fail():
assert err["Message"] == "Location 2 not found."
-@mock_datasync
+@mock_aws
def test_list_tasks():
client = boto3.client("datasync", region_name="us-east-1")
locations = create_locations(client, create_s3=True, create_smb=True)
@@ -204,7 +204,7 @@ def test_list_tasks():
assert task["Name"] == "task_name"
-@mock_datasync
+@mock_aws
def test_describe_task():
client = boto3.client("datasync", region_name="us-east-1")
locations = create_locations(client, create_s3=True, create_smb=True)
@@ -224,7 +224,7 @@ def test_describe_task():
assert "DestinationLocationArn" in response
-@mock_datasync
+@mock_aws
def test_describe_task_not_exist():
client = boto3.client("datasync", region_name="us-east-1")
@@ -235,7 +235,7 @@ def test_describe_task_not_exist():
assert err["Message"] == "The request is not valid."
-@mock_datasync
+@mock_aws
def test_update_task():
client = boto3.client("datasync", region_name="us-east-1")
locations = create_locations(client, create_s3=True, create_smb=True)
@@ -275,7 +275,7 @@ def test_update_task():
client.update_task(TaskArn="doesnt_exist")
-@mock_datasync
+@mock_aws
def test_delete_task():
client = boto3.client("datasync", region_name="us-east-1")
locations = create_locations(client, create_s3=True, create_smb=True)
@@ -299,7 +299,7 @@ def test_delete_task():
client.delete_task(TaskArn=task_arn)
-@mock_datasync
+@mock_aws
def test_start_task_execution():
client = boto3.client("datasync", region_name="us-east-1")
locations = create_locations(client, create_s3=True, create_smb=True)
@@ -321,7 +321,7 @@ def test_start_task_execution():
assert response["CurrentTaskExecutionArn"] == task_execution_arn
-@mock_datasync
+@mock_aws
def test_start_task_execution_twice():
client = boto3.client("datasync", region_name="us-east-1")
locations = create_locations(client, create_s3=True, create_smb=True)
@@ -342,7 +342,7 @@ def test_start_task_execution_twice():
assert err["Code"] == "InvalidRequestException"
-@mock_datasync
+@mock_aws
def test_describe_task_execution():
client = boto3.client("datasync", region_name="us-east-1")
locations = create_locations(client, create_s3=True, create_smb=True)
@@ -398,7 +398,7 @@ def test_describe_task_execution():
assert response["Status"] == "AVAILABLE"
-@mock_datasync
+@mock_aws
def test_describe_task_execution_not_exist():
client = boto3.client("datasync", region_name="us-east-1")
@@ -409,7 +409,7 @@ def test_describe_task_execution_not_exist():
assert err["Message"] == "The request is not valid."
-@mock_datasync
+@mock_aws
def test_cancel_task_execution():
client = boto3.client("datasync", region_name="us-east-1")
locations = create_locations(client, create_s3=True, create_smb=True)
diff --git a/tests/test_dax/test_dax.py b/tests/test_dax/test_dax.py
index 770547ab1..688a1a257 100644
--- a/tests/test_dax/test_dax.py
+++ b/tests/test_dax/test_dax.py
@@ -3,14 +3,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_dax
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_dax
+@mock_aws
def test_create_cluster_minimal():
client = boto3.client("dax", region_name="us-east-2")
iam_role_arn = f"arn:aws:iam::{ACCOUNT_ID}:role/aws-service-role/dax.amazonaws.com/AWSServiceRoleForDAX"
@@ -44,7 +44,7 @@ def test_create_cluster_minimal():
assert cluster["ClusterEndpointEncryptionType"] == "NONE"
-@mock_dax
+@mock_aws
def test_create_cluster_description():
client = boto3.client("dax", region_name="us-east-2")
iam_role_arn = f"arn:aws:iam::{ACCOUNT_ID}:role/aws-service-role/dax.amazonaws.com/AWSServiceRoleForDAX"
@@ -64,7 +64,7 @@ def test_create_cluster_description():
assert cluster["Description"] == "my cluster"
-@mock_dax
+@mock_aws
def test_create_cluster_with_sse_enabled():
client = boto3.client("dax", region_name="us-east-2")
iam_role_arn = f"arn:aws:iam::{ACCOUNT_ID}:role/aws-service-role/dax.amazonaws.com/AWSServiceRoleForDAX"
@@ -86,7 +86,7 @@ def test_create_cluster_with_sse_enabled():
assert cluster["ClusterEndpointEncryptionType"] == "TLS"
-@mock_dax
+@mock_aws
@pytest.mark.parametrize(
"iam_role,expected",
(
@@ -118,7 +118,7 @@ def test_create_cluster_invalid_arn(iam_role: str, expected: str):
assert err["Message"] == expected
-@mock_dax
+@mock_aws
@pytest.mark.parametrize(
"name", ["1invalid", "iИvalid", "in_valid", "invalid-", "in--valid"]
)
@@ -139,7 +139,7 @@ def test_create_cluster_invalid_name(name):
)
-@mock_dax
+@mock_aws
@pytest.mark.parametrize(
"name", ["1invalid", "iИvalid", "in_valid", "invalid-", "in--valid"]
)
@@ -155,7 +155,7 @@ def test_describe_clusters_invalid_name(name):
)
-@mock_dax
+@mock_aws
def test_delete_cluster_unknown():
client = boto3.client("dax", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -166,7 +166,7 @@ def test_delete_cluster_unknown():
assert err["Message"] == "Cluster not found."
-@mock_dax
+@mock_aws
def test_delete_cluster():
client = boto3.client("dax", region_name="eu-west-1")
iam_role_arn = f"arn:aws:iam::{ACCOUNT_ID}:role/aws-service-role/dax.amazonaws.com/AWSServiceRoleForDAX"
@@ -194,7 +194,7 @@ def test_delete_cluster():
assert err["Code"] == "ClusterNotFoundFault"
-@mock_dax
+@mock_aws
def test_describe_cluster_unknown():
client = boto3.client("dax", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -205,7 +205,7 @@ def test_describe_cluster_unknown():
assert err["Message"] == "Cluster unknown not found."
-@mock_dax
+@mock_aws
def test_describe_clusters_returns_all():
client = boto3.client("dax", region_name="us-east-1")
iam_role_arn = f"arn:aws:iam::{ACCOUNT_ID}:role/aws-service-role/dax.amazonaws.com/AWSServiceRoleForDAX"
@@ -220,7 +220,7 @@ def test_describe_clusters_returns_all():
assert len(client.describe_clusters()["Clusters"]) == 50
-@mock_dax
+@mock_aws
def test_describe_clusters_paginates():
client = boto3.client("dax", region_name="us-east-1")
iam_role_arn = f"arn:aws:iam::{ACCOUNT_ID}:role/aws-service-role/dax.amazonaws.com/AWSServiceRoleForDAX"
@@ -245,7 +245,7 @@ def test_describe_clusters_paginates():
assert "NextToken" not in resp
-@mock_dax
+@mock_aws
def test_describe_clusters_returns_nodes_after_some_time():
client = boto3.client("dax", region_name="us-east-2")
iam_role_arn = f"arn:aws:iam::{ACCOUNT_ID}:role/aws-service-role/dax.amazonaws.com/AWSServiceRoleForDAX"
@@ -295,7 +295,7 @@ def test_describe_clusters_returns_nodes_after_some_time():
assert node["ParameterGroupStatus"] == "in-sync"
-@mock_dax
+@mock_aws
def test_list_tags_unknown():
client = boto3.client("dax", region_name="ap-southeast-1")
with pytest.raises(ClientError) as exc:
@@ -305,7 +305,7 @@ def test_list_tags_unknown():
assert err["Code"] == "ClusterNotFoundFault"
-@mock_dax
+@mock_aws
def test_list_tags():
client = boto3.client("dax", region_name="ap-southeast-1")
cluster = client.create_cluster(
@@ -333,7 +333,7 @@ def test_list_tags():
)
-@mock_dax
+@mock_aws
def test_increase_replication_factor_unknown():
client = boto3.client("dax", region_name="ap-southeast-1")
with pytest.raises(ClientError) as exc:
@@ -345,7 +345,7 @@ def test_increase_replication_factor_unknown():
assert err["Code"] == "ClusterNotFoundFault"
-@mock_dax
+@mock_aws
def test_increase_replication_factor():
client = boto3.client("dax", region_name="ap-southeast-1")
name = "daxcluster"
@@ -383,7 +383,7 @@ def test_increase_replication_factor():
)
-@mock_dax
+@mock_aws
def test_decrease_replication_factor_unknown():
client = boto3.client("dax", region_name="ap-southeast-1")
with pytest.raises(ClientError) as exc:
@@ -395,7 +395,7 @@ def test_decrease_replication_factor_unknown():
assert err["Code"] == "ClusterNotFoundFault"
-@mock_dax
+@mock_aws
def test_decrease_replication_factor():
client = boto3.client("dax", region_name="eu-west-1")
name = "daxcluster"
@@ -424,7 +424,7 @@ def test_decrease_replication_factor():
assert node_ids == ({f"{name}-a", f"{name}-b", f"{name}-c"})
-@mock_dax
+@mock_aws
def test_decrease_replication_factor_specific_nodeids():
client = boto3.client("dax", region_name="ap-southeast-1")
name = "daxcluster"
diff --git a/tests/test_dms/test_dms.py b/tests/test_dms/test_dms.py
index f0f4df08f..c9a091a6d 100644
--- a/tests/test_dms/test_dms.py
+++ b/tests/test_dms/test_dms.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_dms
+from moto import mock_aws
-@mock_dms
+@mock_aws
def test_create_and_get_replication_task():
client = boto3.client("dms", region_name="us-east-1")
@@ -40,7 +40,7 @@ def test_create_and_get_replication_task():
assert isinstance(json.loads(task["ReplicationTaskSettings"]), dict)
-@mock_dms
+@mock_aws
def test_create_existing_replication_task_throws_error():
client = boto3.client("dms", region_name="us-east-1")
@@ -71,7 +71,7 @@ def test_create_existing_replication_task_throws_error():
)
-@mock_dms
+@mock_aws
def test_start_replication_task():
client = boto3.client("dms", region_name="us-east-1")
@@ -94,7 +94,7 @@ def test_start_replication_task():
assert tasks["ReplicationTasks"][0]["Status"] == "running"
-@mock_dms
+@mock_aws
def test_start_replication_task_throws_resource_not_found_error():
client = boto3.client("dms", region_name="us-east-1")
@@ -111,7 +111,7 @@ def test_start_replication_task_throws_resource_not_found_error():
)
-@mock_dms
+@mock_aws
def test_stop_replication_task_throws_invalid_state_error():
client = boto3.client("dms", region_name="us-east-1")
@@ -133,7 +133,7 @@ def test_stop_replication_task_throws_invalid_state_error():
assert ex.value.response["Error"]["Message"] == "Replication task is not running"
-@mock_dms
+@mock_aws
def test_stop_replication_task_throws_resource_not_found_error():
client = boto3.client("dms", region_name="us-east-1")
@@ -147,7 +147,7 @@ def test_stop_replication_task_throws_resource_not_found_error():
)
-@mock_dms
+@mock_aws
def test_stop_replication_task():
client = boto3.client("dms", region_name="us-east-1")
@@ -171,7 +171,7 @@ def test_stop_replication_task():
assert tasks["ReplicationTasks"][0]["Status"] == "stopped"
-@mock_dms
+@mock_aws
def test_delete_replication_task():
client = boto3.client("dms", region_name="us-east-1")
@@ -192,7 +192,7 @@ def test_delete_replication_task():
assert len(tasks["ReplicationTasks"]) == 0
-@mock_dms
+@mock_aws
def test_delete_replication_task_throws_resource_not_found_error():
client = boto3.client("dms", region_name="us-east-1")
diff --git a/tests/test_ds/test_ds.py b/tests/test_ds/test_ds.py
index a336b48dd..7d6a94e2b 100644
--- a/tests/test_ds/test_ds.py
+++ b/tests/test_ds/test_ds.py
@@ -9,15 +9,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ds
-from moto.ec2 import mock_ec2
+from moto import mock_aws
from moto.moto_api._internal import mock_random
from .test_ds_simple_ad_directory import TEST_REGION, create_test_directory
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_delete_directory():
"""Test good and bad invocations of delete_directory()."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -67,8 +65,7 @@ def test_ds_delete_directory():
) in err["Message"]
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_get_directory_limits():
"""Test return value for directory limits."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -93,8 +90,7 @@ def test_ds_get_directory_limits():
assert not limits["ConnectedDirectoriesCurrentCount"]
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_describe_directories():
"""Test good and bad invocations of describe_directories()."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -166,8 +162,7 @@ def test_ds_describe_directories():
assert result["DirectoryDescriptions"][0]["DirectoryId"] == directory_ids[5]
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_create_alias():
"""Test good and bad invocations of create_alias()."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -229,8 +224,7 @@ def test_ds_create_alias():
assert f"Alias '{good_alias}' already exists." in err["Message"]
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_enable_sso():
"""Test good and bad invocations of enable_sso()."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -286,8 +280,7 @@ def test_ds_enable_sso():
assert directory["SsoEnabled"]
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_disable_sso():
"""Test good and bad invocations of disable_sso()."""
client = boto3.client("ds", region_name=TEST_REGION)
diff --git a/tests/test_ds/test_ds_ad_connect.py b/tests/test_ds/test_ds_ad_connect.py
index d042c975b..0d3f22ddb 100644
--- a/tests/test_ds/test_ds_ad_connect.py
+++ b/tests/test_ds/test_ds_ad_connect.py
@@ -9,8 +9,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ds
-from moto.ec2 import mock_ec2
+from moto import mock_aws
from moto.moto_api._internal import mock_random
from .test_ds_simple_ad_directory import TEST_REGION, create_subnets, create_vpc
@@ -51,7 +50,7 @@ def create_test_ad_connector(
return result["DirectoryId"]
-@mock_ds
+@mock_aws
def test_ds_connect_directory_validations():
"""Test validation errs that aren't caught by botocore.
@@ -151,8 +150,7 @@ def test_ds_connect_directory_validations():
)
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_connect_directory_good_args():
"""Test creation of AD connect directory using good arguments."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -177,8 +175,7 @@ def test_ds_connect_directory_good_args():
)
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_connect_directory_bad_args():
"""Test validation of non-vpc related ConnectionSettings values."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -212,8 +209,7 @@ def test_ds_connect_directory_bad_args():
)
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_connect_directory_delete():
"""Test deletion of AD Connector directory."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -225,8 +221,7 @@ def test_ds_connect_directory_delete():
assert result["DirectoryId"] == directory_id
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_connect_directory_describe():
"""Test describe_directory() for AD Connector directory."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -257,8 +252,7 @@ def test_ds_connect_directory_describe():
assert "NextToken" not in result
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_connect_directory_tags():
"""Test that directory tags can be added and retrieved."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -272,8 +266,7 @@ def test_ds_connect_directory_tags():
assert result["Tags"] == added_tags
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_get_connect_directory_limits():
"""Test return value for ad connector directory limits."""
client = boto3.client("ds", region_name=TEST_REGION)
diff --git a/tests/test_ds/test_ds_microsoft_ad.py b/tests/test_ds/test_ds_microsoft_ad.py
index 26fe86e81..dc59cc6cb 100644
--- a/tests/test_ds/test_ds_microsoft_ad.py
+++ b/tests/test_ds/test_ds_microsoft_ad.py
@@ -9,8 +9,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ds
-from moto.ec2 import mock_ec2
+from moto import mock_aws
from moto.moto_api._internal import mock_random
from .test_ds_simple_ad_directory import TEST_REGION, create_subnets, create_vpc
@@ -36,7 +35,7 @@ def create_test_microsoft_ad(ds_client, ec2_client, vpc_settings=None, tags=None
return result["DirectoryId"]
-@mock_ds
+@mock_aws
def test_ds_create_microsoft_ad_validations():
"""Test validation errs that aren't caught by botocore.
@@ -127,8 +126,7 @@ def test_ds_create_microsoft_ad_validations():
)
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_create_microsoft_ad_good_args():
"""Test creation of Microsoft AD directory using good arguments."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -153,8 +151,7 @@ def test_ds_create_microsoft_ad_good_args():
)
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_create_microsoft_ad_delete():
"""Test deletion of Microsoft AD directory."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -166,8 +163,7 @@ def test_ds_create_microsoft_ad_delete():
assert result["DirectoryId"] == directory_id
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_create_microsoft_ad_describe():
"""Test describe_directory() for Microsoft AD directory."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -196,8 +192,7 @@ def test_ds_create_microsoft_ad_describe():
assert "NextToken" not in result
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_create_microsoft_ad_tags():
"""Test that AD directory tags can be added and retrieved."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -211,8 +206,7 @@ def test_ds_create_microsoft_ad_tags():
assert result["Tags"] == added_tags
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_get_microsoft_ad_directory_limits():
"""Test return value for directory limits."""
client = boto3.client("ds", region_name=TEST_REGION)
diff --git a/tests/test_ds/test_ds_simple_ad_directory.py b/tests/test_ds/test_ds_simple_ad_directory.py
index c409aec1e..2bc71784f 100644
--- a/tests/test_ds/test_ds_simple_ad_directory.py
+++ b/tests/test_ds/test_ds_simple_ad_directory.py
@@ -1,10 +1,8 @@
-"""Directory-related unit tests for Simple AD Directory Services."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ds, settings
-from moto.ec2 import mock_ec2
+from moto import mock_aws, settings
from moto.moto_api._internal import mock_random
TEST_REGION = "us-east-1" if settings.TEST_SERVER_MODE else "us-west-2"
@@ -49,7 +47,7 @@ def create_test_directory(ds_client, ec2_client, vpc_settings=None, tags=None):
return result["DirectoryId"]
-@mock_ds
+@mock_aws
def test_ds_create_directory_validations():
"""Test validation errs that aren't caught by botocore."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -138,8 +136,7 @@ def test_ds_create_directory_validations():
)
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_create_directory_bad_vpc_settings():
"""Test validation of bad vpc that doesn't raise ValidationException."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -167,8 +164,7 @@ def test_ds_create_directory_bad_vpc_settings():
assert "Invalid VPC ID" in err["Message"]
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_create_directory_bad_subnets():
"""Test validation of VPC subnets."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -219,8 +215,7 @@ def test_ds_create_directory_bad_subnets():
assert "Invalid subnet ID(s). They must correspond to two subnets" in err["Message"]
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_create_directory_good_args():
"""Test creation of AD directory using good arguments."""
client = boto3.client("ds", region_name=TEST_REGION)
diff --git a/tests/test_ds/test_ds_tags.py b/tests/test_ds/test_ds_tags.py
index a6a3032e8..f8da4bfff 100644
--- a/tests/test_ds/test_ds_tags.py
+++ b/tests/test_ds/test_ds_tags.py
@@ -7,15 +7,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ds
+from moto import mock_aws
from moto.ds.models import Directory
-from moto.ec2 import mock_ec2
from .test_ds_simple_ad_directory import TEST_REGION, create_test_directory
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_add_tags_to_resource():
"""Test the addition of tags to a resource."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -64,8 +62,7 @@ def test_ds_add_tags_to_resource():
assert result["Tags"] == added_tags
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_remove_tags_from_resource():
"""Test the removal of tags to a resource."""
client = boto3.client("ds", region_name=TEST_REGION)
@@ -88,8 +85,7 @@ def test_ds_remove_tags_from_resource():
assert "NextToken" not in result
-@mock_ec2
-@mock_ds
+@mock_aws
def test_ds_list_tags_for_resource():
"""Test ability to list all tags for a resource."""
client = boto3.client("ds", region_name=TEST_REGION)
diff --git a/tests/test_dynamodb/__init__.py b/tests/test_dynamodb/__init__.py
index df8354a72..f991188cf 100644
--- a/tests/test_dynamodb/__init__.py
+++ b/tests/test_dynamodb/__init__.py
@@ -4,7 +4,7 @@ from uuid import uuid4
import boto3
-from moto import mock_dynamodb
+from moto import mock_aws
def dynamodb_aws_verified(create_table: bool = True):
@@ -13,7 +13,7 @@ def dynamodb_aws_verified(create_table: bool = True):
Can be run against AWS at any time by setting:
MOTO_TEST_ALLOW_AWS_REQUEST=true
- If this environment variable is not set, the function runs in a `mock_dynamodb` context.
+ If this environment variable is not set, the function runs in a `mock_aws` context.
This decorator will:
- Create a table
@@ -24,7 +24,6 @@ def dynamodb_aws_verified(create_table: bool = True):
def inner(func):
@wraps(func)
def pagination_wrapper():
- client = boto3.client("dynamodb", region_name="us-east-1")
table_name = "t" + str(uuid4())[0:6]
allow_aws_request = (
@@ -34,17 +33,19 @@ def dynamodb_aws_verified(create_table: bool = True):
if allow_aws_request:
if create_table:
print(f"Test {func} will create DynamoDB Table {table_name}")
- return create_table_and_test(table_name, client)
+ return create_table_and_test(table_name)
else:
return func()
else:
- with mock_dynamodb():
+ with mock_aws():
if create_table:
- return create_table_and_test(table_name, client)
+ return create_table_and_test(table_name)
else:
return func()
- def create_table_and_test(table_name, client):
+ def create_table_and_test(table_name):
+ client = boto3.client("dynamodb", region_name="us-east-1")
+
client.create_table(
TableName=table_name,
KeySchema=[{"AttributeName": "pk", "KeyType": "HASH"}],
diff --git a/tests/test_dynamodb/exceptions/test_dynamodb_exceptions.py b/tests/test_dynamodb/exceptions/test_dynamodb_exceptions.py
index 6ed78faea..1152f5285 100644
--- a/tests/test_dynamodb/exceptions/test_dynamodb_exceptions.py
+++ b/tests/test_dynamodb/exceptions/test_dynamodb_exceptions.py
@@ -6,7 +6,7 @@ import pytest
from boto3.dynamodb.conditions import Key
from botocore.exceptions import ClientError
-from moto import mock_dynamodb, settings
+from moto import mock_aws, settings
from .. import dynamodb_aws_verified
@@ -30,7 +30,7 @@ table_schema = {
}
-@mock_dynamodb
+@mock_aws
def test_query_gsi_with_wrong_key_attribute_names_throws_exception():
item = {
"partitionKey": "pk-1",
@@ -97,7 +97,7 @@ def test_query_gsi_with_wrong_key_attribute_names_throws_exception():
assert err["Message"] == "Query condition missed key schema element: gsiK1SortKey"
-@mock_dynamodb
+@mock_aws
def test_query_table_with_wrong_key_attribute_names_throws_exception():
item = {
"partitionKey": "pk-1",
@@ -122,7 +122,7 @@ def test_query_table_with_wrong_key_attribute_names_throws_exception():
assert err["Message"] == "Query condition missed key schema element: partitionKey"
-@mock_dynamodb
+@mock_aws
def test_empty_expressionattributenames():
ddb = boto3.resource("dynamodb", region_name="us-east-1")
ddb.create_table(
@@ -139,7 +139,7 @@ def test_empty_expressionattributenames():
)
-@mock_dynamodb
+@mock_aws
def test_empty_expressionattributenames_with_empty_projection():
ddb = boto3.resource("dynamodb", region_name="us-east-1")
ddb.create_table(
@@ -155,7 +155,7 @@ def test_empty_expressionattributenames_with_empty_projection():
assert err["Message"] == "ExpressionAttributeNames must not be empty"
-@mock_dynamodb
+@mock_aws
def test_empty_expressionattributenames_with_projection():
ddb = boto3.resource("dynamodb", region_name="us-east-1")
ddb.create_table(
@@ -171,7 +171,7 @@ def test_empty_expressionattributenames_with_projection():
assert err["Message"] == "ExpressionAttributeNames must not be empty"
-@mock_dynamodb
+@mock_aws
def test_update_item_range_key_set():
ddb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -194,7 +194,7 @@ def test_update_item_range_key_set():
)
-@mock_dynamodb
+@mock_aws
def test_batch_get_item_non_existing_table():
client = boto3.client("dynamodb", region_name="us-west-2")
@@ -205,7 +205,7 @@ def test_batch_get_item_non_existing_table():
assert err["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
def test_batch_write_item_non_existing_table():
client = boto3.client("dynamodb", region_name="us-west-2")
@@ -219,7 +219,7 @@ def test_batch_write_item_non_existing_table():
assert err["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
def test_create_table_with_redundant_attributes():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -268,7 +268,7 @@ def test_create_table_with_redundant_attributes():
)
-@mock_dynamodb
+@mock_aws
def test_create_table_with_missing_attributes():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -313,7 +313,7 @@ def test_create_table_with_missing_attributes():
)
-@mock_dynamodb
+@mock_aws
def test_create_table_with_redundant_and_missing_attributes():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -358,7 +358,7 @@ def test_create_table_with_redundant_and_missing_attributes():
)
-@mock_dynamodb
+@mock_aws
def test_put_item_wrong_attribute_type():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -406,7 +406,7 @@ def test_put_item_wrong_attribute_type():
)
-@mock_dynamodb
+@mock_aws
# https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html#DDB-Query-request-KeyConditionExpression
def test_hash_key_cannot_use_begins_with_operations():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -435,7 +435,7 @@ def test_hash_key_cannot_use_begins_with_operations():
# Test this again, but with manually supplying an operator
-@mock_dynamodb
+@mock_aws
@pytest.mark.parametrize("operator", ["<", "<=", ">", ">="])
def test_hash_key_can_only_use_equals_operations(operator):
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -457,7 +457,7 @@ def test_hash_key_can_only_use_equals_operations(operator):
assert err["Message"] == "Query key condition not supported"
-@mock_dynamodb
+@mock_aws
def test_creating_table_with_0_local_indexes():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -477,7 +477,7 @@ def test_creating_table_with_0_local_indexes():
)
-@mock_dynamodb
+@mock_aws
def test_creating_table_with_0_global_indexes():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -497,7 +497,81 @@ def test_creating_table_with_0_global_indexes():
)
-@mock_dynamodb
+@mock_aws
+def test_multiple_transactions_on_same_item():
+ schema = {
+ "KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
+ "AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"}],
+ }
+ dynamodb = boto3.client("dynamodb", region_name="us-east-1")
+ dynamodb.create_table(
+ TableName="test-table", BillingMode="PAY_PER_REQUEST", **schema
+ )
+ # Insert an item
+ dynamodb.put_item(TableName="test-table", Item={"id": {"S": "foo"}})
+
+ def update_email_transact(email):
+ return {
+ "Update": {
+ "Key": {"id": {"S": "foo"}},
+ "TableName": "test-table",
+ "UpdateExpression": "SET #e = :v",
+ "ExpressionAttributeNames": {"#e": "email_address"},
+ "ExpressionAttributeValues": {":v": {"S": email}},
+ }
+ }
+
+ with pytest.raises(ClientError) as exc:
+ dynamodb.transact_write_items(
+ TransactItems=[
+ update_email_transact("test1@moto.com"),
+ update_email_transact("test2@moto.com"),
+ ]
+ )
+ err = exc.value.response["Error"]
+ assert err["Code"] == "ValidationException"
+ assert (
+ err["Message"]
+ == "Transaction request cannot include multiple operations on one item"
+ )
+
+
+@mock_aws
+def test_transact_write_items__too_many_transactions():
+ schema = {
+ "KeySchema": [{"AttributeName": "pk", "KeyType": "HASH"}],
+ "AttributeDefinitions": [{"AttributeName": "pk", "AttributeType": "S"}],
+ }
+ dynamodb = boto3.client("dynamodb", region_name="us-east-1")
+ dynamodb.create_table(
+ TableName="test-table", BillingMode="PAY_PER_REQUEST", **schema
+ )
+
+ def update_email_transact(email):
+ return {
+ "Put": {
+ "TableName": "test-table",
+ "Item": {"pk": {"S": ":v"}},
+ "ExpressionAttributeValues": {":v": {"S": email}},
+ }
+ }
+
+ update_email_transact("test1@moto.com")
+ with pytest.raises(ClientError) as exc:
+ dynamodb.transact_write_items(
+ TransactItems=[
+ update_email_transact(f"test{idx}@moto.com") for idx in range(101)
+ ]
+ )
+ err = exc.value.response["Error"]
+ assert err["Code"] == "ValidationException"
+ assert (
+ err["Message"]
+ == "1 validation error detected at 'transactItems' failed to satisfy constraint: Member must have length less than or equal to 100."
+ )
+
+
+@mock_aws
def test_update_item_non_existent_table():
client = boto3.client("dynamodb", region_name="us-west-2")
with pytest.raises(client.exceptions.ResourceNotFoundException) as exc:
@@ -512,7 +586,7 @@ def test_update_item_non_existent_table():
assert err["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
@pytest.mark.parametrize(
"expression",
[
@@ -552,7 +626,7 @@ def test_update_item_with_duplicate_expressions(expression):
assert item == {"pk": "example_id", "example_column": "example"}
-@mock_dynamodb
+@mock_aws
def test_put_item_wrong_datatype():
if settings.TEST_SERVER_MODE:
raise SkipTest("Unable to mock a session with Config in ServerMode")
@@ -582,7 +656,7 @@ def test_put_item_wrong_datatype():
assert err["Message"] == "NUMBER_VALUE cannot be converted to String"
-@mock_dynamodb
+@mock_aws
def test_put_item_empty_set():
client = boto3.client("dynamodb", region_name="us-east-1")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -603,7 +677,7 @@ def test_put_item_empty_set():
)
-@mock_dynamodb
+@mock_aws
def test_put_item_returns_old_item():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
table = dynamodb.create_table(
@@ -645,7 +719,7 @@ def test_put_item_returns_old_item():
assert resp["Item"] == {"pk": {"S": "foo"}, "bar": {"S": "baz"}}
-@mock_dynamodb
+@mock_aws
def test_update_expression_with_trailing_comma():
resource = boto3.resource(service_name="dynamodb", region_name="us-east-1")
table = resource.create_table(
@@ -672,7 +746,7 @@ def test_update_expression_with_trailing_comma():
)
-@mock_dynamodb
+@mock_aws
def test_batch_put_item_with_empty_value():
ddb = boto3.resource("dynamodb", region_name="us-east-1")
ddb.create_table(
@@ -716,7 +790,7 @@ def test_batch_put_item_with_empty_value():
batch.put_item(Item={"pk": "sth", "sk": "else", "par": ""})
-@mock_dynamodb
+@mock_aws
def test_query_begins_with_without_brackets():
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
@@ -742,7 +816,83 @@ def test_query_begins_with_without_brackets():
assert err["Code"] == "ValidationException"
-@mock_dynamodb
+@mock_aws
+def test_transact_write_items_multiple_operations_fail():
+ # Setup
+ schema = {
+ "KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
+ "AttributeDefinitions": [{"AttributeName": "id", "AttributeType": "S"}],
+ }
+ dynamodb = boto3.client("dynamodb", region_name="us-east-1")
+ table_name = "test-table"
+ dynamodb.create_table(TableName=table_name, BillingMode="PAY_PER_REQUEST", **schema)
+
+ # Execute
+ with pytest.raises(ClientError) as exc:
+ dynamodb.transact_write_items(
+ TransactItems=[
+ {
+ "Put": {
+ "Item": {"id": {"S": "test"}},
+ "TableName": table_name,
+ },
+ "Delete": {
+ "Key": {"id": {"S": "test"}},
+ "TableName": table_name,
+ },
+ }
+ ]
+ )
+ # Verify
+ err = exc.value.response["Error"]
+ assert err["Code"] == "ValidationException"
+ assert (
+ err["Message"]
+ == "TransactItems can only contain one of Check, Put, Update or Delete"
+ )
+
+
+@mock_aws
+def test_transact_write_items_with_empty_gsi_key():
+ client = boto3.client("dynamodb", "us-east-2")
+
+ client.create_table(
+ TableName="test_table",
+ KeySchema=[{"AttributeName": "unique_code", "KeyType": "HASH"}],
+ AttributeDefinitions=[
+ {"AttributeName": "unique_code", "AttributeType": "S"},
+ {"AttributeName": "unique_id", "AttributeType": "S"},
+ ],
+ GlobalSecondaryIndexes=[
+ {
+ "IndexName": "gsi_index",
+ "KeySchema": [{"AttributeName": "unique_id", "KeyType": "HASH"}],
+ "Projection": {"ProjectionType": "ALL"},
+ }
+ ],
+ ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5},
+ )
+
+ transact_items = [
+ {
+ "Put": {
+ "Item": {"unique_code": {"S": "some code"}, "unique_id": {"S": ""}},
+ "TableName": "test_table",
+ }
+ }
+ ]
+
+ with pytest.raises(ClientError) as exc:
+ client.transact_write_items(TransactItems=transact_items)
+ err = exc.value.response["Error"]
+ assert err["Code"] == "ValidationException"
+ assert (
+ err["Message"]
+ == "One or more parameter values are not valid. A value specified for a secondary index key is not supported. The AttributeValue for a key attribute cannot contain an empty string value. IndexName: gsi_index, IndexKey: unique_id"
+ )
+
+
+@mock_aws
def test_update_primary_key_with_sortkey():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
schema = {
@@ -781,7 +931,7 @@ def test_update_primary_key_with_sortkey():
assert item == {"pk": "testchangepk", "sk": "else"}
-@mock_dynamodb
+@mock_aws
def test_update_primary_key():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
schema = {
@@ -814,7 +964,7 @@ def test_update_primary_key():
assert item == {"pk": "testchangepk"}
-@mock_dynamodb
+@mock_aws
def test_put_item__string_as_integer_value():
if settings.TEST_SERVER_MODE:
raise SkipTest("Unable to mock a session with Config in ServerMode")
@@ -849,7 +999,7 @@ def test_put_item__string_as_integer_value():
assert item == {"pk": {"S": "val"}, "S": {"S": "asdf"}}
-@mock_dynamodb
+@mock_aws
def test_gsi_key_cannot_be_empty():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
hello_index = {
@@ -890,7 +1040,7 @@ def test_gsi_key_cannot_be_empty():
)
-@mock_dynamodb
+@mock_aws
def test_list_append_errors_for_unknown_attribute_value():
# Verify whether the list_append operation works as expected
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -965,7 +1115,7 @@ def test_list_append_errors_for_unknown_attribute_value():
)
-@mock_dynamodb
+@mock_aws
def test_query_with_empty_filter_expression():
ddb = boto3.resource("dynamodb", region_name="us-east-1")
ddb.create_table(
@@ -992,7 +1142,7 @@ def test_query_with_empty_filter_expression():
)
-@mock_dynamodb
+@mock_aws
def test_query_with_missing_expression_attribute():
ddb = boto3.resource("dynamodb", region_name="us-west-2")
ddb.create_table(TableName="test", BillingMode="PAY_PER_REQUEST", **table_schema)
diff --git a/tests/test_dynamodb/exceptions/test_dynamodb_transactions.py b/tests/test_dynamodb/exceptions/test_dynamodb_transactions.py
index 85de51e6c..61f2c59dd 100644
--- a/tests/test_dynamodb/exceptions/test_dynamodb_transactions.py
+++ b/tests/test_dynamodb/exceptions/test_dynamodb_transactions.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_dynamodb
+from moto import mock_aws
from .. import dynamodb_aws_verified
-@mock_dynamodb
+@mock_aws
def test_multiple_transactions_on_same_item():
schema = {
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
@@ -46,7 +46,7 @@ def test_multiple_transactions_on_same_item():
)
-@mock_dynamodb
+@mock_aws
def test_transact_write_items__too_many_transactions():
schema = {
"KeySchema": [{"AttributeName": "pk", "KeyType": "HASH"}],
@@ -81,7 +81,7 @@ def test_transact_write_items__too_many_transactions():
)
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_multiple_operations_fail():
# Setup
schema = {
@@ -117,7 +117,7 @@ def test_transact_write_items_multiple_operations_fail():
)
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_with_empty_gsi_key():
client = boto3.client("dynamodb", "us-east-2")
diff --git a/tests/test_dynamodb/exceptions/test_key_length_exceptions.py b/tests/test_dynamodb/exceptions/test_key_length_exceptions.py
index 8cf7b1c68..f499d0355 100644
--- a/tests/test_dynamodb/exceptions/test_key_length_exceptions.py
+++ b/tests/test_dynamodb/exceptions/test_key_length_exceptions.py
@@ -3,11 +3,11 @@ import pytest
from boto3.dynamodb.conditions import Key
from botocore.exceptions import ClientError
-from moto import mock_dynamodb
+from moto import mock_aws
from moto.dynamodb.limits import HASH_KEY_MAX_LENGTH, RANGE_KEY_MAX_LENGTH
-@mock_dynamodb
+@mock_aws
def test_item_add_long_string_hash_key_exception():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -49,7 +49,7 @@ def test_item_add_long_string_hash_key_exception():
)
-@mock_dynamodb
+@mock_aws
def test_item_add_long_string_nonascii_hash_key_exception():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -97,7 +97,7 @@ def test_item_add_long_string_nonascii_hash_key_exception():
)
-@mock_dynamodb
+@mock_aws
def test_item_add_long_string_range_key_exception():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -145,7 +145,7 @@ def test_item_add_long_string_range_key_exception():
)
-@mock_dynamodb
+@mock_aws
def test_put_long_string_gsi_range_key_exception():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -215,7 +215,7 @@ def test_put_long_string_gsi_range_key_exception():
)
-@mock_dynamodb
+@mock_aws
def test_update_item_with_long_string_hash_key_exception():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -256,7 +256,7 @@ def test_update_item_with_long_string_hash_key_exception():
)
-@mock_dynamodb
+@mock_aws
def test_update_item_with_long_string_range_key_exception():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -302,7 +302,7 @@ def test_update_item_with_long_string_range_key_exception():
)
-@mock_dynamodb
+@mock_aws
def test_item_add_empty_key_exception():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -326,7 +326,7 @@ def test_item_add_empty_key_exception():
)
-@mock_dynamodb
+@mock_aws
def test_query_empty_key_exception():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="us-west-2")
diff --git a/tests/test_dynamodb/test_dynamodb.py b/tests/test_dynamodb/test_dynamodb.py
index d029e0f00..7a9b5dc54 100644
--- a/tests/test_dynamodb/test_dynamodb.py
+++ b/tests/test_dynamodb/test_dynamodb.py
@@ -11,14 +11,14 @@ from botocore.exceptions import ClientError
import moto.dynamodb.comparisons
import moto.dynamodb.models
-from moto import mock_dynamodb, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.dynamodb import dynamodb_backends
from . import dynamodb_aws_verified
-@mock_dynamodb
+@mock_aws
@pytest.mark.parametrize(
"names",
[[], ["TestTable"], ["TestTable1", "TestTable2"]],
@@ -36,7 +36,7 @@ def test_list_tables_boto3(names):
assert conn.list_tables()["TableNames"] == names
-@mock_dynamodb
+@mock_aws
def test_list_tables_paginated():
conn = boto3.client("dynamodb", region_name="us-west-2")
for name in ["name1", "name2", "name3"]:
@@ -60,7 +60,7 @@ def test_list_tables_paginated():
assert "LastEvaluatedTableName" not in res
-@mock_dynamodb
+@mock_aws
def test_describe_missing_table_boto3():
conn = boto3.client("dynamodb", region_name="us-west-2")
with pytest.raises(ClientError) as ex:
@@ -73,7 +73,7 @@ def test_describe_missing_table_boto3():
)
-@mock_dynamodb
+@mock_aws
def test_list_table_tags():
name = "TestTable"
conn = boto3.client(
@@ -110,7 +110,7 @@ def test_list_table_tags():
assert resp["Tags"] == [{"Key": "TestTag2", "Value": "TestValue2"}]
-@mock_dynamodb
+@mock_aws
def test_list_table_tags_empty():
name = "TestTable"
conn = boto3.client(
@@ -131,7 +131,7 @@ def test_list_table_tags_empty():
assert resp["Tags"] == []
-@mock_dynamodb
+@mock_aws
def test_list_table_tags_paginated():
name = "TestTable"
conn = boto3.client(
@@ -159,7 +159,7 @@ def test_list_table_tags_paginated():
assert "NextToken" not in resp2.keys()
-@mock_dynamodb
+@mock_aws
def test_list_not_found_table_tags():
conn = boto3.client(
"dynamodb",
@@ -174,7 +174,7 @@ def test_list_not_found_table_tags():
assert exception.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_dynamodb
+@mock_aws
def test_item_add_empty_string_hash_key_exception():
name = "TestTable"
conn = boto3.client(
@@ -210,7 +210,7 @@ def test_item_add_empty_string_hash_key_exception():
)
-@mock_dynamodb
+@mock_aws
def test_item_add_empty_string_range_key_exception():
name = "TestTable"
conn = boto3.client(
@@ -252,7 +252,7 @@ def test_item_add_empty_string_range_key_exception():
)
-@mock_dynamodb
+@mock_aws
def test_item_add_empty_string_attr_no_exception():
name = "TestTable"
conn = boto3.client(
@@ -280,7 +280,7 @@ def test_item_add_empty_string_attr_no_exception():
)
-@mock_dynamodb
+@mock_aws
def test_update_item_with_empty_string_attr_no_exception():
name = "TestTable"
conn = boto3.client(
@@ -315,7 +315,7 @@ def test_update_item_with_empty_string_attr_no_exception():
)
-@mock_dynamodb
+@mock_aws
def test_query_invalid_table():
conn = boto3.client(
"dynamodb",
@@ -333,7 +333,7 @@ def test_query_invalid_table():
assert exception.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_dynamodb
+@mock_aws
def test_put_item_with_special_chars():
name = "TestTable"
conn = boto3.client(
@@ -363,7 +363,7 @@ def test_put_item_with_special_chars():
)
-@mock_dynamodb
+@mock_aws
def test_put_item_with_streams():
name = "TestTable"
conn = boto3.client(
@@ -413,7 +413,7 @@ def test_put_item_with_streams():
assert stream_record["dynamodb"]["SizeBytes"] == 447
-@mock_dynamodb
+@mock_aws
def test_basic_projection_expression_using_get_item():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -472,7 +472,7 @@ def test_basic_projection_expression_using_get_item():
)
-@mock_dynamodb
+@mock_aws
def test_basic_projection_expressions_using_scan():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -539,7 +539,7 @@ def test_basic_projection_expressions_using_scan():
assert "forum_name" in results["Items"][1]
-@mock_dynamodb
+@mock_aws
def test_nested_projection_expression_using_get_item():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -591,7 +591,7 @@ def test_nested_projection_expression_using_get_item():
}
-@mock_dynamodb
+@mock_aws
def test_basic_projection_expressions_using_query():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -658,7 +658,7 @@ def test_basic_projection_expressions_using_query():
assert "forum_name" in items[1]
-@mock_dynamodb
+@mock_aws
def test_nested_projection_expression_using_query():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -717,7 +717,7 @@ def test_nested_projection_expression_using_query():
}
-@mock_dynamodb
+@mock_aws
def test_nested_projection_expression_using_scan():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -776,7 +776,7 @@ def test_nested_projection_expression_using_scan():
]
-@mock_dynamodb
+@mock_aws
def test_basic_projection_expression_using_get_item_with_attr_expression_names():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -825,7 +825,7 @@ def test_basic_projection_expression_using_get_item_with_attr_expression_names()
}
-@mock_dynamodb
+@mock_aws
def test_basic_projection_expressions_using_query_with_attr_expression_names():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -874,7 +874,7 @@ def test_basic_projection_expressions_using_query_with_attr_expression_names():
assert results["Items"][0]["attachment"] == "something"
-@mock_dynamodb
+@mock_aws
def test_nested_projection_expression_using_get_item_with_attr_expression():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -940,7 +940,7 @@ def test_nested_projection_expression_using_get_item_with_attr_expression():
assert result == {"nested": {"level3": {"children": [{"Name": "child_a"}]}}}
-@mock_dynamodb
+@mock_aws
def test_nested_projection_expression_using_query_with_attr_expression_names():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -996,7 +996,7 @@ def test_nested_projection_expression_using_query_with_attr_expression_names():
}
-@mock_dynamodb
+@mock_aws
def test_basic_projection_expressions_using_scan_with_attr_expression_names():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1057,7 +1057,7 @@ def test_basic_projection_expressions_using_scan_with_attr_expression_names():
assert "form_name" not in results["Items"][0]
-@mock_dynamodb
+@mock_aws
def test_nested_projection_expression_using_scan_with_attr_expression_names():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1117,7 +1117,7 @@ def test_nested_projection_expression_using_scan_with_attr_expression_names():
]
-@mock_dynamodb
+@mock_aws
def test_put_empty_item():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
dynamodb.create_table(
@@ -1137,7 +1137,7 @@ def test_put_empty_item():
assert ex.value.response["Error"]["Code"] == "ValidationException"
-@mock_dynamodb
+@mock_aws
def test_put_item_nonexisting_hash_key():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
dynamodb.create_table(
@@ -1157,7 +1157,7 @@ def test_put_item_nonexisting_hash_key():
assert ex.value.response["Error"]["Code"] == "ValidationException"
-@mock_dynamodb
+@mock_aws
def test_put_item_nonexisting_range_key():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
dynamodb.create_table(
@@ -1311,7 +1311,7 @@ def test_filter_expression():
assert filter_expr.expr(row2) is False
-@mock_dynamodb
+@mock_aws
def test_query_filter():
client = boto3.client("dynamodb", region_name="us-east-1")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1387,7 +1387,7 @@ def test_query_filter():
assert response["Count"] == 2
-@mock_dynamodb
+@mock_aws
def test_query_filter_overlapping_expression_prefixes():
client = boto3.client("dynamodb", region_name="us-east-1")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1435,7 +1435,7 @@ def test_query_filter_overlapping_expression_prefixes():
}
-@mock_dynamodb
+@mock_aws
def test_scan_filter():
client = boto3.client("dynamodb", region_name="us-east-1")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1471,7 +1471,7 @@ def test_scan_filter():
assert response["Count"] == 0
-@mock_dynamodb
+@mock_aws
def test_scan_filter2():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -1502,7 +1502,7 @@ def test_scan_filter2():
assert response["Count"] == 1
-@mock_dynamodb
+@mock_aws
def test_scan_filter3():
client = boto3.client("dynamodb", region_name="us-east-1")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1542,7 +1542,7 @@ def test_scan_filter3():
assert response["Count"] == 1
-@mock_dynamodb
+@mock_aws
def test_scan_filter4():
client = boto3.client("dynamodb", region_name="us-east-1")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1569,7 +1569,7 @@ def test_scan_filter4():
assert response["Count"] == 0
-@mock_dynamodb
+@mock_aws
def test_scan_filter_should_not_return_non_existing_attributes():
table_name = "my-table"
item = {"partitionKey": "pk-2", "my-attr": 42}
@@ -1595,7 +1595,7 @@ def test_scan_filter_should_not_return_non_existing_attributes():
assert table.scan(FilterExpression=Attr("my-attr").gt(43))["Items"] == []
-@mock_dynamodb
+@mock_aws
def test_bad_scan_filter():
client = boto3.client("dynamodb", region_name="us-east-1")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1621,7 +1621,7 @@ def test_bad_scan_filter():
assert exc.value.response["Error"]["Code"] == "ValidationException"
-@mock_dynamodb
+@mock_aws
def test_scan_with_scanfilter():
table_name = "my-table"
item = {"partitionKey": "pk-2", "my-attr": 42}
@@ -1665,7 +1665,7 @@ def test_scan_with_scanfilter():
assert items == [{"partitionKey": "pk-1"}]
-@mock_dynamodb
+@mock_aws
def test_duplicate_create():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -1700,7 +1700,7 @@ def test_duplicate_create():
assert err["Code"] == "ResourceInUseException"
-@mock_dynamodb
+@mock_aws
def test_delete_table():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -1728,7 +1728,7 @@ def test_delete_table():
assert err.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_dynamodb
+@mock_aws
def test_delete_item():
client = boto3.client("dynamodb", region_name="us-east-1")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1784,7 +1784,7 @@ def test_delete_item():
assert response["Count"] == 0
-@mock_dynamodb
+@mock_aws
def test_delete_item_error():
# Setup
client = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1816,7 +1816,7 @@ def test_delete_item_error():
assert err["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
def test_describe_limits():
client = boto3.client("dynamodb", region_name="eu-central-1")
resp = client.describe_limits()
@@ -1827,7 +1827,7 @@ def test_describe_limits():
assert resp["TableMaxReadCapacityUnits"] == 10000
-@mock_dynamodb
+@mock_aws
def test_set_ttl():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -1863,7 +1863,7 @@ def test_set_ttl():
assert resp["TimeToLiveDescription"]["TimeToLiveStatus"] == "DISABLED"
-@mock_dynamodb
+@mock_aws
def test_describe_continuous_backups():
# given
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -1890,7 +1890,7 @@ def test_describe_continuous_backups():
}
-@mock_dynamodb
+@mock_aws
def test_describe_continuous_backups_errors():
# given
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -1907,7 +1907,7 @@ def test_describe_continuous_backups_errors():
assert ex.response["Error"]["Message"] == "Table not found: not-existing-table"
-@mock_dynamodb
+@mock_aws
def test_update_continuous_backups():
# given
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -1974,7 +1974,7 @@ def test_update_continuous_backups():
}
-@mock_dynamodb
+@mock_aws
def test_update_continuous_backups_errors():
# given
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -1995,7 +1995,7 @@ def test_update_continuous_backups_errors():
# https://github.com/getmoto/moto/issues/1043
-@mock_dynamodb
+@mock_aws
def test_query_missing_expr_names():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -2030,7 +2030,7 @@ def test_query_missing_expr_names():
# https://github.com/getmoto/moto/issues/2328
-@mock_dynamodb
+@mock_aws
def test_update_item_with_list():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -2052,7 +2052,7 @@ def test_update_item_with_list():
# https://github.com/getmoto/moto/issues/2328
-@mock_dynamodb
+@mock_aws
def test_update_item_with_no_action_passed_with_list():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -2076,7 +2076,7 @@ def test_update_item_with_no_action_passed_with_list():
# https://github.com/getmoto/moto/issues/1342
-@mock_dynamodb
+@mock_aws
def test_update_item_on_map():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -2155,7 +2155,7 @@ def test_update_item_on_map():
# https://github.com/getmoto/moto/issues/1358
-@mock_dynamodb
+@mock_aws
def test_update_if_not_exists():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -2199,7 +2199,7 @@ def test_update_if_not_exists():
# https://github.com/getmoto/moto/issues/1937
-@mock_dynamodb
+@mock_aws
def test_update_return_attributes():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -2241,7 +2241,7 @@ def test_update_return_attributes():
# https://github.com/getmoto/moto/issues/3448
-@mock_dynamodb
+@mock_aws
def test_update_return_updated_new_attributes_when_same():
dynamo_client = boto3.resource("dynamodb", region_name="us-east-1")
dynamo_client.create_table(
@@ -2281,7 +2281,7 @@ def test_update_return_updated_new_attributes_when_same():
assert err["Message"] == "Return values set to invalid value"
-@mock_dynamodb
+@mock_aws
def test_put_return_attributes():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -2317,7 +2317,7 @@ def test_put_return_attributes():
assert ex.value.response["Error"]["Message"] == "Return values set to invalid value"
-@mock_dynamodb
+@mock_aws
def test_query_global_secondary_index_when_created_via_update_table_resource():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -2389,7 +2389,7 @@ def test_query_global_secondary_index_when_created_via_update_table_resource():
}
-@mock_dynamodb
+@mock_aws
def test_query_gsi_with_range_key():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
dynamodb.create_table(
@@ -2446,7 +2446,7 @@ def test_query_gsi_with_range_key():
}
-@mock_dynamodb
+@mock_aws
def test_scan_by_non_exists_index():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -2482,7 +2482,7 @@ def test_scan_by_non_exists_index():
)
-@mock_dynamodb
+@mock_aws
def test_query_by_non_exists_index():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -2521,7 +2521,7 @@ def test_query_by_non_exists_index():
)
-@mock_dynamodb
+@mock_aws
def test_index_with_unknown_attributes_should_fail():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -2557,7 +2557,7 @@ def test_index_with_unknown_attributes_should_fail():
assert expected_exception in ex.value.response["Error"]["Message"]
-@mock_dynamodb
+@mock_aws
def test_update_list_index__set_existing_index():
table_name = "test_list_index_access"
client = create_table_with_list(table_name)
@@ -2582,7 +2582,7 @@ def test_update_list_index__set_existing_index():
}
-@mock_dynamodb
+@mock_aws
def test_update_list_index__set_existing_nested_index():
table_name = "test_list_index_access"
client = create_table_with_list(table_name)
@@ -2611,7 +2611,7 @@ def test_update_list_index__set_existing_nested_index():
]
-@mock_dynamodb
+@mock_aws
def test_update_list_index__set_index_out_of_range():
table_name = "test_list_index_access"
client = create_table_with_list(table_name)
@@ -2636,7 +2636,7 @@ def test_update_list_index__set_index_out_of_range():
}
-@mock_dynamodb
+@mock_aws
def test_update_list_index__set_nested_index_out_of_range():
table_name = "test_list_index_access"
client = create_table_with_list(table_name)
@@ -2666,7 +2666,7 @@ def test_update_list_index__set_nested_index_out_of_range():
]
-@mock_dynamodb
+@mock_aws
def test_update_list_index__set_double_nested_index():
table_name = "test_list_index_access"
client = create_table_with_list(table_name)
@@ -2704,7 +2704,7 @@ def test_update_list_index__set_double_nested_index():
} # updated
-@mock_dynamodb
+@mock_aws
def test_update_list_index__set_index_of_a_string():
table_name = "test_list_index_access"
client = create_table_with_list(table_name)
@@ -2727,7 +2727,7 @@ def test_update_list_index__set_index_of_a_string():
)
-@mock_dynamodb
+@mock_aws
def test_remove_top_level_attribute():
table_name = "test_remove"
client = create_table_with_list(table_name)
@@ -2745,7 +2745,7 @@ def test_remove_top_level_attribute():
assert result == {"id": {"S": "foo"}}
-@mock_dynamodb
+@mock_aws
def test_remove_top_level_attribute_non_existent():
"""
Remove statements do not require attribute to exist they silently pass
@@ -2764,7 +2764,7 @@ def test_remove_top_level_attribute_non_existent():
assert result == ddb_item
-@mock_dynamodb
+@mock_aws
def test_remove_list_index__remove_existing_index():
table_name = "test_list_index_access"
client = create_table_with_list(table_name)
@@ -2786,7 +2786,7 @@ def test_remove_list_index__remove_existing_index():
assert result["itemlist"] == {"L": [{"S": "bar1"}, {"S": "bar3"}]}
-@mock_dynamodb
+@mock_aws
def test_remove_list_index__remove_multiple_indexes():
table_name = "remove-test"
create_table_with_list(table_name)
@@ -2809,7 +2809,7 @@ def test_remove_list_index__remove_multiple_indexes():
assert item["bla"] == ["4", "5"]
-@mock_dynamodb
+@mock_aws
def test_remove_list_index__remove_existing_nested_index():
table_name = "test_list_index_access"
client = create_table_with_list(table_name)
@@ -2831,7 +2831,7 @@ def test_remove_list_index__remove_existing_nested_index():
assert result["itemmap"]["M"]["itemlist"]["L"] == [{"S": "bar1"}]
-@mock_dynamodb
+@mock_aws
def test_remove_list_index__remove_existing_double_nested_index():
table_name = "test_list_index_access"
client = create_table_with_list(table_name)
@@ -2868,7 +2868,7 @@ def test_remove_list_index__remove_existing_double_nested_index():
assert result["itemmap"]["M"]["itemlist"]["L"][1]["M"] == {"foo11": {"S": "bar2"}}
-@mock_dynamodb
+@mock_aws
def test_remove_list_index__remove_index_out_of_range():
table_name = "test_list_index_access"
client = create_table_with_list(table_name)
@@ -2901,7 +2901,7 @@ def create_table_with_list(table_name):
return client
-@mock_dynamodb
+@mock_aws
def test_sorted_query_with_numerical_sort_key():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
dynamodb.create_table(
@@ -2939,7 +2939,7 @@ def test_sorted_query_with_numerical_sort_key():
# https://github.com/getmoto/moto/issues/1874
-@mock_dynamodb
+@mock_aws
def test_item_size_is_under_400KB():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -2998,7 +2998,7 @@ def assert_failure_due_to_item_size_to_update(func, **kwargs):
assert err["Message"] == "Item size to update has exceeded the maximum allowed size"
-@mock_dynamodb
+@mock_aws
def test_update_supports_complex_expression_attribute_values():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -3032,7 +3032,7 @@ def test_update_supports_complex_expression_attribute_values():
}
-@mock_dynamodb
+@mock_aws
def test_update_supports_list_append():
# Verify whether the list_append operation works as expected
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -3071,7 +3071,7 @@ def test_update_supports_list_append():
}
-@mock_dynamodb
+@mock_aws
def test_update_supports_nested_list_append():
# Verify whether we can append a list that's inside a map
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -3113,7 +3113,7 @@ def test_update_supports_nested_list_append():
}
-@mock_dynamodb
+@mock_aws
def test_update_supports_multiple_levels_nested_list_append():
# Verify whether we can append a list that's inside a map that's inside a map (Inception!)
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -3156,7 +3156,7 @@ def test_update_supports_multiple_levels_nested_list_append():
}
-@mock_dynamodb
+@mock_aws
def test_update_supports_nested_list_append_onto_another_list():
# Verify whether we can take the contents of one list, and use that to fill another list
# Note that the contents of the other list is completely overwritten
@@ -3205,7 +3205,7 @@ def test_update_supports_nested_list_append_onto_another_list():
}
-@mock_dynamodb
+@mock_aws
def test_update_supports_list_append_maps():
client = boto3.client("dynamodb", region_name="us-west-1")
client.create_table(
@@ -3260,7 +3260,7 @@ def test_update_supports_list_append_maps():
]
-@mock_dynamodb
+@mock_aws
def test_update_supports_nested_update_if_nested_value_not_exists():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
name = "TestTable"
@@ -3290,7 +3290,7 @@ def test_update_supports_nested_update_if_nested_value_not_exists():
}
-@mock_dynamodb
+@mock_aws
def test_update_supports_list_append_with_nested_if_not_exists_operation():
dynamo = boto3.resource("dynamodb", region_name="us-west-1")
table_name = "test"
@@ -3323,7 +3323,7 @@ def test_update_supports_list_append_with_nested_if_not_exists_operation():
}
-@mock_dynamodb
+@mock_aws
def test_update_supports_list_append_with_nested_if_not_exists_operation_and_property_already_exists():
dynamo = boto3.resource("dynamodb", region_name="us-west-1")
table_name = "test"
@@ -3356,7 +3356,7 @@ def test_update_supports_list_append_with_nested_if_not_exists_operation_and_pro
}
-@mock_dynamodb
+@mock_aws
def test_update_item_if_original_value_is_none():
dynamo = boto3.resource("dynamodb", region_name="eu-central-1")
dynamo.create_table(
@@ -3375,7 +3375,7 @@ def test_update_item_if_original_value_is_none():
assert table.scan()["Items"][0]["job_name"] == "updated"
-@mock_dynamodb
+@mock_aws
def test_update_nested_item_if_original_value_is_none():
dynamo = boto3.resource("dynamodb", region_name="eu-central-1")
dynamo.create_table(
@@ -3399,7 +3399,7 @@ def test_update_nested_item_if_original_value_is_none():
assert table.scan()["Items"][0]["job_details"]["job_name"] == "updated"
-@mock_dynamodb
+@mock_aws
def test_allow_update_to_item_with_different_type():
dynamo = boto3.resource("dynamodb", region_name="eu-central-1")
dynamo.create_table(
@@ -3430,7 +3430,7 @@ def test_allow_update_to_item_with_different_type():
}
-@mock_dynamodb
+@mock_aws
def test_query_catches_when_no_filters():
dynamo = boto3.resource("dynamodb", region_name="eu-central-1")
dynamo.create_table(
@@ -3452,7 +3452,7 @@ def test_query_catches_when_no_filters():
)
-@mock_dynamodb
+@mock_aws
def test_invalid_transact_get_items():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
dynamodb.create_table(
@@ -3494,7 +3494,7 @@ def test_invalid_transact_get_items():
assert ex.value.response["Error"]["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
def test_valid_transact_get_items():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
dynamodb.create_table(
@@ -3653,7 +3653,7 @@ def test_valid_transact_get_items():
}
-@mock_dynamodb
+@mock_aws
def test_gsi_verify_negative_number_order():
table_schema = {
"KeySchema": [{"AttributeName": "partitionKey", "KeyType": "HASH"}],
@@ -3708,7 +3708,7 @@ def test_gsi_verify_negative_number_order():
assert [float(item["gsiK1SortKey"]) for item in resp["Items"]] == [-0.7, -0.6, 0.7]
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_put():
table_schema = {
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
@@ -3827,7 +3827,7 @@ def test_transact_write_items_failure__return_item(table_name=None):
assert items[0] == {"pk": {"S": "foo2"}}
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_conditioncheck_passes():
table_schema = {
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
@@ -3867,7 +3867,7 @@ def test_transact_write_items_conditioncheck_passes():
assert items[0] == {"email_address": {"S": "test@moto.com"}, "id": {"S": "foo"}}
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_conditioncheck_fails():
table_schema = {
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
@@ -3916,7 +3916,7 @@ def test_transact_write_items_conditioncheck_fails():
assert items[0] == {"email_address": {"S": "test@moto.com"}, "id": {"S": "foo"}}
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_delete():
table_schema = {
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
@@ -3939,7 +3939,7 @@ def test_transact_write_items_delete():
assert len(items) == 0
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_delete_with_successful_condition_expression():
table_schema = {
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
@@ -3969,7 +3969,7 @@ def test_transact_write_items_delete_with_successful_condition_expression():
assert len(items) == 0
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_delete_with_failed_condition_expression():
table_schema = {
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
@@ -4008,7 +4008,7 @@ def test_transact_write_items_delete_with_failed_condition_expression():
assert items[0] == {"email_address": {"S": "test@moto.com"}, "id": {"S": "foo"}}
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_update():
table_schema = {
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
@@ -4040,7 +4040,7 @@ def test_transact_write_items_update():
assert items[0] == {"id": {"S": "foo"}, "email_address": {"S": "test@moto.com"}}
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_update_with_failed_condition_expression():
table_schema = {
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
@@ -4081,7 +4081,7 @@ def test_transact_write_items_update_with_failed_condition_expression():
assert items[0] == {"email_address": {"S": "test@moto.com"}, "id": {"S": "foo"}}
-@mock_dynamodb
+@mock_aws
def test_dynamodb_max_1mb_limit():
ddb = boto3.resource("dynamodb", region_name="eu-west-1")
@@ -4137,7 +4137,7 @@ def assert_raise_syntax_error(client_error, token, near):
assert expected_syntax_error == client_error["Message"]
-@mock_dynamodb
+@mock_aws
def test_update_expression_with_numeric_literal_instead_of_value():
"""
DynamoDB requires literals to be passed in as values. If they are put literally in the expression a token error will
@@ -4162,7 +4162,7 @@ def test_update_expression_with_numeric_literal_instead_of_value():
assert_raise_syntax_error(err, "1", "+ 1")
-@mock_dynamodb
+@mock_aws
def test_update_expression_with_multiple_set_clauses_must_be_comma_separated():
"""
An UpdateExpression can have multiple set clauses but if they are passed in without the separating comma.
@@ -4186,7 +4186,7 @@ def test_update_expression_with_multiple_set_clauses_must_be_comma_separated():
assert_raise_syntax_error(err, "Mystr2", "myNum Mystr2 myNum2")
-@mock_dynamodb
+@mock_aws
def test_list_tables_exclusive_start_table_name_empty():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -4245,7 +4245,7 @@ def create_simple_table_and_return_client():
# https://github.com/getmoto/moto/issues/2806
# https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html
# #DDB-UpdateItem-request-UpdateExpression
-@mock_dynamodb
+@mock_aws
def test_update_item_with_attribute_in_right_hand_side_and_operation():
dynamodb = create_simple_table_and_return_client()
@@ -4269,7 +4269,7 @@ def test_update_item_with_attribute_in_right_hand_side_and_operation():
assert result["Item"]["myNum"]["N"] == "3"
-@mock_dynamodb
+@mock_aws
def test_non_existing_attribute_should_raise_exception():
"""
Does error message get correctly raised if attribute is referenced but it does not exist for the item.
@@ -4291,7 +4291,7 @@ def test_non_existing_attribute_should_raise_exception():
)
-@mock_dynamodb
+@mock_aws
def test_update_expression_with_plus_in_attribute_name():
"""
Does error message get correctly raised if attribute contains a plus and is passed in without an AttributeName. And
@@ -4318,7 +4318,7 @@ def test_update_expression_with_plus_in_attribute_name():
)
-@mock_dynamodb
+@mock_aws
def test_update_expression_with_minus_in_attribute_name():
"""
Does error message get correctly raised if attribute contains a minus and is passed in without an AttributeName. And
@@ -4345,7 +4345,7 @@ def test_update_expression_with_minus_in_attribute_name():
)
-@mock_dynamodb
+@mock_aws
def test_update_expression_with_space_in_attribute_name():
"""
Does error message get correctly raised if attribute contains a space and is passed in without an AttributeName. And
@@ -4368,7 +4368,7 @@ def test_update_expression_with_space_in_attribute_name():
assert_raise_syntax_error(err, "Num", "my Num")
-@mock_dynamodb
+@mock_aws
def test_summing_up_2_strings_raises_exception():
"""
Update set supports different DynamoDB types but some operations are not supported. For example summing up 2 strings
@@ -4393,7 +4393,7 @@ def test_summing_up_2_strings_raises_exception():
# https://github.com/getmoto/moto/issues/2806
-@mock_dynamodb
+@mock_aws
def test_update_item_with_attribute_in_right_hand_side():
"""
After tokenization and building expression make sure referenced attributes are replaced with their current value
@@ -4416,7 +4416,7 @@ def test_update_item_with_attribute_in_right_hand_side():
assert result["Item"]["myVal1"]["S"] == result["Item"]["myVal2"]["S"] == "Value2"
-@mock_dynamodb
+@mock_aws
def test_multiple_updates():
dynamodb = create_simple_table_and_return_client()
dynamodb.put_item(
@@ -4440,7 +4440,7 @@ def test_multiple_updates():
assert result == expected_result
-@mock_dynamodb
+@mock_aws
def test_update_item_atomic_counter():
table = "table_t"
ddb_mock = boto3.client("dynamodb", region_name="eu-west-3")
@@ -4469,7 +4469,7 @@ def test_update_item_atomic_counter():
assert updated_item["n_f"]["N"] == "5.35"
-@mock_dynamodb
+@mock_aws
def test_update_item_atomic_counter_return_values():
table = "table_t"
ddb_mock = boto3.client("dynamodb", region_name="eu-west-3")
@@ -4517,7 +4517,7 @@ def test_update_item_atomic_counter_return_values():
assert response["Attributes"]["v"]["N"] == "8"
-@mock_dynamodb
+@mock_aws
def test_update_item_atomic_counter_from_zero():
table = "table_t"
ddb_mock = boto3.client("dynamodb", region_name="eu-west-1")
@@ -4543,7 +4543,7 @@ def test_update_item_atomic_counter_from_zero():
assert updated_item["n_f"]["N"] == "-0.5"
-@mock_dynamodb
+@mock_aws
def test_update_item_add_to_non_existent_set():
table = "table_t"
ddb_mock = boto3.client("dynamodb", region_name="eu-west-1")
@@ -4566,7 +4566,7 @@ def test_update_item_add_to_non_existent_set():
assert updated_item["s_i"]["SS"] == ["hello"]
-@mock_dynamodb
+@mock_aws
def test_update_item_add_to_non_existent_number_set():
table = "table_t"
ddb_mock = boto3.client("dynamodb", region_name="eu-west-1")
@@ -4589,7 +4589,7 @@ def test_update_item_add_to_non_existent_number_set():
assert updated_item["s_i"]["NS"] == ["3"]
-@mock_dynamodb
+@mock_aws
def test_transact_write_items_fails_with_transaction_canceled_exception():
table_schema = {
"KeySchema": [{"AttributeName": "id", "KeyType": "HASH"}],
@@ -4635,7 +4635,7 @@ def test_transact_write_items_fails_with_transaction_canceled_exception():
)
-@mock_dynamodb
+@mock_aws
def test_gsi_projection_type_keys_only():
table_schema = {
"KeySchema": [{"AttributeName": "partitionKey", "KeyType": "HASH"}],
@@ -4682,7 +4682,7 @@ def test_gsi_projection_type_keys_only():
}
-@mock_dynamodb
+@mock_aws
def test_gsi_projection_type_include():
table_schema = {
"KeySchema": [{"AttributeName": "partitionKey", "KeyType": "HASH"}],
@@ -4744,7 +4744,7 @@ def test_gsi_projection_type_include():
}
-@mock_dynamodb
+@mock_aws
def test_lsi_projection_type_keys_only():
table_schema = {
"KeySchema": [
@@ -4799,7 +4799,7 @@ def test_lsi_projection_type_keys_only():
}
-@mock_dynamodb
+@mock_aws
@pytest.mark.parametrize(
"attr_name",
["orders", "#placeholder"],
@@ -4841,7 +4841,7 @@ def test_set_attribute_is_dropped_if_empty_after_update_expression(attr_name):
assert "orders" not in item
-@mock_dynamodb
+@mock_aws
def test_transact_get_items_should_return_empty_map_for_non_existent_item():
client = boto3.client("dynamodb", region_name="us-west-2")
table_name = "test-table"
@@ -4866,7 +4866,7 @@ def test_transact_get_items_should_return_empty_map_for_non_existent_item():
assert items[1] == {}
-@mock_dynamodb
+@mock_aws
def test_dynamodb_update_item_fails_on_string_sets():
dynamodb = boto3.resource("dynamodb", region_name="eu-west-1")
client = boto3.client("dynamodb", region_name="eu-west-1")
@@ -4887,7 +4887,7 @@ def test_dynamodb_update_item_fails_on_string_sets():
)
-@mock_dynamodb
+@mock_aws
def test_update_item_add_to_list_using_legacy_attribute_updates():
resource = boto3.resource("dynamodb", region_name="us-west-2")
resource.create_table(
@@ -4910,7 +4910,7 @@ def test_update_item_add_to_list_using_legacy_attribute_updates():
assert resp["Item"]["attr"] == ["a", "b", "c", "d", "e"]
-@mock_dynamodb
+@mock_aws
def test_update_item_add_to_num_set_using_legacy_attribute_updates():
resource = boto3.resource("dynamodb", region_name="us-west-2")
resource.create_table(
@@ -4948,7 +4948,7 @@ def test_update_item_add_to_num_set_using_legacy_attribute_updates():
assert resp["Item"]["attr"] == {1, 4, 5}
-@mock_dynamodb
+@mock_aws
def test_get_item_for_non_existent_table_raises_error():
client = boto3.client("dynamodb", "us-east-1")
with pytest.raises(ClientError) as ex:
@@ -4957,7 +4957,7 @@ def test_get_item_for_non_existent_table_raises_error():
assert ex.value.response["Error"]["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
def test_error_when_providing_expression_and_nonexpression_params():
client = boto3.client("dynamodb", "eu-central-1")
table_name = "testtable"
@@ -4986,7 +4986,7 @@ def test_error_when_providing_expression_and_nonexpression_params():
)
-@mock_dynamodb
+@mock_aws
def test_attribute_item_delete():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="eu-west-1")
@@ -5011,7 +5011,7 @@ def test_attribute_item_delete():
assert items == [{"name": {"S": "foo"}}]
-@mock_dynamodb
+@mock_aws
def test_gsi_key_can_be_updated():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="eu-west-2")
@@ -5057,7 +5057,7 @@ def test_gsi_key_can_be_updated():
assert item["main_key"] == {"S": "testkey1"}
-@mock_dynamodb
+@mock_aws
def test_gsi_key_cannot_be_empty():
name = "TestTable"
conn = boto3.client("dynamodb", region_name="eu-west-2")
@@ -5106,7 +5106,7 @@ def test_gsi_key_cannot_be_empty():
)
-@mock_dynamodb
+@mock_aws
def test_create_backup_for_non_existent_table_raises_error():
client = boto3.client("dynamodb", "us-east-1")
with pytest.raises(ClientError) as ex:
@@ -5116,7 +5116,7 @@ def test_create_backup_for_non_existent_table_raises_error():
assert error["Message"] == "Table not found: non-existent"
-@mock_dynamodb
+@mock_aws
def test_create_backup():
client = boto3.client("dynamodb", "us-east-1")
table_name = "test-table"
@@ -5137,7 +5137,7 @@ def test_create_backup():
assert isinstance(details["BackupCreationDateTime"], datetime)
-@mock_dynamodb
+@mock_aws
def test_create_multiple_backups_with_same_name():
client = boto3.client("dynamodb", "us-east-1")
table_name = "test-table"
@@ -5158,7 +5158,7 @@ def test_create_multiple_backups_with_same_name():
backup_arns.append(backup["BackupArn"])
-@mock_dynamodb
+@mock_aws
def test_describe_backup_for_non_existent_backup_raises_error():
client = boto3.client("dynamodb", "us-east-1")
non_existent_arn = "arn:aws:dynamodb:us-east-1:123456789012:table/table-name/backup/01623095754481-2cfcd6f9"
@@ -5169,7 +5169,7 @@ def test_describe_backup_for_non_existent_backup_raises_error():
assert error["Message"] == f"Backup not found: {non_existent_arn}"
-@mock_dynamodb
+@mock_aws
def test_describe_backup():
client = boto3.client("dynamodb", "us-east-1")
table_name = "test-table"
@@ -5204,14 +5204,14 @@ def test_describe_backup():
assert source["ItemCount"] == table["ItemCount"]
-@mock_dynamodb
+@mock_aws
def test_list_backups_for_non_existent_table():
client = boto3.client("dynamodb", "us-east-1")
resp = client.list_backups(TableName="non-existent")
assert len(resp["BackupSummaries"]) == 0
-@mock_dynamodb
+@mock_aws
def test_list_backups():
client = boto3.client("dynamodb", "us-east-1")
table_names = ["test-table-1", "test-table-2"]
@@ -5241,7 +5241,7 @@ def test_list_backups():
assert isinstance(summary["BackupSizeBytes"], int)
-@mock_dynamodb
+@mock_aws
def test_restore_table_from_non_existent_backup_raises_error():
client = boto3.client("dynamodb", "us-east-1")
non_existent_arn = "arn:aws:dynamodb:us-east-1:123456789012:table/table-name/backup/01623095754481-2cfcd6f9"
@@ -5254,7 +5254,7 @@ def test_restore_table_from_non_existent_backup_raises_error():
assert error["Message"] == f"Backup not found: {non_existent_arn}"
-@mock_dynamodb
+@mock_aws
def test_restore_table_from_backup_raises_error_when_table_already_exists():
client = boto3.client("dynamodb", "us-east-1")
table_name = "test-table"
@@ -5275,7 +5275,7 @@ def test_restore_table_from_backup_raises_error_when_table_already_exists():
assert error["Message"] == f"Table already exists: {table_name}"
-@mock_dynamodb
+@mock_aws
def test_restore_table_from_backup():
client = boto3.client("dynamodb", "us-east-1")
table_name = "test-table"
@@ -5313,7 +5313,7 @@ def test_restore_table_from_backup():
assert summary["RestoreInProgress"] is False
-@mock_dynamodb
+@mock_aws
def test_restore_table_to_point_in_time():
client = boto3.client("dynamodb", "us-east-1")
table_name = "test-table"
@@ -5343,7 +5343,7 @@ def test_restore_table_to_point_in_time():
assert summary["RestoreInProgress"] is False
-@mock_dynamodb
+@mock_aws
def test_restore_table_to_point_in_time_raises_error_when_source_not_exist():
client = boto3.client("dynamodb", "us-east-1")
table_name = "test-table"
@@ -5357,7 +5357,7 @@ def test_restore_table_to_point_in_time_raises_error_when_source_not_exist():
assert error["Message"] == f"Source table not found: {table_name}"
-@mock_dynamodb
+@mock_aws
def test_restore_table_to_point_in_time_raises_error_when_dest_exist():
client = boto3.client("dynamodb", "us-east-1")
table_name = "test-table"
@@ -5383,7 +5383,7 @@ def test_restore_table_to_point_in_time_raises_error_when_dest_exist():
assert error["Message"] == f"Table already exists: {restored_table_name}"
-@mock_dynamodb
+@mock_aws
def test_delete_non_existent_backup_raises_error():
client = boto3.client("dynamodb", "us-east-1")
non_existent_arn = "arn:aws:dynamodb:us-east-1:123456789012:table/table-name/backup/01623095754481-2cfcd6f9"
@@ -5394,7 +5394,7 @@ def test_delete_non_existent_backup_raises_error():
assert error["Message"] == f"Backup not found: {non_existent_arn}"
-@mock_dynamodb
+@mock_aws
def test_delete_backup():
client = boto3.client("dynamodb", "us-east-1")
table_name = "test-table-1"
@@ -5423,7 +5423,7 @@ def test_delete_backup():
assert len(resp["BackupSummaries"]) == 1
-@mock_dynamodb
+@mock_aws
def test_source_and_restored_table_items_are_not_linked():
client = boto3.client("dynamodb", "us-east-1")
@@ -5472,7 +5472,7 @@ def test_source_and_restored_table_items_are_not_linked():
)
-@mock_dynamodb
+@mock_aws
@pytest.mark.parametrize("region", ["eu-central-1", "ap-south-1"])
def test_describe_endpoints(region):
client = boto3.client("dynamodb", region)
@@ -5485,7 +5485,7 @@ def test_describe_endpoints(region):
]
-@mock_dynamodb
+@mock_aws
def test_update_non_existing_item_raises_error_and_does_not_contain_item_afterwards():
"""
https://github.com/getmoto/moto/issues/3729
@@ -5517,7 +5517,7 @@ def test_update_non_existing_item_raises_error_and_does_not_contain_item_afterwa
assert len(conn.scan(TableName=name)["Items"]) == 0
-@mock_dynamodb
+@mock_aws
def test_batch_write_item():
conn = boto3.resource("dynamodb", region_name="us-west-2")
tables = [f"table-{i}" for i in range(3)]
@@ -5556,7 +5556,7 @@ def test_batch_write_item():
assert table.scan()["Count"] == 0
-@mock_dynamodb
+@mock_aws
def test_gsi_lastevaluatedkey():
# github.com/getmoto/moto/issues/3968
conn = boto3.resource("dynamodb", region_name="us-west-2")
@@ -5618,7 +5618,7 @@ def test_gsi_lastevaluatedkey():
assert last_evaluated_key == {"main_key": "testkey1", "index_key": "indexkey"}
-@mock_dynamodb
+@mock_aws
def test_filter_expression_execution_order():
# As mentioned here: https://github.com/getmoto/moto/issues/3909
# and documented here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.FilterExpression
@@ -5708,7 +5708,7 @@ def test_filter_expression_execution_order():
]
-@mock_dynamodb
+@mock_aws
def test_projection_expression_execution_order():
# projection expression needs to be applied after calculation of
# LastEvaluatedKey as it is possible for LastEvaluatedKey to
@@ -5767,7 +5767,7 @@ def test_projection_expression_execution_order():
)
-@mock_dynamodb
+@mock_aws
def test_projection_expression_with_binary_attr():
dynamo_resource = boto3.resource("dynamodb", region_name="us-east-1")
dynamo_resource.create_table(
@@ -5799,7 +5799,7 @@ def test_projection_expression_with_binary_attr():
assert item["key"] == Binary(b"value\xbf")
-@mock_dynamodb
+@mock_aws
def test_invalid_projection_expressions():
table_name = "test-projection-expressions-table"
client = boto3.client("dynamodb", region_name="us-east-1")
diff --git a/tests/test_dynamodb/test_dynamodb_batch_get_item.py b/tests/test_dynamodb/test_dynamodb_batch_get_item.py
index f98ed1013..06d639c6f 100644
--- a/tests/test_dynamodb/test_dynamodb_batch_get_item.py
+++ b/tests/test_dynamodb/test_dynamodb_batch_get_item.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_dynamodb
+from moto import mock_aws
def _create_user_table():
@@ -25,7 +25,7 @@ def _create_user_table():
return client
-@mock_dynamodb
+@mock_aws
def test_batch_items_returns_all():
dynamodb = _create_user_table()
returned_items = dynamodb.batch_get_item(
@@ -47,7 +47,7 @@ def test_batch_items_returns_all():
assert {"username": {"S": "user3"}, "foo": {"S": "bar"}} in returned_items
-@mock_dynamodb
+@mock_aws
def test_batch_items_throws_exception_when_requesting_100_items_for_single_table():
dynamodb = _create_user_table()
with pytest.raises(ClientError) as ex:
@@ -69,7 +69,7 @@ def test_batch_items_throws_exception_when_requesting_100_items_for_single_table
)
-@mock_dynamodb
+@mock_aws
def test_batch_items_throws_exception_when_requesting_100_items_across_all_tables():
dynamodb = _create_user_table()
with pytest.raises(ClientError) as ex:
@@ -94,7 +94,7 @@ def test_batch_items_throws_exception_when_requesting_100_items_across_all_table
assert err["Message"] == "Too many items requested for the BatchGetItem call"
-@mock_dynamodb
+@mock_aws
def test_batch_items_with_basic_projection_expression():
dynamodb = _create_user_table()
returned_items = dynamodb.batch_get_item(
@@ -141,7 +141,7 @@ def test_batch_items_with_basic_projection_expression():
assert {"username": {"S": "user3"}, "foo": {"S": "bar"}} in returned_items
-@mock_dynamodb
+@mock_aws
def test_batch_items_with_basic_projection_expression_and_attr_expression_names():
dynamodb = _create_user_table()
returned_items = dynamodb.batch_get_item(
@@ -166,7 +166,7 @@ def test_batch_items_with_basic_projection_expression_and_attr_expression_names(
assert {"username": {"S": "user3"}} in returned_items
-@mock_dynamodb
+@mock_aws
def test_batch_items_should_throw_exception_for_duplicate_request():
client = _create_user_table()
with pytest.raises(ClientError) as ex:
@@ -186,7 +186,7 @@ def test_batch_items_should_throw_exception_for_duplicate_request():
assert err["Message"] == "Provided list of item keys contains duplicates"
-@mock_dynamodb
+@mock_aws
def test_batch_items_should_return_16mb_max():
"""
A single operation can retrieve up to 16 MB of data [...]. BatchGetItem returns a partial result if the response size limit is exceeded [..].
diff --git a/tests/test_dynamodb/test_dynamodb_cloudformation.py b/tests/test_dynamodb/test_dynamodb_cloudformation.py
index 03222cc0a..8cac53669 100644
--- a/tests/test_dynamodb/test_dynamodb_cloudformation.py
+++ b/tests/test_dynamodb/test_dynamodb_cloudformation.py
@@ -2,7 +2,7 @@ import json
import boto3
-from moto import mock_cloudformation, mock_dynamodb
+from moto import mock_aws
template_create_table = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -29,8 +29,7 @@ template_create_table = {
}
-@mock_dynamodb
-@mock_cloudformation
+@mock_aws
def test_delete_stack_dynamo_template_boto3():
conn = boto3.client("cloudformation", region_name="us-east-1")
dynamodb_client = boto3.client("dynamodb", region_name="us-east-1")
diff --git a/tests/test_dynamodb/test_dynamodb_condition_expressions.py b/tests/test_dynamodb/test_dynamodb_condition_expressions.py
index d05d21f6c..9f74f2d61 100644
--- a/tests/test_dynamodb/test_dynamodb_condition_expressions.py
+++ b/tests/test_dynamodb/test_dynamodb_condition_expressions.py
@@ -4,10 +4,10 @@ from decimal import Decimal
import boto3
import pytest
-from moto import mock_dynamodb
+from moto import mock_aws
-@mock_dynamodb
+@mock_aws
def test_condition_expression_with_dot_in_attr_name():
dynamodb = boto3.resource("dynamodb", region_name="us-east-2")
table_name = "Test"
@@ -41,7 +41,7 @@ def test_condition_expression_with_dot_in_attr_name():
assert item == {"id": "key-0", "first": {}}
-@mock_dynamodb
+@mock_aws
def test_condition_expressions():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -236,7 +236,7 @@ def _assert_conditional_check_failed_exception(exc):
assert err["Message"] == "The conditional request failed"
-@mock_dynamodb
+@mock_aws
def test_condition_expression_numerical_attribute():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
dynamodb.create_table(
@@ -277,7 +277,7 @@ def update_numerical_con_expr(key, con_expr, res, table):
assert table.get_item(Key={"partitionKey": key})["Item"]["myAttr"] == Decimal(res)
-@mock_dynamodb
+@mock_aws
def test_condition_expression__attr_doesnt_exist():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -315,7 +315,7 @@ def test_condition_expression__attr_doesnt_exist():
_assert_conditional_check_failed_exception(exc)
-@mock_dynamodb
+@mock_aws
def test_condition_expression__or_order():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -338,7 +338,7 @@ def test_condition_expression__or_order():
)
-@mock_dynamodb
+@mock_aws
def test_condition_expression__and_order():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -363,7 +363,7 @@ def test_condition_expression__and_order():
_assert_conditional_check_failed_exception(exc)
-@mock_dynamodb
+@mock_aws
def test_condition_expression_with_reserved_keyword_as_attr_name():
dynamodb = boto3.resource("dynamodb", region_name="us-east-2")
table_name = "Test"
diff --git a/tests/test_dynamodb/test_dynamodb_consumedcapacity.py b/tests/test_dynamodb/test_dynamodb_consumedcapacity.py
index 9db70daca..af71f555c 100644
--- a/tests/test_dynamodb/test_dynamodb_consumedcapacity.py
+++ b/tests/test_dynamodb/test_dynamodb_consumedcapacity.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_dynamodb
+from moto import mock_aws
-@mock_dynamodb
+@mock_aws
def test_error_on_wrong_value_for_consumed_capacity():
resource = boto3.resource("dynamodb", region_name="ap-northeast-3")
client = boto3.client("dynamodb", region_name="ap-northeast-3")
@@ -30,7 +30,7 @@ def test_error_on_wrong_value_for_consumed_capacity():
)
-@mock_dynamodb
+@mock_aws
def test_consumed_capacity_get_unknown_item():
conn = boto3.client("dynamodb", region_name="us-east-1")
conn.create_table(
@@ -52,7 +52,7 @@ def test_consumed_capacity_get_unknown_item():
}
-@mock_dynamodb
+@mock_aws
@pytest.mark.parametrize(
"capacity,should_have_capacity,should_have_table",
[
diff --git a/tests/test_dynamodb/test_dynamodb_create_table.py b/tests/test_dynamodb/test_dynamodb_create_table.py
index 1d2e382d7..ed8b1a91c 100644
--- a/tests/test_dynamodb/test_dynamodb_create_table.py
+++ b/tests/test_dynamodb/test_dynamodb_create_table.py
@@ -4,13 +4,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_dynamodb
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from . import dynamodb_aws_verified
-@mock_dynamodb
+@mock_aws
def test_create_table_standard():
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
@@ -52,7 +52,7 @@ def test_create_table_standard():
assert actual["ItemCount"] == 0
-@mock_dynamodb
+@mock_aws
def test_create_table_with_local_index():
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
@@ -115,7 +115,7 @@ def test_create_table_with_local_index():
assert actual["ItemCount"] == 0
-@mock_dynamodb
+@mock_aws
def test_create_table_with_gsi():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -188,7 +188,7 @@ def test_create_table_with_gsi():
]
-@mock_dynamodb
+@mock_aws
def test_create_table_with_stream_specification():
conn = boto3.client("dynamodb", region_name="us-east-1")
@@ -215,7 +215,7 @@ def test_create_table_with_stream_specification():
assert "StreamSpecification" in resp["TableDescription"]
-@mock_dynamodb
+@mock_aws
def test_create_table_with_tags():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -233,7 +233,7 @@ def test_create_table_with_tags():
assert resp["Tags"] == [{"Key": "tk", "Value": "tv"}]
-@mock_dynamodb
+@mock_aws
def test_create_table_pay_per_request():
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
@@ -258,7 +258,7 @@ def test_create_table_pay_per_request():
}
-@mock_dynamodb
+@mock_aws
def test_create_table__provisioned_throughput():
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
@@ -283,7 +283,7 @@ def test_create_table__provisioned_throughput():
}
-@mock_dynamodb
+@mock_aws
def test_create_table_without_specifying_throughput():
dynamodb_client = boto3.client("dynamodb", region_name="us-east-1")
@@ -305,7 +305,7 @@ def test_create_table_without_specifying_throughput():
)
-@mock_dynamodb
+@mock_aws
def test_create_table_error_pay_per_request_with_provisioned_param():
client = boto3.client("dynamodb", region_name="us-east-1")
@@ -331,7 +331,7 @@ def test_create_table_error_pay_per_request_with_provisioned_param():
)
-@mock_dynamodb
+@mock_aws
def test_create_table_with_ssespecification__false():
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
@@ -352,7 +352,7 @@ def test_create_table_with_ssespecification__false():
assert "SSEDescription" not in actual
-@mock_dynamodb
+@mock_aws
def test_create_table_with_ssespecification__true():
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
@@ -377,7 +377,7 @@ def test_create_table_with_ssespecification__true():
assert actual["SSEDescription"]["KMSMasterKeyArn"].startswith("arn:aws:kms")
-@mock_dynamodb
+@mock_aws
def test_create_table_with_ssespecification__custom_kms_key():
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
diff --git a/tests/test_dynamodb/test_dynamodb_statements.py b/tests/test_dynamodb/test_dynamodb_statements.py
index 68e3f21f6..6530cf129 100644
--- a/tests/test_dynamodb/test_dynamodb_statements.py
+++ b/tests/test_dynamodb/test_dynamodb_statements.py
@@ -3,7 +3,7 @@ from unittest import TestCase
import boto3
import pytest
-from moto import mock_dynamodb
+from moto import mock_aws
from . import dynamodb_aws_verified
@@ -88,7 +88,7 @@ def test_execute_statement_with_no_results(table_name=None):
assert items == []
-@mock_dynamodb
+@mock_aws
class TestExecuteTransaction(TestCase):
def setUp(self):
self.client = boto3.client("dynamodb", "us-east-1")
@@ -116,7 +116,7 @@ class TestExecuteTransaction(TestCase):
assert len(items) == 3
-@mock_dynamodb
+@mock_aws
class TestBatchExecuteStatement(TestCase):
def setUp(self):
self.client = boto3.client("dynamodb", "us-east-1")
@@ -346,7 +346,7 @@ def test_delete_data(table_name=None):
assert items == [item2]
-@mock_dynamodb
+@mock_aws
def test_delete_data__with_sort_key():
client = boto3.client("dynamodb", "us-east-1")
client.create_table(
diff --git a/tests/test_dynamodb/test_dynamodb_table_with_range_key.py b/tests/test_dynamodb/test_dynamodb_table_with_range_key.py
index d4a864753..aafad7f1c 100644
--- a/tests/test_dynamodb/test_dynamodb_table_with_range_key.py
+++ b/tests/test_dynamodb/test_dynamodb_table_with_range_key.py
@@ -6,10 +6,10 @@ import pytest
from boto3.dynamodb.conditions import Key
from botocore.exceptions import ClientError
-from moto import mock_dynamodb
+from moto import mock_aws
-@mock_dynamodb
+@mock_aws
def test_get_item_without_range_key_boto3():
client = boto3.resource("dynamodb", region_name="us-east-1")
table = client.create_table(
@@ -36,7 +36,7 @@ def test_get_item_without_range_key_boto3():
assert ex.value.response["Error"]["Message"] == "Validation Exception"
-@mock_dynamodb
+@mock_aws
def test_query_filter_boto3():
table_schema = {
"KeySchema": [
@@ -77,7 +77,7 @@ def test_query_filter_boto3():
assert res["Items"] == [{"pk": "pk", "sk": "sk-1"}, {"pk": "pk", "sk": "sk-2"}]
-@mock_dynamodb
+@mock_aws
def test_boto3_conditions():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -151,7 +151,7 @@ def test_boto3_conditions():
assert results["Count"] == 1
-@mock_dynamodb
+@mock_aws
def test_boto3_conditions_ignorecase():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -216,7 +216,7 @@ def test_boto3_conditions_ignorecase():
)
-@mock_dynamodb
+@mock_aws
def test_boto3_put_item_with_conditions():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -294,7 +294,7 @@ def _create_table_with_range_key():
return dynamodb.Table("users")
-@mock_dynamodb
+@mock_aws
def test_update_item_range_key_set():
table = _create_table_with_range_key()
table.put_item(
@@ -329,7 +329,7 @@ def test_update_item_range_key_set():
}
-@mock_dynamodb
+@mock_aws
def test_update_item_does_not_exist_is_created():
table = _create_table_with_range_key()
@@ -359,7 +359,7 @@ def test_update_item_does_not_exist_is_created():
}
-@mock_dynamodb
+@mock_aws
def test_update_item_add_value():
table = _create_table_with_range_key()
@@ -384,7 +384,7 @@ def test_update_item_add_value():
}
-@mock_dynamodb
+@mock_aws
def test_update_item_add_value_string_set():
table = _create_table_with_range_key()
@@ -413,7 +413,7 @@ def test_update_item_add_value_string_set():
}
-@mock_dynamodb
+@mock_aws
def test_update_item_delete_value_string_set():
table = _create_table_with_range_key()
@@ -442,7 +442,7 @@ def test_update_item_delete_value_string_set():
}
-@mock_dynamodb
+@mock_aws
def test_update_item_add_value_does_not_exist_is_created():
table = _create_table_with_range_key()
@@ -463,7 +463,7 @@ def test_update_item_add_value_does_not_exist_is_created():
}
-@mock_dynamodb
+@mock_aws
def test_update_item_with_expression():
table = _create_table_with_range_key()
@@ -502,7 +502,7 @@ def assert_failure_due_to_key_not_in_schema(func, **kwargs):
assert err["Message"] == "The provided key element does not match the schema"
-@mock_dynamodb
+@mock_aws
def test_update_item_add_with_expression():
table = _create_table_with_range_key()
@@ -607,7 +607,7 @@ def test_update_item_add_with_expression():
)
-@mock_dynamodb
+@mock_aws
def test_update_item_add_with_nested_sets():
table = _create_table_with_range_key()
@@ -643,7 +643,7 @@ def test_update_item_add_with_nested_sets():
assert table.get_item(Key=item_key)["Item"] == current_item
-@mock_dynamodb
+@mock_aws
def test_update_item_delete_with_nested_sets():
table = _create_table_with_range_key()
@@ -669,7 +669,7 @@ def test_update_item_delete_with_nested_sets():
assert table.get_item(Key=item_key)["Item"] == current_item
-@mock_dynamodb
+@mock_aws
def test_update_item_delete_with_expression():
table = _create_table_with_range_key()
@@ -743,7 +743,7 @@ def test_update_item_delete_with_expression():
)
-@mock_dynamodb
+@mock_aws
def test_boto3_query_gsi_range_comparison():
table = _create_table_with_range_key()
@@ -840,7 +840,7 @@ def test_boto3_query_gsi_range_comparison():
assert item["created"] == expected[index]
-@mock_dynamodb
+@mock_aws
def test_boto3_update_table_throughput():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -872,7 +872,7 @@ def test_boto3_update_table_throughput():
assert table.provisioned_throughput["WriteCapacityUnits"] == 11
-@mock_dynamodb
+@mock_aws
def test_boto3_update_table_gsi_throughput():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -939,7 +939,7 @@ def test_boto3_update_table_gsi_throughput():
assert gsi_throughput["WriteCapacityUnits"] == 11
-@mock_dynamodb
+@mock_aws
def test_update_table_gsi_create():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1021,7 +1021,7 @@ def test_update_table_gsi_create():
assert len(table.global_secondary_indexes) == 0
-@mock_dynamodb
+@mock_aws
def test_update_table_gsi_throughput():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -1063,7 +1063,7 @@ def test_update_table_gsi_throughput():
assert len(table.global_secondary_indexes) == 0
-@mock_dynamodb
+@mock_aws
def test_query_pagination():
table = _create_table_with_range_key()
for i in range(10):
@@ -1096,7 +1096,7 @@ def test_query_pagination():
assert subjects == set(range(10))
-@mock_dynamodb
+@mock_aws
def test_scan_by_index():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
@@ -1216,7 +1216,7 @@ def test_scan_by_index():
assert last_eval_key["lsi_range_key"]["S"] == "1"
-@mock_dynamodb
+@mock_aws
@pytest.mark.parametrize("create_item_first", [False, True])
@pytest.mark.parametrize(
"expression", ["set h=:New", "set r=:New", "set x=:New, r=:New"]
diff --git a/tests/test_dynamodb/test_dynamodb_table_without_range_key.py b/tests/test_dynamodb/test_dynamodb_table_without_range_key.py
index 546caa4b2..774ba3f58 100644
--- a/tests/test_dynamodb/test_dynamodb_table_without_range_key.py
+++ b/tests/test_dynamodb/test_dynamodb_table_without_range_key.py
@@ -5,11 +5,11 @@ import pytest
from boto3.dynamodb.conditions import Key
from botocore.exceptions import ClientError
-from moto import mock_dynamodb
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_dynamodb
+@mock_aws
def test_create_table():
client = boto3.client("dynamodb", region_name="us-east-2")
client.create_table(
@@ -68,7 +68,7 @@ def test_create_table():
assert actual["ItemCount"] == 0
-@mock_dynamodb
+@mock_aws
def test_delete_table():
conn = boto3.client("dynamodb", region_name="us-west-2")
conn.create_table(
@@ -90,7 +90,7 @@ def test_delete_table():
assert ex.value.response["Error"]["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
def test_item_add_and_describe_and_update():
conn = boto3.resource("dynamodb", region_name="us-west-2")
table = conn.create_table(
@@ -130,7 +130,7 @@ def test_item_add_and_describe_and_update():
}
-@mock_dynamodb
+@mock_aws
def test_item_put_without_table():
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -149,7 +149,7 @@ def test_item_put_without_table():
assert ex.value.response["Error"]["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
def test_get_item_with_undeclared_table():
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -161,7 +161,7 @@ def test_get_item_with_undeclared_table():
assert ex.value.response["Error"]["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
def test_delete_item():
conn = boto3.resource("dynamodb", region_name="us-west-2")
table = conn.create_table(
@@ -188,7 +188,7 @@ def test_delete_item():
table.delete_item(Key={"id": "LOLCat Forum"})
-@mock_dynamodb
+@mock_aws
def test_delete_item_with_undeclared_table():
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -202,7 +202,7 @@ def test_delete_item_with_undeclared_table():
assert ex.value.response["Error"]["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
def test_scan_with_undeclared_table():
conn = boto3.client("dynamodb", region_name="us-west-2")
@@ -214,7 +214,7 @@ def test_scan_with_undeclared_table():
assert ex.value.response["Error"]["Message"] == "Requested resource not found"
-@mock_dynamodb
+@mock_aws
def test_get_key_schema():
conn = boto3.resource("dynamodb", region_name="us-west-2")
table = conn.create_table(
@@ -227,7 +227,7 @@ def test_get_key_schema():
assert table.key_schema == [{"AttributeName": "id", "KeyType": "HASH"}]
-@mock_dynamodb
+@mock_aws
def test_update_item_double_nested_remove():
conn = boto3.client("dynamodb", region_name="us-east-1")
conn.create_table(
@@ -262,7 +262,7 @@ def test_update_item_double_nested_remove():
assert returned_item["Item"] == expected_item
-@mock_dynamodb
+@mock_aws
def test_update_item_set():
conn = boto3.resource("dynamodb", region_name="us-east-1")
table = conn.create_table(
@@ -286,7 +286,7 @@ def test_update_item_set():
assert returned_item == {"username": "steve", "foo": "bar", "blah": "baz"}
-@mock_dynamodb
+@mock_aws
def test_create_table__using_resource():
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
@@ -311,7 +311,7 @@ def _create_user_table():
return dynamodb.Table("users")
-@mock_dynamodb
+@mock_aws
def test_conditions():
table = _create_user_table()
@@ -323,7 +323,7 @@ def test_conditions():
assert response["Items"] == [{"username": "johndoe"}]
-@mock_dynamodb
+@mock_aws
def test_put_item_conditions_pass():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "bar"})
@@ -335,7 +335,7 @@ def test_put_item_conditions_pass():
assert final_item["Item"]["foo"] == "baz"
-@mock_dynamodb
+@mock_aws
def test_put_item_conditions_pass_because_expect_not_exists_by_compare_to_null():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "bar"})
@@ -347,7 +347,7 @@ def test_put_item_conditions_pass_because_expect_not_exists_by_compare_to_null()
assert final_item["Item"]["foo"] == "baz"
-@mock_dynamodb
+@mock_aws
def test_put_item_conditions_pass_because_expect_exists_by_compare_to_not_null():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "bar"})
@@ -359,7 +359,7 @@ def test_put_item_conditions_pass_because_expect_exists_by_compare_to_not_null()
assert final_item["Item"]["foo"] == "baz"
-@mock_dynamodb
+@mock_aws
def test_put_item_conditions_fail():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "bar"})
@@ -374,7 +374,7 @@ def test_put_item_conditions_fail():
assert err["Code"] == "ConditionalCheckFailedException"
-@mock_dynamodb
+@mock_aws
def test_update_item_conditions_fail():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "baz"})
@@ -389,7 +389,7 @@ def test_update_item_conditions_fail():
assert err["Code"] == "ConditionalCheckFailedException"
-@mock_dynamodb
+@mock_aws
def test_update_item_conditions_fail_because_expect_not_exists():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "baz"})
@@ -404,7 +404,7 @@ def test_update_item_conditions_fail_because_expect_not_exists():
assert err["Code"] == "ConditionalCheckFailedException"
-@mock_dynamodb
+@mock_aws
def test_update_item_conditions_fail_because_expect_not_exists_by_compare_to_null():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "baz"})
@@ -419,7 +419,7 @@ def test_update_item_conditions_fail_because_expect_not_exists_by_compare_to_nul
assert err["Code"] == "ConditionalCheckFailedException"
-@mock_dynamodb
+@mock_aws
def test_update_item_conditions_pass():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "bar"})
@@ -433,7 +433,7 @@ def test_update_item_conditions_pass():
assert returned_item["Item"]["foo"] == "baz"
-@mock_dynamodb
+@mock_aws
def test_update_item_conditions_pass_because_expect_not_exists():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "bar"})
@@ -447,7 +447,7 @@ def test_update_item_conditions_pass_because_expect_not_exists():
assert returned_item["Item"]["foo"] == "baz"
-@mock_dynamodb
+@mock_aws
def test_update_item_conditions_pass_because_expect_not_exists_by_compare_to_null():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "bar"})
@@ -461,7 +461,7 @@ def test_update_item_conditions_pass_because_expect_not_exists_by_compare_to_nul
assert returned_item["Item"]["foo"] == "baz"
-@mock_dynamodb
+@mock_aws
def test_update_item_conditions_pass_because_expect_exists_by_compare_to_not_null():
table = _create_user_table()
table.put_item(Item={"username": "johndoe", "foo": "bar"})
@@ -475,7 +475,7 @@ def test_update_item_conditions_pass_because_expect_exists_by_compare_to_not_nul
assert returned_item["Item"]["foo"] == "baz"
-@mock_dynamodb
+@mock_aws
def test_update_settype_item_with_conditions():
class OrderedSet(set):
"""A set with predictable iteration order"""
@@ -512,7 +512,7 @@ def test_update_settype_item_with_conditions():
assert returned_item["Item"]["foo"] == set(["baz"])
-@mock_dynamodb
+@mock_aws
def test_scan_pagination():
table = _create_user_table()
@@ -538,7 +538,7 @@ def test_scan_pagination():
assert usernames == set(expected_usernames)
-@mock_dynamodb
+@mock_aws
def test_scan_by_index():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
diff --git a/tests/test_dynamodb/test_dynamodb_update_table.py b/tests/test_dynamodb/test_dynamodb_update_table.py
index 509bb0f5a..f73adcbda 100644
--- a/tests/test_dynamodb/test_dynamodb_update_table.py
+++ b/tests/test_dynamodb/test_dynamodb_update_table.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_dynamodb
+from moto import mock_aws
-@mock_dynamodb
+@mock_aws
def test_update_table__billing_mode():
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
@@ -33,7 +33,7 @@ def test_update_table__billing_mode():
}
-@mock_dynamodb
+@mock_aws
def test_update_table_throughput():
conn = boto3.resource("dynamodb", region_name="us-west-2")
table = conn.create_table(
@@ -53,7 +53,7 @@ def test_update_table_throughput():
assert table.provisioned_throughput["WriteCapacityUnits"] == 6
-@mock_dynamodb
+@mock_aws
def test_update_table__enable_stream():
conn = boto3.client("dynamodb", region_name="us-east-1")
diff --git a/tests/test_dynamodb/test_server.py b/tests/test_dynamodb/test_server.py
index b3ee10526..484f82d73 100644
--- a/tests/test_dynamodb/test_server.py
+++ b/tests/test_dynamodb/test_server.py
@@ -1,14 +1,10 @@
import json
import moto.server as server
-from moto import mock_dynamodb
-
-"""
-Test the different server responses
-"""
+from moto import mock_aws
-@mock_dynamodb
+@mock_aws
def test_table_list():
backend = server.create_backend_app("dynamodb")
test_client = backend.test_client()
diff --git a/tests/test_dynamodbstreams/test_dynamodbstreams.py b/tests/test_dynamodbstreams/test_dynamodbstreams.py
index a0d8959b4..5afb993c7 100644
--- a/tests/test_dynamodbstreams/test_dynamodbstreams.py
+++ b/tests/test_dynamodbstreams/test_dynamodbstreams.py
@@ -1,7 +1,7 @@
import boto3
import pytest
-from moto import mock_dynamodb, mock_dynamodbstreams
+from moto import mock_aws
class TestCore:
@@ -9,9 +9,8 @@ class TestCore:
mocks = []
def setup_method(self):
- self.mocks = [mock_dynamodb(), mock_dynamodbstreams()]
- for m in self.mocks:
- m.start()
+ self.mock = mock_aws()
+ self.mock.start()
# create a table with a stream
conn = boto3.client("dynamodb", region_name="us-east-1")
@@ -33,11 +32,10 @@ class TestCore:
conn.delete_table(TableName="test-streams")
self.stream_arn = None
- for m in self.mocks:
- try:
- m.stop()
- except RuntimeError:
- pass
+ try:
+ self.mock.stop()
+ except RuntimeError:
+ pass
def test_verify_stream(self):
conn = boto3.client("dynamodb", region_name="us-east-1")
@@ -195,16 +193,11 @@ class TestEdges:
mocks = []
def setup_method(self):
- self.mocks = [mock_dynamodb(), mock_dynamodbstreams()]
- for m in self.mocks:
- m.start()
+ self.mock = mock_aws()
+ self.mock.start()
def teardown_method(self):
- for m in self.mocks:
- try:
- m.stop()
- except RuntimeError:
- pass
+ self.mock.stop()
def test_enable_stream_on_table(self):
conn = boto3.client("dynamodb", region_name="us-east-1")
diff --git a/tests/test_ebs/test_ebs.py b/tests/test_ebs/test_ebs.py
index ee039a23c..47cc83c63 100644
--- a/tests/test_ebs/test_ebs.py
+++ b/tests/test_ebs/test_ebs.py
@@ -1,16 +1,15 @@
-"""Unit tests for ebs-supported APIs."""
import hashlib
import boto3
-from moto import mock_ebs, mock_ec2
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_ebs
+@mock_aws
def test_start_snapshot__minimal():
client = boto3.client("ebs", region_name="eu-west-1")
resp = client.start_snapshot(VolumeSize=720)
@@ -23,7 +22,7 @@ def test_start_snapshot__minimal():
assert resp["BlockSize"] == 512
-@mock_ebs
+@mock_aws
def test_start_snapshot():
client = boto3.client("ebs", region_name="eu-west-1")
resp = client.start_snapshot(
@@ -42,7 +41,7 @@ def test_start_snapshot():
assert resp["Description"] == "my fancy snapshot"
-@mock_ebs
+@mock_aws
def test_complete_snapshot():
client = boto3.client("ebs", region_name="ap-southeast-1")
snapshot_id = client.start_snapshot(VolumeSize=720)["SnapshotId"]
@@ -51,7 +50,7 @@ def test_complete_snapshot():
assert resp["Status"] == "completed"
-@mock_ebs
+@mock_aws
def test_put_snapshot_block():
data = b"data for this specific block\xbf"
checksum = hashlib.sha256(data).hexdigest()
@@ -70,7 +69,7 @@ def test_put_snapshot_block():
assert resp["ChecksumAlgorithm"] == "SHA256"
-@mock_ebs
+@mock_aws
def test_get_snapshot_block():
client = boto3.client("ebs", region_name="eu-west-1")
snapshot_id = client.start_snapshot(VolumeSize=720)["SnapshotId"]
@@ -96,7 +95,7 @@ def test_get_snapshot_block():
assert resp["ChecksumAlgorithm"] == "SHA256"
-@mock_ebs
+@mock_aws
def test_list_changed_blocks():
client = boto3.client("ebs", region_name="ap-southeast-1")
snapshot_id1 = client.start_snapshot(VolumeSize=415)["SnapshotId"]
@@ -135,7 +134,7 @@ def test_list_changed_blocks():
assert "SecondBlockToken" not in changed_blocks[1]
-@mock_ebs
+@mock_aws
def test_list_snapshot_blocks():
client = boto3.client("ebs", region_name="ap-southeast-1")
snapshot_id = client.start_snapshot(VolumeSize=415)["SnapshotId"]
@@ -159,8 +158,7 @@ def test_list_snapshot_blocks():
assert [b["BlockIndex"] for b in resp["Blocks"]] == [1, 2, 3]
-@mock_ebs
-@mock_ec2
+@mock_aws
def test_start_snapshot__should_be_created_in_ec2():
ebs = boto3.client("ebs", region_name="eu-north-1")
ec2 = boto3.client("ec2", region_name="eu-north-1")
diff --git a/tests/test_ec2/__init__.py b/tests/test_ec2/__init__.py
index e3a730d82..be81cec8e 100644
--- a/tests/test_ec2/__init__.py
+++ b/tests/test_ec2/__init__.py
@@ -1,7 +1,7 @@
import os
from functools import wraps
-from moto import mock_ec2, mock_ssm
+from moto import mock_aws
def ec2_aws_verified(func):
@@ -10,7 +10,7 @@ def ec2_aws_verified(func):
Can be run against AWS at any time by setting:
MOTO_TEST_ALLOW_AWS_REQUEST=true
- If this environment variable is not set, the function runs in a `mock_s3` context.
+ If this environment variable is not set, the function runs in a `mock_aws` context.
This decorator will:
- Create a bucket
@@ -27,7 +27,7 @@ def ec2_aws_verified(func):
if allow_aws:
resp = func()
else:
- with mock_ec2(), mock_ssm():
+ with mock_aws():
resp = func()
return resp
diff --git a/tests/test_ec2/test_account_attributes.py b/tests/test_ec2/test_account_attributes.py
index f89b4f3d3..aafcc4a4c 100644
--- a/tests/test_ec2/test_account_attributes.py
+++ b/tests/test_ec2/test_account_attributes.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_ec2
+from moto import mock_aws
-@mock_ec2
+@mock_aws
def test_describe_account_attributes():
conn = boto3.client("ec2", region_name="us-east-1")
response = conn.describe_account_attributes()
diff --git a/tests/test_ec2/test_amis.py b/tests/test_ec2/test_amis.py
index 018247e56..e8bff43a0 100644
--- a/tests/test_ec2/test_amis.py
+++ b/tests/test_ec2/test_amis.py
@@ -7,7 +7,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.ec2.models.amis import AMIS
from tests import EXAMPLE_AMI_ID, EXAMPLE_AMI_PARAVIRTUAL
@@ -16,7 +16,7 @@ from tests import EXAMPLE_AMI_ID, EXAMPLE_AMI_PARAVIRTUAL
# The default AMIs are not loaded for our test case, to speed things up
# But we do need it for this specific test (and others in this file..)
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_snapshots_for_initial_amis():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -37,7 +37,7 @@ def test_snapshots_for_initial_amis():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_ami_create_and_delete():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -130,7 +130,7 @@ def test_ami_create_and_delete():
assert ex.value.response["ResponseMetadata"]["RequestId"] is not None
-@mock_ec2
+@mock_aws
def test_deregister_image__unknown():
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -142,7 +142,7 @@ def test_deregister_image__unknown():
assert ex.value.response["ResponseMetadata"]["RequestId"] is not None
-@mock_ec2
+@mock_aws
def test_deregister_image__and_describe():
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -161,7 +161,7 @@ def test_deregister_image__and_describe():
assert len(ec2.describe_images(ImageIds=[image_id])["Images"]) == 0
-@mock_ec2
+@mock_aws
def test_ami_copy_dryrun():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -193,7 +193,7 @@ def test_ami_copy_dryrun():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_ami_copy():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -240,7 +240,7 @@ def test_ami_copy():
assert copied_image_snapshot_id != source_image_snapshot_id
-@mock_ec2
+@mock_aws
def test_ami_copy_nonexistent_source_id():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -257,7 +257,7 @@ def test_ami_copy_nonexistent_source_id():
assert ex.value.response["Error"]["Code"] == "InvalidAMIID.NotFound"
-@mock_ec2
+@mock_aws
def test_ami_copy_nonexisting_source_region():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -285,7 +285,7 @@ def test_ami_copy_nonexisting_source_region():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_copy_image_changes_owner_id():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -316,7 +316,7 @@ def test_copy_image_changes_owner_id():
assert describe_resp[0]["ImageId"] == copy_resp["ImageId"]
-@mock_ec2
+@mock_aws
def test_ami_tagging():
ec2 = boto3.client("ec2", region_name="us-east-1")
res = boto3.resource("ec2", region_name="us-east-1")
@@ -346,7 +346,7 @@ def test_ami_tagging():
assert image["Tags"] == [{"Value": "some value", "Key": "a key"}]
-@mock_ec2
+@mock_aws
def test_ami_create_from_missing_instance():
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -359,7 +359,7 @@ def test_ami_create_from_missing_instance():
assert ex.value.response["Error"]["Code"] == "InvalidInstanceID.NotFound"
-@mock_ec2
+@mock_aws
def test_ami_pulls_attributes_from_instance():
ec2 = boto3.client("ec2", region_name="us-east-1")
reservation = ec2.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -375,7 +375,7 @@ def test_ami_pulls_attributes_from_instance():
assert image.kernel_id == "test-kernel"
-@mock_ec2
+@mock_aws
def test_ami_uses_account_id_if_valid_access_key_is_supplied():
# The boto-equivalent required an access_key to be passed in, but Moto will always mock this in boto3
# So the only thing we're testing here, really.. is whether OwnerId is equal to ACCOUNT_ID?
@@ -394,7 +394,7 @@ def test_ami_uses_account_id_if_valid_access_key_is_supplied():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_ami_filters():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -482,7 +482,7 @@ def test_ami_filters():
assert len(amis_by_nonpublic) >= 2, "Should have at least 2 non-public images"
-@mock_ec2
+@mock_aws
def test_ami_filtering_via_tag():
tag_value = f"value {str(uuid4())}"
other_value = f"value {str(uuid4())}"
@@ -515,7 +515,7 @@ def test_ami_filtering_via_tag():
assert [ami["ImageId"] for ami in amis_by_tagB] == [imageB_id]
-@mock_ec2
+@mock_aws
def test_getting_missing_ami():
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -526,7 +526,7 @@ def test_getting_missing_ami():
assert ex.value.response["Error"]["Code"] == "InvalidAMIID.NotFound"
-@mock_ec2
+@mock_aws
def test_getting_malformed_ami():
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -537,7 +537,7 @@ def test_getting_malformed_ami():
assert ex.value.response["Error"]["Code"] == "InvalidAMIID.Malformed"
-@mock_ec2
+@mock_aws
def test_ami_attribute_group_permissions():
ec2 = boto3.client("ec2", region_name="us-east-1")
reservation = ec2.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -604,7 +604,7 @@ def test_ami_attribute_group_permissions():
image.modify_attribute(**REMOVE_GROUP_ARGS)
-@mock_ec2
+@mock_aws
def test_ami_attribute_user_permissions():
ec2 = boto3.client("ec2", region_name="us-east-1")
reservation = ec2.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -684,7 +684,7 @@ def test_ami_attribute_user_permissions():
image.modify_attribute(**REMOVE_USERS_ARGS)
-@mock_ec2
+@mock_aws
def test_ami_describe_executable_users():
conn = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", "us-east-1")
@@ -717,7 +717,7 @@ def test_ami_describe_executable_users():
assert images[0]["ImageId"] == image_id
-@mock_ec2
+@mock_aws
def test_ami_describe_executable_users_negative():
conn = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", "us-east-1")
@@ -751,7 +751,7 @@ def test_ami_describe_executable_users_negative():
assert len(images) == 0
-@mock_ec2
+@mock_aws
def test_ami_describe_executable_users_and_filter():
conn = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", "us-east-1")
@@ -788,7 +788,7 @@ def test_ami_describe_executable_users_and_filter():
assert images[0]["ImageId"] == image_id
-@mock_ec2
+@mock_aws
def test_ami_attribute_user_and_group_permissions():
"""
Boto supports adding/removing both users and groups at the same time.
@@ -854,7 +854,7 @@ def test_ami_attribute_user_and_group_permissions():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_filter_description():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -881,7 +881,7 @@ def test_filter_description():
assert len(resp) == 1
-@mock_ec2
+@mock_aws
def test_ami_attribute_error_cases():
ec2 = boto3.client("ec2", region_name="us-east-1")
reservation = ec2.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -983,7 +983,7 @@ def test_ami_attribute_error_cases():
assert ex.value.response["Error"]["Code"] == "InvalidAMIID.NotFound"
-@mock_ec2
+@mock_aws
def test_ami_describe_non_existent():
ec2 = boto3.resource("ec2", region_name="us-west-1")
# Valid pattern but non-existent id
@@ -996,7 +996,7 @@ def test_ami_describe_non_existent():
img.load()
-@mock_ec2
+@mock_aws
def test_ami_registration():
ec2 = boto3.client("ec2", region_name="us-east-1")
image_id = ec2.register_image(Name="test-register-image").get("ImageId", "")
@@ -1006,7 +1006,7 @@ def test_ami_registration():
assert images[0]["State"] == "available", "State should be available."
-@mock_ec2
+@mock_aws
def test_ami_filter_wildcard():
ec2_resource = boto3.resource("ec2", region_name="us-west-1")
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -1029,7 +1029,7 @@ def test_ami_filter_wildcard():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_ami_filter_by_owner_id():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -1049,7 +1049,7 @@ def test_ami_filter_by_owner_id():
assert len(ubuntu_ids) < len(all_ids)
-@mock_ec2
+@mock_aws
def test_ami_filter_by_self():
ec2_resource = boto3.resource("ec2", region_name="us-west-1")
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -1071,7 +1071,7 @@ def test_ami_filter_by_self():
assert unique_name in image_names
-@mock_ec2
+@mock_aws
def test_ami_snapshots_have_correct_owner():
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -1100,7 +1100,7 @@ def test_ami_snapshots_have_correct_owner():
assert owner_id == snapshot["OwnerId"]
-@mock_ec2
+@mock_aws
def test_create_image_with_tag_specification():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -1146,7 +1146,7 @@ def test_create_image_with_tag_specification():
)
-@mock_ec2
+@mock_aws
def test_ami_filter_by_empty_tag():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -1190,7 +1190,7 @@ def test_ami_filter_by_empty_tag():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_ami_filter_by_ownerid():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -1205,7 +1205,7 @@ def test_ami_filter_by_ownerid():
assert len(images) > 0, "We should have at least 1 image created by amazon"
-@mock_ec2
+@mock_aws
def test_ami_filter_by_unknown_ownerid():
ec2_connection = boto3.client("ec2", region_name="us-east-1")
@@ -1215,7 +1215,7 @@ def test_ami_filter_by_unknown_ownerid():
assert len(images) == 0
-@mock_ec2
+@mock_aws
def test_describe_images_dryrun():
client = boto3.client("ec2", region_name="us-east-1")
@@ -1229,7 +1229,7 @@ def test_describe_images_dryrun():
)
-@mock_ec2
+@mock_aws
def test_delete_snapshot_from_create_image():
ec2_client = boto3.client("ec2", region_name="us-east-1")
resp = ec2_client.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -1266,7 +1266,7 @@ def test_delete_snapshot_from_create_image():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_ami_describe_image_attribute_product_codes():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -1294,7 +1294,7 @@ def test_ami_describe_image_attribute_product_codes():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_ami_describe_image_attribute():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -1328,7 +1328,7 @@ def test_ami_describe_image_attribute():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_ami_describe_image_attribute_block_device_fail():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -1352,7 +1352,7 @@ def test_ami_describe_image_attribute_block_device_fail():
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_ami_describe_image_attribute_invalid_param():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
diff --git a/tests/test_ec2/test_availability_zones_and_regions.py b/tests/test_ec2/test_availability_zones_and_regions.py
index a0886b75f..16874457a 100644
--- a/tests/test_ec2/test_availability_zones_and_regions.py
+++ b/tests/test_ec2/test_availability_zones_and_regions.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
-@mock_ec2
+@mock_aws
def test_boto3_describe_regions():
ec2 = boto3.client("ec2", "us-east-1")
resp = ec2.describe_regions()
@@ -26,7 +26,7 @@ def test_boto3_describe_regions():
assert resp["Regions"][0]["OptInStatus"] == "not-opted-in"
-@mock_ec2
+@mock_aws
def test_boto3_availability_zones():
ec2 = boto3.client("ec2", "us-east-1")
resp = ec2.describe_regions()
@@ -38,7 +38,7 @@ def test_boto3_availability_zones():
assert region in rec["ZoneName"]
-@mock_ec2
+@mock_aws
def test_availability_zones__parameters():
us_east = boto3.client("ec2", "us-east-1")
zones = us_east.describe_availability_zones(ZoneNames=["us-east-1b"])[
@@ -77,7 +77,7 @@ def test_availability_zones__parameters():
assert zones[0]["ZoneId"] == "use1-az1"
-@mock_ec2
+@mock_aws
def test_describe_availability_zones_dryrun():
client = boto3.client("ec2", region_name="us-east-1")
@@ -91,7 +91,7 @@ def test_describe_availability_zones_dryrun():
)
-@mock_ec2
+@mock_aws
def test_boto3_zoneId_in_availability_zones():
conn = boto3.client("ec2", "us-east-1")
resp = conn.describe_availability_zones()
diff --git a/tests/test_ec2/test_carrier_gateways.py b/tests/test_ec2/test_carrier_gateways.py
index 4dbcda440..cff018c2a 100644
--- a/tests/test_ec2/test_carrier_gateways.py
+++ b/tests/test_ec2/test_carrier_gateways.py
@@ -4,11 +4,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_ec2
+@mock_aws
def test_describe_carrier_gateways_none():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode is not guaranteed to be empty")
@@ -16,7 +16,7 @@ def test_describe_carrier_gateways_none():
assert ec2.describe_carrier_gateways()["CarrierGateways"] == []
-@mock_ec2
+@mock_aws
def test_describe_carrier_gateways_multiple():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -43,7 +43,7 @@ def test_describe_carrier_gateways_multiple():
assert find_one[0]["CarrierGatewayId"] == cg2["CarrierGatewayId"]
-@mock_ec2
+@mock_aws
def test_create_carrier_gateways_without_tags():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -57,7 +57,7 @@ def test_create_carrier_gateways_without_tags():
assert cg["Tags"] == []
-@mock_ec2
+@mock_aws
def test_create_carrier_gateways_with_tags():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -76,7 +76,7 @@ def test_create_carrier_gateways_with_tags():
assert cg["Tags"] == [{"Key": "tk", "Value": "tv"}]
-@mock_ec2
+@mock_aws
def test_create_carrier_gateways_invalid_vpc():
ec2 = boto3.client("ec2", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -86,7 +86,7 @@ def test_create_carrier_gateways_invalid_vpc():
assert err["Message"] == "VpcID vpc-asdf does not exist."
-@mock_ec2
+@mock_aws
def test_delete_carrier_gateways():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
diff --git a/tests/test_ec2/test_customer_gateways.py b/tests/test_ec2/test_customer_gateways.py
index 769b1821d..20274e248 100644
--- a/tests/test_ec2/test_customer_gateways.py
+++ b/tests/test_ec2/test_customer_gateways.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
-@mock_ec2
+@mock_aws
def test_create_customer_gateways():
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -16,7 +16,7 @@ def test_create_customer_gateways():
assert customer_gateway["IpAddress"] == "205.251.242.54"
-@mock_ec2
+@mock_aws
def test_create_customer_gateways_using_publicip_argument():
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -31,7 +31,7 @@ def test_create_customer_gateways_using_publicip_argument():
assert customer_gateway["IpAddress"] == "205.251.242.53"
-@mock_ec2
+@mock_aws
def test_describe_customer_gateways_dryrun():
client = boto3.client("ec2", region_name="us-east-1")
@@ -45,7 +45,7 @@ def test_describe_customer_gateways_dryrun():
)
-@mock_ec2
+@mock_aws
def test_describe_customer_gateways():
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -71,7 +71,7 @@ def test_describe_customer_gateways():
), "Should have at least the one CustomerGateway we just created"
-@mock_ec2
+@mock_aws
def test_delete_customer_gateways():
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -93,7 +93,7 @@ def test_delete_customer_gateways():
assert cgws[0]["State"] == "deleted"
-@mock_ec2
+@mock_aws
def test_delete_customer_gateways_bad_id():
ec2 = boto3.client("ec2", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
diff --git a/tests/test_ec2/test_dhcp_options.py b/tests/test_ec2/test_dhcp_options.py
index 45e6cf0c9..9128b084f 100644
--- a/tests/test_ec2/test_dhcp_options.py
+++ b/tests/test_ec2/test_dhcp_options.py
@@ -6,13 +6,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
SAMPLE_DOMAIN_NAME = "example.com"
SAMPLE_NAME_SERVERS = ["10.0.0.6", "10.0.0.7"]
-@mock_ec2
+@mock_aws
def test_dhcp_options_associate():
"""associate dhcp option"""
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -32,7 +32,7 @@ def test_dhcp_options_associate():
assert vpc.dhcp_options_id == dhcp_options.id
-@mock_ec2
+@mock_aws
def test_dhcp_options_associate_invalid_dhcp_id():
"""associate dhcp option bad dhcp options id"""
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -46,7 +46,7 @@ def test_dhcp_options_associate_invalid_dhcp_id():
assert ex.value.response["Error"]["Code"] == "InvalidDhcpOptionID.NotFound"
-@mock_ec2
+@mock_aws
def test_dhcp_options_associate_invalid_vpc_id():
"""associate dhcp option invalid vpc id"""
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -65,7 +65,7 @@ def test_dhcp_options_associate_invalid_vpc_id():
assert ex.value.response["Error"]["Code"] == "InvalidVpcID.NotFound"
-@mock_ec2
+@mock_aws
def test_dhcp_options_disassociation():
"""Ensure that VPCs can be set to the 'default' DHCP options set for disassociation."""
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -93,7 +93,7 @@ def test_dhcp_options_disassociation():
assert vpc.dhcp_options_id == "default"
-@mock_ec2
+@mock_aws
def test_dhcp_options_delete_with_vpc():
"""Test deletion of dhcp options with vpc"""
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -123,7 +123,7 @@ def test_dhcp_options_delete_with_vpc():
assert ex.value.response["Error"]["Code"] == "InvalidDhcpOptionID.NotFound"
-@mock_ec2
+@mock_aws
def test_create_dhcp_options():
"""Create most basic dhcp option"""
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -144,7 +144,7 @@ def test_create_dhcp_options():
assert {"Key": "domain-name", "Values": [{"Value": SAMPLE_DOMAIN_NAME}]} in config
-@mock_ec2
+@mock_aws
def test_create_dhcp_options_invalid_options():
"""Create invalid dhcp options"""
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -167,7 +167,7 @@ def test_create_dhcp_options_invalid_options():
assert ex.value.response["Error"]["Code"] == "InvalidParameterValue"
-@mock_ec2
+@mock_aws
def test_describe_dhcp_options():
"""Test dhcp options lookup by id"""
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -199,7 +199,7 @@ def test_describe_dhcp_options():
assert {"Key": "domain-name", "Values": [{"Value": SAMPLE_DOMAIN_NAME}]} in config
-@mock_ec2
+@mock_aws
def test_describe_dhcp_options_invalid_id():
"""get error on invalid dhcp_option_id lookup"""
client = boto3.client("ec2", region_name="us-west-1")
@@ -211,7 +211,7 @@ def test_describe_dhcp_options_invalid_id():
assert ex.value.response["Error"]["Code"] == "InvalidDhcpOptionID.NotFound"
-@mock_ec2
+@mock_aws
def test_delete_dhcp_options():
"""delete dhcp option"""
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -233,7 +233,7 @@ def test_delete_dhcp_options():
assert ex.value.response["Error"]["Code"] == "InvalidDhcpOptionID.NotFound"
-@mock_ec2
+@mock_aws
def test_delete_dhcp_options_invalid_id():
client = boto3.client("ec2", region_name="us-west-1")
@@ -244,7 +244,7 @@ def test_delete_dhcp_options_invalid_id():
assert ex.value.response["Error"]["Code"] == "InvalidDhcpOptionID.NotFound"
-@mock_ec2
+@mock_aws
def test_delete_dhcp_options_malformed_id():
client = boto3.client("ec2", region_name="us-west-1")
@@ -255,7 +255,7 @@ def test_delete_dhcp_options_malformed_id():
assert ex.value.response["Error"]["Code"] == "InvalidDhcpOptionsId.Malformed"
-@mock_ec2
+@mock_aws
def test_dhcp_tagging():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -285,7 +285,7 @@ def test_dhcp_tagging():
assert dhcp_option["Tags"] == [{"Key": "a tag", "Value": tag_value}]
-@mock_ec2
+@mock_aws
def test_dhcp_options_get_by_tag():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -361,7 +361,7 @@ def test_dhcp_options_get_by_tag():
assert len(dhcp_options_sets) == 2
-@mock_ec2
+@mock_aws
def test_dhcp_options_get_by_id():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -404,7 +404,7 @@ def test_dhcp_options_get_by_id():
assert d[0]["DhcpOptionsId"] == dhcp2.id
-@mock_ec2
+@mock_aws
def test_dhcp_options_get_by_value_filter():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -438,7 +438,7 @@ def test_dhcp_options_get_by_value_filter():
assert len(dhcp_options_sets) == 1
-@mock_ec2
+@mock_aws
def test_dhcp_options_get_by_key_filter():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -474,7 +474,7 @@ def test_dhcp_options_get_by_key_filter():
assert {"Value": "example.com"} in servers
-@mock_ec2
+@mock_aws
def test_dhcp_options_get_by_invalid_filter():
if settings.TEST_SERVER_MODE:
raise SkipTest("Will throw a generic 500 in ServerMode")
diff --git a/tests/test_ec2/test_ec2_cloudformation.py b/tests/test_ec2/test_ec2_cloudformation.py
index f2872a722..215872fa9 100644
--- a/tests/test_ec2/test_ec2_cloudformation.py
+++ b/tests/test_ec2/test_ec2_cloudformation.py
@@ -5,7 +5,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudformation, mock_ec2
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
from tests.test_cloudformation.fixtures import (
ec2_classic_eip,
@@ -36,8 +36,7 @@ template_subnet = {
}
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_vpc_single_instance_in_subnet():
template_json = json.dumps(vpc_single_instance_in_subnet.template)
cf = boto3.client("cloudformation", region_name="us-west-1")
@@ -96,8 +95,7 @@ def test_vpc_single_instance_in_subnet():
assert eip["InstanceId"] == instance["InstanceId"]
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_delete_stack_with_vpc():
cf = boto3.client("cloudformation", region_name="us-east-1")
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -114,8 +112,7 @@ def test_delete_stack_with_vpc():
ec2.describe_vpcs(VpcIds=[vpc_id])
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_delete_stack_with_subnet():
cf = boto3.client("cloudformation", region_name="us-east-1")
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -137,8 +134,7 @@ def test_delete_stack_with_subnet():
ec2.describe_subnets(SubnetIds=subnet_ids)
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_elastic_network_interfaces_cloudformation_boto3():
template = vpc_eni.template
template_json = json.dumps(template)
@@ -165,8 +161,7 @@ def test_elastic_network_interfaces_cloudformation_boto3():
assert received_ip in all_ips
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_volume_size_through_cloudformation():
ec2 = boto3.client("ec2", region_name="us-east-1")
cf = boto3.client("cloudformation", region_name="us-east-1")
@@ -214,8 +209,7 @@ def test_volume_size_through_cloudformation():
assert volumes["Volumes"][0]["Size"] == 50
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_attach_internet_gateway():
ec2 = boto3.client("ec2", region_name="us-east-1")
cf = boto3.client("cloudformation", region_name="us-east-1")
@@ -261,8 +255,7 @@ def test_attach_internet_gateway():
} in gateway["Tags"]
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_attach_vpn_gateway():
ec2 = boto3.client("ec2", region_name="us-east-1")
cf = boto3.client("cloudformation", region_name="us-east-1")
@@ -307,8 +300,7 @@ def get_resource_id(resource_type, stack_resources):
return r["PhysicalResourceId"]
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_subnet_tags_through_cloudformation_boto3():
ec2 = boto3.client("ec2", region_name="us-west-1")
ec2_res = boto3.resource("ec2", region_name="us-west-1")
@@ -344,8 +336,7 @@ def test_subnet_tags_through_cloudformation_boto3():
assert {"Key": "blah", "Value": "baz"} in subnet["Tags"]
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_single_instance_with_ebs_volume():
template_json = json.dumps(single_instance_with_ebs_volume.template)
cf = boto3.client("cloudformation", region_name="us-west-1")
@@ -381,8 +372,7 @@ def test_single_instance_with_ebs_volume():
assert volume["Attachments"][0]["InstanceId"] == ec2_instance["InstanceId"]
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_classic_eip():
template_json = json.dumps(ec2_classic_eip.template)
cf = boto3.client("cloudformation", region_name="us-west-1")
@@ -400,8 +390,7 @@ def test_classic_eip():
assert cfn_eip["PhysicalResourceId"] in all_ips
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_vpc_eip():
template_json = json.dumps(vpc_eip.template)
cf = boto3.client("cloudformation", region_name="us-west-1")
@@ -420,8 +409,7 @@ def test_vpc_eip():
assert cfn_eip["PhysicalResourceId"] in all_ips
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_vpc_gateway_attachment_creation_should_attach_itself_to_vpc():
template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -464,8 +452,7 @@ def test_vpc_gateway_attachment_creation_should_attach_itself_to_vpc():
assert len(igws) == 1
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_vpc_peering_creation():
ec2 = boto3.resource("ec2", region_name="us-west-1")
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -494,8 +481,7 @@ def test_vpc_peering_creation():
assert len(peering_connections) == 1
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_multiple_security_group_ingress_separate_from_security_group_by_id():
sg1 = str(uuid4())[0:6]
sg2 = str(uuid4())[0:6]
@@ -548,8 +534,7 @@ def test_multiple_security_group_ingress_separate_from_security_group_by_id():
assert security_group1["IpPermissions"][0]["ToPort"] == 8080
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_security_group_ingress_separate_from_security_group_by_id():
ec2 = boto3.client("ec2", region_name="us-west-1")
sg_name = str(uuid4())
@@ -598,8 +583,7 @@ def test_security_group_ingress_separate_from_security_group_by_id():
assert security_group1["IpPermissions"][0]["ToPort"] == 8080
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_security_group_ingress_separate_from_security_group_by_id_using_vpc():
ec2 = boto3.resource("ec2", region_name="us-west-1")
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -655,8 +639,7 @@ def test_security_group_ingress_separate_from_security_group_by_id_using_vpc():
assert security_group1["IpPermissions"][0]["ToPort"] == 8080
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_security_group_with_update():
ec2 = boto3.resource("ec2", region_name="us-west-1")
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -692,8 +675,7 @@ def test_security_group_with_update():
assert security_group["VpcId"] == vpc2.id
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_subnets_should_be_created_with_availability_zone():
ec2 = boto3.resource("ec2", region_name="us-west-1")
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -729,8 +711,7 @@ def get_secgroup_by_tag(ec2, sg_):
)["SecurityGroups"][0]
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_vpc_endpoint_creation():
ec2 = boto3.resource("ec2", region_name="us-west-1")
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -795,8 +776,7 @@ def test_vpc_endpoint_creation():
assert endpoint["VpcEndpointType"] == "GatewayLoadBalancer"
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_launch_template_create():
cf = boto3.client("cloudformation", region_name="us-west-1")
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -878,8 +858,7 @@ def test_launch_template_create():
)
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_launch_template_update():
cf = boto3.client("cloudformation", region_name="us-west-1")
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -935,8 +914,7 @@ def test_launch_template_update():
assert launch_template_versions[1]["VersionDescription"] == "a better template"
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_launch_template_delete():
cf = boto3.client("cloudformation", region_name="us-west-1")
ec2 = boto3.client("ec2", region_name="us-west-1")
diff --git a/tests/test_ec2/test_ec2_integration.py b/tests/test_ec2/test_ec2_integration.py
index f0b181860..56e543e59 100644
--- a/tests/test_ec2/test_ec2_integration.py
+++ b/tests/test_ec2/test_ec2_integration.py
@@ -1,11 +1,10 @@
import boto3
-from moto import mock_ec2, mock_kms
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
-@mock_ec2
-@mock_kms
+@mock_aws
def test_run_instance_with_encrypted_ebs():
kms = boto3.client("kms", region_name="us-east-1")
resp = kms.create_key(Description="my key", KeyUsage="ENCRYPT_DECRYPT")
diff --git a/tests/test_ec2/test_egress_only_igw.py b/tests/test_ec2/test_egress_only_igw.py
index 70fc8ee46..d6312b3e8 100644
--- a/tests/test_ec2/test_egress_only_igw.py
+++ b/tests/test_ec2/test_egress_only_igw.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
-@mock_ec2
+@mock_aws
def test_create():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -20,7 +20,7 @@ def test_create():
assert gateway["Attachments"][0] == {"State": "attached", "VpcId": vpc.id}
-@mock_ec2
+@mock_aws
def test_create_with_unknown_vpc():
client = boto3.client("ec2", region_name="us-west-1")
@@ -31,7 +31,7 @@ def test_create_with_unknown_vpc():
assert err["Message"] == "VpcID vpc-says-what does not exist."
-@mock_ec2
+@mock_aws
def test_describe_all():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -52,7 +52,7 @@ def test_describe_all():
assert gw2 in gateways
-@mock_ec2
+@mock_aws
def test_describe_one():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -78,7 +78,7 @@ def test_describe_one():
assert gw3 in gateways
-@mock_ec2
+@mock_aws
def test_create_and_delete():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
diff --git a/tests/test_ec2/test_elastic_block_store.py b/tests/test_ec2/test_elastic_block_store.py
index 3a103fd13..2f9b6ae95 100644
--- a/tests/test_ec2/test_elastic_block_store.py
+++ b/tests/test_ec2/test_elastic_block_store.py
@@ -6,14 +6,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as OWNER_ID
from moto.ec2.models.elastic_block_store import IOPS_REQUIRED_VOLUME_TYPES
-from moto.kms import mock_kms
from tests import EXAMPLE_AMI_ID
-@mock_ec2
+@mock_aws
def test_create_and_delete_volume():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -50,7 +49,7 @@ def test_create_and_delete_volume():
assert ex.value.response["Error"]["Code"] == "InvalidVolume.NotFound"
-@mock_ec2
+@mock_aws
def test_modify_volumes():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -87,7 +86,7 @@ def test_modify_volumes():
assert len(modifications["VolumesModifications"]) == 2
-@mock_ec2
+@mock_aws
def test_delete_attached_volume():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -126,7 +125,7 @@ def test_delete_attached_volume():
assert volume.id not in [v["VolumeId"] for v in all_volumes]
-@mock_ec2
+@mock_aws
def test_create_encrypted_volume_dryrun():
ec2 = boto3.resource("ec2", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -139,7 +138,7 @@ def test_create_encrypted_volume_dryrun():
)
-@mock_ec2
+@mock_aws
def test_create_encrypted_volume():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -149,7 +148,7 @@ def test_create_encrypted_volume():
assert all_volumes[0]["Encrypted"] is True
-@mock_ec2
+@mock_aws
def test_filter_volume_by_id():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -171,7 +170,7 @@ def test_filter_volume_by_id():
assert ex.value.response["Error"]["Code"] == "InvalidVolume.NotFound"
-@mock_ec2
+@mock_aws
def test_volume_filters():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -294,7 +293,7 @@ def test_volume_filters():
assert volume4.id in [vol["VolumeId"] for vol in volumes_by_attach_device]
-@mock_ec2
+@mock_aws
def test_volume_attach_and_detach():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -362,7 +361,7 @@ def test_volume_attach_and_detach():
assert ex3.value.response["Error"]["Code"] == "InvalidInstanceID.NotFound"
-@mock_ec2
+@mock_aws
def test_create_snapshot():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -407,7 +406,7 @@ def test_create_snapshot():
assert ex.value.response["Error"]["Code"] == "InvalidSnapshot.NotFound"
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("encrypted", [True, False])
def test_create_encrypted_snapshot(encrypted):
client = boto3.client("ec2", region_name="us-east-1")
@@ -431,7 +430,7 @@ def test_create_encrypted_snapshot(encrypted):
assert snapshots[0]["Encrypted"] == encrypted
-@mock_ec2
+@mock_aws
def test_filter_snapshot_by_id():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -459,7 +458,7 @@ def test_filter_snapshot_by_id():
assert ex.value.response["Error"]["Code"] == "InvalidSnapshot.NotFound"
-@mock_ec2
+@mock_aws
def test_snapshot_filters():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -529,7 +528,7 @@ def test_snapshot_filters():
assert snapshot3.id in [s["SnapshotId"] for s in snapshots]
-@mock_ec2
+@mock_aws
def test_modify_snapshot_attribute():
ec2_client = boto3.client("ec2", region_name="us-east-1")
response = ec2_client.create_volume(Size=80, AvailabilityZone="us-east-1a")
@@ -694,7 +693,7 @@ def test_modify_snapshot_attribute():
assert len(attributes["CreateVolumePermissions"]) == 0
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("encrypted", [True, False])
def test_create_volume_from_snapshot(encrypted):
client = boto3.client("ec2", region_name="us-east-1")
@@ -714,7 +713,7 @@ def test_create_volume_from_snapshot(encrypted):
assert new_volume["Encrypted"] == encrypted
-@mock_ec2
+@mock_aws
def test_modify_attribute_blockDeviceMapping():
"""
Reproduces the missing feature explained at [0], where we want to mock a
@@ -754,7 +753,7 @@ def test_modify_attribute_blockDeviceMapping():
assert mapping["Ebs"]["DeleteOnTermination"] is True
-@mock_ec2
+@mock_aws
def test_volume_tag_escaping():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -778,7 +777,7 @@ def test_volume_tag_escaping():
assert snapshot.tags == [{"Key": "key", "Value": ""}]
-@mock_ec2
+@mock_aws
def test_volume_property_hidden_when_no_tags_exist():
ec2_client = boto3.client("ec2", region_name="us-east-1")
@@ -787,7 +786,7 @@ def test_volume_property_hidden_when_no_tags_exist():
assert volume_response.get("Tags") is None
-@mock_ec2
+@mock_aws
def test_copy_snapshot():
ec2_client = boto3.client("ec2", region_name="eu-west-1")
dest_ec2_client = boto3.client("ec2", region_name="eu-west-2")
@@ -854,7 +853,7 @@ def test_copy_snapshot():
assert cm.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_ec2
+@mock_aws
def test_search_for_many_snapshots():
ec2_client = boto3.client("ec2", region_name="eu-west-1")
@@ -872,7 +871,7 @@ def test_search_for_many_snapshots():
assert len(snapshots_response["Snapshots"]) == len(snapshot_ids)
-@mock_ec2
+@mock_aws
def test_create_unencrypted_volume_with_kms_key_fails():
resource = boto3.resource("ec2", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -883,8 +882,7 @@ def test_create_unencrypted_volume_with_kms_key_fails():
assert "KmsKeyId" in ex.value.response["Error"]["Message"]
-@mock_kms
-@mock_ec2
+@mock_aws
def test_create_encrypted_volume_without_kms_key_should_use_default_key():
kms = boto3.client("kms", region_name="us-east-1")
@@ -904,7 +902,7 @@ def test_create_encrypted_volume_without_kms_key_should_use_default_key():
assert volume.encrypted is True
-@mock_ec2
+@mock_aws
def test_create_volume_with_kms_key():
resource = boto3.resource("ec2", region_name="us-east-1")
volume = resource.create_volume(
@@ -914,7 +912,7 @@ def test_create_volume_with_kms_key():
assert volume.encrypted is True
-@mock_ec2
+@mock_aws
def test_kms_key_id_property_hidden_when_volume_not_encrypted():
client = boto3.client("ec2", region_name="us-east-1")
resp = client.create_volume(AvailabilityZone="us-east-1a", Encrypted=False, Size=10)
@@ -931,7 +929,7 @@ def test_kms_key_id_property_hidden_when_volume_not_encrypted():
assert volume.kms_key_id is None
-@mock_ec2
+@mock_aws
def test_create_volume_with_standard_type():
ec2 = boto3.client("ec2", region_name="us-east-1")
volume = ec2.create_volume(AvailabilityZone="us-east-1a", Size=100)
@@ -942,7 +940,7 @@ def test_create_volume_with_standard_type():
@pytest.mark.parametrize("volume_type", ["gp2", "gp3", "io1", "io2", "standard"])
-@mock_ec2
+@mock_aws
def test_create_volume_with_non_standard_type(volume_type):
ec2 = boto3.client("ec2", region_name="us-east-1")
if volume_type in IOPS_REQUIRED_VOLUME_TYPES:
@@ -959,7 +957,7 @@ def test_create_volume_with_non_standard_type(volume_type):
assert volume["VolumeType"] == volume_type
-@mock_ec2
+@mock_aws
def test_create_snapshots_dryrun():
client = boto3.client("ec2", region_name="us-east-1")
@@ -975,7 +973,7 @@ def test_create_snapshots_dryrun():
)
-@mock_ec2
+@mock_aws
def test_create_snapshots_with_tagspecification():
client = boto3.client("ec2", region_name="us-east-1")
@@ -1005,7 +1003,7 @@ def test_create_snapshots_with_tagspecification():
]
-@mock_ec2
+@mock_aws
def test_create_snapshots_single_volume():
client = boto3.client("ec2", region_name="us-east-1")
@@ -1030,7 +1028,7 @@ def test_create_snapshots_single_volume():
assert snapshots[0]["Tags"] == []
-@mock_ec2
+@mock_aws
def test_create_snapshots_multiple_volumes():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -1073,7 +1071,7 @@ def test_create_snapshots_multiple_volumes():
# The default AMIs are not loaded for our test case, to speed things up
# But we do need it for this specific test
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_create_snapshots_multiple_volumes_without_boot():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
@@ -1106,7 +1104,7 @@ def test_create_snapshots_multiple_volumes_without_boot():
assert snapshot2["VolumeSize"] == 100
-@mock_ec2
+@mock_aws
def test_create_volume_with_iops():
ec2 = boto3.client("ec2", region_name="us-east-1")
volume = ec2.create_volume(
@@ -1118,7 +1116,7 @@ def test_create_volume_with_iops():
assert volume["Iops"] == 4000
-@mock_ec2
+@mock_aws
def test_create_volume_with_throughput():
ec2 = boto3.client("ec2", region_name="us-east-1")
volume = ec2.create_volume(
@@ -1130,7 +1128,7 @@ def test_create_volume_with_throughput():
assert volume["Throughput"] == 200
-@mock_ec2
+@mock_aws
def test_create_volume_with_throughput_fails():
resource = boto3.resource("ec2", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
diff --git a/tests/test_ec2/test_elastic_ip_addresses.py b/tests/test_ec2/test_elastic_ip_addresses.py
index ee607a023..c43884291 100644
--- a/tests/test_ec2/test_elastic_ip_addresses.py
+++ b/tests/test_ec2/test_elastic_ip_addresses.py
@@ -4,11 +4,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
-@mock_ec2
+@mock_aws
def test_eip_allocate_classic():
"""Allocate/release Classic EIP"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -47,7 +47,7 @@ def test_eip_allocate_classic():
assert public_ip not in [a["PublicIp"] for a in all_addresses]
-@mock_ec2
+@mock_aws
def test_describe_addresses_dryrun():
client = boto3.client("ec2", region_name="us-east-1")
@@ -61,7 +61,7 @@ def test_describe_addresses_dryrun():
)
-@mock_ec2
+@mock_aws
def test_eip_allocate_vpc():
"""Allocate/release VPC EIP"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -106,7 +106,7 @@ def test_eip_allocate_vpc():
]
-@mock_ec2
+@mock_aws
def test_specific_eip_allocate_vpc():
"""Allocate VPC EIP with specific address"""
client = boto3.client("ec2", region_name="us-west-1")
@@ -116,7 +116,7 @@ def test_specific_eip_allocate_vpc():
assert vpc["PublicIp"] == "127.38.43.222"
-@mock_ec2
+@mock_aws
def test_eip_associate_classic():
"""Associate/Disassociate EIP to classic instance"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -177,7 +177,7 @@ def test_eip_associate_classic():
instance.terminate()
-@mock_ec2
+@mock_aws
def test_eip_associate_vpc():
"""Associate/Disassociate EIP to VPC instance"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -223,7 +223,7 @@ def test_eip_associate_vpc():
instance.terminate()
-@mock_ec2
+@mock_aws
def test_eip_vpc_association():
"""Associate EIP to VPC instance in a new subnet with boto3"""
service = boto3.resource("ec2", region_name="us-west-1")
@@ -270,7 +270,7 @@ def test_eip_vpc_association():
assert address.instance_id == ""
-@mock_ec2
+@mock_aws
def test_eip_associate_network_interface():
"""Associate/Disassociate EIP to NIC"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -306,7 +306,7 @@ def test_eip_associate_network_interface():
eip.release()
-@mock_ec2
+@mock_aws
def test_eip_reassociate():
"""reassociate EIP"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -347,7 +347,7 @@ def test_eip_reassociate():
instance2.terminate()
-@mock_ec2
+@mock_aws
def test_eip_reassociate_nic():
"""reassociate EIP"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -384,7 +384,7 @@ def test_eip_reassociate_nic():
eip.release()
-@mock_ec2
+@mock_aws
def test_eip_associate_invalid_args():
"""Associate EIP, invalid args"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -404,7 +404,7 @@ def test_eip_associate_invalid_args():
instance.terminate()
-@mock_ec2
+@mock_aws
def test_eip_disassociate_bogus_association():
"""Disassociate bogus EIP"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -416,7 +416,7 @@ def test_eip_disassociate_bogus_association():
assert ex.value.response["Error"]["Code"] == "InvalidAssociationID.NotFound"
-@mock_ec2
+@mock_aws
def test_eip_release_bogus_eip():
"""Release bogus EIP"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -428,7 +428,7 @@ def test_eip_release_bogus_eip():
assert ex.value.response["Error"]["Code"] == "InvalidAllocationID.NotFound"
-@mock_ec2
+@mock_aws
def test_eip_disassociate_arg_error():
"""Invalid arguments disassociate address"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -440,7 +440,7 @@ def test_eip_disassociate_arg_error():
assert ex.value.response["Error"]["Code"] == "MissingParameter"
-@mock_ec2
+@mock_aws
def test_eip_release_arg_error():
"""Invalid arguments release address"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -452,7 +452,7 @@ def test_eip_release_arg_error():
assert ex.value.response["Error"]["Code"] == "MissingParameter"
-@mock_ec2
+@mock_aws
def test_eip_describe():
"""Listing of allocated Elastic IP Addresses."""
client = boto3.client("ec2", region_name="us-east-1")
@@ -498,7 +498,7 @@ def test_eip_describe():
assert eips[1].public_ip not in [a["PublicIp"] for a in all_addresses]
-@mock_ec2
+@mock_aws
def test_eip_describe_none():
"""Error when search for bogus IP"""
client = boto3.client("ec2", region_name="us-east-1")
@@ -510,7 +510,7 @@ def test_eip_describe_none():
assert ex.value.response["Error"]["Code"] == "InvalidAddress.NotFound"
-@mock_ec2
+@mock_aws
def test_eip_filters():
service = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -613,7 +613,7 @@ def test_eip_filters():
assert inst1.public_ip_address in public_ips
-@mock_ec2
+@mock_aws
def test_eip_tags():
service = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -662,7 +662,7 @@ def test_eip_tags():
assert alloc_tags["AllocationId"] in [a.allocation_id for a in addresses]
-@mock_ec2
+@mock_aws
def test_describe_addresses_tags():
client = boto3.client("ec2", region_name="us-west-1")
@@ -680,7 +680,7 @@ def test_describe_addresses_tags():
]
-@mock_ec2
+@mock_aws
def test_describe_addresses_with_vpc_associated_eni():
"""Extra attributes for EIP associated with a ENI inside a VPC"""
client = boto3.client("ec2", region_name="us-east-1")
diff --git a/tests/test_ec2/test_elastic_network_interfaces.py b/tests/test_ec2/test_elastic_network_interfaces.py
index fc8dbde65..3e387189d 100644
--- a/tests/test_ec2/test_elastic_network_interfaces.py
+++ b/tests/test_ec2/test_elastic_network_interfaces.py
@@ -5,13 +5,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.ec2.utils import random_private_ip
from tests import EXAMPLE_AMI_ID
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -66,7 +66,7 @@ def test_elastic_network_interfaces():
assert ex.value.response["Error"]["Code"] == "InvalidNetworkInterfaceID.NotFound"
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_subnet_validation():
client = boto3.client("ec2", "us-east-1")
@@ -77,7 +77,7 @@ def test_elastic_network_interfaces_subnet_validation():
assert ex.value.response["Error"]["Code"] == "InvalidSubnetID.NotFound"
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_with_private_ip():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -102,7 +102,7 @@ def test_elastic_network_interfaces_with_private_ip():
assert eni["PrivateIpAddresses"][0]["PrivateIpAddress"] == private_ip
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_with_groups():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -137,7 +137,7 @@ def test_elastic_network_interfaces_with_groups():
}
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_without_group():
# ENI should use the default SecurityGroup if not provided
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -156,7 +156,7 @@ def test_elastic_network_interfaces_without_group():
assert my_eni["Groups"][0]["GroupName"] == "default"
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_modify_attribute():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -196,7 +196,7 @@ def test_elastic_network_interfaces_modify_attribute():
assert my_eni["Groups"][0]["GroupId"] == sec_group2.id
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_filtering():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -265,7 +265,7 @@ def test_elastic_network_interfaces_filtering():
client.describe_network_interfaces(Filters=filters)
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_get_by_tag_name():
ec2 = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -304,7 +304,7 @@ def test_elastic_network_interfaces_get_by_tag_name():
assert len(enis) == 0
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_get_by_availability_zone():
ec2 = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -341,7 +341,7 @@ def test_elastic_network_interfaces_get_by_availability_zone():
assert eni2.id not in [eni.id for eni in enis]
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_get_by_private_ip():
ec2 = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -375,7 +375,7 @@ def test_elastic_network_interfaces_get_by_private_ip():
assert len(enis) == 0
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_get_by_vpc_id():
ec2 = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -402,7 +402,7 @@ def test_elastic_network_interfaces_get_by_vpc_id():
assert len(enis) == 0
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_get_by_subnet_id():
ec2 = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -429,7 +429,7 @@ def test_elastic_network_interfaces_get_by_subnet_id():
assert len(enis) == 0
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_get_by_description():
ec2 = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -457,7 +457,7 @@ def test_elastic_network_interfaces_get_by_description():
assert len(enis) == 0
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_get_by_attachment_instance_id():
ec2_resource = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -499,7 +499,7 @@ def test_elastic_network_interfaces_get_by_attachment_instance_id():
assert len(enis.get("NetworkInterfaces")) == 0
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_get_by_attachment_instance_owner_id():
ec2_resource = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -531,7 +531,7 @@ def test_elastic_network_interfaces_get_by_attachment_instance_owner_id():
assert eni1.id in eni_ids
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_describe_network_interfaces_with_filter():
ec2 = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -642,7 +642,7 @@ def test_elastic_network_interfaces_describe_network_interfaces_with_filter():
assert response["NetworkInterfaces"][0]["Description"] == eni1.description
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_filter_by_tag():
ec2 = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -706,7 +706,7 @@ def test_elastic_network_interfaces_filter_by_tag():
assert len(resp["NetworkInterfaces"]) == 2
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_auto_create_securitygroup():
ec2 = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -732,7 +732,7 @@ def test_elastic_network_interfaces_auto_create_securitygroup():
assert found_sg[0]["Description"] == "testgroup"
-@mock_ec2
+@mock_aws
def test_assign_private_ip_addresses__by_address():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -778,7 +778,7 @@ def test_assign_private_ip_addresses__by_address():
]
-@mock_ec2
+@mock_aws
def test_assign_private_ip_addresses__with_secondary_count():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -807,7 +807,7 @@ def test_assign_private_ip_addresses__with_secondary_count():
assert my_eni["Ipv6Addresses"] == []
-@mock_ec2
+@mock_aws
def test_unassign_private_ip_addresses():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -842,7 +842,7 @@ def test_unassign_private_ip_addresses():
]
-@mock_ec2
+@mock_aws
def test_unassign_private_ip_addresses__multiple():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -883,7 +883,7 @@ def test_unassign_private_ip_addresses__multiple():
]
-@mock_ec2
+@mock_aws
def test_assign_ipv6_addresses__by_address():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -913,7 +913,7 @@ def test_assign_ipv6_addresses__by_address():
assert {"Ipv6Address": ipv6_3} in my_eni["Ipv6Addresses"]
-@mock_ec2
+@mock_aws
def test_assign_ipv6_addresses__by_count():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -936,7 +936,7 @@ def test_assign_ipv6_addresses__by_count():
assert {"Ipv6Address": ipv6_orig} in my_eni["Ipv6Addresses"]
-@mock_ec2
+@mock_aws
def test_assign_ipv6_addresses__by_address_and_count():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -966,7 +966,7 @@ def test_assign_ipv6_addresses__by_address_and_count():
assert {"Ipv6Address": ipv6_3} in my_eni["Ipv6Addresses"]
-@mock_ec2
+@mock_aws
def test_unassign_ipv6_addresses():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -996,7 +996,7 @@ def test_unassign_ipv6_addresses():
assert {"Ipv6Address": ipv6_3} in my_eni["Ipv6Addresses"]
-@mock_ec2
+@mock_aws
def test_elastic_network_interfaces_describe_attachment():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", "us-east-1")
diff --git a/tests/test_ec2/test_fleets.py b/tests/test_ec2/test_fleets.py
index a60548c85..be04fbf3c 100644
--- a/tests/test_ec2/test_fleets.py
+++ b/tests/test_ec2/test_fleets.py
@@ -3,7 +3,7 @@ from uuid import uuid4
import boto3
import pytest
-from moto import mock_ec2
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
from . import ec2_aws_verified
@@ -67,7 +67,7 @@ def test_launch_template_is_created_properly():
assert template["LatestVersionNumber"] == 1
-@mock_ec2
+@mock_aws
def test_create_spot_fleet_with_lowest_price():
conn = boto3.client("ec2", region_name="us-west-2")
launch_template_id, _ = get_launch_template(conn)
@@ -118,7 +118,7 @@ def test_create_spot_fleet_with_lowest_price():
assert len(instances) == 1
-@mock_ec2
+@mock_aws
def test_create_on_demand_fleet():
conn = boto3.client("ec2", region_name="us-west-2")
launch_template_id, _ = get_launch_template(conn)
@@ -169,7 +169,7 @@ def test_create_on_demand_fleet():
assert len(instances) == 1
-@mock_ec2
+@mock_aws
def test_create_diversified_spot_fleet():
conn = boto3.client("ec2", region_name="us-west-2")
launch_template_id_1, _ = get_launch_template(conn, instance_type="t2.small")
@@ -214,7 +214,7 @@ def test_create_diversified_spot_fleet():
assert "i-" in instances[0]["InstanceId"]
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"spot_allocation_strategy",
[
@@ -271,7 +271,7 @@ def test_request_fleet_using_launch_template_config__name(
assert "i-" in instances[0]["InstanceId"]
-@mock_ec2
+@mock_aws
def test_create_fleet_request_with_tags():
conn = boto3.client("ec2", region_name="us-west-2")
@@ -328,7 +328,7 @@ def test_create_fleet_request_with_tags():
assert tag in instance["Tags"]
-@mock_ec2
+@mock_aws
def test_create_fleet_using_launch_template_config__overrides():
conn = boto3.client("ec2", region_name="us-east-2")
subnet_id = get_subnet_id(conn)
@@ -440,7 +440,7 @@ def test_delete_fleet():
assert len(instances) == 0
-@mock_ec2
+@mock_aws
def test_describe_fleet_instances_api():
conn = boto3.client("ec2", region_name="us-west-1")
@@ -487,7 +487,7 @@ def test_describe_fleet_instances_api():
assert instance_healths == ["healthy", "healthy", "healthy"]
-@mock_ec2
+@mock_aws
def test_create_fleet_api():
conn = boto3.client("ec2", region_name="us-west-1")
@@ -535,7 +535,7 @@ def test_create_fleet_api():
assert "on-demand" in lifecycle
-@mock_ec2
+@mock_aws
def test_create_fleet_api_response():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
diff --git a/tests/test_ec2/test_flow_logs.py b/tests/test_ec2/test_flow_logs.py
index b47d4d5de..4eca93221 100644
--- a/tests/test_ec2/test_flow_logs.py
+++ b/tests/test_ec2/test_flow_logs.py
@@ -4,12 +4,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_logs, mock_s3
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_s3
-@mock_ec2
+@mock_aws
def test_create_flow_logs_s3():
s3 = boto3.resource("s3", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -66,8 +65,7 @@ def test_create_flow_logs_s3():
assert flow_log["MaxAggregationInterval"] == 600
-@mock_s3
-@mock_ec2
+@mock_aws
def test_create_multiple_flow_logs_s3():
s3 = boto3.resource("s3", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -116,8 +114,7 @@ def test_create_multiple_flow_logs_s3():
assert flow_log_1["LogDestination"] != flow_log_2["LogDestination"]
-@mock_logs
-@mock_ec2
+@mock_aws
def test_create_flow_logs_cloud_watch():
client = boto3.client("ec2", region_name="us-west-1")
logs_client = boto3.client("logs", region_name="us-west-1")
@@ -178,8 +175,7 @@ def test_create_flow_logs_cloud_watch():
assert flow_log["MaxAggregationInterval"] == 600
-@mock_logs
-@mock_ec2
+@mock_aws
def test_create_multiple_flow_logs_cloud_watch():
client = boto3.client("ec2", region_name="us-west-1")
logs_client = boto3.client("logs", region_name="us-west-1")
@@ -223,8 +219,7 @@ def test_create_multiple_flow_logs_cloud_watch():
assert flow_log_1["LogGroupName"] != flow_log_2["LogGroupName"]
-@mock_s3
-@mock_ec2
+@mock_aws
def test_create_flow_log_create():
s3 = boto3.resource("s3", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -260,8 +255,7 @@ def test_create_flow_log_create():
)
-@mock_s3
-@mock_ec2
+@mock_aws
def test_delete_flow_logs():
s3 = boto3.resource("s3", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -299,8 +293,7 @@ def test_delete_flow_logs():
assert len(flow_logs) == 0
-@mock_s3
-@mock_ec2
+@mock_aws
def test_delete_flow_logs_delete_many():
s3 = boto3.resource("s3", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -333,7 +326,7 @@ def test_delete_flow_logs_delete_many():
assert fl_id not in all_ids
-@mock_ec2
+@mock_aws
def test_delete_flow_logs_non_existing():
client = boto3.client("ec2", region_name="us-west-1")
@@ -356,7 +349,7 @@ def test_delete_flow_logs_non_existing():
)
-@mock_ec2
+@mock_aws
def test_create_flow_logs_unsuccessful():
client = boto3.client("ec2", region_name="us-west-1")
@@ -382,8 +375,7 @@ def test_create_flow_logs_unsuccessful():
assert error2["Message"] == "LogDestination: non-existing-bucket does not exist."
-@mock_s3
-@mock_ec2
+@mock_aws
def test_create_flow_logs_invalid_parameters():
s3 = boto3.resource("s3", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -504,9 +496,7 @@ def test_create_flow_logs_invalid_parameters():
)
-@mock_s3
-@mock_ec2
-@mock_logs
+@mock_aws
def test_describe_flow_logs_filtering():
s3 = boto3.resource("s3", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -667,8 +657,7 @@ def test_describe_flow_logs_filtering():
client.describe_flow_logs(Filters=[{"Name": "unknown", "Values": ["foobar"]}])
-@mock_s3
-@mock_ec2
+@mock_aws
def test_flow_logs_by_ids():
client = boto3.client("ec2", region_name="us-west-1")
diff --git a/tests/test_ec2/test_flow_logs_cloudformation.py b/tests/test_ec2/test_flow_logs_cloudformation.py
index ee64834ab..8d1b39e24 100644
--- a/tests/test_ec2/test_flow_logs_cloudformation.py
+++ b/tests/test_ec2/test_flow_logs_cloudformation.py
@@ -3,14 +3,12 @@ from uuid import uuid4
import boto3
-from moto import mock_cloudformation, mock_ec2, mock_s3
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
-@mock_cloudformation
-@mock_ec2
-@mock_s3
+@mock_aws
def test_flow_logs_by_cloudformation():
s3 = boto3.resource("s3", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -56,8 +54,7 @@ def test_flow_logs_by_cloudformation():
assert flow_logs[0]["MaxAggregationInterval"] == 60
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_cloudformation():
dummy_template_json = {
"AWSTemplateFormatVersion": "2010-09-09",
diff --git a/tests/test_ec2/test_general.py b/tests/test_ec2/test_general.py
index c5547ce28..2e6761eb7 100644
--- a/tests/test_ec2/test_general.py
+++ b/tests/test_ec2/test_general.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
-@mock_ec2
+@mock_aws
def test_console_output():
conn = boto3.resource("ec2", "us-east-1")
instances = conn.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -15,7 +15,7 @@ def test_console_output():
assert output.get("Output") is not None
-@mock_ec2
+@mock_aws
def test_console_output_without_instance():
client = boto3.client("ec2", "us-east-1")
diff --git a/tests/test_ec2/test_hosts.py b/tests/test_ec2/test_hosts.py
index aa65f3a7a..277ce7961 100644
--- a/tests/test_ec2/test_hosts.py
+++ b/tests/test_ec2/test_hosts.py
@@ -2,10 +2,10 @@ from uuid import uuid4
import boto3
-from moto import mock_ec2
+from moto import mock_aws
-@mock_ec2
+@mock_aws
def test_allocate_hosts():
client = boto3.client("ec2", "us-west-1")
resp = client.allocate_hosts(
@@ -18,7 +18,7 @@ def test_allocate_hosts():
assert len(resp["HostIds"]) == 3
-@mock_ec2
+@mock_aws
def test_describe_hosts_with_instancefamily():
client = boto3.client("ec2", "us-west-1")
host_ids = client.allocate_hosts(
@@ -31,7 +31,7 @@ def test_describe_hosts_with_instancefamily():
assert host["HostProperties"]["InstanceFamily"] == "c5"
-@mock_ec2
+@mock_aws
def test_describe_hosts():
client = boto3.client("ec2", "us-west-1")
host_ids = client.allocate_hosts(
@@ -52,7 +52,7 @@ def test_describe_hosts():
assert hosts[0]["AutoPlacement"] == "off"
-@mock_ec2
+@mock_aws
def test_describe_hosts_with_tags():
client = boto3.client("ec2", "us-west-1")
tagkey = str(uuid4())
@@ -77,7 +77,7 @@ def test_describe_hosts_with_tags():
assert len(hosts) == 1
-@mock_ec2
+@mock_aws
def test_describe_hosts_using_filters():
client = boto3.client("ec2", "us-west-1")
host_id1 = client.allocate_hosts(
@@ -109,7 +109,7 @@ def test_describe_hosts_using_filters():
assert len(hosts) == 0
-@mock_ec2
+@mock_aws
def test_modify_hosts():
client = boto3.client("ec2", "us-west-1")
host_ids = client.allocate_hosts(
@@ -131,7 +131,7 @@ def test_modify_hosts():
assert host["HostProperties"]["InstanceType"] == "c5.medium"
-@mock_ec2
+@mock_aws
def test_release_hosts():
client = boto3.client("ec2", "us-west-1")
host_ids = client.allocate_hosts(
@@ -150,7 +150,7 @@ def test_release_hosts():
assert host["State"] == "released"
-@mock_ec2
+@mock_aws
def test_add_tags_to_dedicated_hosts():
client = boto3.client("ec2", "us-west-1")
resp = client.allocate_hosts(
diff --git a/tests/test_ec2/test_iam_integration.py b/tests/test_ec2/test_iam_integration.py
index 81fb41232..8651d739c 100644
--- a/tests/test_ec2/test_iam_integration.py
+++ b/tests/test_ec2/test_iam_integration.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_iam
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
@@ -25,8 +25,7 @@ def quick_instance_profile_creation(name):
return test_instance_profile.arn, test_instance_profile.name
-@mock_ec2
-@mock_iam
+@mock_aws
def test_associate():
client = boto3.client("ec2", region_name="us-east-1")
instance_id = quick_instance_creation()
@@ -49,8 +48,7 @@ def test_associate():
assert association["IamInstanceProfileAssociation"]["State"] == "associating"
-@mock_ec2
-@mock_iam
+@mock_aws
def test_invalid_associate():
client = boto3.client("ec2", region_name="us-east-1")
instance_id = quick_instance_creation()
@@ -101,8 +99,7 @@ def test_invalid_associate():
assert "does not exist" in ex.value.response["Error"]["Message"]
-@mock_ec2
-@mock_iam
+@mock_aws
def test_describe():
client = boto3.client("ec2", region_name="us-east-1")
@@ -178,8 +175,7 @@ def test_describe():
)
-@mock_ec2
-@mock_iam
+@mock_aws
def test_replace():
client = boto3.client("ec2", region_name="us-east-1")
instance_id1 = quick_instance_creation()
@@ -213,8 +209,7 @@ def test_replace():
assert association["IamInstanceProfileAssociation"]["State"] == "associating"
-@mock_ec2
-@mock_iam
+@mock_aws
def test_invalid_replace():
client = boto3.client("ec2", region_name="us-east-1")
instance_id = quick_instance_creation()
@@ -255,8 +250,7 @@ def test_invalid_replace():
assert "not found" in ex.value.response["Error"]["Message"]
-@mock_ec2
-@mock_iam
+@mock_aws
def test_disassociate():
client = boto3.client("ec2", region_name="us-east-1")
instance_id = quick_instance_creation()
@@ -295,8 +289,7 @@ def test_disassociate():
]
-@mock_ec2
-@mock_iam
+@mock_aws
def test_invalid_disassociate():
client = boto3.client("ec2", region_name="us-east-1")
diff --git a/tests/test_ec2/test_instance_type_offerings.py b/tests/test_ec2/test_instance_type_offerings.py
index b4fe31359..52f4e4315 100644
--- a/tests/test_ec2/test_instance_type_offerings.py
+++ b/tests/test_ec2/test_instance_type_offerings.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_ec2
+from moto import mock_aws
-@mock_ec2
+@mock_aws
def test_describe_instance_type_offerings():
client = boto3.client("ec2", "us-east-1")
offerings = client.describe_instance_type_offerings()
@@ -14,7 +14,7 @@ def test_describe_instance_type_offerings():
assert "LocationType" in offerings["InstanceTypeOfferings"][0]
-@mock_ec2
+@mock_aws
def test_describe_instance_type_offering_filter_by_type():
client = boto3.client("ec2", "us-east-1")
@@ -50,7 +50,7 @@ def test_describe_instance_type_offering_filter_by_type():
]
-@mock_ec2
+@mock_aws
def test_describe_instance_type_offering_filter_by_zone():
client = boto3.client("ec2", "us-east-1")
offerings = client.describe_instance_type_offerings(
@@ -67,7 +67,7 @@ def test_describe_instance_type_offering_filter_by_zone():
assert any([o["InstanceType"] == "a1.2xlarge" for o in offerings])
-@mock_ec2
+@mock_aws
def test_describe_instance_type_offering_filter_by_zone_id():
client = boto3.client("ec2", "ca-central-1")
offerings = client.describe_instance_type_offerings(
diff --git a/tests/test_ec2/test_instance_types.py b/tests/test_ec2/test_instance_types.py
index d4c8d5508..8d7ee944b 100644
--- a/tests/test_ec2/test_instance_types.py
+++ b/tests/test_ec2/test_instance_types.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
-@mock_ec2
+@mock_aws
def test_describe_instance_types():
client = boto3.client("ec2", "us-east-1")
instance_types = client.describe_instance_types()
@@ -20,7 +20,7 @@ def test_describe_instance_types():
assert ena_support == {"required", "unsupported", "supported"}
-@mock_ec2
+@mock_aws
def test_describe_instance_types_filter_by_type():
client = boto3.client("ec2", "us-east-1")
instance_types = client.describe_instance_types(
@@ -33,7 +33,7 @@ def test_describe_instance_types_filter_by_type():
assert instance_types["InstanceTypes"][1]["InstanceType"] in ["t1.micro", "t2.nano"]
-@mock_ec2
+@mock_aws
def test_describe_instance_types_gpu_instance_types():
client = boto3.client("ec2", "us-east-1")
instance_types = client.describe_instance_types(
@@ -74,7 +74,7 @@ def test_describe_instance_types_gpu_instance_types():
}
-@mock_ec2
+@mock_aws
def test_describe_instance_types_unknown_type():
client = boto3.client("ec2", "us-east-1")
@@ -89,7 +89,7 @@ def test_describe_instance_types_unknown_type():
assert exc_info.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_ec2
+@mock_aws
def test_describe_instance_types_filter_by_vcpus():
client = boto3.client("ec2", "us-east-1")
instance_types = client.describe_instance_types(
@@ -107,7 +107,7 @@ def test_describe_instance_types_filter_by_vcpus():
assert "m5d.xlarge" not in types
-@mock_ec2
+@mock_aws
def test_describe_instance_types_filter_by_memory():
client = boto3.client("ec2", "us-east-1")
instance_types = client.describe_instance_types(
@@ -124,7 +124,7 @@ def test_describe_instance_types_filter_by_memory():
assert "m5d.xlarge" not in types
-@mock_ec2
+@mock_aws
def test_describe_instance_types_filter_by_bare_metal():
client = boto3.client("ec2", "us-east-1")
instance_types = client.describe_instance_types(
@@ -141,7 +141,7 @@ def test_describe_instance_types_filter_by_bare_metal():
assert "t1.micro" not in types
-@mock_ec2
+@mock_aws
def test_describe_instance_types_filter_by_burstable_performance_supported():
client = boto3.client("ec2", "us-east-1")
instance_types = client.describe_instance_types(
@@ -158,7 +158,7 @@ def test_describe_instance_types_filter_by_burstable_performance_supported():
assert "t1.micro" not in types
-@mock_ec2
+@mock_aws
def test_describe_instance_types_filter_by_current_generation():
client = boto3.client("ec2", "us-east-1")
instance_types = client.describe_instance_types(
@@ -175,7 +175,7 @@ def test_describe_instance_types_filter_by_current_generation():
assert "t1.micro" not in types
-@mock_ec2
+@mock_aws
def test_describe_instance_types_small_instances():
client = boto3.client("ec2", "us-east-1")
instance_types = client.describe_instance_types(Filters=[
@@ -190,7 +190,7 @@ def test_describe_instance_types_small_instances():
assert types == {"t3.nano", "t3.micro", "t3a.nano", "t3a.micro"}
-@mock_ec2
+@mock_aws
def test_describe_instance_types_invalid_filter():
client = boto3.client("ec2", "us-east-1")
diff --git a/tests/test_ec2/test_instances.py b/tests/test_ec2/test_instances.py
index 0c6dcef8e..6dbc12b69 100644
--- a/tests/test_ec2/test_instances.py
+++ b/tests/test_ec2/test_instances.py
@@ -11,14 +11,14 @@ import pytest
from botocore.exceptions import ClientError, ParamValidationError
from freezegun import freeze_time
-from moto import mock_ec2, mock_iam, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
decode_method = base64.decodebytes
-@mock_ec2
+@mock_aws
def test_add_servers():
client = boto3.client("ec2", region_name="us-east-1")
resp = client.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=2, MaxCount=2)
@@ -34,7 +34,7 @@ def test_add_servers():
@freeze_time("2014-01-01 05:00:00")
-@mock_ec2
+@mock_aws
def test_instance_launch_and_terminate():
client = boto3.client("ec2", region_name="us-east-1")
@@ -104,7 +104,7 @@ def test_instance_launch_and_terminate():
assert instance["State"] == {"Code": 48, "Name": "terminated"}
-@mock_ec2
+@mock_aws
def test_instance_terminate_discard_volumes():
ec2_resource = boto3.resource("ec2", "us-west-1")
@@ -133,7 +133,7 @@ def test_instance_terminate_discard_volumes():
assert my_id not in all_volumes_ids
-@mock_ec2
+@mock_aws
def test_instance_terminate_keep_volumes_explicit():
ec2_resource = boto3.resource("ec2", "us-west-1")
@@ -162,7 +162,7 @@ def test_instance_terminate_keep_volumes_explicit():
assert my_id in all_volumes_ids
-@mock_ec2
+@mock_aws
def test_instance_terminate_keep_volumes_implicit():
ec2_resource = boto3.resource("ec2", "us-west-1")
@@ -186,7 +186,7 @@ def test_instance_terminate_keep_volumes_implicit():
assert volume.state == "available"
-@mock_ec2
+@mock_aws
def test_instance_terminate_detach_volumes():
ec2_resource = boto3.resource("ec2", "us-west-1")
result = ec2_resource.create_instances(
@@ -213,7 +213,7 @@ def test_instance_terminate_detach_volumes():
assert my_id in all_volumes_ids
-@mock_ec2
+@mock_aws
def test_instance_detach_volume_wrong_path():
ec2_resource = boto3.resource("ec2", "us-west-1")
result = ec2_resource.create_instances(
@@ -235,7 +235,7 @@ def test_instance_detach_volume_wrong_path():
)
-@mock_ec2
+@mock_aws
def test_terminate_empty_instances():
client = boto3.client("ec2", region_name="us-east-1")
@@ -247,7 +247,7 @@ def test_terminate_empty_instances():
@freeze_time("2014-01-01 05:00:00")
-@mock_ec2
+@mock_aws
def test_instance_attach_volume():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -280,7 +280,7 @@ def test_instance_attach_volume():
assert expected_vol3.create_time == instance.launch_time
-@mock_ec2
+@mock_aws
def test_get_instances_by_id():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -311,7 +311,7 @@ def test_get_instances_by_id():
assert ex.value.response["Error"]["Code"] == "InvalidInstanceID.NotFound"
-@mock_ec2
+@mock_aws
def test_get_paginated_instances():
client = boto3.client("ec2", region_name="us-east-1")
conn = boto3.resource("ec2", "us-east-1")
@@ -337,7 +337,7 @@ def test_get_paginated_instances():
i.terminate()
-@mock_ec2
+@mock_aws
def test_describe_instances_pagination_error():
client = boto3.client("ec2", region_name="us-east-1")
@@ -360,7 +360,7 @@ def test_describe_instances_pagination_error():
)
-@mock_ec2
+@mock_aws
def test_create_with_tags():
ec2 = boto3.client("ec2", region_name="us-west-2")
instances = ec2.run_instances(
@@ -386,7 +386,7 @@ def test_create_with_tags():
assert len(instances["Instances"][0]["Tags"]) == 3
-@mock_ec2
+@mock_aws
def test_create_with_volume_tags():
ec2 = boto3.client("ec2", region_name="us-west-2")
volume_tags = [
@@ -413,7 +413,7 @@ def test_create_with_volume_tags():
assert sorted(volume["Tags"], key=lambda i: i["Key"]) == volume_tags
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_state():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -460,7 +460,7 @@ def test_get_instances_filtering_by_state():
client.describe_instances(Filters=filters)
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_instance_id():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -482,7 +482,7 @@ def test_get_instances_filtering_by_instance_id():
_filter(values=["non-existing-id"], exists=False)
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_instance_type():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -523,7 +523,7 @@ def test_get_instances_filtering_by_instance_type():
assert len(res["Reservations"]) == 0
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_reason_code():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -550,7 +550,7 @@ def test_get_instances_filtering_by_reason_code():
assert instance2.id not in instance_ids
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_source_dest_check():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -574,7 +574,7 @@ def test_get_instances_filtering_by_source_dest_check():
assert instance2.id in [i["InstanceId"] for i in instances_true]
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_vpc_id():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -611,7 +611,7 @@ def test_get_instances_filtering_by_vpc_id():
assert res2[0]["Instances"][0]["SubnetId"] == subnet2.id
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_dns_name():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -645,7 +645,7 @@ def test_get_instances_filtering_by_dns_name():
assert res2[0]["Instances"][0]["InstanceId"] == instance2.id
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_architecture():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -658,7 +658,7 @@ def test_get_instances_filtering_by_architecture():
assert len(reservations[0]["Instances"]) == 1
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_image_id():
client = boto3.client("ec2", region_name="us-east-1")
conn = boto3.resource("ec2", "us-east-1")
@@ -670,7 +670,7 @@ def test_get_instances_filtering_by_image_id():
assert len(reservations[0]["Instances"]) >= 1, "Should return just created instance"
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_account_id():
client = boto3.client("ec2", region_name="us-east-1")
conn = boto3.resource("ec2", "us-east-1")
@@ -683,7 +683,7 @@ def test_get_instances_filtering_by_account_id():
assert instance.id in [i["InstanceId"] for i in instances]
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_private_dns():
client = boto3.client("ec2", region_name="us-east-1")
conn = boto3.resource("ec2", "us-east-1")
@@ -696,7 +696,7 @@ def test_get_instances_filtering_by_private_dns():
assert len(reservations[0]["Instances"]) == 1
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_ni_private_dns():
client = boto3.client("ec2", region_name="us-west-2")
conn = boto3.resource("ec2", "us-west-2")
@@ -714,7 +714,7 @@ def test_get_instances_filtering_by_ni_private_dns():
assert len(reservations[0]["Instances"]) == 1
-@mock_ec2
+@mock_aws
def test_run_instances_with_unknown_security_group():
client = boto3.client("ec2", region_name="us-east-1")
sg_id = f"sg-{str(uuid4())[0:6]}"
@@ -727,7 +727,7 @@ def test_run_instances_with_unknown_security_group():
assert err["Message"] == f"The security group '{sg_id}' does not exist"
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_instance_group_name():
client = boto3.client("ec2", region_name="us-east-1")
sec_group_name = str(uuid4())[0:6]
@@ -741,7 +741,7 @@ def test_get_instances_filtering_by_instance_group_name():
assert len(reservations[0]["Instances"]) == 1
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_instance_group_id():
client = boto3.client("ec2", region_name="us-east-1")
sec_group_name = str(uuid4())[0:6]
@@ -758,7 +758,7 @@ def test_get_instances_filtering_by_instance_group_id():
assert len(reservations[0]["Instances"]) == 1
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_subnet_id():
client = boto3.client("ec2", region_name="us-east-1")
@@ -781,7 +781,7 @@ def test_get_instances_filtering_by_subnet_id():
assert len(reservations) == 1
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_tag():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -852,7 +852,7 @@ def test_get_instances_filtering_by_tag():
assert res["Reservations"][0]["Instances"][0]["InstanceId"] == instance1.id
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_tag_value():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -906,7 +906,7 @@ def test_get_instances_filtering_by_tag_value():
assert res["Reservations"][0]["Instances"][1]["InstanceId"] == instance3.id
-@mock_ec2
+@mock_aws
def test_get_instances_filtering_by_tag_name():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -945,7 +945,7 @@ def test_get_instances_filtering_by_tag_name():
assert res["Reservations"][0]["Instances"][2]["InstanceId"] == instance3.id
-@mock_ec2
+@mock_aws
def test_instance_start_and_stop():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -994,7 +994,7 @@ def test_instance_start_and_stop():
assert started_instances[0]["PreviousState"] == {"Code": 80, "Name": "stopped"}
-@mock_ec2
+@mock_aws
def test_instance_reboot():
ec2 = boto3.resource("ec2", region_name="us-east-1")
response = ec2.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -1018,7 +1018,7 @@ def test_instance_reboot():
assert instance.state == {"Code": 16, "Name": "running"}
-@mock_ec2
+@mock_aws
def test_instance_attribute_instance_type():
ec2 = boto3.resource("ec2", region_name="us-east-1")
response = ec2.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -1042,7 +1042,7 @@ def test_instance_attribute_instance_type():
}
-@mock_ec2
+@mock_aws
def test_modify_instance_attribute_security_groups():
ec2 = boto3.resource("ec2", region_name="us-east-1")
response = ec2.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -1074,7 +1074,7 @@ def test_modify_instance_attribute_security_groups():
assert {"GroupId": sg_id2} in new_groups
-@mock_ec2
+@mock_aws
def test_instance_attribute_user_data():
ec2 = boto3.resource("ec2", region_name="us-east-1")
res = ec2.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -1098,7 +1098,7 @@ def test_instance_attribute_user_data():
assert decode_method(retrieved_user_data) == b"this is my user data"
-@mock_ec2
+@mock_aws
def test_instance_attribute_source_dest_check():
ec2 = boto3.resource("ec2", region_name="us-west-1")
instance = ec2.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)[0]
@@ -1129,7 +1129,7 @@ def test_instance_attribute_source_dest_check():
assert instance_attribute.get("SourceDestCheck") == {"Value": True}
-@mock_ec2
+@mock_aws
def test_user_data_with_run_instance():
user_data = b"some user data"
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -1143,7 +1143,7 @@ def test_user_data_with_run_instance():
assert decoded_user_data == b"some user data"
-@mock_ec2
+@mock_aws
def test_run_instance_with_security_group_name():
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -1174,7 +1174,7 @@ def test_run_instance_with_security_group_name():
]
-@mock_ec2
+@mock_aws
def test_run_instance_with_security_group_id():
ec2 = boto3.resource("ec2", region_name="us-east-1")
sec_group_name = str(uuid4())
@@ -1190,7 +1190,7 @@ def test_run_instance_with_security_group_id():
]
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("hibernate", [True, False])
def test_run_instance_with_additional_args(hibernate):
client = boto3.client("ec2", region_name="us-east-1")
@@ -1213,7 +1213,7 @@ def test_run_instance_with_additional_args(hibernate):
assert instance["HibernationOptions"] == {"Configured": hibernate}
-@mock_ec2
+@mock_aws
def test_run_instance_with_default_placement():
ec2 = boto3.resource("ec2", region_name="us-east-1")
instance = ec2.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)[0]
@@ -1221,7 +1221,7 @@ def test_run_instance_with_default_placement():
assert instance.placement["AvailabilityZone"] == "us-east-1a"
-@mock_ec2
+@mock_aws
@mock.patch(
"moto.ec2.models.instances.settings.EC2_ENABLE_INSTANCE_TYPE_VALIDATION",
new_callable=mock.PropertyMock(return_value=True),
@@ -1248,7 +1248,7 @@ def test_run_instance_with_invalid_instance_type(m_flag):
assert m_flag is True
-@mock_ec2
+@mock_aws
def test_run_instance_with_availability_zone_not_from_region():
ec2 = boto3.resource("ec2", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -1267,7 +1267,7 @@ def test_run_instance_with_availability_zone_not_from_region():
)
-@mock_ec2
+@mock_aws
def test_run_instance_with_subnet():
client = boto3.client("ec2", region_name="eu-central-1")
@@ -1302,7 +1302,7 @@ def test_run_instance_with_subnet():
assert priv_ipv4 in subnet_cidr
-@mock_ec2
+@mock_aws
def test_run_instance_with_specified_private_ipv4():
client = boto3.client("ec2", region_name="eu-central-1")
@@ -1332,7 +1332,7 @@ def test_run_instance_with_specified_private_ipv4():
assert instance["PrivateIpAddress"] == "192.168.42.5"
-@mock_ec2
+@mock_aws
def test_run_instance_with_placement():
client = boto3.client("ec2", region_name="eu-central-1")
host_id = "h-asdfasdfasdf"
@@ -1349,7 +1349,7 @@ def test_run_instance_with_placement():
assert resp["Placement"]["HostId"] == host_id
-@mock_ec2
+@mock_aws
def test_run_instance_mapped_public_ipv4():
client = boto3.client("ec2", region_name="eu-central-1")
@@ -1380,7 +1380,7 @@ def test_run_instance_mapped_public_ipv4():
assert len(instance["PublicIpAddress"]) > 0
-@mock_ec2
+@mock_aws
def test_run_instance_with_nic_autocreated():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -1432,7 +1432,7 @@ def test_run_instance_with_nic_autocreated():
assert eni["PrivateIpAddresses"][0]["PrivateIpAddress"] == private_ip
-@mock_ec2
+@mock_aws
def test_run_instance_with_nic_preexisting():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -1483,7 +1483,7 @@ def test_run_instance_with_nic_preexisting():
assert instance_eni["PrivateIpAddresses"][0]["PrivateIpAddress"] == private_ip
-@mock_ec2
+@mock_aws
def test_run_instance_with_new_nic_and_security_groups():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -1524,7 +1524,7 @@ def test_run_instance_with_new_nic_and_security_groups():
}
-@mock_ec2
+@mock_aws
def test_instance_with_nic_attach_detach():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -1624,7 +1624,7 @@ def test_instance_with_nic_attach_detach():
assert ex.value.response["Error"]["Code"] == "InvalidAttachmentID.NotFound"
-@mock_ec2
+@mock_aws
def test_ec2_classic_has_public_ip_address():
ec2 = boto3.resource("ec2", region_name="us-east-1")
instance = ec2.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)[0]
@@ -1634,7 +1634,7 @@ def test_ec2_classic_has_public_ip_address():
assert instance.private_ip_address.replace(".", "-") in instance.private_dns_name
-@mock_ec2
+@mock_aws
def test_run_instance_with_keypair():
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -1645,7 +1645,7 @@ def test_run_instance_with_keypair():
assert instance.key_name == "keypair_name"
-@mock_ec2
+@mock_aws
def test_describe_instances_with_keypair_filter():
ec2 = boto3.resource("ec2", region_name="us-east-1")
for i in range(3):
@@ -1664,7 +1664,7 @@ def test_describe_instances_with_keypair_filter():
assert len(instances_found) == expected_instance_count
-@mock_ec2
+@mock_aws
@mock.patch(
"moto.ec2.models.instances.settings.ENABLE_KEYPAIR_VALIDATION",
new_callable=mock.PropertyMock(return_value=True),
@@ -1688,7 +1688,7 @@ def test_run_instance_with_invalid_keypair(m_flag):
assert m_flag is True
-@mock_ec2
+@mock_aws
def test_run_instance_with_block_device_mappings():
ec2_client = boto3.client("ec2", region_name="us-east-1")
@@ -1712,7 +1712,7 @@ def test_run_instance_with_block_device_mappings():
assert volumes["Volumes"][0]["Size"] == 50
-@mock_ec2
+@mock_aws
def test_run_instance_with_block_device_mappings_missing_ebs():
ec2_client = boto3.client("ec2", region_name="us-east-1")
@@ -1735,7 +1735,7 @@ def test_run_instance_with_block_device_mappings_missing_ebs():
)
-@mock_ec2
+@mock_aws
def test_run_instance_with_block_device_mappings_using_no_device():
ec2_client = boto3.client("ec2", region_name="us-east-1")
@@ -1775,7 +1775,7 @@ def test_run_instance_with_block_device_mappings_using_no_device():
assert ex.value.response["Error"]["Message"] == "The request received was invalid"
-@mock_ec2
+@mock_aws
def test_run_instance_with_block_device_mappings_missing_size():
ec2_client = boto3.client("ec2", region_name="us-east-1")
@@ -1800,7 +1800,7 @@ def test_run_instance_with_block_device_mappings_missing_size():
)
-@mock_ec2
+@mock_aws
def test_run_instance_with_block_device_mappings_from_snapshot():
ec2_client = boto3.client("ec2", region_name="us-east-1")
ec2_resource = boto3.resource("ec2", region_name="us-east-1")
@@ -1837,7 +1837,7 @@ def test_run_instance_with_block_device_mappings_from_snapshot():
assert volumes["Volumes"][0]["SnapshotId"] == snapshot.snapshot_id
-@mock_ec2
+@mock_aws
def test_describe_instance_status_no_instances():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode is not guaranteed to be empty")
@@ -1846,7 +1846,7 @@ def test_describe_instance_status_no_instances():
assert len(all_status) == 0
-@mock_ec2
+@mock_aws
def test_describe_instance_status_with_instances():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -1861,7 +1861,7 @@ def test_describe_instance_status_with_instances():
assert my_status["SystemStatus"]["Status"] == "ok"
-@mock_ec2
+@mock_aws
def test_describe_instance_status_with_instance_filter_deprecated():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -1886,7 +1886,7 @@ def test_describe_instance_status_with_instance_filter_deprecated():
assert ex.value.response["Error"]["Code"] == "InvalidInstanceID.NotFound"
-@mock_ec2
+@mock_aws
def test_describe_instance_credit_specifications():
conn = boto3.client("ec2", region_name="us-west-1")
@@ -1901,7 +1901,7 @@ def test_describe_instance_credit_specifications():
)
-@mock_ec2
+@mock_aws
def test_describe_instance_status_with_instance_filter():
conn = boto3.client("ec2", region_name="us-west-1")
@@ -1984,7 +1984,7 @@ def test_describe_instance_status_with_instance_filter():
assert _id not in found_instance_ids
-@mock_ec2
+@mock_aws
def test_describe_instance_status_with_non_running_instances():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -2018,7 +2018,7 @@ def test_describe_instance_status_with_non_running_instances():
assert status3["InstanceState"] == {"Code": 16, "Name": "running"}
-@mock_ec2
+@mock_aws
def test_get_instance_by_security_group():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -2051,7 +2051,7 @@ def test_get_instance_by_security_group():
assert security_group_instances == [{"GroupId": security_group.id}]
-@mock_ec2
+@mock_aws
def test_modify_delete_on_termination():
ec2_client = boto3.resource("ec2", region_name="us-west-1")
result = ec2_client.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1)
@@ -2067,7 +2067,7 @@ def test_modify_delete_on_termination():
assert instance.block_device_mappings[0]["Ebs"]["DeleteOnTermination"] is False
-@mock_ec2
+@mock_aws
def test_create_instance_with_default_options():
client = boto3.client("ec2", region_name="eu-west-1")
@@ -2083,7 +2083,7 @@ def test_create_instance_with_default_options():
assert_instance(resp["Reservations"][0]["Instances"][0])
-@mock_ec2
+@mock_aws
def test_create_instance_ebs_optimized():
ec2_resource = boto3.resource("ec2", region_name="eu-west-1")
@@ -2104,7 +2104,7 @@ def test_create_instance_ebs_optimized():
assert instance.ebs_optimized is False
-@mock_ec2
+@mock_aws
def test_run_multiple_instances_in_same_command():
instance_count = 4
client = boto3.client("ec2", region_name="us-east-1")
@@ -2127,7 +2127,7 @@ def test_run_multiple_instances_in_same_command():
assert instances[i]["AmiLaunchIndex"] == i
-@mock_ec2
+@mock_aws
def test_describe_instance_attribute():
client = boto3.client("ec2", region_name="us-east-1")
security_group_id = client.create_security_group(
@@ -2188,7 +2188,7 @@ def test_describe_instance_attribute():
assert ex.value.response["Error"]["Message"] == message
-@mock_ec2
+@mock_aws
def test_warn_on_invalid_ami():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't capture warnings in server mode.")
@@ -2200,7 +2200,7 @@ def test_warn_on_invalid_ami():
ec2.create_instances(ImageId="invalid-ami", MinCount=1, MaxCount=1)
-@mock_ec2
+@mock_aws
@mock.patch(
"moto.ec2.models.instances.settings.ENABLE_AMI_VALIDATION",
new_callable=mock.PropertyMock(return_value=True),
@@ -2221,7 +2221,7 @@ def test_error_on_invalid_ami(m_flag):
assert m_flag is True
-@mock_ec2
+@mock_aws
@mock.patch(
"moto.ec2.models.instances.settings.ENABLE_AMI_VALIDATION",
new_callable=mock.PropertyMock(return_value=True),
@@ -2244,7 +2244,7 @@ def test_error_on_invalid_ami_format(m_flag):
assert m_flag is True
-@mock_ec2
+@mock_aws
def test_filter_wildcard_in_specified_tag_only():
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -2274,7 +2274,7 @@ def test_filter_wildcard_in_specified_tag_only():
assert instances[0]["Tags"][0]["Key"] == "Name"
-@mock_ec2
+@mock_aws
def test_instance_termination_protection():
client = boto3.client("ec2", region_name="us-west-1")
@@ -2308,7 +2308,7 @@ def test_instance_termination_protection():
assert instance["State"]["Name"] == "terminated"
-@mock_ec2
+@mock_aws
def test_terminate_unknown_instances():
client = boto3.client("ec2", region_name="us-west-1")
@@ -2343,7 +2343,7 @@ def test_terminate_unknown_instances():
assert instance["State"]["Name"] == "running"
-@mock_ec2
+@mock_aws
def test_instance_lifecycle():
ec2_resource = boto3.resource("ec2", "us-west-1")
@@ -2366,7 +2366,7 @@ def test_instance_lifecycle():
# The default AMIs are not loaded for our test case, to speed things up
# But we do need it for this specific test
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"launch_template_kind", ("LaunchTemplateId", "LaunchTemplateName")
)
@@ -2396,7 +2396,7 @@ def test_create_instance_with_launch_template_id_produces_no_warning(
assert all(["Could not find AMI" not in msg for msg in messages])
-@mock_ec2
+@mock_aws
def test_create_instance_from_launch_template__process_tags():
client = boto3.client("ec2", region_name="us-west-1")
@@ -2419,7 +2419,7 @@ def test_create_instance_from_launch_template__process_tags():
assert instance["Tags"] == [{"Key": "k", "Value": "v"}]
-@mock_ec2
+@mock_aws
def test_run_instance_and_associate_public_ip():
ec2 = boto3.resource("ec2", "us-west-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -2472,7 +2472,7 @@ def test_run_instance_and_associate_public_ip():
assert "PublicIp" in addresses["Association"]
-@mock_ec2
+@mock_aws
def test_run_instance_cannot_have_subnet_and_networkinterface_parameter():
ec2 = boto3.resource("ec2", "us-west-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -2494,7 +2494,7 @@ def test_run_instance_cannot_have_subnet_and_networkinterface_parameter():
)
-@mock_ec2
+@mock_aws
def test_run_instance_in_subnet_with_nic_private_ip():
vpc_cidr_block = "10.26.0.0/16"
subnet_cidr_block = "10.26.1.0/24"
@@ -2520,7 +2520,7 @@ def test_run_instance_in_subnet_with_nic_private_ip():
assert "Association" not in address
-@mock_ec2
+@mock_aws
def test_run_instance_in_subnet_with_nic_private_ip_and_public_association():
vpc_cidr_block = "10.26.0.0/16"
subnet_cidr_block = "10.26.1.0/24"
@@ -2551,7 +2551,7 @@ def test_run_instance_in_subnet_with_nic_private_ip_and_public_association():
assert address["Association"]["IpOwnerId"] == ACCOUNT_ID
-@mock_ec2
+@mock_aws
def test_describe_instances_dryrun():
client = boto3.client("ec2", region_name="us-east-1")
@@ -2565,7 +2565,7 @@ def test_describe_instances_dryrun():
)
-@mock_ec2
+@mock_aws
def test_describe_instances_filter_vpcid_via_networkinterface():
vpc_cidr_block = "10.26.0.0/16"
subnet_cidr_block = "10.26.1.0/24"
@@ -2589,8 +2589,7 @@ def test_describe_instances_filter_vpcid_via_networkinterface():
assert found == [instance]
-@mock_ec2
-@mock_iam
+@mock_aws
def test_instance_iam_instance_profile():
ec2_resource = boto3.resource("ec2", "us-west-1")
iam = boto3.client("iam", "us-west-1")
@@ -2661,7 +2660,7 @@ def retrieve_all_instances(client, filters=[]): # pylint: disable=W0102
return [i for r in reservations for i in r["Instances"]]
-@mock_ec2
+@mock_aws
def test_run_multiple_instances_with_single_nic_template():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -2717,7 +2716,7 @@ def test_run_multiple_instances_with_single_nic_template():
assert instance_0_ip != instance_1_ip
-@mock_ec2
+@mock_aws
def test_describe_instance_without_enhanced_monitoring():
conn = boto3.client("ec2", region_name="us-west-1")
@@ -2733,7 +2732,7 @@ def test_describe_instance_without_enhanced_monitoring():
assert result[0]["Monitoring"] == {"State": "enabled"}
-@mock_ec2
+@mock_aws
def test_describe_instance_with_enhanced_monitoring():
conn = boto3.client("ec2", region_name="us-west-1")
diff --git a/tests/test_ec2/test_internet_gateways.py b/tests/test_ec2/test_internet_gateways.py
index 454e58722..d9a70495d 100644
--- a/tests/test_ec2/test_internet_gateways.py
+++ b/tests/test_ec2/test_internet_gateways.py
@@ -4,14 +4,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
VPC_CIDR = "10.0.0.0/16"
BAD_VPC = "vpc-deadbeef"
BAD_IGW = "igw-deadbeef"
-@mock_ec2
+@mock_aws
def test_igw_create_boto3():
"""internet gateway create"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -35,7 +35,7 @@ def test_igw_create_boto3():
assert len(igw["Attachments"]) == 0
-@mock_ec2
+@mock_aws
def test_igw_attach_boto3():
"""internet gateway attach"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -61,7 +61,7 @@ def test_igw_attach_boto3():
assert igw["Attachments"] == [{"State": "available", "VpcId": vpc.id}]
-@mock_ec2
+@mock_aws
def test_igw_attach_bad_vpc_boto3():
"""internet gateway fail to attach w/ bad vpc"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -74,7 +74,7 @@ def test_igw_attach_bad_vpc_boto3():
assert ex.value.response["Error"]["Code"] == "InvalidVpcID.NotFound"
-@mock_ec2
+@mock_aws
def test_igw_attach_twice_boto3():
"""internet gateway fail to attach twice"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -91,7 +91,7 @@ def test_igw_attach_twice_boto3():
assert ex.value.response["Error"]["Code"] == "Resource.AlreadyAssociated"
-@mock_ec2
+@mock_aws
def test_igw_detach_boto3():
"""internet gateway detach"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -118,7 +118,7 @@ def test_igw_detach_boto3():
assert len(igw["Attachments"]) == 0
-@mock_ec2
+@mock_aws
def test_igw_detach_wrong_vpc_boto3():
"""internet gateway fail to detach w/ wrong vpc"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -135,7 +135,7 @@ def test_igw_detach_wrong_vpc_boto3():
assert ex.value.response["Error"]["Code"] == "Gateway.NotAttached"
-@mock_ec2
+@mock_aws
def test_igw_detach_invalid_vpc_boto3():
"""internet gateway fail to detach w/ invalid vpc"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -151,7 +151,7 @@ def test_igw_detach_invalid_vpc_boto3():
assert ex.value.response["Error"]["Code"] == "Gateway.NotAttached"
-@mock_ec2
+@mock_aws
def test_igw_detach_unattached_boto3():
"""internet gateway fail to detach unattached"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -166,7 +166,7 @@ def test_igw_detach_unattached_boto3():
assert ex.value.response["Error"]["Code"] == "Gateway.NotAttached"
-@mock_ec2
+@mock_aws
def test_igw_delete_boto3():
"""internet gateway delete"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -189,7 +189,7 @@ def test_igw_delete_boto3():
assert igw.id not in [i["InternetGatewayId"] for i in (retrieve_all(client))]
-@mock_ec2
+@mock_aws
def test_igw_delete_attached_boto3():
"""internet gateway fail to delete attached"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -205,7 +205,7 @@ def test_igw_delete_attached_boto3():
assert ex.value.response["Error"]["Code"] == "DependencyViolation"
-@mock_ec2
+@mock_aws
def test_igw_describe_boto3():
"""internet gateway fetch by id"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -217,7 +217,7 @@ def test_igw_describe_boto3():
assert igw.id == igw_by_search["InternetGatewayId"]
-@mock_ec2
+@mock_aws
def test_igw_describe_bad_id_boto3():
"""internet gateway fail to fetch by bad id"""
client = boto3.client("ec2", "us-west-1")
@@ -228,7 +228,7 @@ def test_igw_describe_bad_id_boto3():
assert ex.value.response["Error"]["Code"] == "InvalidInternetGatewayID.NotFound"
-@mock_ec2
+@mock_aws
def test_igw_filter_by_vpc_id_boto3():
"""internet gateway filter by vpc id"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -246,7 +246,7 @@ def test_igw_filter_by_vpc_id_boto3():
assert result["InternetGateways"][0]["InternetGatewayId"] == igw1.id
-@mock_ec2
+@mock_aws
def test_igw_filter_by_tags_boto3():
"""internet gateway filter by vpc id"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -262,7 +262,7 @@ def test_igw_filter_by_tags_boto3():
assert result[0]["InternetGatewayId"] == igw1.id
-@mock_ec2
+@mock_aws
def test_igw_filter_by_internet_gateway_id_boto3():
"""internet gateway filter by internet gateway id"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -278,7 +278,7 @@ def test_igw_filter_by_internet_gateway_id_boto3():
assert result["InternetGateways"][0]["InternetGatewayId"] == igw1.id
-@mock_ec2
+@mock_aws
def test_igw_filter_by_attachment_state_boto3():
"""internet gateway filter by attachment state"""
ec2 = boto3.resource("ec2", "us-west-1")
@@ -295,7 +295,7 @@ def test_igw_filter_by_attachment_state_boto3():
assert igw2.id not in all_ids
-@mock_ec2
+@mock_aws
def test_create_internet_gateway_with_tags():
ec2 = boto3.resource("ec2", region_name="eu-central-1")
diff --git a/tests/test_ec2/test_key_pairs.py b/tests/test_ec2/test_key_pairs.py
index 37988acdb..abd2e6e23 100644
--- a/tests/test_ec2/test_key_pairs.py
+++ b/tests/test_ec2/test_key_pairs.py
@@ -6,7 +6,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from .helpers import check_private_key
@@ -50,7 +50,7 @@ ffsm7UIHtCBYERr9Nx0u20ldfhkgB1lhaJb5o0ZJ3pmJ38KChfyHe5EUcqRdEFo89Mp72VI2Z6UHyL17
moto@github.com"""
-@mock_ec2
+@mock_aws
def test_key_pairs_empty_boto3():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode is not guaranteed to be empty")
@@ -58,7 +58,7 @@ def test_key_pairs_empty_boto3():
assert client.describe_key_pairs()["KeyPairs"] == []
-@mock_ec2
+@mock_aws
def test_key_pairs_invalid_id_boto3():
client = boto3.client("ec2", "us-west-1")
@@ -69,7 +69,7 @@ def test_key_pairs_invalid_id_boto3():
assert ex.value.response["Error"]["Code"] == "InvalidKeyPair.NotFound"
-@mock_ec2
+@mock_aws
def test_key_pairs_create_dryrun_boto3():
ec2 = boto3.resource("ec2", "us-west-1")
@@ -83,7 +83,7 @@ def test_key_pairs_create_dryrun_boto3():
)
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("key_type", ["rsa", "ed25519"])
def test_key_pairs_create_boto3(key_type):
ec2 = boto3.resource("ec2", "us-west-1")
@@ -112,7 +112,7 @@ def test_key_pairs_create_boto3(key_type):
assert isinstance(kps[0]["CreateTime"], datetime)
-@mock_ec2
+@mock_aws
def test_key_pairs_create_exist_boto3():
client = boto3.client("ec2", "us-west-1")
key_name = str(uuid4())[0:6]
@@ -125,13 +125,13 @@ def test_key_pairs_create_exist_boto3():
assert ex.value.response["Error"]["Code"] == "InvalidKeyPair.Duplicate"
-@mock_ec2
+@mock_aws
def test_key_pairs_delete_no_exist_boto3():
client = boto3.client("ec2", "us-west-1")
client.delete_key_pair(KeyName=str(uuid4())[0:6])
-@mock_ec2
+@mock_aws
def test_key_pairs_delete_exist_boto3():
client = boto3.client("ec2", "us-west-1")
key_name = str(uuid4())[0:6]
@@ -152,7 +152,7 @@ def test_key_pairs_delete_exist_boto3():
]
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"public_key,fingerprint",
[
@@ -188,7 +188,7 @@ def test_key_pairs_import_boto3(public_key, fingerprint):
assert kp1["KeyName"] in all_names
-@mock_ec2
+@mock_aws
def test_key_pairs_import_exist_boto3():
client = boto3.client("ec2", "us-west-1")
@@ -207,7 +207,7 @@ def test_key_pairs_import_exist_boto3():
assert ex.value.response["Error"]["Code"] == "InvalidKeyPair.Duplicate"
-@mock_ec2
+@mock_aws
def test_key_pairs_invalid_boto3():
client = boto3.client("ec2", "us-west-1")
@@ -233,7 +233,7 @@ def test_key_pairs_invalid_boto3():
assert err["Message"] == "Key is not in valid OpenSSH public key format"
-@mock_ec2
+@mock_aws
def test_key_pair_filters_boto3():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -256,7 +256,7 @@ def test_key_pair_filters_boto3():
assert set([kp["KeyName"] for kp in kp_by_name]) == set([kp3.name])
-@mock_ec2
+@mock_aws
def test_key_pair_with_tags():
client = boto3.client("ec2", "us-east-1")
diff --git a/tests/test_ec2/test_launch_templates.py b/tests/test_ec2/test_launch_templates.py
index 44cdee397..3b8eeee18 100644
--- a/tests/test_ec2/test_launch_templates.py
+++ b/tests/test_ec2/test_launch_templates.py
@@ -4,11 +4,11 @@ import boto3
import pytest
from botocore.client import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from tests import EXAMPLE_AMI_ID
-@mock_ec2
+@mock_aws
def test_launch_template_create():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -51,7 +51,7 @@ def test_launch_template_create():
)
-@mock_ec2
+@mock_aws
def test_create_launch_template__dryrun():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -74,7 +74,7 @@ def test_create_launch_template__dryrun():
)
-@mock_ec2
+@mock_aws
def test_describe_launch_template_versions():
template_data = {
"ImageId": "ami-abc123",
@@ -126,7 +126,7 @@ def test_describe_launch_template_versions():
assert templ == template_data
-@mock_ec2
+@mock_aws
def test_describe_launch_template_versions_by_name_when_absent():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -148,7 +148,7 @@ def test_describe_launch_template_versions_by_name_when_absent():
assert resp["LaunchTemplateVersions"] == []
-@mock_ec2
+@mock_aws
def test_create_launch_template_version():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -173,7 +173,7 @@ def test_create_launch_template_version():
assert version["VersionNumber"] == 2
-@mock_ec2
+@mock_aws
def test_create_launch_template_version__dryrun():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -197,7 +197,7 @@ def test_create_launch_template_version__dryrun():
)
-@mock_ec2
+@mock_aws
def test_create_launch_template_version_by_id():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -222,7 +222,7 @@ def test_create_launch_template_version_by_id():
assert version["VersionNumber"] == 2
-@mock_ec2
+@mock_aws
def test_describe_launch_template_versions_with_multiple_versions():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -250,7 +250,7 @@ def test_describe_launch_template_versions_with_multiple_versions():
)
-@mock_ec2
+@mock_aws
def test_describe_launch_template_versions_with_versions_option():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -286,7 +286,7 @@ def test_describe_launch_template_versions_with_versions_option():
)
-@mock_ec2
+@mock_aws
def test_describe_launch_template_versions_with_min():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -322,7 +322,7 @@ def test_describe_launch_template_versions_with_min():
)
-@mock_ec2
+@mock_aws
def test_describe_launch_template_versions_with_max():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -358,7 +358,7 @@ def test_describe_launch_template_versions_with_max():
)
-@mock_ec2
+@mock_aws
def test_describe_launch_template_versions_with_min_and_max():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -400,7 +400,7 @@ def test_describe_launch_template_versions_with_min_and_max():
)
-@mock_ec2
+@mock_aws
def test_describe_launch_templates_with_non_existent_name():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -415,7 +415,7 @@ def test_describe_launch_templates_with_non_existent_name():
)
-@mock_ec2
+@mock_aws
def test_describe_launch_templates():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -458,7 +458,7 @@ def test_describe_launch_templates():
assert resp["LaunchTemplates"][1]["LaunchTemplateName"] == template_name2
-@mock_ec2
+@mock_aws
def test_describe_launch_templates_with_filters():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -496,7 +496,7 @@ def test_describe_launch_templates_with_filters():
assert resp["LaunchTemplates"][0]["LaunchTemplateName"] == template_name_no_tags
-@mock_ec2
+@mock_aws
def test_create_launch_template_with_tag_spec():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -522,7 +522,7 @@ def test_create_launch_template_with_tag_spec():
}
-@mock_ec2
+@mock_aws
def test_get_launch_template_data():
client = boto3.client("ec2", region_name="us-east-1")
@@ -544,7 +544,7 @@ def test_get_launch_template_data():
)
-@mock_ec2
+@mock_aws
def test_delete_launch_template__dryrun():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -586,7 +586,7 @@ def test_delete_launch_template__dryrun():
)
-@mock_ec2
+@mock_aws
def test_delete_launch_template__by_name():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -624,7 +624,7 @@ def test_delete_launch_template__by_name():
)
-@mock_ec2
+@mock_aws
def test_delete_launch_template__by_id():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -681,7 +681,7 @@ def retrieve_all_templates(client, filters=[]): # pylint: disable=W0102
return all_templates
-@mock_ec2
+@mock_aws
def test_launch_template_create_with_tags():
cli = boto3.client("ec2", region_name="us-east-1")
@@ -714,7 +714,7 @@ def test_launch_template_create_with_tags():
assert lt["Tags"][0] == {"Key": "test1", "Value": "value1"}
-@mock_ec2
+@mock_aws
def test_launch_template_describe_with_tags():
cli = boto3.client("ec2", region_name="us-east-1")
diff --git a/tests/test_ec2/test_launch_templates_cloudformation.py b/tests/test_ec2/test_launch_templates_cloudformation.py
index b80361671..1d4e04acf 100644
--- a/tests/test_ec2/test_launch_templates_cloudformation.py
+++ b/tests/test_ec2/test_launch_templates_cloudformation.py
@@ -3,13 +3,11 @@ from uuid import uuid4
import boto3
-from moto import mock_autoscaling, mock_cloudformation, mock_ec2
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID, EXAMPLE_AMI_ID2
-@mock_autoscaling
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_asg_with_latest_launch_template_version():
cf_client = boto3.client("cloudformation", region_name="us-west-1")
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -127,9 +125,7 @@ def test_asg_with_latest_launch_template_version():
assert autoscaling_group["LaunchTemplate"]["Version"] == "2"
-@mock_autoscaling
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_asg_with_default_launch_template_version():
cf_client = boto3.client("cloudformation", region_name="us-west-1")
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -247,9 +243,7 @@ def test_asg_with_default_launch_template_version():
assert autoscaling_group["LaunchTemplate"]["Version"] == "1"
-@mock_autoscaling
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_two_launch_templates():
cf_client = boto3.client("cloudformation", region_name="us-west-1")
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -299,9 +293,7 @@ def test_two_launch_templates():
)
-@mock_autoscaling
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_launch_template_unnamed_update():
cf_client = boto3.client("cloudformation", region_name="us-west-1")
ec2_client = boto3.client("ec2", region_name="us-west-1")
diff --git a/tests/test_ec2/test_nat_gateway.py b/tests/test_ec2/test_nat_gateway.py
index 4bb050377..c0d17c36d 100644
--- a/tests/test_ec2/test_nat_gateway.py
+++ b/tests/test_ec2/test_nat_gateway.py
@@ -2,10 +2,10 @@ from unittest import SkipTest
import boto3
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
-@mock_ec2
+@mock_aws
def test_describe_nat_gateways():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode is not guaranteed to have no resources")
@@ -16,7 +16,7 @@ def test_describe_nat_gateways():
assert len(response["NatGateways"]) == 0
-@mock_ec2
+@mock_aws
def test_create_nat_gateway():
conn = boto3.client("ec2", "us-east-1")
vpc = conn.create_vpc(CidrBlock="10.0.0.0/16")
@@ -34,7 +34,7 @@ def test_create_nat_gateway():
assert response["NatGateway"]["State"] == "available"
-@mock_ec2
+@mock_aws
def test_describe_nat_gateway_tags():
conn = boto3.client("ec2", "us-east-1")
vpc = conn.create_vpc(CidrBlock="10.0.0.0/16")
@@ -71,7 +71,7 @@ def test_describe_nat_gateway_tags():
]
-@mock_ec2
+@mock_aws
def test_delete_nat_gateway():
conn = boto3.client("ec2", "us-east-1")
vpc = conn.create_vpc(CidrBlock="10.0.0.0/16")
@@ -100,7 +100,7 @@ def test_delete_nat_gateway():
}
-@mock_ec2
+@mock_aws
def test_create_and_describe_nat_gateway():
conn = boto3.client("ec2", "us-east-1")
vpc = conn.create_vpc(CidrBlock="10.0.0.0/16")
@@ -138,7 +138,7 @@ def test_create_and_describe_nat_gateway():
assert describe[0]["NatGatewayAddresses"][0]["PublicIp"] == public_ip
-@mock_ec2
+@mock_aws
def test_describe_nat_gateway_filter_by_net_gateway_id_and_state():
conn = boto3.client("ec2", "us-east-1")
vpc = conn.create_vpc(CidrBlock="10.0.0.0/16")
@@ -180,7 +180,7 @@ def test_describe_nat_gateway_filter_by_net_gateway_id_and_state():
)
-@mock_ec2
+@mock_aws
def test_describe_nat_gateway_filter_by_subnet_id():
conn = boto3.client("ec2", "us-east-1")
vpc = conn.create_vpc(CidrBlock="10.0.0.0/16")
@@ -222,7 +222,7 @@ def test_describe_nat_gateway_filter_by_subnet_id():
)
-@mock_ec2
+@mock_aws
def test_describe_nat_gateway_filter_vpc_id():
conn = boto3.client("ec2", "us-east-1")
vpc_1 = conn.create_vpc(CidrBlock="10.0.0.0/16")
diff --git a/tests/test_ec2/test_network_acls.py b/tests/test_ec2/test_network_acls.py
index 8e2f678f8..f861974f2 100644
--- a/tests/test_ec2/test_network_acls.py
+++ b/tests/test_ec2/test_network_acls.py
@@ -5,11 +5,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as OWNER_ID
-@mock_ec2
+@mock_aws
def test_default_network_acl_created_with_vpc():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -21,7 +21,7 @@ def test_default_network_acl_created_with_vpc():
assert our_acl[0]["IsDefault"] is True
-@mock_ec2
+@mock_aws
def test_network_create_and_list_acls():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -38,7 +38,7 @@ def test_network_create_and_list_acls():
assert acl_found["IsDefault"] is False
-@mock_ec2
+@mock_aws
def test_new_subnet_associates_with_default_network_acl():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode will have conflicting CidrBlocks")
@@ -55,7 +55,7 @@ def test_new_subnet_associates_with_default_network_acl():
assert subnet.id in [a["SubnetId"] for a in acl["Associations"]]
-@mock_ec2
+@mock_aws
def test_network_acl_entries():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -90,7 +90,7 @@ def test_network_acl_entries():
assert entries[0]["CidrBlock"] == "0.0.0.0/0"
-@mock_ec2
+@mock_aws
def test_delete_network_acl_entry():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -119,7 +119,7 @@ def test_delete_network_acl_entry():
assert len(test_network_acl["Entries"]) == 0
-@mock_ec2
+@mock_aws
def test_replace_network_acl_entry():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -159,7 +159,7 @@ def test_replace_network_acl_entry():
assert entries[0]["PortRange"] == {"To": 22, "From": 22}
-@mock_ec2
+@mock_aws
def test_delete_network_acl():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -182,7 +182,7 @@ def test_delete_network_acl():
)
-@mock_ec2
+@mock_aws
def test_network_acl_tagging():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -205,7 +205,7 @@ def test_network_acl_tagging():
assert test_network_acl["Tags"] == [{"Value": "some value", "Key": "a key"}]
-@mock_ec2
+@mock_aws
def test_new_subnet_in_new_vpc_associates_with_default_network_acl():
ec2 = boto3.resource("ec2", region_name="us-west-1")
new_vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -221,7 +221,7 @@ def test_new_subnet_in_new_vpc_associates_with_default_network_acl():
assert new_vpcs_default_network_acl.associations[0]["SubnetId"] == subnet.id
-@mock_ec2
+@mock_aws
def test_default_network_acl_default_entries():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -260,7 +260,7 @@ def test_default_network_acl_default_entries():
assert len(unique_entries) == 4
-@mock_ec2
+@mock_aws
def test_delete_default_network_acl_default_entry():
if settings.TEST_SERVER_MODE:
raise SkipTest(
@@ -281,7 +281,7 @@ def test_delete_default_network_acl_default_entry():
assert len(default_network_acl.entries) == 3
-@mock_ec2
+@mock_aws
def test_duplicate_network_acl_entry():
ec2 = boto3.resource("ec2", region_name="us-west-1")
default_network_acl = next(iter(ec2.network_acls.all()), None)
@@ -311,7 +311,7 @@ def test_duplicate_network_acl_entry():
)
-@mock_ec2
+@mock_aws
def test_describe_network_acls():
conn = boto3.client("ec2", region_name="us-west-2")
@@ -421,7 +421,7 @@ def test_describe_network_acls():
)
-@mock_ec2
+@mock_aws
def test_create_network_acl_with_tags():
conn = boto3.client("ec2", region_name="us-west-2")
diff --git a/tests/test_ec2/test_prefix_lists.py b/tests/test_ec2/test_prefix_lists.py
index 27783f661..8e44252f6 100644
--- a/tests/test_ec2/test_prefix_lists.py
+++ b/tests/test_ec2/test_prefix_lists.py
@@ -1,10 +1,10 @@
import boto3
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_ec2
+@mock_aws
def test_create():
ec2 = boto3.client("ec2", region_name="us-west-1")
prefix_list = ec2.create_managed_prefix_list(
@@ -24,7 +24,7 @@ def test_create():
assert prefix_list["OwnerId"] == ACCOUNT_ID
-@mock_ec2
+@mock_aws
def test_create_with_tags():
ec2 = boto3.client("ec2", region_name="us-west-1")
prefix_list = ec2.create_managed_prefix_list(
@@ -41,7 +41,7 @@ def test_create_with_tags():
assert prefix_list["Tags"] == [{"Key": "key1", "Value": "val1"}]
-@mock_ec2
+@mock_aws
def test_describe_managed_prefix_lists():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -55,7 +55,7 @@ def test_describe_managed_prefix_lists():
assert set([pl["OwnerId"] for pl in all_lists]) == {"aws", ACCOUNT_ID}
-@mock_ec2
+@mock_aws
def test_describe_managed_prefix_lists_with_prefix():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -74,7 +74,7 @@ def test_describe_managed_prefix_lists_with_prefix():
assert lists_by_id[0]["OwnerId"] == "aws"
-@mock_ec2
+@mock_aws
def test_describe_managed_prefix_lists_with_tags():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -99,7 +99,7 @@ def test_describe_managed_prefix_lists_with_tags():
assert untagged_pl_id not in [pl["PrefixListId"] for pl in tagged_lists]
-@mock_ec2
+@mock_aws
def test_get_managed_prefix_list_entries():
ec2 = boto3.client("ec2", region_name="us-west-1")
resp = ec2.create_managed_prefix_list(
@@ -130,7 +130,7 @@ def test_get_managed_prefix_list_entries():
assert {"Cidr": "10.0.0.2", "Description": "entry2"} in entries
-@mock_ec2
+@mock_aws
def test_get_managed_prefix_list_entries_0_entries():
ec2 = boto3.client("ec2", region_name="us-west-1")
resp = ec2.create_managed_prefix_list(
@@ -144,7 +144,7 @@ def test_get_managed_prefix_list_entries_0_entries():
assert entries == []
-@mock_ec2
+@mock_aws
def test_delete_managed_prefix_list():
ec2 = boto3.client("ec2", region_name="us-west-1")
id1 = ec2.create_managed_prefix_list(
@@ -172,7 +172,7 @@ def test_delete_managed_prefix_list():
}
-@mock_ec2
+@mock_aws
def test_describe_prefix_lists():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -189,7 +189,7 @@ def test_describe_prefix_lists():
assert "com.amazonaws" in pl["PrefixListName"]
-@mock_ec2
+@mock_aws
def test_modify_manage_prefix_list():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -228,7 +228,7 @@ def test_modify_manage_prefix_list():
assert {"Cidr": "10.0.0.2", "Description": "entry2"} not in entries
-@mock_ec2
+@mock_aws
def test_modify_manage_prefix_list_add_to_empty_list():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -260,7 +260,7 @@ def test_modify_manage_prefix_list_add_to_empty_list():
assert {"Cidr": "10.0.0.2", "Description": "entry2"} not in entries
-@mock_ec2
+@mock_aws
def test_modify_manage_prefix_list_name_only():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -283,7 +283,7 @@ def test_modify_manage_prefix_list_name_only():
assert described == prefix_list
-@mock_ec2
+@mock_aws
def test_modify_manage_prefix_list_specifying_version():
ec2 = boto3.client("ec2", region_name="us-west-1")
diff --git a/tests/test_ec2/test_regions.py b/tests/test_ec2/test_regions.py
index db8bf37e4..5258e4e69 100644
--- a/tests/test_ec2/test_regions.py
+++ b/tests/test_ec2/test_regions.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_autoscaling, mock_ec2, mock_elb
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID, EXAMPLE_AMI_ID2
from .test_instances import retrieve_all_instances
@@ -15,7 +15,7 @@ def add_servers_to_region_boto3(ami_id, count, region):
return ec2.create_instances(ImageId=ami_id, MinCount=count, MaxCount=count)
-@mock_ec2
+@mock_aws
def test_add_servers_to_a_single_region_boto3():
region = "ap-northeast-1"
id_1 = add_servers_to_region_boto3(EXAMPLE_AMI_ID, 1, region)[0].id
@@ -30,7 +30,7 @@ def test_add_servers_to_a_single_region_boto3():
assert instance2["ImageId"] == EXAMPLE_AMI_ID2
-@mock_ec2
+@mock_aws
def test_add_servers_to_multiple_regions_boto3():
region1 = "us-east-1"
region2 = "ap-northeast-1"
@@ -57,9 +57,7 @@ def test_add_servers_to_multiple_regions_boto3():
assert ap_instance["ImageId"] == EXAMPLE_AMI_ID2
-@mock_autoscaling
-@mock_elb
-@mock_ec2
+@mock_aws
def test_create_autoscaling_group_boto3():
regions = [("us-east-1", "c"), ("ap-northeast-1", "a")]
for region, zone in regions:
@@ -125,7 +123,7 @@ def test_create_autoscaling_group_boto3():
assert group["TerminationPolicies"] == ["OldestInstance", "NewestInstance"]
-@mock_ec2
+@mock_aws
def test_describe_regions_dryrun():
client = boto3.client("ec2", region_name="us-east-1")
@@ -139,7 +137,7 @@ def test_describe_regions_dryrun():
)
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"region_name", ["us-east-1", "us-east-2", "us-west-1", "us-west-2"]
)
diff --git a/tests/test_ec2/test_route_tables.py b/tests/test_ec2/test_route_tables.py
index e2b8b8e75..9a955c946 100644
--- a/tests/test_ec2/test_route_tables.py
+++ b/tests/test_ec2/test_route_tables.py
@@ -4,11 +4,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from tests import EXAMPLE_AMI_ID
-@mock_ec2
+@mock_aws
def test_route_tables_defaults():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -38,7 +38,7 @@ def test_route_tables_defaults():
assert len(all_route_tables) == 0
-@mock_ec2
+@mock_aws
def test_route_tables_additional():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -83,7 +83,7 @@ def test_route_tables_additional():
assert "RequestId" in ex.value.response["ResponseMetadata"]
-@mock_ec2
+@mock_aws
def test_route_tables_filters_standard():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -169,7 +169,7 @@ def test_route_tables_filters_standard():
client.describe_route_tables(Filters=filters)
-@mock_ec2
+@mock_aws
def test_route_tables_filters_associations():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -217,7 +217,7 @@ def test_route_tables_filters_associations():
assert len(subnet_route_tables[0]["Associations"]) == 2
-@mock_ec2
+@mock_aws
def test_route_tables_filters_vpc_peering_connection():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -269,7 +269,7 @@ def test_route_tables_filters_vpc_peering_connection():
all(vpc_pcx_id == vpc_pcx.id for vpc_pcx_id in vpc_pcx_ids)
-@mock_ec2
+@mock_aws
def test_route_table_associations():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -340,7 +340,7 @@ def test_route_table_associations():
assert ex.value.response["Error"]["Code"] == "InvalidRouteTableID.NotFound"
-@mock_ec2
+@mock_aws
def test_route_table_replace_route_table_association():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -430,7 +430,7 @@ def test_route_table_replace_route_table_association():
assert ex.value.response["Error"]["Code"] == "InvalidRouteTableID.NotFound"
-@mock_ec2
+@mock_aws
def test_route_table_replace_route_table_association_for_main():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -477,7 +477,7 @@ def test_route_table_replace_route_table_association_for_main():
assert new_route_table["Associations"][0]["Main"] is True
-@mock_ec2
+@mock_aws
def test_route_table_get_by_tag():
ec2 = boto3.resource("ec2", region_name="eu-central-1")
@@ -497,7 +497,7 @@ def test_route_table_get_by_tag():
assert route_tables[0].tags[0] == {"Key": "Name", "Value": tag_value}
-@mock_ec2
+@mock_aws
def test_routes_additional():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -550,7 +550,7 @@ def test_routes_additional():
assert ex.value.response["Error"]["Code"] == "InvalidRoute.NotFound"
-@mock_ec2
+@mock_aws
def test_routes_replace():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -651,7 +651,7 @@ def test_routes_replace():
assert ex.value.response["Error"]["Code"] == "InvalidParameterValue"
-@mock_ec2
+@mock_aws
def test_routes_already_exist():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -703,7 +703,7 @@ def test_routes_already_exist():
)
-@mock_ec2
+@mock_aws
def test_routes_not_supported():
client = boto3.client("ec2", region_name="us-east-1")
main_route_table_id = client.describe_route_tables()["RouteTables"][0][
@@ -724,7 +724,7 @@ def test_routes_not_supported():
assert ex.value.response["Error"]["Code"] == "InvalidNetworkInterfaceID.NotFound"
-@mock_ec2
+@mock_aws
def test_routes_vpc_peering_connection():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -762,7 +762,7 @@ def test_routes_vpc_peering_connection():
assert new_route.destination_cidr_block == ROUTE_CIDR
-@mock_ec2
+@mock_aws
def test_routes_vpn_gateway():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -795,7 +795,7 @@ def test_routes_vpn_gateway():
assert new_route.vpc_peering_connection_id is None
-@mock_ec2
+@mock_aws
def test_network_acl_tagging():
client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -818,7 +818,7 @@ def test_network_acl_tagging():
assert test_route_table["Tags"] == [{"Value": "some value", "Key": "a key"}]
-@mock_ec2
+@mock_aws
def test_create_route_with_invalid_destination_cidr_block_parameter():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -856,7 +856,7 @@ def test_create_route_with_invalid_destination_cidr_block_parameter():
assert new_routes[0].route_table_id is not None
-@mock_ec2
+@mock_aws
def test_create_route_with_network_interface_id():
ec2 = boto3.resource("ec2", region_name="us-west-2")
ec2_client = boto3.client("ec2", region_name="us-west-2")
@@ -882,7 +882,7 @@ def test_create_route_with_network_interface_id():
assert route["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_ec2
+@mock_aws
def test_describe_route_tables_with_nat_gateway():
ec2 = boto3.client("ec2", region_name="us-west-1")
vpc_id = ec2.create_vpc(CidrBlock="192.168.0.0/23")["Vpc"]["VpcId"]
@@ -919,7 +919,7 @@ def test_describe_route_tables_with_nat_gateway():
assert nat_gw_routes[0]["State"] == "active"
-@mock_ec2
+@mock_aws
def test_create_vpc_end_point():
ec2 = boto3.client("ec2", region_name="us-west-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -972,7 +972,7 @@ def test_create_vpc_end_point():
assert len(vpc_end_point["VpcEndpoint"]["DnsEntries"]) > 0
-@mock_ec2
+@mock_aws
def test_create_route_tables_with_tags():
ec2 = boto3.resource("ec2", region_name="eu-central-1")
@@ -991,7 +991,7 @@ def test_create_route_tables_with_tags():
assert len(route_table.tags) == 1
-@mock_ec2
+@mock_aws
def test_create_route_with_egress_only_igw():
ec2 = boto3.resource("ec2", region_name="eu-central-1")
ec2_client = boto3.client("ec2", region_name="eu-central-1")
@@ -1018,7 +1018,7 @@ def test_create_route_with_egress_only_igw():
assert eigw_route.get("State") == "active"
-@mock_ec2
+@mock_aws
def test_create_route_with_unknown_egress_only_igw():
ec2 = boto3.resource("ec2", region_name="eu-central-1")
ec2_client = boto3.client("ec2", region_name="eu-central-1")
@@ -1039,7 +1039,7 @@ def test_create_route_with_unknown_egress_only_igw():
assert err["Message"] == "The eigw ID 'eoigw' does not exist"
-@mock_ec2
+@mock_aws
def test_create_route_with_vpc_endpoint():
# Setup
_, ec2_client, route_table, vpc = setup_vpc()
@@ -1066,7 +1066,7 @@ def test_create_route_with_vpc_endpoint():
assert new_route["GatewayId"] == vpce_id
-@mock_ec2
+@mock_aws
def test_create_route_with_invalid_vpc_endpoint():
# Setup
_, ec2_client, route_table, vpc = setup_vpc()
@@ -1095,7 +1095,7 @@ def test_create_route_with_invalid_vpc_endpoint():
)
-@mock_ec2
+@mock_aws
def test_associate_route_table_by_gateway():
ec2 = boto3.client("ec2", region_name="us-west-1")
vpc_id = ec2.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]["VpcId"]
@@ -1118,7 +1118,7 @@ def test_associate_route_table_by_gateway():
assert "SubnetId" not in verify[0]["Associations"][0]
-@mock_ec2
+@mock_aws
def test_associate_route_table_by_subnet():
ec2 = boto3.client("ec2", region_name="us-west-1")
vpc_id = ec2.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]["VpcId"]
diff --git a/tests/test_ec2/test_security_groups.py b/tests/test_ec2/test_security_groups.py
index 3587912c6..d826c1578 100644
--- a/tests/test_ec2/test_security_groups.py
+++ b/tests/test_ec2/test_security_groups.py
@@ -9,12 +9,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID
from moto.ec2 import ec2_backends
-@mock_ec2
+@mock_aws
def test_create_and_describe_security_group():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -49,7 +49,7 @@ def test_create_and_describe_security_group():
assert sec_name in group_names
-@mock_ec2
+@mock_aws
def test_create_security_group_without_description_raises_error():
ec2 = boto3.resource("ec2", "us-west-1")
@@ -60,14 +60,14 @@ def test_create_security_group_without_description_raises_error():
assert ex.value.response["Error"]["Code"] == "MissingParameter"
-@mock_ec2
+@mock_aws
def test_default_security_group():
client = boto3.client("ec2", "us-west-1")
groups = retrieve_all_sgs(client)
assert "default" in [g["GroupName"] for g in groups]
-@mock_ec2
+@mock_aws
def test_create_and_describe_vpc_security_group():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -109,7 +109,7 @@ def test_create_and_describe_vpc_security_group():
assert all_groups[0]["GroupName"] == name
-@mock_ec2
+@mock_aws
def test_create_two_security_groups_with_same_name_in_different_vpc():
ec2 = boto3.resource("ec2", "us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -130,7 +130,7 @@ def test_create_two_security_groups_with_same_name_in_different_vpc():
assert name in group_names
-@mock_ec2
+@mock_aws
def test_create_two_security_groups_in_vpc_with_ipv6_enabled():
ec2 = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16", AmazonProvidedIpv6CidrBlock=True)
@@ -143,7 +143,7 @@ def test_create_two_security_groups_in_vpc_with_ipv6_enabled():
assert len(security_group.ip_permissions_egress) == 2
-@mock_ec2
+@mock_aws
def test_deleting_security_groups():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -186,7 +186,7 @@ def test_deleting_security_groups():
assert group1.id not in [g["GroupId"] for g in all_groups]
-@mock_ec2
+@mock_aws
def test_delete_security_group_in_vpc():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -205,7 +205,7 @@ def test_delete_security_group_in_vpc():
assert group.id not in [g["GroupId"] for g in all_groups]
-@mock_ec2
+@mock_aws
def test_authorize_ip_range_and_revoke():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -330,7 +330,7 @@ def test_authorize_ip_range_and_revoke():
assert len(egress_security_group["IpPermissionsEgress"]) == 1
-@mock_ec2
+@mock_aws
def test_authorize_other_group_and_revoke():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -387,7 +387,7 @@ def test_authorize_other_group_and_revoke():
assert len(found_sec_group["IpPermissions"]) == 0
-@mock_ec2
+@mock_aws
def test_authorize_other_group_egress_and_revoke():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -422,7 +422,7 @@ def test_authorize_other_group_egress_and_revoke():
assert len(sg01.ip_permissions_egress) == 1
-@mock_ec2
+@mock_aws
def test_authorize_group_in_vpc():
ec2 = boto3.resource("ec2", "ap-south-1")
client = boto3.client("ec2", region_name="ap-south-1")
@@ -474,7 +474,7 @@ def test_authorize_group_in_vpc():
assert len(found_sec_group["IpPermissions"]) == 0
-@mock_ec2
+@mock_aws
def test_describe_security_groups():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -512,7 +512,7 @@ def test_describe_security_groups():
assert sg2.id in sg_ids
-@mock_ec2
+@mock_aws
def test_authorize_bad_cidr_throws_invalid_parameter_value():
ec2 = boto3.resource("ec2", "us-west-1")
sec_group = ec2.create_security_group(GroupName=str(uuid4()), Description="test")
@@ -531,7 +531,7 @@ def test_authorize_bad_cidr_throws_invalid_parameter_value():
assert ex.value.response["Error"]["Code"] == "InvalidParameterValue"
-@mock_ec2
+@mock_aws
def test_security_group_tag_filtering():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -551,7 +551,7 @@ def test_security_group_tag_filtering():
assert len(groups) == 0
-@mock_ec2
+@mock_aws
def test_authorize_all_protocols_with_no_port_specification():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -569,7 +569,7 @@ def test_authorize_all_protocols_with_no_port_specification():
assert "ToPort" not in permission
-@mock_ec2
+@mock_aws
def test_security_group_rule_tagging():
ec2 = boto3.resource("ec2", "us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -598,7 +598,7 @@ def test_security_group_rule_tagging():
assert response["SecurityGroupRules"][0]["Tags"][0]["Value"] == tag_val
-@mock_ec2
+@mock_aws
def test_create_and_describe_security_grp_rule():
ec2 = boto3.resource("ec2", "us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -624,7 +624,7 @@ def test_create_and_describe_security_grp_rule():
assert "GroupId" in rules[0]
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("use_vpc", [True, False], ids=["Use VPC", "Without VPC"])
def test_sec_group_rule_limit(use_vpc):
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -726,7 +726,7 @@ def test_sec_group_rule_limit(use_vpc):
assert ex.value.response["Error"]["Code"] == "RulesPerSecurityGroupLimitExceeded"
-@mock_ec2
+@mock_aws
def test_add_same_rule_twice_throws_error():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -766,7 +766,7 @@ def test_add_same_rule_twice_throws_error():
assert ex.value.response["Error"]["Code"] == "InvalidPermission.Duplicate"
-@mock_ec2
+@mock_aws
def test_description_in_ip_permissions():
ec2 = boto3.resource("ec2", region_name="us-west-1")
conn = boto3.client("ec2", region_name="us-east-1")
@@ -816,7 +816,7 @@ def test_description_in_ip_permissions():
assert group["IpPermissions"][0]["IpRanges"][0]["CidrIp"] == "1.2.3.4/32"
-@mock_ec2
+@mock_aws
def test_security_group_tagging():
conn = boto3.client("ec2", region_name="us-east-1")
@@ -847,7 +847,7 @@ def test_security_group_tagging():
assert tag["Key"] == "Test"
-@mock_ec2
+@mock_aws
def test_security_group_wildcard_tag_filter():
conn = boto3.client("ec2", region_name="us-east-1")
sg = conn.create_security_group(GroupName=str(uuid4()), Description="Test SG")
@@ -866,7 +866,7 @@ def test_security_group_wildcard_tag_filter():
assert tag["Key"] == "Test"
-@mock_ec2
+@mock_aws
def test_security_group_filter_ip_permission():
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -908,7 +908,7 @@ def retrieve_all_sgs(conn, filters=[]): # pylint: disable=W0102
return all_groups
-@mock_ec2
+@mock_aws
def test_authorize_and_revoke_in_bulk():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -1052,7 +1052,7 @@ def test_authorize_and_revoke_in_bulk():
assert ip_permission not in sg01.ip_permissions_egress
-@mock_ec2
+@mock_aws
def test_security_group_ingress_without_multirule():
ec2 = boto3.resource("ec2", "ca-central-1")
client = boto3.client("ec2", "ca-central-1")
@@ -1073,7 +1073,7 @@ def test_security_group_ingress_without_multirule():
assert ingress[0]["IsEgress"] is False
-@mock_ec2
+@mock_aws
def test_security_group_ingress_without_multirule_after_reload():
ec2 = boto3.resource("ec2", "ca-central-1")
sg = ec2.create_security_group(Description="Test SG", GroupName=str(uuid4()))
@@ -1088,7 +1088,7 @@ def test_security_group_ingress_without_multirule_after_reload():
assert len(sg_after.ip_permissions) == 1
-@mock_ec2
+@mock_aws
def test_get_all_security_groups_filter_with_same_vpc_id():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -1115,7 +1115,7 @@ def test_get_all_security_groups_filter_with_same_vpc_id():
assert ex.value.response["Error"]["Code"] == "InvalidGroup.NotFound"
-@mock_ec2
+@mock_aws
def test_revoke_security_group_egress():
ec2 = boto3.resource("ec2", "us-east-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -1149,7 +1149,7 @@ def test_revoke_security_group_egress():
assert len(sg.ip_permissions_egress) == 0
-@mock_ec2
+@mock_aws
def test_revoke_security_group_egress__without_ipprotocol():
ec2 = boto3.resource("ec2", "eu-west-2")
client = boto3.client("ec2", region_name="eu-west-2")
@@ -1175,7 +1175,7 @@ def test_revoke_security_group_egress__without_ipprotocol():
assert len(remaining_rules) == 0
-@mock_ec2
+@mock_aws
def test_update_security_group_rule_descriptions_egress():
ec2 = boto3.resource("ec2", "us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -1212,7 +1212,7 @@ def test_update_security_group_rule_descriptions_egress():
assert ip_ranges[0] == {"CidrIp": "0.0.0.0/0", "Description": "my d3scription"}
-@mock_ec2
+@mock_aws
def test_update_security_group_rule_descriptions_ingress():
ec2 = boto3.resource("ec2", "us-east-1")
client = boto3.client("ec2", "us-east-1")
@@ -1258,7 +1258,7 @@ def test_update_security_group_rule_descriptions_ingress():
assert ip_ranges[0] == {"CidrIp": "1.2.3.4/32", "Description": "second desc"}
-@mock_ec2
+@mock_aws
def test_non_existent_security_group_raises_error_on_authorize():
client = boto3.client("ec2", "us-east-1")
non_existent_sg = "sg-123abc"
@@ -1274,7 +1274,7 @@ def test_non_existent_security_group_raises_error_on_authorize():
assert ex.value.response["Error"]["Message"] == expected_error
-@mock_ec2
+@mock_aws
def test_security_group_rules_added_via_the_backend_can_be_revoked_via_the_api():
if settings.TEST_SERVER_MODE:
raise unittest.SkipTest("Can't test backend directly in server mode.")
@@ -1327,7 +1327,7 @@ def test_security_group_rules_added_via_the_backend_can_be_revoked_via_the_api()
assert len(sg["IpPermissionsEgress"]) == 0
-@mock_ec2
+@mock_aws
def test_filter_description():
ec2r = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2r.create_vpc(CidrBlock="10.250.0.0/16")
@@ -1354,7 +1354,7 @@ def test_filter_description():
assert security_groups[0].group_id == sg1.group_id
-@mock_ec2
+@mock_aws
def test_filter_ip_permission__cidr():
if settings.TEST_SERVER_MODE:
raise SkipTest(
@@ -1401,7 +1401,7 @@ def test_filter_ip_permission__cidr():
assert security_groups[0].group_id == sg1.group_id
-@mock_ec2
+@mock_aws
def test_filter_egress__ip_permission__cidr():
if settings.TEST_SERVER_MODE:
raise SkipTest(
@@ -1448,7 +1448,7 @@ def test_filter_egress__ip_permission__cidr():
assert security_groups[0].group_id == sg1.group_id
-@mock_ec2
+@mock_aws
def test_filter_egress__ip_permission__from_port():
ec2r = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2r.create_vpc(CidrBlock="10.250.1.0/16")
@@ -1492,7 +1492,7 @@ def test_filter_egress__ip_permission__from_port():
assert sg2.group_id not in [s.group_id for s in security_groups]
-@mock_ec2
+@mock_aws
def test_filter_egress__ip_permission__group_id():
ec2r = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2r.create_vpc(CidrBlock="10.250.1.0/16")
@@ -1542,7 +1542,7 @@ def test_filter_egress__ip_permission__group_id():
assert security_groups[0].group_id == sg1.group_id
-@mock_ec2
+@mock_aws
def test_filter_egress__ip_permission__group_name_create_with_id_filter_by_name():
"""
this fails to find the group in the AWS API, so we should also fail to find it
@@ -1597,7 +1597,7 @@ def test_filter_egress__ip_permission__group_name_create_with_id_filter_by_name(
assert len(security_groups) == 0
-@mock_ec2
+@mock_aws
def test_filter_egress__ip_permission__group_name_create_with_id_filter_by_id():
ec2r = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2r.create_vpc(CidrBlock="10.250.1.0/16")
@@ -1650,7 +1650,7 @@ def test_filter_egress__ip_permission__group_name_create_with_id_filter_by_id():
assert security_groups[0].group_id == sg1.group_id
-@mock_ec2
+@mock_aws
def test_filter_egress__ip_permission__protocol():
ec2r = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2r.create_vpc(CidrBlock="10.250.1.0/16")
@@ -1693,7 +1693,7 @@ def test_filter_egress__ip_permission__protocol():
assert sg2.group_id not in group_ids
-@mock_ec2
+@mock_aws
def test_filter_egress__ip_permission__to_port():
ec2r = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2r.create_vpc(CidrBlock="10.250.1.0/16")
@@ -1737,7 +1737,7 @@ def test_filter_egress__ip_permission__to_port():
assert sg2.group_id not in [s.group_id for s in security_groups]
-@mock_ec2
+@mock_aws
def test_get_groups_by_ippermissions_group_id_filter():
ec2r = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2r.create_vpc(CidrBlock="10.250.0.0/16")
@@ -1768,7 +1768,7 @@ def test_get_groups_by_ippermissions_group_id_filter():
assert security_groups[0].group_id == sg1.group_id
-@mock_ec2
+@mock_aws
def test_get_groups_by_ippermissions_group_id_filter_across_vpcs():
# setup 2 VPCs, each with a single Security Group
# where one security group authorizes the other sg (in another vpc) via GroupId
@@ -1804,7 +1804,7 @@ def test_get_groups_by_ippermissions_group_id_filter_across_vpcs():
assert security_groups[0].group_id == sg1.group_id
-@mock_ec2
+@mock_aws
def test_filter_group_name():
"""
this filter is an exact match, not a glob
@@ -1841,7 +1841,7 @@ def test_filter_group_name():
assert security_groups[0].group_name == sg1.group_name
-@mock_ec2
+@mock_aws
def test_revoke_security_group_ingress():
ec2 = boto3.client("ec2", region_name="us-east-1")
diff --git a/tests/test_ec2/test_security_groups_cloudformation.py b/tests/test_ec2/test_security_groups_cloudformation.py
index d2b6a7c5d..8f935db85 100644
--- a/tests/test_ec2/test_security_groups_cloudformation.py
+++ b/tests/test_ec2/test_security_groups_cloudformation.py
@@ -6,7 +6,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudformation, mock_ec2
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
SEC_GROUP_INGRESS = Template(
@@ -134,8 +134,7 @@ SEC_GROUP_SOURCE = {
}
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_security_group_ingress():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -164,8 +163,7 @@ def test_security_group_ingress():
]
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_delete_security_group_ingress():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -198,8 +196,7 @@ def test_delete_security_group_ingress():
assert exc.value.response["Error"]["Code"] == "InvalidGroup.NotFound"
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_security_group_ingress_without_description():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -223,8 +220,7 @@ def test_security_group_ingress_without_description():
assert ingress["IpRanges"] == [{"CidrIp": "10.0.0.0/8"}]
-@mock_ec2
-@mock_cloudformation
+@mock_aws
def test_stack_security_groups():
first_desc = str(uuid4())
second_desc = str(uuid4())
diff --git a/tests/test_ec2/test_settings.py b/tests/test_ec2/test_settings.py
index 6ad540df4..11987bdf4 100644
--- a/tests/test_ec2/test_settings.py
+++ b/tests/test_ec2/test_settings.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_ec2
+from moto import mock_aws
-@mock_ec2
+@mock_aws
def test_disable_ebs_encryption_by_default():
ec2 = boto3.client("ec2", "eu-central-1")
@@ -16,7 +16,7 @@ def test_disable_ebs_encryption_by_default():
assert after_disable_response["EbsEncryptionByDefault"] is False
-@mock_ec2
+@mock_aws
def test_enable_ebs_encryption_by_default():
ec2 = boto3.client("ec2", region_name="eu-central-1")
response = ec2.enable_ebs_encryption_by_default()
@@ -25,7 +25,7 @@ def test_enable_ebs_encryption_by_default():
assert response["EbsEncryptionByDefault"] is True
-@mock_ec2
+@mock_aws
def test_get_ebs_encryption_by_default():
ec2 = boto3.client("ec2", region_name="eu-west-1")
@@ -33,7 +33,7 @@ def test_get_ebs_encryption_by_default():
assert response["EbsEncryptionByDefault"] is False
-@mock_ec2
+@mock_aws
def test_enable_ebs_encryption_by_default_region():
ec2_eu = boto3.client("ec2", region_name="eu-central-1")
ec2_eu.enable_ebs_encryption_by_default()
diff --git a/tests/test_ec2/test_spot_fleet.py b/tests/test_ec2/test_spot_fleet.py
index 13bc13265..23fa66bb2 100644
--- a/tests/test_ec2/test_spot_fleet.py
+++ b/tests/test_ec2/test_spot_fleet.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
@@ -84,7 +84,7 @@ def spot_config(subnet_id, allocation_strategy="lowestPrice"):
}
-@mock_ec2
+@mock_aws
def test_create_spot_fleet_with_invalid_tag_specifications():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -109,7 +109,7 @@ def test_create_spot_fleet_with_invalid_tag_specifications():
)
-@mock_ec2
+@mock_aws
def test_create_spot_fleet_with_lowest_price():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -155,7 +155,7 @@ def test_create_spot_fleet_with_lowest_price():
assert len(instances) == 3
-@mock_ec2
+@mock_aws
def test_create_diversified_spot_fleet():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -171,7 +171,7 @@ def test_create_diversified_spot_fleet():
assert "i-" in instances[0]["InstanceId"]
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("allocation_strategy", ["diversified", "lowestCost"])
def test_request_spot_fleet_using_launch_template_config__name(allocation_strategy):
conn = boto3.client("ec2", region_name="us-east-2")
@@ -217,7 +217,7 @@ def test_request_spot_fleet_using_launch_template_config__name(allocation_strate
assert "i-" in instances[0]["InstanceId"]
-@mock_ec2
+@mock_aws
def test_request_spot_fleet_using_launch_template_config__id():
conn = boto3.client("ec2", region_name="us-east-2")
@@ -258,7 +258,7 @@ def test_request_spot_fleet_using_launch_template_config__id():
assert "i-" in instances[0]["InstanceId"]
-@mock_ec2
+@mock_aws
def test_request_spot_fleet_using_launch_template_config__overrides():
conn = boto3.client("ec2", region_name="us-east-2")
subnet_id = get_subnet_id(conn)
@@ -313,7 +313,7 @@ def test_request_spot_fleet_using_launch_template_config__overrides():
assert instance["SubnetId"] == subnet_id
-@mock_ec2
+@mock_aws
def test_create_spot_fleet_request_with_tag_spec():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -351,7 +351,7 @@ def test_create_spot_fleet_request_with_tag_spec():
assert tag in instance["Tags"]
-@mock_ec2
+@mock_aws
def test_cancel_spot_fleet_request():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -371,7 +371,7 @@ def test_cancel_spot_fleet_request():
assert len(spot_fleet_requests) == 0
-@mock_ec2
+@mock_aws
def test_cancel_spot_fleet_request__but_dont_terminate_instances():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -407,7 +407,7 @@ def test_cancel_spot_fleet_request__but_dont_terminate_instances():
assert len(spot_fleet_requests) == 0
-@mock_ec2
+@mock_aws
def test_modify_spot_fleet_request_up():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -429,7 +429,7 @@ def test_modify_spot_fleet_request_up():
assert spot_fleet_config["FulfilledCapacity"] == 20.0
-@mock_ec2
+@mock_aws
def test_modify_spot_fleet_request_up_diversified():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -451,7 +451,7 @@ def test_modify_spot_fleet_request_up_diversified():
assert spot_fleet_config["FulfilledCapacity"] == 20.0
-@mock_ec2
+@mock_aws
def test_modify_spot_fleet_request_down_no_terminate():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -477,7 +477,7 @@ def test_modify_spot_fleet_request_down_no_terminate():
assert spot_fleet_config["FulfilledCapacity"] == 6.0
-@mock_ec2
+@mock_aws
def test_modify_spot_fleet_request_down_odd():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -500,7 +500,7 @@ def test_modify_spot_fleet_request_down_odd():
assert spot_fleet_config["FulfilledCapacity"] == 6.0
-@mock_ec2
+@mock_aws
def test_modify_spot_fleet_request_down():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -522,7 +522,7 @@ def test_modify_spot_fleet_request_down():
assert spot_fleet_config["FulfilledCapacity"] == 2.0
-@mock_ec2
+@mock_aws
def test_modify_spot_fleet_request_down_no_terminate_after_custom_terminate():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
@@ -551,7 +551,7 @@ def test_modify_spot_fleet_request_down_no_terminate_after_custom_terminate():
assert spot_fleet_config["FulfilledCapacity"] == 2.0
-@mock_ec2
+@mock_aws
def test_create_spot_fleet_without_spot_price():
conn = boto3.client("ec2", region_name="us-west-2")
subnet_id = get_subnet_id(conn)
diff --git a/tests/test_ec2/test_spot_instances.py b/tests/test_ec2/test_spot_instances.py
index 16d428052..8a99f2585 100644
--- a/tests/test_ec2/test_spot_instances.py
+++ b/tests/test_ec2/test_spot_instances.py
@@ -6,12 +6,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core.utils import iso_8601_datetime_with_milliseconds
from tests import EXAMPLE_AMI_ID
-@mock_ec2
+@mock_aws
def test_request_spot_instances():
conn = boto3.client("ec2", "us-east-1")
vpc = conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -110,7 +110,7 @@ def test_request_spot_instances():
assert launch_spec["SubnetId"] == subnet_id
-@mock_ec2
+@mock_aws
def test_request_spot_instances_default_arguments():
"""
Test that moto set the correct default arguments
@@ -151,7 +151,7 @@ def test_request_spot_instances_default_arguments():
assert "SubnetId" not in request
-@mock_ec2
+@mock_aws
def test_cancel_spot_instance_request():
client = boto3.client("ec2", region_name="us-west-1")
@@ -192,7 +192,7 @@ def test_cancel_spot_instance_request():
assert len(requests) == 0
-@mock_ec2
+@mock_aws
def test_request_spot_instances_fulfilled():
"""
Test that moto correctly fullfills a spot instance request
@@ -213,7 +213,7 @@ def test_request_spot_instances_fulfilled():
assert request["State"] == "active"
-@mock_ec2
+@mock_aws
def test_tag_spot_instance_request():
"""
Test that moto correctly tags a spot instance request
@@ -240,7 +240,7 @@ def test_tag_spot_instance_request():
assert {"Key": "tag2", "Value": "value2"} in request["Tags"]
-@mock_ec2
+@mock_aws
def test_get_all_spot_instance_requests_filtering():
"""
Test that moto correctly filters spot instance requests
@@ -296,7 +296,7 @@ def test_get_all_spot_instance_requests_filtering():
assert len(requests) == 1
-@mock_ec2
+@mock_aws
@pytest.mark.filterwarnings("ignore")
def test_request_spot_instances_instance_lifecycle():
if settings.TEST_SERVER_MODE:
@@ -312,7 +312,7 @@ def test_request_spot_instances_instance_lifecycle():
assert instance["InstanceLifecycle"] == "spot"
-@mock_ec2
+@mock_aws
@pytest.mark.filterwarnings("ignore")
def test_request_spot_instances_with_tags():
client = boto3.client("ec2", region_name="us-east-1")
@@ -334,7 +334,7 @@ def test_request_spot_instances_with_tags():
assert request["Tags"] == [{"Key": "k", "Value": "v"}]
-@mock_ec2
+@mock_aws
def test_launch_spot_instance_instance_lifecycle():
client = boto3.client("ec2", region_name="us-east-1")
@@ -358,7 +358,7 @@ def test_launch_spot_instance_instance_lifecycle():
assert instance["InstanceLifecycle"] == "spot"
-@mock_ec2
+@mock_aws
def test_launch_instance_instance_lifecycle():
client = boto3.client("ec2", region_name="us-east-1")
@@ -381,7 +381,7 @@ def test_launch_instance_instance_lifecycle():
assert instance.get("InstanceLifecycle") is None
-@mock_ec2
+@mock_aws
def test_spot_price_history():
client = boto3.client("ec2", region_name="us-east-1")
# test filter
@@ -402,7 +402,7 @@ def test_spot_price_history():
assert price["InstanceType"] in i_types
-@mock_ec2
+@mock_aws
def test_request_spot_instances__instance_should_exist():
client = boto3.client("ec2", region_name="us-east-1")
request = client.request_spot_instances(
diff --git a/tests/test_ec2/test_subnets.py b/tests/test_ec2/test_subnets.py
index 32ff55284..850277ed3 100644
--- a/tests/test_ec2/test_subnets.py
+++ b/tests/test_ec2/test_subnets.py
@@ -6,11 +6,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from tests import EXAMPLE_AMI_ID
-@mock_ec2
+@mock_aws
def test_subnets():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -34,7 +34,7 @@ def test_subnets():
assert ex.value.response["Error"]["Code"] == "InvalidSubnetID.NotFound"
-@mock_ec2
+@mock_aws
def test_subnet_create_vpc_validation():
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -45,7 +45,7 @@ def test_subnet_create_vpc_validation():
assert ex.value.response["Error"]["Code"] == "InvalidVpcID.NotFound"
-@mock_ec2
+@mock_aws
def test_subnet_tagging():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -65,7 +65,7 @@ def test_subnet_tagging():
assert subnet["Tags"] == [{"Key": "a key", "Value": "some value"}]
-@mock_ec2
+@mock_aws
def test_subnet_should_have_proper_availability_zone_set():
ec2 = boto3.resource("ec2", region_name="us-west-1")
vpcA = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -75,7 +75,7 @@ def test_subnet_should_have_proper_availability_zone_set():
assert subnetA.availability_zone == "us-west-1b"
-@mock_ec2
+@mock_aws
def test_availability_zone_in_create_subnet():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -87,7 +87,7 @@ def test_availability_zone_in_create_subnet():
assert subnet.availability_zone_id == "use1-az6"
-@mock_ec2
+@mock_aws
def test_default_subnet():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode will have conflicting CidrBlocks")
@@ -105,7 +105,7 @@ def test_default_subnet():
assert subnet.map_public_ip_on_launch is False
-@mock_ec2
+@mock_aws
def test_non_default_subnet():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -121,7 +121,7 @@ def test_non_default_subnet():
assert subnet.map_public_ip_on_launch is False
-@mock_ec2
+@mock_aws
def test_modify_subnet_attribute_public_ip_on_launch():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -154,7 +154,7 @@ def test_modify_subnet_attribute_public_ip_on_launch():
assert subnet.map_public_ip_on_launch is True
-@mock_ec2
+@mock_aws
def test_modify_subnet_attribute_assign_ipv6_address_on_creation():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -188,7 +188,7 @@ def test_modify_subnet_attribute_assign_ipv6_address_on_creation():
assert subnet.assign_ipv6_address_on_creation is True
-@mock_ec2
+@mock_aws
def test_modify_subnet_attribute_validation():
# TODO: implement some actual logic
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -198,7 +198,7 @@ def test_modify_subnet_attribute_validation():
)
-@mock_ec2
+@mock_aws
def test_subnet_get_by_id():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -229,7 +229,7 @@ def test_subnet_get_by_id():
assert ex.value.response["Error"]["Code"] == "InvalidSubnetID.NotFound"
-@mock_ec2
+@mock_aws
def test_get_subnets_filtering():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -331,7 +331,7 @@ def test_get_subnets_filtering():
client.describe_subnets(Filters=filters)
-@mock_ec2
+@mock_aws
def test_create_subnet_response_fields():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -360,7 +360,7 @@ def test_create_subnet_response_fields():
assert subnet["Ipv6CidrBlockAssociationSet"] == []
-@mock_ec2
+@mock_aws
def test_describe_subnet_response_fields():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -393,7 +393,7 @@ def test_describe_subnet_response_fields():
assert subnet["Ipv6CidrBlockAssociationSet"] == []
-@mock_ec2
+@mock_aws
def test_create_subnet_with_invalid_availability_zone():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -413,7 +413,7 @@ def test_create_subnet_with_invalid_availability_zone():
)
-@mock_ec2
+@mock_aws
def test_create_subnet_with_invalid_cidr_range():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -430,7 +430,7 @@ def test_create_subnet_with_invalid_cidr_range():
)
-@mock_ec2
+@mock_aws
def test_create_subnet_with_invalid_cidr_range_multiple_vpc_cidr_blocks():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -448,7 +448,7 @@ def test_create_subnet_with_invalid_cidr_range_multiple_vpc_cidr_blocks():
)
-@mock_ec2
+@mock_aws
def test_create_subnet_with_invalid_cidr_block_parameter():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -465,7 +465,7 @@ def test_create_subnet_with_invalid_cidr_block_parameter():
)
-@mock_ec2
+@mock_aws
def test_create_subnets_with_multiple_vpc_cidr_blocks():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -505,7 +505,7 @@ def test_create_subnets_with_multiple_vpc_cidr_blocks():
assert subnet["AssignIpv6AddressOnCreation"] is False
-@mock_ec2
+@mock_aws
def test_create_subnets_with_overlapping_cidr_blocks():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -523,7 +523,7 @@ def test_create_subnets_with_overlapping_cidr_blocks():
)
-@mock_ec2
+@mock_aws
def test_create_subnet_with_tags():
ec2 = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2.create_vpc(CidrBlock="172.31.0.0/16")
@@ -545,7 +545,7 @@ def test_create_subnet_with_tags():
assert subnet.tags == [{"Key": "name", "Value": "some-vpc"}]
-@mock_ec2
+@mock_aws
def test_available_ip_addresses_in_subnet():
if settings.TEST_SERVER_MODE:
raise SkipTest(
@@ -574,7 +574,7 @@ def test_available_ip_addresses_in_subnet():
validate_subnet_details(client, vpc, cidr, expected_count)
-@mock_ec2
+@mock_aws
def test_available_ip_addresses_in_subnet_with_enis():
if settings.TEST_SERVER_MODE:
raise SkipTest(
@@ -668,7 +668,7 @@ def validate_subnet_details_after_creating_eni(
client.delete_subnet(SubnetId=subnet["SubnetId"])
-@mock_ec2
+@mock_aws
def test_run_instances_should_attach_to_default_subnet():
# https://github.com/getmoto/moto/issues/2877
ec2 = boto3.resource("ec2", region_name="sa-east-1")
@@ -703,7 +703,7 @@ def test_run_instances_should_attach_to_default_subnet():
)
-@mock_ec2
+@mock_aws
def test_describe_subnets_by_vpc_id():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -742,7 +742,7 @@ def test_describe_subnets_by_vpc_id():
assert len(subnets) == 0
-@mock_ec2
+@mock_aws
def test_describe_subnets_by_state():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -759,7 +759,7 @@ def test_describe_subnets_by_state():
assert subnet["State"] == "available"
-@mock_ec2
+@mock_aws
def test_associate_subnet_cidr_block():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -789,7 +789,7 @@ def test_associate_subnet_cidr_block():
assert association_set[0]["Ipv6CidrBlock"] == "1080::1:200C:417A/112"
-@mock_ec2
+@mock_aws
def test_disassociate_subnet_cidr_block():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -818,7 +818,7 @@ def test_disassociate_subnet_cidr_block():
assert association_set[0]["Ipv6CidrBlock"] == "1080::1:200C:417A/111"
-@mock_ec2
+@mock_aws
def test_describe_subnets_dryrun():
client = boto3.client("ec2", region_name="us-east-1")
diff --git a/tests/test_ec2/test_tags.py b/tests/test_ec2/test_tags.py
index b55856da9..209e3ffda 100644
--- a/tests/test_ec2/test_tags.py
+++ b/tests/test_ec2/test_tags.py
@@ -4,13 +4,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
from .test_instances import retrieve_all_instances
-@mock_ec2
+@mock_aws
def test_instance_create_tags():
ec2 = boto3.resource("ec2", "us-west-1")
client = boto3.client("ec2", "us-west-1")
@@ -33,7 +33,7 @@ def test_instance_create_tags():
assert ours["Tags"] == [{"Key": "a key", "Value": "some value"}]
-@mock_ec2
+@mock_aws
def test_instance_delete_tags():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -68,7 +68,7 @@ def test_instance_delete_tags():
assert len(client.describe_tags(Filters=instance_filters)["Tags"]) == 0
-@mock_ec2
+@mock_aws
def test_get_all_tags_with_special_characters():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -84,7 +84,7 @@ def test_get_all_tags_with_special_characters():
assert tag["Value"] == "some<> value"
-@mock_ec2
+@mock_aws
def test_create_tags():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -118,7 +118,7 @@ def test_create_tags():
} in tags
-@mock_ec2
+@mock_aws
def test_tag_limit_exceeded():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -148,7 +148,7 @@ def test_tag_limit_exceeded():
assert tags[0]["Value"] == "a value"
-@mock_ec2
+@mock_aws
def test_invalid_id():
client = boto3.client("ec2", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -168,7 +168,7 @@ def test_invalid_id():
assert ex.value.response["Error"]["Code"] == "InvalidID"
-@mock_ec2
+@mock_aws
def test_get_all_tags_resource_filter():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -220,7 +220,7 @@ def test_get_all_tags_resource_filter():
assert tags == []
-@mock_ec2
+@mock_aws
def test_get_all_tags_value_filter():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -258,7 +258,7 @@ def test_get_all_tags_value_filter():
filter_by_value(r"*value\*\?", [instance_e.id])
-@mock_ec2
+@mock_aws
def test_retrieved_instances_must_contain_their_tags():
tag_key = "Tag name"
tag_value = "Tag value"
@@ -284,7 +284,7 @@ def test_retrieved_instances_must_contain_their_tags():
assert retrieved_tags == [{"Key": tag_key, "Value": tag_value}]
-@mock_ec2
+@mock_aws
def test_retrieved_volumes_must_contain_their_tags():
tag_key = "Tag name"
tag_value = "Tag value"
@@ -301,7 +301,7 @@ def test_retrieved_volumes_must_contain_their_tags():
assert volume.tags == [{"Key": tag_key, "Value": tag_value}]
-@mock_ec2
+@mock_aws
def test_retrieved_snapshots_must_contain_their_tags():
tag_key = "Tag name"
tag_value = "Tag value"
@@ -318,7 +318,7 @@ def test_retrieved_snapshots_must_contain_their_tags():
assert snapshot["Tags"] == [{"Key": tag_key, "Value": tag_value}]
-@mock_ec2
+@mock_aws
def test_filter_instances_by_wildcard_tags():
ec2 = boto3.resource("ec2", region_name="eu-west-1")
client = boto3.client("ec2", region_name="eu-west-1")
@@ -348,7 +348,7 @@ def test_filter_instances_by_wildcard_tags():
assert len(res["Reservations"][0]["Instances"]) == 1
-@mock_ec2
+@mock_aws
def test_create_volume_with_tags():
client = boto3.client("ec2", "us-west-2")
response = client.create_volume(
@@ -366,7 +366,7 @@ def test_create_volume_with_tags():
assert response["Tags"][0]["Key"] == "TEST_TAG"
-@mock_ec2
+@mock_aws
def test_create_snapshot_with_tags():
client = boto3.client("ec2", "us-west-2")
volume_id = client.create_volume(
@@ -395,7 +395,7 @@ def test_create_snapshot_with_tags():
assert snapshot["Tags"] == expected_tags
-@mock_ec2
+@mock_aws
def test_create_volume_without_tags():
client = boto3.client("ec2", "us-east-1")
with pytest.raises(ClientError) as exc:
@@ -415,7 +415,7 @@ def test_create_volume_without_tags():
assert err["Message"] == "Tag specification must have at least one tag"
-@mock_ec2
+@mock_aws
def test_create_tag_empty_resource():
# create ec2 client in us-west-1
client = boto3.client("ec2", region_name="us-west-1")
@@ -429,7 +429,7 @@ def test_create_tag_empty_resource():
)
-@mock_ec2
+@mock_aws
def test_delete_tag_empty_resource():
# create ec2 client in us-west-1
client = boto3.client("ec2", region_name="us-west-1")
@@ -443,7 +443,7 @@ def test_delete_tag_empty_resource():
)
-@mock_ec2
+@mock_aws
def test_retrieve_resource_with_multiple_tags():
ec2 = boto3.resource("ec2", region_name="us-west-1")
blue, green = ec2.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=2, MaxCount=2)
@@ -469,7 +469,7 @@ def test_retrieve_resource_with_multiple_tags():
assert blue_instances == [blue]
-@mock_ec2
+@mock_aws
def test_ec2_validate_subnet_tags():
client = boto3.client("ec2", region_name="us-west-1")
diff --git a/tests/test_ec2/test_transit_gateway.py b/tests/test_ec2/test_transit_gateway.py
index cc6f3baeb..7687e2b8b 100644
--- a/tests/test_ec2/test_transit_gateway.py
+++ b/tests/test_ec2/test_transit_gateway.py
@@ -3,11 +3,11 @@ from unittest import SkipTest
import boto3
import pytest
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_ec2
+@mock_aws
def test_describe_transit_gateways():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode is not guaranteed to be empty")
@@ -16,7 +16,7 @@ def test_describe_transit_gateways():
assert response["TransitGateways"] == []
-@mock_ec2
+@mock_aws
def test_create_transit_gateway():
ec2 = boto3.client("ec2", region_name="us-west-1")
response = ec2.create_transit_gateway(
@@ -66,7 +66,7 @@ def test_create_transit_gateway():
assert gateway == gateways[0]
-@mock_ec2
+@mock_aws
def test_create_transit_gateway_with_tags():
ec2 = boto3.client("ec2", region_name="us-west-1")
response = ec2.create_transit_gateway(
@@ -89,7 +89,7 @@ def test_create_transit_gateway_with_tags():
assert {"Key": "tag2", "Value": "val2"} in tags
-@mock_ec2
+@mock_aws
def test_delete_transit_gateway():
ec2 = boto3.client("ec2", region_name="us-west-1")
g = ec2.create_transit_gateway(Description="my first gateway")["TransitGateway"]
@@ -104,7 +104,7 @@ def test_delete_transit_gateway():
assert g_id not in [g["TransitGatewayId"] for g in all_gateways]
-@mock_ec2
+@mock_aws
def test_describe_transit_gateway_by_id():
ec2 = boto3.client("ec2", region_name="us-west-1")
ec2.create_transit_gateway(Description="my first gatway")["TransitGateway"]
@@ -122,7 +122,7 @@ def test_describe_transit_gateway_by_id():
assert my_gateway["Description"] == "my second gatway"
-@mock_ec2
+@mock_aws
def test_describe_transit_gateway_by_tags():
ec2 = boto3.client("ec2", region_name="us-west-1")
ec2.create_transit_gateway(
@@ -164,7 +164,7 @@ def test_describe_transit_gateway_by_tags():
assert my_gateway["Description"] == "my second gatway"
-@mock_ec2
+@mock_aws
def test_modify_transit_gateway():
ec2 = boto3.client("ec2", region_name="us-west-1")
g = ec2.create_transit_gateway(Description="my first gatway")["TransitGateway"]
@@ -183,7 +183,7 @@ def test_modify_transit_gateway():
assert my_gateway["Description"] == "my first gateway"
-@mock_ec2
+@mock_aws
def test_describe_transit_gateway_vpc_attachments():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode is not guaranteed to be empty")
@@ -192,7 +192,7 @@ def test_describe_transit_gateway_vpc_attachments():
assert response["TransitGatewayVpcAttachments"] == []
-@mock_ec2
+@mock_aws
def test_describe_transit_gateway_attachments():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode is not guaranteed to be empty")
@@ -212,7 +212,7 @@ def retrieve_all_transit_gateways(ec2):
return all_tg
-@mock_ec2
+@mock_aws
def test_create_transit_gateway_vpn_attachment():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -250,7 +250,7 @@ def retrieve_all_attachments(client):
return att
-@mock_ec2
+@mock_aws
def test_create_and_describe_transit_gateway_vpc_attachment():
ec2 = boto3.client("ec2", region_name="us-west-1")
response = ec2.create_transit_gateway_vpc_attachment(
@@ -298,7 +298,7 @@ def test_create_and_describe_transit_gateway_vpc_attachment():
assert attachments[0]["TransitGatewayId"] == "gateway_id"
-@mock_ec2
+@mock_aws
def test_describe_transit_gateway_route_tables():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode is not guaranteed to be empty")
@@ -307,7 +307,7 @@ def test_describe_transit_gateway_route_tables():
assert response["TransitGatewayRouteTables"] == []
-@mock_ec2
+@mock_aws
def test_create_transit_gateway_route_table():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -331,7 +331,7 @@ def test_create_transit_gateway_route_table():
assert len(tables) == 1
-@mock_ec2
+@mock_aws
def test_create_transit_gateway_route_table_with_tags():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -356,7 +356,7 @@ def test_create_transit_gateway_route_table_with_tags():
assert {"Key": "tag2", "Value": "val2"} in table["Tags"]
-@mock_ec2
+@mock_aws
def test_delete_transit_gateway_route_table():
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -385,7 +385,7 @@ def test_delete_transit_gateway_route_table():
assert tables[0]["State"] == "deleted"
-@mock_ec2
+@mock_aws
def test_search_transit_gateway_routes_empty():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -403,7 +403,7 @@ def test_search_transit_gateway_routes_empty():
assert response["AdditionalRoutesAvailable"] is False
-@mock_ec2
+@mock_aws
def test_create_transit_gateway_route():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -422,7 +422,7 @@ def test_create_transit_gateway_route():
assert route["State"] == "active"
-@mock_ec2
+@mock_aws
def test_create_transit_gateway_route_as_blackhole():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -443,7 +443,7 @@ def test_create_transit_gateway_route_as_blackhole():
assert route["State"] == "blackhole"
-@mock_ec2
+@mock_aws
def test_search_transit_gateway_routes_by_state():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -493,7 +493,7 @@ def test_search_transit_gateway_routes_by_state():
assert routes == []
-@mock_ec2
+@mock_aws
def test_search_transit_gateway_routes_by_routesearch():
client = boto3.client("ec2", region_name="us-west-2")
vpc = client.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -530,7 +530,7 @@ def test_search_transit_gateway_routes_by_routesearch():
assert expected_route["Routes"][0]["DestinationCidrBlock"] == route
-@mock_ec2
+@mock_aws
def test_delete_transit_gateway_route():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -567,7 +567,7 @@ def test_delete_transit_gateway_route():
]
-@mock_ec2
+@mock_aws
def test_create_transit_gateway_vpc_attachment():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -587,7 +587,7 @@ def test_create_transit_gateway_vpc_attachment():
assert attachment["Tags"] == []
-@mock_ec2
+@mock_aws
def test_modify_transit_gateway_vpc_attachment_add_subnets():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -608,7 +608,7 @@ def test_modify_transit_gateway_vpc_attachment_add_subnets():
assert sorted(attachment["SubnetIds"]) == ["sub1", "sub2", "sub3"]
-@mock_ec2
+@mock_aws
def test_modify_transit_gateway_vpc_attachment_remove_subnets():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -629,7 +629,7 @@ def test_modify_transit_gateway_vpc_attachment_remove_subnets():
assert attachment["SubnetIds"] == ["sub1", "sub3"]
-@mock_ec2
+@mock_aws
def test_modify_transit_gateway_vpc_attachment_change_options():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -660,7 +660,7 @@ def test_modify_transit_gateway_vpc_attachment_change_options():
assert attachment["Options"]["Ipv6Support"] == "enable"
-@mock_ec2
+@mock_aws
def test_delete_transit_gateway_vpc_attachment():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -692,7 +692,7 @@ def test_delete_transit_gateway_vpc_attachment():
assert [a["TransitGatewayAttachmentId"] for a in all_attchmnts] == [a2]
-@mock_ec2
+@mock_aws
def test_associate_transit_gateway_route_table():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -735,7 +735,7 @@ def test_associate_transit_gateway_route_table():
]
-@mock_ec2
+@mock_aws
def test_disassociate_transit_gateway_route_table():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -779,7 +779,7 @@ def test_disassociate_transit_gateway_route_table():
assert updated["State"] == ""
-@mock_ec2
+@mock_aws
def test_enable_transit_gateway_route_table_propagation():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -827,7 +827,7 @@ def test_enable_transit_gateway_route_table_propagation():
]
-@mock_ec2
+@mock_aws
def test_disable_transit_gateway_route_table_propagation_without_enabling_first():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
@@ -864,7 +864,7 @@ def test_disable_transit_gateway_route_table_propagation_without_enabling_first(
)
-@mock_ec2
+@mock_aws
def test_disable_transit_gateway_route_table_propagation():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][
diff --git a/tests/test_ec2/test_transit_gateway_cloudformation.py b/tests/test_ec2/test_transit_gateway_cloudformation.py
index dd2ac5013..da095eaaf 100644
--- a/tests/test_ec2/test_transit_gateway_cloudformation.py
+++ b/tests/test_ec2/test_transit_gateway_cloudformation.py
@@ -3,11 +3,10 @@ from uuid import uuid4
import boto3
-from moto import mock_cloudformation, mock_ec2
+from moto import mock_aws
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_transit_gateway_by_cloudformation_simple():
ec2 = boto3.client("ec2", region_name="us-east-1")
cf_client = boto3.client("cloudformation", "us-east-1")
@@ -45,8 +44,7 @@ def test_transit_gateway_by_cloudformation_simple():
assert len(gateways[0]["Tags"]) == 3
-@mock_cloudformation
-@mock_ec2
+@mock_aws
def test_transit_gateway_by_cloudformation():
ec2 = boto3.client("ec2", region_name="us-east-1")
cf_client = boto3.client("cloudformation", "us-east-1")
diff --git a/tests/test_ec2/test_transit_gateway_peering_attachments.py b/tests/test_ec2/test_transit_gateway_peering_attachments.py
index 6e5412af8..66201e0a4 100644
--- a/tests/test_ec2/test_transit_gateway_peering_attachments.py
+++ b/tests/test_ec2/test_transit_gateway_peering_attachments.py
@@ -5,11 +5,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_ec2
+@mock_aws
def test_describe_transit_gateway_peering_attachment_empty():
if settings.TEST_SERVER_MODE:
raise SkipTest("ServerMode is not guaranteed to be empty")
@@ -21,7 +21,7 @@ def test_describe_transit_gateway_peering_attachment_empty():
assert all_attachments == []
-@mock_ec2
+@mock_aws
def test_create_and_describe_transit_gateway_peering_attachment():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id1 = ec2.create_transit_gateway(Description="my first gateway")[
@@ -53,7 +53,7 @@ def test_create_and_describe_transit_gateway_peering_attachment():
assert our_attachment == [attachment]
-@mock_ec2
+@mock_aws
def test_describe_transit_gateway_peering_attachment_by_filters():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id1 = ec2.create_transit_gateway(Description="my first gateway")[
@@ -115,7 +115,7 @@ def test_describe_transit_gateway_peering_attachment_by_filters():
assert [a["TransitGatewayAttachmentId"] for a in find_available] == [attchmnt1]
-@mock_ec2
+@mock_aws
def test_create_and_accept_transit_gateway_peering_attachment():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id1 = ec2.create_transit_gateway(Description="my first gateway")[
@@ -139,7 +139,7 @@ def test_create_and_accept_transit_gateway_peering_attachment():
assert attachment["State"] == "available"
-@mock_ec2
+@mock_aws
def test_create_and_reject_transit_gateway_peering_attachment():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id1 = ec2.create_transit_gateway(Description="my first gateway")[
@@ -161,7 +161,7 @@ def test_create_and_reject_transit_gateway_peering_attachment():
assert attachment["State"] == "rejected"
-@mock_ec2
+@mock_aws
def test_create_and_delete_transit_gateway_peering_attachment():
ec2 = boto3.client("ec2", region_name="us-west-1")
gateway_id1 = ec2.create_transit_gateway(Description="my first gateway")[
@@ -183,7 +183,7 @@ def test_create_and_delete_transit_gateway_peering_attachment():
assert attachment["State"] == "deleted"
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
diff --git a/tests/test_ec2/test_virtual_private_gateways.py b/tests/test_ec2/test_virtual_private_gateways.py
index d94b6f670..ca389655b 100644
--- a/tests/test_ec2/test_virtual_private_gateways.py
+++ b/tests/test_ec2/test_virtual_private_gateways.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
from .test_tags import retrieve_all_tagged
-@mock_ec2
+@mock_aws
def test_attach_unknown_vpn_gateway():
"""describe_vpn_gateways attachment.vpc-id filter"""
@@ -22,7 +22,7 @@ def test_attach_unknown_vpn_gateway():
assert err["Code"] == "InvalidVpnGatewayID.NotFound"
-@mock_ec2
+@mock_aws
def test_delete_unknown_vpn_gateway():
"""describe_vpn_gateways attachment.vpc-id filter"""
@@ -35,7 +35,7 @@ def test_delete_unknown_vpn_gateway():
assert err["Code"] == "InvalidVpnGatewayID.NotFound"
-@mock_ec2
+@mock_aws
def test_detach_unknown_vpn_gateway():
"""describe_vpn_gateways attachment.vpc-id filter"""
@@ -50,7 +50,7 @@ def test_detach_unknown_vpn_gateway():
assert err["Code"] == "InvalidVpnGatewayID.NotFound"
-@mock_ec2
+@mock_aws
def test_describe_vpn_connections_attachment_vpc_id_filter():
"""describe_vpn_gateways attachment.vpc-id filter"""
@@ -74,7 +74,7 @@ def test_describe_vpn_connections_attachment_vpc_id_filter():
]
-@mock_ec2
+@mock_aws
def test_describe_vpn_connections_state_filter_attached():
"""describe_vpn_gateways attachment.state filter - match attached"""
@@ -96,7 +96,7 @@ def test_describe_vpn_connections_state_filter_attached():
assert {"State": "attached", "VpcId": vpc_id} in my_gateway["VpcAttachments"]
-@mock_ec2
+@mock_aws
def test_virtual_private_gateways_boto3():
client = boto3.client("ec2", region_name="us-west-1")
@@ -110,7 +110,7 @@ def test_virtual_private_gateways_boto3():
assert vpn_gateway["AvailabilityZone"] == "us-east-1a"
-@mock_ec2
+@mock_aws
def test_describe_vpn_gateway_boto3():
client = boto3.client("ec2", region_name="us-west-1")
vpn_gateway = client.create_vpn_gateway(
@@ -131,7 +131,7 @@ def test_describe_vpn_gateway_boto3():
assert gateway["AvailabilityZone"] == "us-east-1a"
-@mock_ec2
+@mock_aws
def test_describe_vpn_connections_state_filter_deatched():
"""describe_vpn_gateways attachment.state filter - don't match detatched"""
@@ -151,7 +151,7 @@ def test_describe_vpn_connections_state_filter_deatched():
assert len(gateways["VpnGateways"]) == 0
-@mock_ec2
+@mock_aws
def test_describe_vpn_connections_id_filter_match():
"""describe_vpn_gateways vpn-gateway-id filter - match correct id"""
@@ -168,7 +168,7 @@ def test_describe_vpn_connections_id_filter_match():
assert gateways["VpnGateways"][0]["VpnGatewayId"] == gateway_id
-@mock_ec2
+@mock_aws
def test_describe_vpn_connections_id_filter_miss():
"""describe_vpn_gateways vpn-gateway-id filter - don't match"""
@@ -183,7 +183,7 @@ def test_describe_vpn_connections_id_filter_miss():
assert len(gateways["VpnGateways"]) == 0
-@mock_ec2
+@mock_aws
def test_describe_vpn_connections_type_filter_match():
"""describe_vpn_gateways type filter - match"""
@@ -197,7 +197,7 @@ def test_describe_vpn_connections_type_filter_match():
assert gateway_id in [gw["VpnGatewayId"] for gw in my_gateways]
-@mock_ec2
+@mock_aws
def test_describe_vpn_connections_type_filter_miss():
"""describe_vpn_gateways type filter - don't match"""
@@ -212,7 +212,7 @@ def test_describe_vpn_connections_type_filter_miss():
assert len(gateways["VpnGateways"]) == 0
-@mock_ec2
+@mock_aws
def test_vpn_gateway_vpc_attachment_boto3():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -229,7 +229,7 @@ def test_vpn_gateway_vpc_attachment_boto3():
assert attachments == [{"State": "attached", "VpcId": vpc.id}]
-@mock_ec2
+@mock_aws
def test_delete_vpn_gateway_boto3():
client = boto3.client("ec2", region_name="us-west-1")
vpn_gateway = client.create_vpn_gateway(
@@ -243,7 +243,7 @@ def test_delete_vpn_gateway_boto3():
assert gateways[0]["State"] == "deleted"
-@mock_ec2
+@mock_aws
def test_vpn_gateway_tagging_boto3():
client = boto3.client("ec2", region_name="us-west-1")
vpn_gateway = client.create_vpn_gateway(
@@ -264,7 +264,7 @@ def test_vpn_gateway_tagging_boto3():
# assert vpn_gateway["Tags"] == [{'Key': 'a key', 'Value': 'some value'}]
-@mock_ec2
+@mock_aws
def test_detach_vpn_gateway_boto3():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
diff --git a/tests/test_ec2/test_vpc_endpoint_services_integration.py b/tests/test_ec2/test_vpc_endpoint_services_integration.py
index dc47ecdbc..313f133f5 100644
--- a/tests/test_ec2/test_vpc_endpoint_services_integration.py
+++ b/tests/test_ec2/test_vpc_endpoint_services_integration.py
@@ -1,7 +1,7 @@
"""Unit tests specific to VPC endpoint services."""
# boto3 tests are defined in `tests/test_core/test_ec2_vpc_endpoint_services`
-from moto import mock_ec2
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
@@ -99,7 +99,7 @@ def validate_s3_service_endpoint_interface(details):
assert details["Tags"][1] == {"Key": "Environ", "Value": "test"}
-@mock_ec2
+@mock_aws
def test_describe_vpc_endpoint_services_filters():
"""Verify that different type of filters return the expected results."""
from moto.ec2.models import ec2_backends # pylint: disable=import-outside-toplevel
diff --git a/tests/test_ec2/test_vpc_peering.py b/tests/test_ec2/test_vpc_peering.py
index f99389f6e..18f4b64df 100644
--- a/tests/test_ec2/test_vpc_peering.py
+++ b/tests/test_ec2/test_vpc_peering.py
@@ -5,7 +5,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
def create_vpx_pcx(ec2, client):
@@ -16,7 +16,7 @@ def create_vpx_pcx(ec2, client):
return vpc_pcx
-@mock_ec2
+@mock_aws
def test_vpc_peering_connections_boto3():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -27,7 +27,7 @@ def test_vpc_peering_connections_boto3():
assert vpc_pcx["Status"]["Code"] == "initiating-request"
-@mock_ec2
+@mock_aws
def test_vpc_peering_connections_get_all_boto3():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -45,7 +45,7 @@ def test_vpc_peering_connections_get_all_boto3():
assert my_vpc_pcx["Status"]["Message"] == "Pending Acceptance by 123456789012"
-@mock_ec2
+@mock_aws
def test_vpc_peering_connections_accept_boto3():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -69,7 +69,7 @@ def test_vpc_peering_connections_accept_boto3():
assert my_vpc_pcxs[0]["Status"]["Code"] == "active"
-@mock_ec2
+@mock_aws
def test_vpc_peering_connections_reject_boto3():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -91,7 +91,7 @@ def test_vpc_peering_connections_reject_boto3():
assert my_pcxs[0]["Status"]["Code"] == "rejected"
-@mock_ec2
+@mock_aws
def test_vpc_peering_connections_delete_boto3():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -117,7 +117,7 @@ def test_vpc_peering_connections_delete_boto3():
)
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
@@ -207,7 +207,7 @@ def test_vpc_peering_connections_cross_region(account1, account2):
assert requester_options["AllowEgressFromLocalVpcToRemoteClassicLink"] is False
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
@@ -259,7 +259,7 @@ def test_modify_vpc_peering_connections_accepter_only(account1, account2):
assert requester_options["AllowEgressFromLocalVpcToRemoteClassicLink"] is False
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
@@ -311,7 +311,7 @@ def test_modify_vpc_peering_connections_requester_only(account1, account2):
assert accepter_options["AllowEgressFromLocalVpcToRemoteClassicLink"] is False
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
@@ -352,7 +352,7 @@ def test_modify_vpc_peering_connections_unknown_vpc(account1, account2):
assert err["Message"] == "VpcPeeringConnectionID vpx-unknown does not exist."
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
@@ -385,7 +385,7 @@ def test_vpc_peering_connections_cross_region_fail(account1, account2):
assert cm.value.response["Error"]["Code"] == "InvalidVpcID.NotFound"
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
@@ -440,7 +440,7 @@ def test_describe_vpc_peering_connections_only_returns_requested_id(account1, ac
assert len(one_pcx) == 1
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
@@ -515,7 +515,7 @@ def test_vpc_peering_connections_cross_region_accept(account1, account2):
)
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
@@ -565,7 +565,7 @@ def test_vpc_peering_connections_cross_region_reject(account1, account2):
assert des_pcx_usw1["VpcPeeringConnections"][0]["Status"]["Code"] == "rejected"
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
@@ -625,7 +625,7 @@ def test_vpc_peering_connections_cross_region_delete(account1, account2):
)
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
@@ -684,7 +684,7 @@ def test_vpc_peering_connections_cross_region_accept_wrong_region(account1, acco
assert cm.value.response["Error"]["Message"] == exp_msg
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"account1,account2",
[
diff --git a/tests/test_ec2/test_vpc_service_configuration_integration.py b/tests/test_ec2/test_vpc_service_configuration_integration.py
index 36fe8e1f0..c5ac30c77 100644
--- a/tests/test_ec2/test_vpc_service_configuration_integration.py
+++ b/tests/test_ec2/test_vpc_service_configuration_integration.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_elbv2
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID
from moto.moto_api._internal import mock_random
@@ -10,7 +10,7 @@ from moto.moto_api._internal import mock_random
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_ec2
+@mock_aws
def test_create_vpc_endpoint_service_configuration_without_params():
client = boto3.client("ec2", region_name="us-west-2")
@@ -25,8 +25,7 @@ def test_create_vpc_endpoint_service_configuration_without_params():
)
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_create_vpc_endpoint_service_configuration_with_network_load_balancer():
region_name = "eu-west-3"
client = boto3.client("ec2", region_name=region_name)
@@ -59,8 +58,7 @@ def test_create_vpc_endpoint_service_configuration_with_network_load_balancer():
assert "GatewayLoadBalancerArns" not in config
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_create_vpc_endpoint_service_configuration_with_gateway_load_balancer():
region = "us-east-2"
client = boto3.client("ec2", region_name=region)
@@ -93,8 +91,7 @@ def test_create_vpc_endpoint_service_configuration_with_gateway_load_balancer():
assert "NetworkLoadBalancerArns" not in config
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_create_vpc_endpoint_service_configuration_with_options():
client = boto3.client("ec2", region_name="us-east-2")
@@ -125,8 +122,7 @@ def test_create_vpc_endpoint_service_configuration_with_options():
assert detail["Owner"] == DEFAULT_ACCOUNT_ID
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_describe_vpc_endpoint_service_configurations():
region = "us-east-2"
client = boto3.client("ec2", region_name=region)
@@ -159,8 +155,7 @@ def test_describe_vpc_endpoint_service_configurations():
assert result["GatewayLoadBalancerArns"] == [lb_arn]
-@mock_ec2
-@mock_elbv2
+@mock_aws
@pytest.mark.parametrize(
"tags",
[
@@ -190,8 +185,7 @@ def test_describe_vpc_endpoint_service_configurations_with_tags(tags):
assert tag in result["Tags"]
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_describe_vpc_endpoint_service_configurations_and_add_tags():
tags = [{"Key": "k1", "Value": "v1"}]
region = "us-east-2"
@@ -216,7 +210,7 @@ def test_describe_vpc_endpoint_service_configurations_and_add_tags():
assert tag in result["Tags"]
-@mock_ec2
+@mock_aws
def test_describe_vpc_endpoint_service_configurations_unknown():
client = boto3.client("ec2", region_name="eu-west-3")
@@ -233,8 +227,7 @@ def test_describe_vpc_endpoint_service_configurations_unknown():
)
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_delete_vpc_endpoint_service_configurations():
region = "us-east-2"
client = boto3.client("ec2", region_name=region)
@@ -251,7 +244,7 @@ def test_delete_vpc_endpoint_service_configurations():
assert resp["Unsuccessful"] == []
-@mock_ec2
+@mock_aws
def test_delete_vpc_endpoint_service_configurations_already_deleted():
client = boto3.client("ec2", region_name="eu-west-3")
@@ -270,8 +263,7 @@ def test_delete_vpc_endpoint_service_configurations_already_deleted():
)
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_describe_vpc_endpoint_service_permissions():
region = "us-east-2"
client = boto3.client("ec2", region_name=region)
@@ -288,8 +280,7 @@ def test_describe_vpc_endpoint_service_permissions():
assert resp["AllowedPrincipals"] == []
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_modify_vpc_endpoint_service_permissions():
region = "us-east-2"
client = boto3.client("ec2", region_name=region)
@@ -320,8 +311,7 @@ def test_modify_vpc_endpoint_service_permissions():
assert {"Principal": "cipal2"} in resp["AllowedPrincipals"]
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_modify_vpc_endpoint_service_configuration():
region = "us-east-2"
client = boto3.client("ec2", region_name=region)
@@ -346,8 +336,7 @@ def test_modify_vpc_endpoint_service_configuration():
assert config["PrivateDnsName"] == "dnsname"
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_modify_vpc_endpoint_service_configuration_with_new_loadbalancers():
region = "us-east-2"
client = boto3.client("ec2", region_name=region)
diff --git a/tests/test_ec2/test_vpcs.py b/tests/test_ec2/test_vpcs.py
index 6fd401e7d..221b66a31 100644
--- a/tests/test_ec2/test_vpcs.py
+++ b/tests/test_ec2/test_vpcs.py
@@ -7,7 +7,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from .test_tags import retrieve_all_tagged
@@ -15,7 +15,7 @@ SAMPLE_DOMAIN_NAME = "example.com"
SAMPLE_NAME_SERVERS = ["10.0.0.6", "10.0.0.7"]
-@mock_ec2
+@mock_aws
def test_creating_a_vpc_in_empty_region_does_not_make_this_vpc_the_default():
if settings.TEST_SERVER_MODE:
raise SkipTest("Lets not start deleting VPC's while other tests are using it")
@@ -32,7 +32,7 @@ def test_creating_a_vpc_in_empty_region_does_not_make_this_vpc_the_default():
assert all_vpcs[0]["IsDefault"] is False
-@mock_ec2
+@mock_aws
def test_create_default_vpc():
if settings.TEST_SERVER_MODE:
raise SkipTest("Lets not start deleting VPC's while other tests are using it")
@@ -49,7 +49,7 @@ def test_create_default_vpc():
assert all_vpcs[0]["IsDefault"] is True
-@mock_ec2
+@mock_aws
def test_create_multiple_default_vpcs():
client = boto3.client("ec2", region_name="eu-north-1")
with pytest.raises(ClientError) as exc:
@@ -62,7 +62,7 @@ def test_create_multiple_default_vpcs():
)
-@mock_ec2
+@mock_aws
def test_create_and_delete_vpc():
ec2 = boto3.resource("ec2", region_name="eu-north-1")
client = boto3.client("ec2", region_name="eu-north-1")
@@ -84,7 +84,7 @@ def test_create_and_delete_vpc():
assert ex.value.response["Error"]["Code"] == "InvalidVpcID.NotFound"
-@mock_ec2
+@mock_aws
def test_vpc_defaults():
ec2 = boto3.resource("ec2", region_name="eu-north-1")
client = boto3.client("ec2", region_name="eu-north-1")
@@ -101,7 +101,7 @@ def test_vpc_defaults():
assert len(client.describe_security_groups(Filters=filters)["SecurityGroups"]) == 0
-@mock_ec2
+@mock_aws
def test_vpc_isdefault_filter():
ec2 = boto3.resource("ec2", region_name="eu-west-1")
client = boto3.client("ec2", region_name="eu-west-1")
@@ -119,7 +119,7 @@ def test_vpc_isdefault_filter():
assert len(default_vpcs) == 1
-@mock_ec2
+@mock_aws
def test_multiple_vpcs_default_filter():
ec2 = boto3.resource("ec2", region_name="eu-west-1")
client = boto3.client("ec2", region_name="eu-west-1")
@@ -132,7 +132,7 @@ def test_multiple_vpcs_default_filter():
assert "172.31.0.0/16" in [v["CidrBlock"] for v in default_vpcs]
-@mock_ec2
+@mock_aws
def test_vpc_state_available_filter():
ec2 = boto3.resource("ec2", region_name="eu-west-1")
client = boto3.client("ec2", region_name="eu-west-1")
@@ -161,7 +161,7 @@ def retrieve_all_vpcs(client, filters=[]): # pylint: disable=W0102
return all_vpcs
-@mock_ec2
+@mock_aws
def test_vpc_tagging():
ec2 = boto3.resource("ec2", region_name="eu-west-1")
client = boto3.client("ec2", region_name="eu-west-1")
@@ -179,7 +179,7 @@ def test_vpc_tagging():
assert vpc["Tags"] == [{"Key": "a key", "Value": "some value"}]
-@mock_ec2
+@mock_aws
def test_vpc_get_by_id():
ec2 = boto3.resource("ec2", region_name="eu-west-1")
client = boto3.client("ec2", region_name="eu-west-1")
@@ -200,7 +200,7 @@ def test_vpc_get_by_id():
assert ex.value.response["Error"]["Code"] == "InvalidVpcID.NotFound"
-@mock_ec2
+@mock_aws
def test_vpc_get_by_cidr_block():
ec2 = boto3.resource("ec2", region_name="eu-west-1")
client = boto3.client("ec2", region_name="eu-west-1")
@@ -216,7 +216,7 @@ def test_vpc_get_by_cidr_block():
assert set([vpc["VpcId"] for vpc in vpcs]) == {vpc1.id, vpc2.id}
-@mock_ec2
+@mock_aws
def test_vpc_get_by_dhcp_options_id():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -242,7 +242,7 @@ def test_vpc_get_by_dhcp_options_id():
assert vpc2.id in vpc_ids
-@mock_ec2
+@mock_aws
def test_vpc_get_by_tag():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -262,7 +262,7 @@ def test_vpc_get_by_tag():
assert set([vpc["VpcId"] for vpc in vpcs]) == {vpc1.id, vpc2.id}
-@mock_ec2
+@mock_aws
def test_vpc_get_by_tag_key_superset():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -284,7 +284,7 @@ def test_vpc_get_by_tag_key_superset():
assert set([vpc["VpcId"] for vpc in vpcs]) == {vpc1.id, vpc2.id}
-@mock_ec2
+@mock_aws
def test_vpc_get_by_tag_key_subset():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -307,7 +307,7 @@ def test_vpc_get_by_tag_key_subset():
assert set([vpc["VpcId"] for vpc in vpcs]) == {vpc1.id, vpc2.id}
-@mock_ec2
+@mock_aws
def test_vpc_get_by_tag_value_superset():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -329,7 +329,7 @@ def test_vpc_get_by_tag_value_superset():
assert set([vpc["VpcId"] for vpc in vpcs]) == {vpc1.id, vpc2.id}
-@mock_ec2
+@mock_aws
def test_vpc_get_by_tag_value_subset():
ec2 = boto3.resource("ec2", region_name="us-east-1")
client = boto3.client("ec2", region_name="us-east-1")
@@ -353,7 +353,7 @@ def test_vpc_get_by_tag_value_subset():
assert vpc2.id in vpc_ids
-@mock_ec2
+@mock_aws
def test_default_vpc():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -380,7 +380,7 @@ def test_default_vpc():
assert attr.get("Value") is False
-@mock_ec2
+@mock_aws
def test_non_default_vpc():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -415,7 +415,7 @@ def test_non_default_vpc():
assert "vpc-cidr-assoc" in cidr_block_association_set["AssociationId"]
-@mock_ec2
+@mock_aws
def test_vpc_dedicated_tenancy():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -430,7 +430,7 @@ def test_vpc_dedicated_tenancy():
assert vpc.instance_tenancy == "dedicated"
-@mock_ec2
+@mock_aws
def test_vpc_modify_tenancy_unknown():
ec2 = boto3.resource("ec2", region_name="us-west-1")
ec2_client = boto3.client("ec2", region_name="us-west-1")
@@ -455,7 +455,7 @@ def test_vpc_modify_tenancy_unknown():
assert vpc.instance_tenancy == "default"
-@mock_ec2
+@mock_aws
def test_vpc_modify_enable_dns_support():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -476,7 +476,7 @@ def test_vpc_modify_enable_dns_support():
assert attr.get("Value") is False
-@mock_ec2
+@mock_aws
def test_vpc_modify_enable_dns_hostnames():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -496,7 +496,7 @@ def test_vpc_modify_enable_dns_hostnames():
assert attr.get("Value") is not None
-@mock_ec2
+@mock_aws
def test_vpc_modify_enable_network_address_usage_metrics():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -516,7 +516,7 @@ def test_vpc_modify_enable_network_address_usage_metrics():
assert attr.get("Value") is True
-@mock_ec2
+@mock_aws
def test_vpc_associate_dhcp_options():
ec2 = boto3.resource("ec2", region_name="us-west-1")
client = boto3.client("ec2", region_name="us-west-1")
@@ -534,7 +534,7 @@ def test_vpc_associate_dhcp_options():
assert dhcp_options.id == vpc.dhcp_options_id
-@mock_ec2
+@mock_aws
def test_associate_vpc_ipv4_cidr_block():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -568,7 +568,7 @@ def test_associate_vpc_ipv4_cidr_block():
)
-@mock_ec2
+@mock_aws
def test_disassociate_vpc_ipv4_cidr_block():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -634,7 +634,7 @@ def test_disassociate_vpc_ipv4_cidr_block():
)
-@mock_ec2
+@mock_aws
def test_cidr_block_association_filters():
ec2 = boto3.resource("ec2", region_name="us-west-1")
vpc1 = ec2.create_vpc(CidrBlock="10.90.0.0/16")
@@ -688,7 +688,7 @@ def test_cidr_block_association_filters():
assert len(filtered_vpcs) == 0
-@mock_ec2
+@mock_aws
def test_vpc_associate_ipv6_cidr_block():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -723,7 +723,7 @@ def test_vpc_associate_ipv6_cidr_block():
assert len(vpc.ipv6_cidr_block_association_set) == 1
-@mock_ec2
+@mock_aws
def test_vpc_disassociate_ipv6_cidr_block():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -739,7 +739,7 @@ def test_vpc_disassociate_ipv6_cidr_block():
assert cidr["AssociationId"] == assoc_id
-@mock_ec2
+@mock_aws
def test_ipv6_cidr_block_association_filters():
ec2 = boto3.resource("ec2", region_name="us-west-1")
vpc1 = ec2.create_vpc(CidrBlock="10.90.0.0/16")
@@ -801,7 +801,7 @@ def test_ipv6_cidr_block_association_filters():
assert vpc4.id not in assoc_vpcs
-@mock_ec2
+@mock_aws
def test_create_vpc_with_invalid_cidr_block_parameter():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -814,7 +814,7 @@ def test_create_vpc_with_invalid_cidr_block_parameter():
)
-@mock_ec2
+@mock_aws
def test_create_vpc_with_invalid_cidr_range():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -827,7 +827,7 @@ def test_create_vpc_with_invalid_cidr_range():
)
-@mock_ec2
+@mock_aws
def test_create_vpc_with_tags():
ec2 = boto3.resource("ec2", region_name="us-west-1")
# Create VPC
@@ -840,7 +840,7 @@ def test_create_vpc_with_tags():
assert vpc.tags == [{"Key": "name", "Value": "some-vpc"}]
-@mock_ec2
+@mock_aws
def test_enable_vpc_classic_link():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -851,7 +851,7 @@ def test_enable_vpc_classic_link():
assert response.get("Return") is True
-@mock_ec2
+@mock_aws
def test_enable_vpc_classic_link_failure():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -862,7 +862,7 @@ def test_enable_vpc_classic_link_failure():
assert response.get("Return") is False
-@mock_ec2
+@mock_aws
def test_disable_vpc_classic_link():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -874,7 +874,7 @@ def test_disable_vpc_classic_link():
assert response.get("Return") is False
-@mock_ec2
+@mock_aws
def test_describe_classic_link_enabled():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -886,7 +886,7 @@ def test_describe_classic_link_enabled():
assert response.get("Vpcs")[0].get("ClassicLinkEnabled") is True
-@mock_ec2
+@mock_aws
def test_describe_classic_link_disabled():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -897,7 +897,7 @@ def test_describe_classic_link_disabled():
assert response.get("Vpcs")[0].get("ClassicLinkEnabled") is False
-@mock_ec2
+@mock_aws
def test_describe_classic_link_multiple():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -918,7 +918,7 @@ def test_describe_classic_link_multiple():
)
-@mock_ec2
+@mock_aws
def test_enable_vpc_classic_link_dns_support():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -929,7 +929,7 @@ def test_enable_vpc_classic_link_dns_support():
assert response.get("Return") is True
-@mock_ec2
+@mock_aws
def test_disable_vpc_classic_link_dns_support():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -941,7 +941,7 @@ def test_disable_vpc_classic_link_dns_support():
assert response.get("Return") is False
-@mock_ec2
+@mock_aws
def test_describe_classic_link_dns_support_enabled():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -953,7 +953,7 @@ def test_describe_classic_link_dns_support_enabled():
assert response.get("Vpcs")[0].get("ClassicLinkDnsSupported") is True
-@mock_ec2
+@mock_aws
def test_describe_classic_link_dns_support_disabled():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -964,7 +964,7 @@ def test_describe_classic_link_dns_support_disabled():
assert response.get("Vpcs")[0].get("ClassicLinkDnsSupported") is False
-@mock_ec2
+@mock_aws
def test_describe_classic_link_dns_support_multiple():
ec2 = boto3.resource("ec2", region_name="us-west-1")
@@ -987,7 +987,7 @@ def test_describe_classic_link_dns_support_multiple():
)
-@mock_ec2
+@mock_aws
def test_create_vpc_endpoint__policy():
ec2 = boto3.client("ec2", region_name="us-west-1")
vpc_id = ec2.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]["VpcId"]
@@ -1017,7 +1017,7 @@ def test_create_vpc_endpoint__policy():
assert vpc_end_point["PolicyDocument"] == "my policy document"
-@mock_ec2
+@mock_aws
def test_describe_vpc_gateway_end_points():
ec2 = boto3.client("ec2", region_name="us-west-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -1065,7 +1065,7 @@ def test_describe_vpc_gateway_end_points():
assert err["Code"] == "InvalidVpcEndpointId.NotFound"
-@mock_ec2
+@mock_aws
def test_describe_vpc_interface_end_points():
ec2 = boto3.client("ec2", region_name="us-west-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -1127,7 +1127,7 @@ def retrieve_all_endpoints(ec2):
return all_endpoints
-@mock_ec2
+@mock_aws
def test_modify_vpc_endpoint():
ec2 = boto3.client("ec2", region_name="us-west-1")
vpc_id = ec2.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]["VpcId"]
@@ -1171,7 +1171,7 @@ def test_modify_vpc_endpoint():
assert endpoint["PolicyDocument"] == "doc"
-@mock_ec2
+@mock_aws
def test_delete_vpc_end_points():
ec2 = boto3.client("ec2", region_name="us-west-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -1213,7 +1213,7 @@ def test_delete_vpc_end_points():
assert ep2["State"] == "available"
-@mock_ec2
+@mock_aws
def test_describe_vpcs_dryrun():
client = boto3.client("ec2", region_name="us-east-1")
@@ -1227,7 +1227,7 @@ def test_describe_vpcs_dryrun():
)
-@mock_ec2
+@mock_aws
def test_describe_prefix_lists():
client = boto3.client("ec2", region_name="us-east-1")
result_unfiltered = client.describe_prefix_lists()
diff --git a/tests/test_ec2/test_vpn_connections.py b/tests/test_ec2/test_vpn_connections.py
index 099674c77..bae4a2047 100644
--- a/tests/test_ec2/test_vpn_connections.py
+++ b/tests/test_ec2/test_vpn_connections.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2
+from moto import mock_aws
-@mock_ec2
+@mock_aws
def test_create_vpn_connections_boto3():
client = boto3.client("ec2", region_name="us-east-1")
vpn_connection = client.create_vpn_connection(
@@ -15,7 +15,7 @@ def test_create_vpn_connections_boto3():
assert vpn_connection["Type"] == "ipsec.1"
-@mock_ec2
+@mock_aws
def test_delete_vpn_connections_boto3():
client = boto3.client("ec2", region_name="us-east-1")
vpn_connection = client.create_vpn_connection(
@@ -35,7 +35,7 @@ def test_delete_vpn_connections_boto3():
assert my_cnx["State"] == "deleted"
-@mock_ec2
+@mock_aws
def test_delete_vpn_connections_bad_id_boto3():
client = boto3.client("ec2", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -45,7 +45,7 @@ def test_delete_vpn_connections_bad_id_boto3():
assert ex.value.response["Error"]["Code"] == "InvalidVpnConnectionID.NotFound"
-@mock_ec2
+@mock_aws
def test_create_vpn_connection_with_vpn_gateway():
client = boto3.client("ec2", region_name="us-east-1")
@@ -64,7 +64,7 @@ def test_create_vpn_connection_with_vpn_gateway():
assert vpn_connection["CustomerGatewayId"] == customer_gateway["CustomerGatewayId"]
-@mock_ec2
+@mock_aws
def test_describe_vpn_connections_boto3():
client = boto3.client("ec2", region_name="us-east-1")
@@ -98,7 +98,7 @@ def test_describe_vpn_connections_boto3():
assert conns[0]["State"] == "available"
-@mock_ec2
+@mock_aws
def test_describe_vpn_connections_unknown():
client = boto3.client("ec2", region_name="us-east-1")
diff --git a/tests/test_ec2/test_windows.py b/tests/test_ec2/test_windows.py
index 9b5f2545f..6d391c698 100644
--- a/tests/test_ec2/test_windows.py
+++ b/tests/test_ec2/test_windows.py
@@ -3,14 +3,14 @@ from unittest import SkipTest, mock
import boto3
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from tests import EXAMPLE_AMI_PARAVIRTUAL, EXAMPLE_AMI_WINDOWS
# The default AMIs are not loaded for our test case, to speed things up
# But we do need it for this specific test (and others in this file..)
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
def test_get_password_data():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
diff --git a/tests/test_ec2instanceconnect/test_ec2instanceconnect_boto3.py b/tests/test_ec2instanceconnect/test_ec2instanceconnect_boto3.py
index 3f676af96..9af890e6f 100644
--- a/tests/test_ec2instanceconnect/test_ec2instanceconnect_boto3.py
+++ b/tests/test_ec2instanceconnect/test_ec2instanceconnect_boto3.py
@@ -1,6 +1,6 @@
import boto3
-from moto import mock_ec2instanceconnect
+from moto import mock_aws
pubkey = """ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABAQDV5+voluw2zmzqpqCAqtsyoP01TQ8Ydx1eS1yD6wUsHcPqMIqpo57YxiC8XPwrdeKQ6GG6MC3bHsgXoPypGP0LyixbiuLTU31DnnqorcHt4bWs6rQa7dK2pCCflz2fhYRt5ZjqSNsAKivIbqkH66JozN0SySIka3kEV79GdB0BicioKeEJlCwM9vvxafyzjWf/z8E0lh4ni3vkLpIVJ0t5l+Qd9QMJrT6Is0SCQPVagTYZoi8+fWDoGsBa8vyRwDjEzBl28ZplKh9tSyDkRIYszWTpmK8qHiqjLYZBfAxXjGJbEYL1iig4ZxvbYzKEiKSBi1ZMW9iWjHfZDZuxXAmB
@@ -8,7 +8,7 @@ example
"""
-@mock_ec2instanceconnect
+@mock_aws
def test_send_ssh_public_key():
client = boto3.client("ec2-instance-connect", region_name="us-east-1")
fake_request_id = "example-2a47-4c91-9700-e37e85162cb6"
diff --git a/tests/test_ecr/test_ecr_boto3.py b/tests/test_ecr/test_ecr_boto3.py
index a6bd83a00..a810718c4 100644
--- a/tests/test_ecr/test_ecr_boto3.py
+++ b/tests/test_ecr/test_ecr_boto3.py
@@ -8,7 +8,7 @@ from botocore.exceptions import ClientError
from dateutil.tz import tzlocal
from freezegun import freeze_time
-from moto import mock_ecr, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .test_ecr_helpers import _create_image_manifest, _create_image_manifest_list
@@ -18,7 +18,7 @@ ECR_REPO = "test-repo"
ECR_REPO_NOT_EXIST = "does-not-exist"
-@mock_ecr
+@mock_aws
def test_create_repository():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -44,7 +44,7 @@ def test_create_repository():
assert repo["encryptionConfiguration"] == {"encryptionType": "AES256"}
-@mock_ecr
+@mock_aws
def test_create_repository_with_non_default_config():
# given
region_name = "eu-central-1"
@@ -81,7 +81,7 @@ def test_create_repository_with_non_default_config():
}
-@mock_ecr
+@mock_aws
def test_create_repository_in_different_account():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -112,7 +112,7 @@ def test_create_repository_in_different_account():
assert len(response["repositories"]) == 0
-@mock_ecr
+@mock_aws
def test_create_repository_with_aws_managed_kms():
# given
region_name = "eu-central-1"
@@ -131,7 +131,7 @@ def test_create_repository_with_aws_managed_kms():
)
-@mock_ecr
+@mock_aws
def test_create_repository_error_already_exists():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -152,7 +152,7 @@ def test_create_repository_error_already_exists():
)
-@mock_ecr
+@mock_aws
def test_create_repository_error_name_validation():
client = boto3.client("ecr", region_name=ECR_REGION)
repo_name = "tesT"
@@ -165,7 +165,7 @@ def test_create_repository_error_name_validation():
assert ex.response["Error"]["Code"] == "InvalidParameterException"
-@mock_ecr
+@mock_aws
def test_describe_repositories():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository1")
@@ -192,7 +192,7 @@ def test_describe_repositories():
} == repository_uris
-@mock_ecr
+@mock_aws
def test_describe_repositories_1():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository1")
@@ -219,7 +219,7 @@ def test_describe_repositories_1():
} == repository_uris
-@mock_ecr
+@mock_aws
def test_describe_repositories_2():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository1")
@@ -228,7 +228,7 @@ def test_describe_repositories_2():
assert len(response["repositories"]) == 0
-@mock_ecr
+@mock_aws
def test_describe_repositories_3():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository1")
@@ -242,7 +242,7 @@ def test_describe_repositories_3():
assert response["repositories"][0]["repositoryUri"] == repository_uri
-@mock_ecr
+@mock_aws
def test_describe_repositories_with_image():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -276,7 +276,7 @@ def test_describe_repositories_with_image():
assert repo["encryptionConfiguration"] == {"encryptionType": "AES256"}
-@mock_ecr
+@mock_aws
def test_delete_repository():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -304,7 +304,7 @@ def test_delete_repository():
assert len(response["repositories"]) == 0
-@mock_ecr
+@mock_aws
def test_delete_repository_with_force():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName=ECR_REPO)
@@ -337,7 +337,7 @@ def test_delete_repository_with_force():
assert len(response["repositories"]) == 0
-@mock_ecr
+@mock_aws
def test_put_image():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -354,7 +354,7 @@ def test_put_image():
assert response["image"]["registryId"] == ACCOUNT_ID
-@mock_ecr
+@mock_aws
def test_put_image_without_mediatype():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -375,7 +375,7 @@ def test_put_image_without_mediatype():
)
-@mock_ecr
+@mock_aws
def test_put_image_with_imagemanifestmediatype():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -397,7 +397,7 @@ def test_put_image_with_imagemanifestmediatype():
assert response["image"]["registryId"] == ACCOUNT_ID
-@mock_ecr()
+@mock_aws()
def test_put_manifest_list():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -425,7 +425,7 @@ def test_put_manifest_list():
assert "manifests" in image_manifest
-@mock_ecr
+@mock_aws
def test_put_image_with_push_date():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cant manipulate time in server mode")
@@ -460,7 +460,7 @@ def test_put_image_with_push_date():
} == {image1_date, image2_date}
-@mock_ecr
+@mock_aws
def test_put_image_with_multiple_tags():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -500,7 +500,7 @@ def test_put_image_with_multiple_tags():
assert response2["imageDetails"][0]["imageTags"] == ["v1", "latest"]
-@mock_ecr
+@mock_aws
def test_put_multiple_images_with_same_tag():
image_tag = "my-tag"
manifest = json.dumps(_create_image_manifest())
@@ -542,7 +542,7 @@ def test_put_multiple_images_with_same_tag():
assert set([img["imageDigest"] for img in images]) == {image_2, image_3}
-@mock_ecr
+@mock_aws
def test_put_same_image_with_same_tag():
image_tag = "my-tag"
manifest = json.dumps(_create_image_manifest())
@@ -577,7 +577,7 @@ def test_put_same_image_with_same_tag():
assert len(images) == 1
-@mock_ecr
+@mock_aws
def test_multiple_tags__ensure_tags_exist_only_on_one_image():
tag_to_move = "mock-tag"
image_manifests = {
@@ -625,7 +625,7 @@ def test_multiple_tags__ensure_tags_exist_only_on_one_image():
assert new_image["imageManifest"] == image_manifests["image_002"]
-@mock_ecr
+@mock_aws
def test_list_images():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository_1")
@@ -677,7 +677,7 @@ def test_list_images():
assert "sha" in response["imageIds"][0]["imageDigest"]
-@mock_ecr
+@mock_aws
def test_list_images_from_repository_that_doesnt_exist():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository_1")
@@ -695,7 +695,7 @@ def test_list_images_from_repository_that_doesnt_exist():
assert err["Code"] == "RepositoryNotFoundException"
-@mock_ecr
+@mock_aws
def test_describe_images():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -772,7 +772,7 @@ def test_describe_images():
assert response["imageDetails"][5]["imageSizeInBytes"] > 0
-@mock_ecr
+@mock_aws
def test_describe_images_by_tag():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -798,7 +798,7 @@ def test_describe_images_by_tag():
assert image_detail["imageDigest"] == put_response["imageId"]["imageDigest"]
-@mock_ecr
+@mock_aws
def test_describe_images_tags_should_not_contain_empty_tag1():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -825,7 +825,7 @@ def test_describe_images_tags_should_not_contain_empty_tag1():
assert image_detail["imageTags"] == tags
-@mock_ecr
+@mock_aws
def test_describe_images_tags_should_not_contain_empty_tag2():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -858,7 +858,7 @@ def test_describe_images_tags_should_not_contain_empty_tag2():
assert image_detail["imageTags"] == ["v1", "v2", "latest"]
-@mock_ecr
+@mock_aws
def test_describe_repository_that_doesnt_exist():
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -870,7 +870,7 @@ def test_describe_repository_that_doesnt_exist():
assert err["Code"] == "RepositoryNotFoundException"
-@mock_ecr
+@mock_aws
def test_describe_image_that_doesnt_exist():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName="test_repository")
@@ -894,7 +894,7 @@ def test_describe_image_that_doesnt_exist():
assert err["Code"] == "RepositoryNotFoundException"
-@mock_ecr
+@mock_aws
def test_delete_repository_that_doesnt_exist():
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -913,7 +913,7 @@ def test_delete_repository_that_doesnt_exist():
)
-@mock_ecr
+@mock_aws
def test_delete_repository_error_not_empty():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName=ECR_REPO)
@@ -938,7 +938,7 @@ def test_delete_repository_error_not_empty():
)
-@mock_ecr
+@mock_aws
def test_describe_images_by_digest():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -967,7 +967,7 @@ def test_describe_images_by_digest():
assert image_detail["imageDigest"] == digest
-@mock_ecr
+@mock_aws
def test_get_authorization_token_assume_region():
client = boto3.client("ecr", region_name=ECR_REGION)
auth_token_response = client.get_authorization_token()
@@ -983,7 +983,7 @@ def test_get_authorization_token_assume_region():
]
-@mock_ecr
+@mock_aws
def test_get_authorization_token_explicit_regions():
client = boto3.client("ecr", region_name=ECR_REGION)
auth_token_response = client.get_authorization_token(
@@ -1006,7 +1006,7 @@ def test_get_authorization_token_explicit_regions():
]
-@mock_ecr
+@mock_aws
def test_batch_get_image():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -1050,7 +1050,7 @@ def test_batch_get_image():
assert len(response["failures"]) == 0
-@mock_ecr
+@mock_aws
def test_batch_get_image_that_doesnt_exist():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -1087,7 +1087,7 @@ def test_batch_get_image_that_doesnt_exist():
assert response["failures"][0]["imageId"]["imageTag"] == "v5"
-@mock_ecr
+@mock_aws
def test_batch_get_image_with_multiple_tags():
client = boto3.client("ecr", region_name=ECR_REGION)
_ = client.create_repository(repositoryName="test_repository")
@@ -1119,7 +1119,7 @@ def test_batch_get_image_with_multiple_tags():
)
-@mock_ecr
+@mock_aws
def test_batch_delete_image_by_tag():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName="test_repository")
@@ -1159,7 +1159,7 @@ def test_batch_delete_image_by_tag():
assert len(batch_delete_response["failures"]) == 0
-@mock_ecr
+@mock_aws
def test_batch_delete_image_delete_last_tag():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName="test_repository")
@@ -1195,7 +1195,7 @@ def test_batch_delete_image_delete_last_tag():
assert len(batch_delete_response["failures"]) == 0
-@mock_ecr
+@mock_aws
def test_batch_delete_image_with_nonexistent_tag():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName="test_repository")
@@ -1236,7 +1236,7 @@ def test_batch_delete_image_with_nonexistent_tag():
assert len(batch_delete_response["failures"]) == 1
-@mock_ecr
+@mock_aws
def test_batch_delete_image_by_digest():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName="test_repository")
@@ -1282,7 +1282,7 @@ def test_batch_delete_image_by_digest():
assert len(batch_delete_response["failures"]) == 0
-@mock_ecr
+@mock_aws
def test_batch_delete_image_with_invalid_digest():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName="test_repository")
@@ -1322,7 +1322,7 @@ def test_batch_delete_image_with_invalid_digest():
)
-@mock_ecr
+@mock_aws
def test_batch_delete_image_with_missing_parameters():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName="test_repository")
@@ -1344,7 +1344,7 @@ def test_batch_delete_image_with_missing_parameters():
)
-@mock_ecr
+@mock_aws
def test_batch_delete_image_with_matching_digest_and_tag():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName="test_repository")
@@ -1390,7 +1390,7 @@ def test_batch_delete_image_with_matching_digest_and_tag():
assert len(batch_delete_response["failures"]) == 0
-@mock_ecr
+@mock_aws
def test_batch_delete_image_with_mismatched_digest_and_tag():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName="test_repository")
@@ -1431,7 +1431,7 @@ def test_batch_delete_image_with_mismatched_digest_and_tag():
)
-@mock_ecr
+@mock_aws
def test_delete_batch_image_with_multiple_images():
client = boto3.client("ecr", region_name=ECR_REGION)
client.create_repository(repositoryName=ECR_REPO)
@@ -1473,7 +1473,7 @@ def test_delete_batch_image_with_multiple_images():
]
-@mock_ecr
+@mock_aws
def test_list_tags_for_resource():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -1488,7 +1488,7 @@ def test_list_tags_for_resource():
assert tags == [{"Key": "key-1", "Value": "value-1"}]
-@mock_ecr
+@mock_aws
def test_list_tags_for_resource_error_not_exists():
# given
region_name = "eu-central-1"
@@ -1511,7 +1511,7 @@ def test_list_tags_for_resource_error_not_exists():
)
-@mock_ecr
+@mock_aws
def test_list_tags_for_resource_error_invalid_param():
# given
region_name = "eu-central-1"
@@ -1532,7 +1532,7 @@ def test_list_tags_for_resource_error_invalid_param():
)
-@mock_ecr
+@mock_aws
def test_tag_resource():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -1551,7 +1551,7 @@ def test_tag_resource():
]
-@mock_ecr
+@mock_aws
def test_tag_resource_error_not_exists():
# given
region_name = "eu-central-1"
@@ -1575,7 +1575,7 @@ def test_tag_resource_error_not_exists():
)
-@mock_ecr
+@mock_aws
def test_untag_resource():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -1595,7 +1595,7 @@ def test_untag_resource():
assert tags == [{"Key": "key-2", "Value": "value-2"}]
-@mock_ecr
+@mock_aws
def test_untag_resource_error_not_exists():
# given
region_name = "eu-central-1"
@@ -1619,7 +1619,7 @@ def test_untag_resource_error_not_exists():
)
-@mock_ecr
+@mock_aws
def test_put_image_tag_mutability():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -1642,7 +1642,7 @@ def test_put_image_tag_mutability():
assert response["repositories"][0]["imageTagMutability"] == "IMMUTABLE"
-@mock_ecr
+@mock_aws
def test_put_image_tag_mutability_error_not_exists():
# given
region_name = "eu-central-1"
@@ -1665,7 +1665,7 @@ def test_put_image_tag_mutability_error_not_exists():
)
-@mock_ecr
+@mock_aws
def test_put_image_tag_mutability_error_invalid_param():
# given
region_name = "eu-central-1"
@@ -1689,7 +1689,7 @@ def test_put_image_tag_mutability_error_invalid_param():
)
-@mock_ecr
+@mock_aws
def test_put_image_scanning_configuration():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -1716,7 +1716,7 @@ def test_put_image_scanning_configuration():
}
-@mock_ecr
+@mock_aws
def test_put_image_scanning_configuration_error_not_exists():
# given
region_name = "eu-central-1"
@@ -1740,7 +1740,7 @@ def test_put_image_scanning_configuration_error_not_exists():
)
-@mock_ecr
+@mock_aws
def test_set_repository_policy():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -1768,7 +1768,7 @@ def test_set_repository_policy():
assert json.loads(response["policyText"]) == policy
-@mock_ecr
+@mock_aws
def test_set_repository_policy_error_not_exists():
# given
region_name = "eu-central-1"
@@ -1802,7 +1802,7 @@ def test_set_repository_policy_error_not_exists():
)
-@mock_ecr
+@mock_aws
def test_set_repository_policy_error_invalid_param():
# given
region_name = "eu-central-1"
@@ -1830,7 +1830,7 @@ def test_set_repository_policy_error_invalid_param():
)
-@mock_ecr
+@mock_aws
def test_get_repository_policy():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -1857,7 +1857,7 @@ def test_get_repository_policy():
assert json.loads(response["policyText"]) == policy
-@mock_ecr
+@mock_aws
def test_get_repository_policy_error_repo_not_exists():
# given
region_name = "eu-central-1"
@@ -1878,7 +1878,7 @@ def test_get_repository_policy_error_repo_not_exists():
)
-@mock_ecr
+@mock_aws
def test_get_repository_policy_error_policy_not_exists():
# given
region_name = "eu-central-1"
@@ -1900,7 +1900,7 @@ def test_get_repository_policy_error_policy_not_exists():
)
-@mock_ecr
+@mock_aws
def test_delete_repository_policy():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -1932,7 +1932,7 @@ def test_delete_repository_policy():
assert e.value.response["Error"]["Code"] == "RepositoryPolicyNotFoundException"
-@mock_ecr
+@mock_aws
def test_delete_repository_policy_error_repo_not_exists():
# given
region_name = "eu-central-1"
@@ -1953,7 +1953,7 @@ def test_delete_repository_policy_error_repo_not_exists():
)
-@mock_ecr
+@mock_aws
def test_delete_repository_policy_error_policy_not_exists():
# given
region_name = "eu-central-1"
@@ -1975,7 +1975,7 @@ def test_delete_repository_policy_error_policy_not_exists():
)
-@mock_ecr
+@mock_aws
def test_put_lifecycle_policy():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2006,7 +2006,7 @@ def test_put_lifecycle_policy():
assert json.loads(response["lifecyclePolicyText"]) == policy
-@mock_ecr
+@mock_aws
def test_put_lifecycle_policy_error_repo_not_exists():
# given
region_name = "eu-central-1"
@@ -2043,7 +2043,7 @@ def test_put_lifecycle_policy_error_repo_not_exists():
)
-@mock_ecr
+@mock_aws
def test_get_lifecycle_policy():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2076,7 +2076,7 @@ def test_get_lifecycle_policy():
assert isinstance(response["lastEvaluatedAt"], datetime)
-@mock_ecr
+@mock_aws
def test_get_lifecycle_policy_error_repo_not_exists():
# given
region_name = "eu-central-1"
@@ -2097,7 +2097,7 @@ def test_get_lifecycle_policy_error_repo_not_exists():
)
-@mock_ecr
+@mock_aws
def test_get_lifecycle_policy_error_policy_not_exists():
# given
region_name = "eu-central-1"
@@ -2119,7 +2119,7 @@ def test_get_lifecycle_policy_error_policy_not_exists():
)
-@mock_ecr
+@mock_aws
def test_delete_lifecycle_policy():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2157,7 +2157,7 @@ def test_delete_lifecycle_policy():
assert e.value.response["Error"]["Code"] == "LifecyclePolicyNotFoundException"
-@mock_ecr
+@mock_aws
def test_delete_lifecycle_policy_error_repo_not_exists():
# given
region_name = "eu-central-1"
@@ -2178,7 +2178,7 @@ def test_delete_lifecycle_policy_error_repo_not_exists():
)
-@mock_ecr
+@mock_aws
def test_delete_lifecycle_policy_error_policy_not_exists():
# given
region_name = "eu-central-1"
@@ -2200,7 +2200,7 @@ def test_delete_lifecycle_policy_error_policy_not_exists():
)
-@mock_ecr
+@mock_aws
@pytest.mark.parametrize(
"actions",
["ecr:CreateRepository", ["ecr:CreateRepository", "ecr:ReplicateImage"]],
@@ -2231,7 +2231,7 @@ def test_put_registry_policy(actions):
assert json.loads(response["policyText"]) == policy
-@mock_ecr
+@mock_aws
def test_put_registry_policy_error_invalid_action():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2266,7 +2266,7 @@ def test_put_registry_policy_error_invalid_action():
)
-@mock_ecr
+@mock_aws
def test_get_registry_policy():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2293,7 +2293,7 @@ def test_get_registry_policy():
assert json.loads(response["policyText"]) == policy
-@mock_ecr
+@mock_aws
def test_get_registry_policy_error_policy_not_exists():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2313,7 +2313,7 @@ def test_get_registry_policy_error_policy_not_exists():
)
-@mock_ecr
+@mock_aws
def test_delete_registry_policy():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2345,7 +2345,7 @@ def test_delete_registry_policy():
assert e.value.response["Error"]["Code"] == "RegistryPolicyNotFoundException"
-@mock_ecr
+@mock_aws
def test_delete_registry_policy_error_policy_not_exists():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2365,7 +2365,7 @@ def test_delete_registry_policy_error_policy_not_exists():
)
-@mock_ecr
+@mock_aws
def test_start_image_scan():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2389,7 +2389,7 @@ def test_start_image_scan():
assert response["imageScanStatus"] == {"status": "IN_PROGRESS"}
-@mock_ecr
+@mock_aws
def test_start_image_scan_error_repo_not_exists():
# given
region_name = "eu-central-1"
@@ -2412,7 +2412,7 @@ def test_start_image_scan_error_repo_not_exists():
)
-@mock_ecr
+@mock_aws
def test_start_image_scan_error_image_not_exists():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2436,7 +2436,7 @@ def test_start_image_scan_error_image_not_exists():
)
-@mock_ecr
+@mock_aws
def test_start_image_scan_error_image_tag_digest_mismatch():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2466,7 +2466,7 @@ def test_start_image_scan_error_image_tag_digest_mismatch():
)
-@mock_ecr
+@mock_aws
def test_start_image_scan_error_daily_limit():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2496,7 +2496,7 @@ def test_start_image_scan_error_daily_limit():
)
-@mock_ecr
+@mock_aws
def test_describe_image_scan_findings():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2541,7 +2541,7 @@ def test_describe_image_scan_findings():
assert scan_findings["findingSeverityCounts"] == {"HIGH": 1}
-@mock_ecr
+@mock_aws
def test_describe_image_scan_findings_error_repo_not_exists():
# given
region_name = "eu-central-1"
@@ -2564,7 +2564,7 @@ def test_describe_image_scan_findings_error_repo_not_exists():
)
-@mock_ecr
+@mock_aws
def test_describe_image_scan_findings_error_image_not_exists():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2588,7 +2588,7 @@ def test_describe_image_scan_findings_error_image_not_exists():
)
-@mock_ecr
+@mock_aws
def test_describe_image_scan_findings_error_scan_not_exists():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2617,7 +2617,7 @@ def test_describe_image_scan_findings_error_scan_not_exists():
)
-@mock_ecr
+@mock_aws
def test_put_replication_configuration():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2632,7 +2632,7 @@ def test_put_replication_configuration():
assert response["replicationConfiguration"] == config
-@mock_ecr
+@mock_aws
def test_put_replication_configuration_error_feature_disabled():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2663,7 +2663,7 @@ def test_put_replication_configuration_error_feature_disabled():
assert ex.response["Error"]["Message"] == "This feature is disabled"
-@mock_ecr
+@mock_aws
def test_put_replication_configuration_error_same_source():
# given
region_name = "eu-central-1"
@@ -2689,7 +2689,7 @@ def test_put_replication_configuration_error_same_source():
)
-@mock_ecr
+@mock_aws
def test_describe_registry():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2702,7 +2702,7 @@ def test_describe_registry():
assert response["replicationConfiguration"] == {"rules": []}
-@mock_ecr
+@mock_aws
def test_describe_registry_after_update():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
@@ -2720,7 +2720,7 @@ def test_describe_registry_after_update():
assert response["replicationConfiguration"] == config
-@mock_ecr
+@mock_aws
def test_ecr_image_digest():
# given
client = boto3.client("ecr", region_name=ECR_REGION)
diff --git a/tests/test_ecr/test_ecr_cloudformation.py b/tests/test_ecr/test_ecr_cloudformation.py
index b5cfd3609..d23b6ee44 100644
--- a/tests/test_ecr/test_ecr_cloudformation.py
+++ b/tests/test_ecr/test_ecr_cloudformation.py
@@ -4,7 +4,7 @@ from string import Template
import boto3
-from moto import mock_cloudformation, mock_ecr
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
repo_template = Template(
@@ -29,8 +29,7 @@ repo_template = Template(
)
-@mock_ecr
-@mock_cloudformation
+@mock_aws
def test_create_repository():
# given
cfn_client = boto3.client("cloudformation", region_name="eu-central-1")
@@ -52,8 +51,7 @@ def test_create_repository():
assert response["repositories"][0]["repositoryArn"] == repo_arn
-@mock_ecr
-@mock_cloudformation
+@mock_aws
def test_update_repository():
# given
cfn_client = boto3.client("cloudformation", region_name="eu-central-1")
@@ -84,8 +82,7 @@ def test_update_repository():
assert repo["imageTagMutability"] == "IMMUTABLE"
-@mock_ecr
-@mock_cloudformation
+@mock_aws
def test_delete_repository():
# given
cfn_client = boto3.client("cloudformation", region_name="eu-central-1")
diff --git a/tests/test_ecr/test_ecr_scanning_config.py b/tests/test_ecr/test_ecr_scanning_config.py
index 4114f53f6..5858ba9d0 100644
--- a/tests/test_ecr/test_ecr_scanning_config.py
+++ b/tests/test_ecr/test_ecr_scanning_config.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_ecr
+from moto import mock_aws
-@mock_ecr
+@mock_aws
def test_batch_get_repository_scanning_configuration():
client = boto3.client("ecr", region_name="us-east-1")
repo_name = "test-repo"
@@ -42,7 +42,7 @@ def test_batch_get_repository_scanning_configuration():
]
-@mock_ecr
+@mock_aws
def test_put_registry_scanning_configuration():
client = boto3.client("ecr", region_name="us-east-1")
repo_name = "test-repo"
diff --git a/tests/test_ecs/test_ecs_account_settings.py b/tests/test_ecs/test_ecs_account_settings.py
index ccbe22abd..caf22a439 100644
--- a/tests/test_ecs/test_ecs_account_settings.py
+++ b/tests/test_ecs/test_ecs_account_settings.py
@@ -4,13 +4,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_ecs
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.ec2 import utils as ec2_utils
from tests import EXAMPLE_AMI_ID
-@mock_ecs
+@mock_aws
def test_list_account_settings_initial():
client = boto3.client("ecs", region_name="eu-west-1")
@@ -18,7 +18,7 @@ def test_list_account_settings_initial():
assert resp["settings"] == []
-@mock_ecs
+@mock_aws
@pytest.mark.parametrize(
"name",
["containerInstanceLongArnFormat", "serviceLongArnFormat", "taskLongArnFormat"],
@@ -31,7 +31,7 @@ def test_put_account_setting(name, value):
assert resp["setting"] == {"name": name, "value": value}
-@mock_ecs
+@mock_aws
def test_list_account_setting():
client = boto3.client("ecs", region_name="eu-west-1")
@@ -59,7 +59,7 @@ def test_list_account_setting():
assert {"name": "taskLongArnFormat", "value": "enabled"} in resp["settings"]
-@mock_ecs
+@mock_aws
def test_list_account_settings_wrong_name():
client = boto3.client("ecs", region_name="eu-west-1")
@@ -73,7 +73,7 @@ def test_list_account_settings_wrong_name():
)
-@mock_ecs
+@mock_aws
def test_delete_account_setting():
client = boto3.client("ecs", region_name="eu-west-1")
@@ -94,8 +94,7 @@ def test_delete_account_setting():
assert {"name": "taskLongArnFormat", "value": "enabled"} in resp["settings"]
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_put_account_setting_changes_service_arn():
client = boto3.client("ecs", region_name="eu-west-1")
client.put_account_setting(name="serviceLongArnFormat", value="disabled")
@@ -136,8 +135,7 @@ def test_put_account_setting_changes_service_arn():
)
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_put_account_setting_changes_containerinstance_arn():
ecs_client = boto3.client("ecs", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -176,8 +174,7 @@ def test_put_account_setting_changes_containerinstance_arn():
)
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_run_task_default_cluster_new_arn_format():
client = boto3.client("ecs", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
diff --git a/tests/test_ecs/test_ecs_boto3.py b/tests/test_ecs/test_ecs_boto3.py
index d63f0cc10..75a5cebfa 100644
--- a/tests/test_ecs/test_ecs_boto3.py
+++ b/tests/test_ecs/test_ecs_boto3.py
@@ -8,7 +8,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_ecs, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.ec2 import utils as ec2_utils
from moto.moto_api import state_manager
@@ -17,7 +17,7 @@ from tests import EXAMPLE_AMI_ID
ECS_REGION = "us-east-1"
-@mock_ecs
+@mock_aws
def test_create_cluster():
client = boto3.client("ecs", region_name=ECS_REGION)
response = client.create_cluster(clusterName="test_ecs_cluster")
@@ -33,7 +33,7 @@ def test_create_cluster():
assert response["cluster"]["activeServicesCount"] == 0
-@mock_ecs
+@mock_aws
def test_create_cluster_with_setting():
client = boto3.client("ecs", region_name=ECS_REGION)
cluster = client.create_cluster(
@@ -47,7 +47,7 @@ def test_create_cluster_with_setting():
assert cluster["serviceConnectDefaults"] == {"namespace": "ns"}
-@mock_ecs
+@mock_aws
def test_create_cluster_with_capacity_providers():
client = boto3.client("ecs", region_name=ECS_REGION)
cluster = client.create_cluster(
@@ -65,7 +65,7 @@ def test_create_cluster_with_capacity_providers():
]
-@mock_ecs
+@mock_aws
def test_put_capacity_providers():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -85,7 +85,7 @@ def test_put_capacity_providers():
]
-@mock_ecs
+@mock_aws
def test_list_clusters():
client = boto3.client("ecs", region_name="us-east-2")
client.create_cluster(clusterName="test_cluster0")
@@ -101,7 +101,7 @@ def test_list_clusters():
)
-@mock_ecs
+@mock_aws
def test_create_cluster_with_tags():
client = boto3.client("ecs", region_name=ECS_REGION)
tag_list = [{"key": "tagName", "value": "TagValue"}]
@@ -120,7 +120,7 @@ def test_create_cluster_with_tags():
assert tags == [{"key": "tagName", "value": "TagValue"}]
-@mock_ecs
+@mock_aws
def test_describe_clusters():
client = boto3.client("ecs", region_name=ECS_REGION)
tag_list = [{"key": "tagName", "value": "TagValue"}]
@@ -150,7 +150,7 @@ def test_describe_clusters():
assert "tags" not in clusters[1]
-@mock_ecs
+@mock_aws
def test_describe_clusters_missing():
client = boto3.client("ecs", region_name=ECS_REGION)
response = client.describe_clusters(clusters=["some-cluster"])
@@ -160,7 +160,7 @@ def test_describe_clusters_missing():
} in response["failures"]
-@mock_ecs
+@mock_aws
def test_delete_cluster():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -180,7 +180,7 @@ def test_delete_cluster():
assert len(response["clusterArns"]) == 1
-@mock_ecs
+@mock_aws
def test_delete_cluster_exceptions():
client = boto3.client("ecs", region_name=ECS_REGION)
with pytest.raises(ClientError) as exc:
@@ -188,7 +188,7 @@ def test_delete_cluster_exceptions():
assert exc.value.response["Error"]["Code"] == "ClusterNotFoundException"
-@mock_ecs
+@mock_aws
def test_register_task_definition():
client = boto3.client("ecs", region_name=ECS_REGION)
# Registering with minimal definition
@@ -296,7 +296,7 @@ def test_register_task_definition():
)
-@mock_ecs
+@mock_aws
def test_register_task_definition_fargate_with_pid_mode():
client = boto3.client("ecs", region_name=ECS_REGION)
definition = dict(
@@ -323,7 +323,7 @@ def test_register_task_definition_fargate_with_pid_mode():
)
-@mock_ecs
+@mock_aws
def test_register_task_definition_memory_validation():
client = boto3.client("ecs", region_name=ECS_REGION)
container_name = "hello_world"
@@ -348,7 +348,7 @@ def test_register_task_definition_memory_validation():
)
-@mock_ecs
+@mock_aws
@pytest.mark.parametrize(
"ecs_def,missing_prop",
[({"image": "hello-world:latest"}, "name"), ({"name": "test-name"}, "image")],
@@ -376,7 +376,7 @@ def test_register_task_definition_container_definition_validation(
)
-@mock_ecs
+@mock_aws
def test_list_task_definitions():
client = boto3.client("ecs", region_name=ECS_REGION)
client.register_task_definition(
@@ -423,7 +423,7 @@ def test_list_task_definitions():
)
-@mock_ecs
+@mock_aws
def test_list_task_definitions_with_family_prefix():
client = boto3.client("ecs", region_name=ECS_REGION)
client.register_task_definition(
@@ -488,7 +488,7 @@ def test_list_task_definitions_with_family_prefix():
)
-@mock_ecs
+@mock_aws
def test_describe_task_definitions():
client = boto3.client("ecs", region_name=ECS_REGION)
client.register_task_definition(
@@ -556,7 +556,7 @@ def test_describe_task_definitions():
assert response["taskDefinition"]["executionRoleArn"] == "my-execution-role-arn"
-@mock_ecs
+@mock_aws
def test_deregister_task_definition_1():
client = boto3.client("ecs", region_name=ECS_REGION)
client.register_task_definition(
@@ -607,7 +607,7 @@ def test_deregister_task_definition_1():
)
-@mock_ecs
+@mock_aws
def test_deregister_task_definition_2():
client = boto3.client("ecs", region_name=ECS_REGION)
with pytest.raises(ClientError) as exc:
@@ -627,7 +627,7 @@ def test_deregister_task_definition_2():
)
-@mock_ecs
+@mock_aws
def test_create_service():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -678,8 +678,7 @@ def test_create_service():
assert response["service"]["platformVersion"] == "2"
-@mock_ecs
-@mock_ec2
+@mock_aws
def test_create_running_service():
if settings.TEST_SERVER_MODE:
raise SkipTest(
@@ -705,8 +704,7 @@ def test_create_running_service():
assert response["service"]["pendingCount"] == 1
-@mock_ecs
-@mock_ec2
+@mock_aws
def test_create_running_service_bad_env_var():
running_service_count = "ALSDHLHA;''"
with mock.patch.dict(
@@ -727,8 +725,7 @@ def test_create_running_service_bad_env_var():
assert response["service"]["runningCount"] == 0
-@mock_ecs
-@mock_ec2
+@mock_aws
def test_create_running_service_negative_env_var():
running_service_count = "-20"
with mock.patch.dict(
@@ -749,7 +746,7 @@ def test_create_running_service_negative_env_var():
assert response["service"]["runningCount"] == 0
-@mock_ecs
+@mock_aws
def test_create_service_errors():
# given
client = boto3.client("ecs", region_name=ECS_REGION)
@@ -792,7 +789,7 @@ def test_create_service_errors():
)
-@mock_ecs
+@mock_aws
def test_create_service_scheduling_strategy():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -841,7 +838,7 @@ def test_create_service_scheduling_strategy():
assert response["service"]["schedulingStrategy"] == "DAEMON"
-@mock_ecs
+@mock_aws
def test_list_services():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster1")
@@ -908,7 +905,7 @@ def test_list_services():
assert cluster1_fargate_services["serviceArns"][0] == test_ecs_service2_arn
-@mock_ecs
+@mock_aws
@pytest.mark.parametrize("args", [{}, {"cluster": "foo"}], ids=["no args", "unknown"])
def test_list_unknown_service(args):
client = boto3.client("ecs", region_name=ECS_REGION)
@@ -919,7 +916,7 @@ def test_list_unknown_service(args):
assert err["Message"] == "Cluster not found."
-@mock_ecs
+@mock_aws
def test_describe_services():
client = boto3.client("ecs", region_name=ECS_REGION)
cluster_arn = client.create_cluster(clusterName="test_ecs_cluster")["cluster"][
@@ -1009,7 +1006,7 @@ def test_describe_services():
assert response["services"][1]["launchType"] == "EC2"
-@mock_ecs
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_ECS_NEW_ARN": "TrUe"})
def test_describe_services_new_arn():
if settings.TEST_SERVER_MODE:
@@ -1041,7 +1038,7 @@ def test_describe_services_new_arn():
)
-@mock_ecs
+@mock_aws
def test_describe_services_scheduling_strategy():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -1110,7 +1107,7 @@ def test_describe_services_scheduling_strategy():
assert response["services"][2]["schedulingStrategy"] == "REPLICA"
-@mock_ecs
+@mock_aws
def test_describe_services_error_unknown_cluster():
# given
client = boto3.client("ecs", region_name="eu-central-1")
@@ -1128,7 +1125,7 @@ def test_describe_services_error_unknown_cluster():
assert ex.response["Error"]["Message"] == "Cluster not found."
-@mock_ecs
+@mock_aws
def test_describe_services_with_known_unknown_services():
# given
client = boto3.client("ecs", region_name="eu-central-1")
@@ -1183,7 +1180,7 @@ def test_describe_services_with_known_unknown_services():
]
-@mock_ecs
+@mock_aws
def test_update_service():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -1230,7 +1227,7 @@ def test_update_service():
assert response["service"]["desiredCount"] == 1
-@mock_ecs
+@mock_aws
def test_update_missing_service():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -1244,7 +1241,7 @@ def test_update_missing_service():
)
-@mock_ecs
+@mock_aws
def test_delete_service():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -1304,7 +1301,7 @@ def test_delete_service():
assert service["status"] == "INACTIVE"
-@mock_ecs
+@mock_aws
def test_delete_service__using_arns():
client = boto3.client("ecs", region_name=ECS_REGION)
cluster_arn = client.create_cluster(clusterName="test_ecs_cluster")["cluster"][
@@ -1342,7 +1339,7 @@ def test_delete_service__using_arns():
)
-@mock_ecs
+@mock_aws
def test_delete_service_force():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -1392,7 +1389,7 @@ def test_delete_service_force():
)
-@mock_ecs
+@mock_aws
def test_delete_service_exceptions():
client = boto3.client("ecs", region_name=ECS_REGION)
@@ -1430,7 +1427,7 @@ def test_delete_service_exceptions():
)
-@mock_ecs
+@mock_aws
def test_update_service_exceptions():
client = boto3.client("ecs", region_name=ECS_REGION)
@@ -1445,8 +1442,7 @@ def test_update_service_exceptions():
assert "ServiceNotFoundException" in exc.value.response["Error"]["Message"]
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_register_container_instance():
ecs_client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -1485,8 +1481,7 @@ def test_register_container_instance():
)
-@mock_ec2
-@mock_ecs
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_ECS_NEW_ARN": "TrUe"})
def test_register_container_instance_new_arn_format():
if settings.TEST_SERVER_MODE:
@@ -1518,8 +1513,7 @@ def test_register_container_instance_new_arn_format():
)
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_deregister_container_instance():
ecs_client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -1596,8 +1590,7 @@ def test_deregister_container_instance():
assert len(container_instances_response["containerInstanceArns"]) == 0
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_list_container_instances():
ecs_client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -1629,8 +1622,7 @@ def test_list_container_instances():
assert arn in response["containerInstanceArns"]
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_describe_container_instances():
ecs_client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -1680,7 +1672,7 @@ def test_describe_container_instances():
assert err["Message"] == "Container Instances cannot be empty."
-@mock_ecs
+@mock_aws
def test_describe_container_instances_exceptions():
client = boto3.client("ecs", region_name=ECS_REGION)
@@ -1696,8 +1688,7 @@ def test_describe_container_instances_exceptions():
)
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_update_container_instances_state():
ecs_client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -1759,8 +1750,7 @@ def test_update_container_instances_state():
)
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_update_container_instances_state_by_arn():
ecs_client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -1823,8 +1813,7 @@ def test_update_container_instances_state_by_arn():
)
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_run_task():
client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -1902,8 +1891,7 @@ def test_run_task():
assert task["tags"][0].get("value") == "tagValue0"
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_wait_tasks_stopped():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set transition directly in ServerMode")
@@ -1969,8 +1957,7 @@ def test_wait_tasks_stopped():
state_manager.unset_transition("ecs::task")
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_task_state_transitions():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set transition directly in ServerMode")
@@ -2036,8 +2023,7 @@ def test_task_state_transitions():
state_manager.unset_transition("ecs::task")
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_run_task_awsvpc_network():
# Setup
client = boto3.client("ecs", region_name=ECS_REGION)
@@ -2085,8 +2071,7 @@ def test_run_task_awsvpc_network():
assert {"name": "macAddress", "value": eni["MacAddress"]} in details
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_run_task_awsvpc_network_error():
# Setup
client = boto3.client("ecs", region_name=ECS_REGION)
@@ -2112,7 +2097,7 @@ def test_run_task_awsvpc_network_error():
)
-@mock_ecs
+@mock_aws
def test_run_task_default_cluster():
client = boto3.client("ecs", region_name=ECS_REGION)
@@ -2158,8 +2143,7 @@ def test_run_task_default_cluster():
assert response["tasks"][0]["stoppedReason"] == ""
-@mock_ec2
-@mock_ecs
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_ECS_NEW_ARN": "TrUe"})
def test_run_task_default_cluster_new_arn_format():
if settings.TEST_SERVER_MODE:
@@ -2208,7 +2192,7 @@ def test_run_task_default_cluster_new_arn_format():
)
-@mock_ecs
+@mock_aws
def test_run_task_exceptions():
client = boto3.client("ecs", region_name=ECS_REGION)
client.register_task_definition(
@@ -2234,8 +2218,7 @@ def test_run_task_exceptions():
assert err["Message"] == "launch type should be one of [EC2,FARGATE,EXTERNAL]"
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_start_task():
client = boto3.client("ecs", region_name=ECS_REGION)
test_cluster_name = "test_ecs_cluster"
@@ -2278,8 +2261,7 @@ def test_start_task():
assert response["tasks"][0]["stoppedReason"] == ""
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_start_task_with_tags():
client = boto3.client("ecs", region_name=ECS_REGION)
test_cluster_name = "test_ecs_cluster"
@@ -2324,7 +2306,7 @@ def test_start_task_with_tags():
assert response["tasks"][0]["stoppedReason"] == ""
-@mock_ecs
+@mock_aws
def test_start_task_exceptions():
client = boto3.client("ecs", region_name=ECS_REGION)
client.register_task_definition(
@@ -2350,8 +2332,7 @@ def test_start_task_exceptions():
client.start_task(taskDefinition="test_ecs_task", containerInstances=[])
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_list_tasks():
client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -2408,7 +2389,7 @@ def test_list_tasks():
assert len(client.list_tasks(startedBy="foo")["taskArns"]) == 1
-@mock_ecs
+@mock_aws
def test_list_tasks_exceptions():
client = boto3.client("ecs", region_name=ECS_REGION)
with pytest.raises(ClientError) as exc:
@@ -2416,8 +2397,7 @@ def test_list_tasks_exceptions():
assert exc.value.response["Error"]["Code"] == "ClusterNotFoundException"
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_describe_tasks():
client = boto3.client("ecs", region_name=ECS_REGION)
test_cluster_name = "test_ecs_cluster"
@@ -2447,8 +2427,7 @@ def test_describe_tasks():
assert len(response["tasks"]) == 1
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_describe_tasks_empty_tags():
client = boto3.client("ecs", region_name=ECS_REGION)
test_cluster_name = "test_ecs_cluster"
@@ -2481,7 +2460,42 @@ def test_describe_tasks_empty_tags():
assert len(response["tasks"]) == 1
-@mock_ecs
+@mock_aws
+def test_describe_tasks_include_tags():
+ client = boto3.client("ecs", region_name=ECS_REGION)
+ test_cluster_name = "test_ecs_cluster"
+ setup_ecs_cluster_with_ec2_instance(client, test_cluster_name)
+
+ task_tags = [{"key": "Name", "value": "test_ecs_task"}]
+ tasks_arns = [
+ task["taskArn"]
+ for task in client.run_task(
+ cluster="test_ecs_cluster",
+ overrides={},
+ taskDefinition="test_ecs_task",
+ count=2,
+ startedBy="moto",
+ tags=task_tags,
+ )["tasks"]
+ ]
+ response = client.describe_tasks(
+ cluster="test_ecs_cluster", tasks=tasks_arns, include=["TAGS"]
+ )
+
+ assert len(response["tasks"]) == 2
+ assert set(
+ [response["tasks"][0]["taskArn"], response["tasks"][1]["taskArn"]]
+ ) == set(tasks_arns)
+ assert response["tasks"][0]["tags"] == task_tags
+
+ # Test we can pass task ids instead of ARNs
+ response = client.describe_tasks(
+ cluster="test_ecs_cluster", tasks=[tasks_arns[0].split("/")[-1]]
+ )
+ assert len(response["tasks"]) == 1
+
+
+@mock_aws
def test_describe_tasks_exceptions():
client = boto3.client("ecs", region_name=ECS_REGION)
@@ -2495,7 +2509,7 @@ def test_describe_tasks_exceptions():
assert exc.value.response["Error"]["Code"] == "InvalidParameterException"
-@mock_ecs
+@mock_aws
def test_describe_task_definition_by_family():
client = boto3.client("ecs", region_name=ECS_REGION)
container_definition = {
@@ -2540,8 +2554,7 @@ def test_describe_task_definition_by_family():
assert task["ephemeralStorage"] == {"sizeInGiB": 123}
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_stop_task():
client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -2597,7 +2610,7 @@ def test_stop_task():
assert stop_response["task"]["stoppedReason"] == "moto testing"
-@mock_ecs
+@mock_aws
def test_stop_task_exceptions():
client = boto3.client("ecs", region_name=ECS_REGION)
@@ -2606,8 +2619,7 @@ def test_stop_task_exceptions():
assert exc.value.response["Error"]["Code"] == "ClusterNotFoundException"
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_resource_reservation_and_release():
client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -2681,8 +2693,7 @@ def test_resource_reservation_and_release():
assert container_instance_description["runningTasksCount"] == 0
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_resource_reservation_and_release_memory_reservation():
client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -2754,8 +2765,7 @@ def test_resource_reservation_and_release_memory_reservation():
assert container_instance_description["runningTasksCount"] == 0
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_task_definitions_unable_to_be_placed():
client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -2795,8 +2805,7 @@ def test_task_definitions_unable_to_be_placed():
assert len(response["tasks"]) == 0
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_task_definitions_with_port_clash():
client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -2864,8 +2873,7 @@ def test_task_definitions_with_port_clash():
assert response["tasks"][0]["stoppedReason"] == ""
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_attributes():
# Combined put, list delete attributes into the same test due to the amount of setup
ecs_client = boto3.client("ecs", region_name=ECS_REGION)
@@ -2975,7 +2983,7 @@ def test_attributes():
)
-@mock_ecs
+@mock_aws
def test_poll_endpoint():
# Combined put, list delete attributes into the same test due to the amount of setup
ecs_client = boto3.client("ecs", region_name=ECS_REGION)
@@ -2986,7 +2994,7 @@ def test_poll_endpoint():
assert "telemetryEndpoint" in resp
-@mock_ecs
+@mock_aws
def test_list_task_definition_families():
client = boto3.client("ecs", region_name=ECS_REGION)
client.register_task_definition(
@@ -3029,8 +3037,7 @@ def test_list_task_definition_families():
assert len(resp2["families"]) == 1
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_default_container_instance_attributes():
ecs_client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -3071,8 +3078,7 @@ def test_default_container_instance_attributes():
)
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_describe_container_instances_with_attributes():
ecs_client = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
@@ -3163,7 +3169,7 @@ def _fetch_container_instance_resources(container_instance_description):
return remaining_resources, registered_resources
-@mock_ecs
+@mock_aws
def test_create_service_load_balancing():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -3226,7 +3232,7 @@ def test_create_service_load_balancing():
)
-@mock_ecs
+@mock_aws
def test_list_tags_for_resource():
client = boto3.client("ecs", region_name=ECS_REGION)
response = client.register_task_definition(
@@ -3264,7 +3270,7 @@ def test_list_tags_for_resource():
]
-@mock_ecs
+@mock_aws
def test_list_tags_exceptions():
client = boto3.client("ecs", region_name=ECS_REGION)
with pytest.raises(ClientError) as exc:
@@ -3282,7 +3288,7 @@ def test_list_tags_exceptions():
)
-@mock_ecs
+@mock_aws
def test_list_tags_for_resource_ecs_service():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -3316,7 +3322,7 @@ def test_list_tags_for_resource_ecs_service():
]
-@mock_ecs
+@mock_aws
@pytest.mark.parametrize("long_arn", ["disabled", "enabled"])
def test_ecs_service_tag_resource(long_arn):
"""
@@ -3377,7 +3383,7 @@ def test_ecs_service_tag_resource(long_arn):
]
-@mock_ecs
+@mock_aws
def test_ecs_service_tag_resource_overwrites_tag():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -3413,7 +3419,7 @@ def test_ecs_service_tag_resource_overwrites_tag():
]
-@mock_ecs
+@mock_aws
def test_ecs_service_untag_resource():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -3440,7 +3446,7 @@ def test_ecs_service_untag_resource():
assert response["tags"] == []
-@mock_ecs
+@mock_aws
def test_ecs_service_untag_resource_multiple_tags():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -3471,7 +3477,7 @@ def test_ecs_service_untag_resource_multiple_tags():
assert response["tags"] == [{"key": "hello", "value": "world"}]
-@mock_ecs
+@mock_aws
def test_update_cluster():
client = boto3.client("ecs", region_name=ECS_REGION)
client.create_cluster(clusterName="test_ecs_cluster")
@@ -3487,7 +3493,7 @@ def test_update_cluster():
}
-@mock_ecs
+@mock_aws
def test_ecs_task_definition_placement_constraints():
client = boto3.client("ecs", region_name=ECS_REGION)
task_def = client.register_task_definition(
@@ -3515,8 +3521,7 @@ def test_ecs_task_definition_placement_constraints():
]
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_list_tasks_with_filters():
ecs = boto3.client("ecs", region_name=ECS_REGION)
ec2 = boto3.resource("ec2", region_name=ECS_REGION)
diff --git a/tests/test_ecs/test_ecs_capacity_provider.py b/tests/test_ecs/test_ecs_capacity_provider.py
index 7307a0919..2924854ca 100644
--- a/tests/test_ecs/test_ecs_capacity_provider.py
+++ b/tests/test_ecs/test_ecs_capacity_provider.py
@@ -1,10 +1,10 @@
import boto3
-from moto import mock_ecs
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_ecs
+@mock_aws
def test_create_capacity_provider():
client = boto3.client("ecs", region_name="us-west-1")
resp = client.create_capacity_provider(
@@ -37,7 +37,7 @@ def test_create_capacity_provider():
}
-@mock_ecs
+@mock_aws
def test_create_capacity_provider_with_tags():
client = boto3.client("ecs", region_name="us-west-1")
resp = client.create_capacity_provider(
@@ -66,7 +66,7 @@ def test_create_capacity_provider_with_tags():
assert resp["tags"] == [{"key": "k2", "value": "v2"}]
-@mock_ecs
+@mock_aws
def test_describe_capacity_provider__using_name():
client = boto3.client("ecs", region_name="us-west-1")
client.create_capacity_provider(
@@ -102,7 +102,7 @@ def test_describe_capacity_provider__using_name():
}
-@mock_ecs
+@mock_aws
def test_describe_capacity_provider__using_arn():
client = boto3.client("ecs", region_name="us-west-1")
provider_arn = client.create_capacity_provider(
@@ -125,7 +125,7 @@ def test_describe_capacity_provider__using_arn():
assert provider["name"] == "my_provider"
-@mock_ecs
+@mock_aws
def test_describe_capacity_provider__missing():
client = boto3.client("ecs", region_name="us-west-1")
client.create_capacity_provider(
@@ -153,7 +153,7 @@ def test_describe_capacity_provider__missing():
]
-@mock_ecs
+@mock_aws
def test_delete_capacity_provider():
client = boto3.client("ecs", region_name="us-west-1")
client.create_capacity_provider(
@@ -179,7 +179,7 @@ def test_delete_capacity_provider():
} in resp["failures"]
-@mock_ecs
+@mock_aws
def test_update_capacity_provider():
client = boto3.client("ecs", region_name="us-west-1")
client.create_capacity_provider(
diff --git a/tests/test_ecs/test_ecs_cloudformation.py b/tests/test_ecs/test_ecs_cloudformation.py
index 0b3b6b805..88a771261 100644
--- a/tests/test_ecs/test_ecs_cloudformation.py
+++ b/tests/test_ecs/test_ecs_cloudformation.py
@@ -3,12 +3,11 @@ from copy import deepcopy
import boto3
-from moto import mock_cloudformation, mock_ecs
+from moto import mock_aws
from moto.core.utils import pascal_to_camelcase, remap_nested_keys
-@mock_ecs
-@mock_cloudformation
+@mock_aws
def test_update_task_definition_family_through_cloudformation_should_trigger_a_replacement():
template1 = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -49,8 +48,7 @@ def test_update_task_definition_family_through_cloudformation_should_trigger_a_r
assert resp["taskDefinitionArns"][0].endswith("testTaskDefinition2:1")
-@mock_ecs
-@mock_cloudformation
+@mock_aws
def test_create_service_through_cloudformation():
template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -94,8 +92,7 @@ def test_create_service_through_cloudformation():
assert len(resp["serviceArns"]) == 1
-@mock_ecs
-@mock_cloudformation
+@mock_aws
def test_create_service_through_cloudformation_without_desiredcount():
template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -139,8 +136,7 @@ def test_create_service_through_cloudformation_without_desiredcount():
assert len(resp["serviceArns"]) == 1
-@mock_ecs
-@mock_cloudformation
+@mock_aws
def test_update_service_through_cloudformation_should_trigger_replacement():
template1 = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -189,8 +185,7 @@ def test_update_service_through_cloudformation_should_trigger_replacement():
assert len(resp["serviceArns"]) == 1
-@mock_ecs
-@mock_cloudformation
+@mock_aws
def test_update_service_through_cloudformation_without_desiredcount():
template1 = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -239,8 +234,7 @@ def test_update_service_through_cloudformation_without_desiredcount():
assert len(resp["serviceArns"]) == 1
-@mock_ecs
-@mock_cloudformation
+@mock_aws
def test_create_cluster_through_cloudformation():
template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -265,8 +259,7 @@ def test_create_cluster_through_cloudformation():
assert len(resp["clusterArns"]) == 1
-@mock_ecs
-@mock_cloudformation
+@mock_aws
def test_create_cluster_through_cloudformation_no_name():
# cloudformation should create a cluster name for you if you do not provide it
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-cluster.html#cfn-ecs-cluster-clustername
@@ -284,8 +277,7 @@ def test_create_cluster_through_cloudformation_no_name():
assert len(resp["clusterArns"]) == 1
-@mock_ecs
-@mock_cloudformation
+@mock_aws
def test_update_cluster_name_through_cloudformation_should_trigger_a_replacement():
template1 = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -320,8 +312,7 @@ def test_update_cluster_name_through_cloudformation_should_trigger_a_replacement
assert cluster1["status"] == "ACTIVE"
-@mock_ecs
-@mock_cloudformation
+@mock_aws
def test_create_task_definition_through_cloudformation():
template = {
"AWSTemplateFormatVersion": "2010-09-09",
diff --git a/tests/test_ecs/test_ecs_efs.py b/tests/test_ecs/test_ecs_efs.py
index b34332b85..1356ee3cd 100644
--- a/tests/test_ecs/test_ecs_efs.py
+++ b/tests/test_ecs/test_ecs_efs.py
@@ -1,10 +1,9 @@
import boto3
-from moto import mock_ecs, mock_efs
+from moto import mock_aws
-@mock_ecs
-@mock_efs
+@mock_aws
def test_register_task_definition__use_efs_root():
client = boto3.client("ecs", region_name="us-east-1")
diff --git a/tests/test_ecs/test_ecs_task_def_tags.py b/tests/test_ecs/test_ecs_task_def_tags.py
index 0c77bbe75..7ec1c21bf 100644
--- a/tests/test_ecs/test_ecs_task_def_tags.py
+++ b/tests/test_ecs/test_ecs_task_def_tags.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_ecs
+from moto import mock_aws
-@mock_ecs
+@mock_aws
def test_describe_task_definition_with_tags():
client = boto3.client("ecs", region_name="us-east-1")
task_def = client.register_task_definition(
diff --git a/tests/test_ecs/test_ecs_task_tags.py b/tests/test_ecs/test_ecs_task_tags.py
index 9f706a457..38fb9358f 100644
--- a/tests/test_ecs/test_ecs_task_tags.py
+++ b/tests/test_ecs/test_ecs_task_tags.py
@@ -1,12 +1,11 @@
import boto3
-from moto import mock_ec2, mock_ecs
+from moto import mock_aws
from .test_ecs_boto3 import setup_ecs_cluster_with_ec2_instance
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_describe_tasks_include_tags():
client = boto3.client("ecs", region_name="us-east-1")
test_cluster_name = "test_ecs_cluster"
@@ -42,8 +41,7 @@ def test_describe_tasks_include_tags():
assert tags == task_tags
-@mock_ec2
-@mock_ecs
+@mock_aws
def test_add_tags_to_task():
client = boto3.client("ecs", region_name="us-east-1")
test_cluster_name = "test_ecs_cluster"
diff --git a/tests/test_ecs/test_ecs_tasksets.py b/tests/test_ecs/test_ecs_tasksets.py
index bad12dc31..ce6087949 100644
--- a/tests/test_ecs/test_ecs_tasksets.py
+++ b/tests/test_ecs/test_ecs_tasksets.py
@@ -2,14 +2,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ecs
+from moto import mock_aws
cluster_name = "test_ecs_cluster"
service_name = "test_ecs_service"
task_def_name = "test_ecs_task"
-@mock_ecs
+@mock_aws
def test_create_task_set():
client = boto3.client("ecs", region_name="us-east-1")
_ = client.create_cluster(clusterName=cluster_name)
@@ -56,7 +56,7 @@ def test_create_task_set():
assert task_set["platformVersion"] == "LATEST"
-@mock_ecs
+@mock_aws
def test_create_task_set_errors():
# given
client = boto3.client("ecs", region_name="us-east-1")
@@ -90,7 +90,7 @@ def test_create_task_set_errors():
)
-@mock_ecs
+@mock_aws
def test_describe_task_sets():
client = boto3.client("ecs", region_name="us-east-1")
_ = client.create_cluster(clusterName=cluster_name)
@@ -151,7 +151,7 @@ def test_describe_task_sets():
assert task_sets[0]["launchType"] == "EC2"
-@mock_ecs
+@mock_aws
def test_delete_task_set():
client = boto3.client("ecs", region_name="us-east-1")
_ = client.create_cluster(clusterName=cluster_name)
@@ -197,7 +197,7 @@ def test_delete_task_set():
)
-@mock_ecs
+@mock_aws
def test_delete_task_set__using_partial_arn():
client = boto3.client("ecs", region_name="us-east-1")
_ = client.create_cluster(clusterName=cluster_name)
@@ -230,7 +230,7 @@ def test_delete_task_set__using_partial_arn():
assert response["taskSet"]["taskSetArn"] == task_set["taskSetArn"]
-@mock_ecs
+@mock_aws
def test_update_service_primary_task_set():
client = boto3.client("ecs", region_name="us-east-1")
_ = client.create_cluster(clusterName=cluster_name)
@@ -283,7 +283,7 @@ def test_update_service_primary_task_set():
assert service["taskDefinition"] == service["taskSets"][1]["taskDefinition"]
-@mock_ecs
+@mock_aws
def test_update_task_set():
client = boto3.client("ecs", region_name="us-east-1")
_ = client.create_cluster(clusterName=cluster_name)
@@ -319,7 +319,7 @@ def test_update_task_set():
assert updated_task_set["scale"]["unit"] == "PERCENT"
-@mock_ecs
+@mock_aws
def test_create_task_sets_with_tags():
client = boto3.client("ecs", region_name="us-east-1")
_ = client.create_cluster(clusterName=cluster_name)
diff --git a/tests/test_efs/__init__.py b/tests/test_efs/__init__.py
index d2de7b685..6c88ab629 100644
--- a/tests/test_efs/__init__.py
+++ b/tests/test_efs/__init__.py
@@ -1,16 +1,16 @@
import boto3
import pytest
-from moto import mock_ec2, mock_efs
+from moto import mock_aws
@pytest.fixture(scope="function", name="ec2")
def fixture_ec2():
- with mock_ec2():
+ with mock_aws():
yield boto3.client("ec2", region_name="us-east-1")
@pytest.fixture(scope="function", name="efs")
def fixture_efs():
- with mock_efs():
+ with mock_aws():
yield boto3.client("efs", region_name="us-east-1")
diff --git a/tests/test_efs/test_server.py b/tests/test_efs/test_server.py
index 848ea9fcb..d06e7900b 100644
--- a/tests/test_efs/test_server.py
+++ b/tests/test_efs/test_server.py
@@ -4,7 +4,7 @@ from unittest import SkipTest
import pytest
import moto.server as server
-from moto import mock_ec2, mock_efs, settings
+from moto import mock_aws, settings
FILE_SYSTEMS = "/2015-02-01/file-systems"
MOUNT_TARGETS = "/2015-02-01/mount-targets"
@@ -23,13 +23,14 @@ def fixture_aws_credentials(monkeypatch):
def fixture_efs_client(aws_credentials): # pylint: disable=unused-argument
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Using server directly - no point in testing ServerMode")
- with mock_efs():
+
+ with mock_aws():
yield server.create_backend_app("efs").test_client()
@pytest.fixture(scope="function", name="subnet_id")
def fixture_subnet_id(aws_credentials): # pylint: disable=unused-argument
- with mock_ec2():
+ with mock_aws():
ec2_client = server.create_backend_app("ec2").test_client()
resp = ec2_client.get("/?Action=DescribeSubnets")
subnet_ids = re.findall("(.*?)", resp.data.decode("utf-8"))
diff --git a/tests/test_eks/test_eks.py b/tests/test_eks/test_eks.py
index 6dc9efeeb..56d814673 100644
--- a/tests/test_eks/test_eks.py
+++ b/tests/test_eks/test_eks.py
@@ -6,7 +6,7 @@ import pytest
from botocore.exceptions import ClientError
from freezegun import freeze_time
-from moto import mock_eks, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core.utils import iso_8601_datetime_without_milliseconds
from moto.eks.exceptions import (
@@ -186,7 +186,7 @@ def fixture_NodegroupBuilder(ClusterBuilder):
###
-@mock_eks
+@mock_aws
def test_list_clusters_returns_empty_by_default():
client = boto3.client(SERVICE, region_name=REGION)
@@ -195,7 +195,7 @@ def test_list_clusters_returns_empty_by_default():
assert result == []
-@mock_eks
+@mock_aws
def test_list_tags_returns_empty_by_default(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.SINGLE)
cluster_arn = generated_test_data.cluster_describe_output[ClusterAttributes.ARN]
@@ -203,7 +203,7 @@ def test_list_tags_returns_empty_by_default(ClusterBuilder):
assert len(result["tags"]) == 0
-@mock_eks
+@mock_aws
def test_list_tags_returns_all(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.SINGLE)
cluster_arn = generated_test_data.cluster_describe_output[ClusterAttributes.ARN]
@@ -213,7 +213,7 @@ def test_list_tags_returns_all(ClusterBuilder):
assert result["tags"] == {"key1": "val1", "key2": "val2"}
-@mock_eks
+@mock_aws
def test_list_tags_returns_all_after_delete(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.SINGLE)
cluster_arn = generated_test_data.cluster_describe_output[ClusterAttributes.ARN]
@@ -224,7 +224,7 @@ def test_list_tags_returns_all_after_delete(ClusterBuilder):
assert result["tags"] == {"key2": "val2"}
-@mock_eks
+@mock_aws
def test_list_clusters_returns_sorted_cluster_names(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.SMALL)
expected_result = sorted(generated_test_data.cluster_names)
@@ -234,7 +234,7 @@ def test_list_clusters_returns_sorted_cluster_names(ClusterBuilder):
assert_result_matches_expected_list(result, expected_result, BatchCountSize.SMALL)
-@mock_eks
+@mock_aws
def test_list_clusters_returns_default_max_results(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.LARGE)
expected_len = DEFAULT_MAX_RESULTS
@@ -245,7 +245,7 @@ def test_list_clusters_returns_default_max_results(ClusterBuilder):
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_list_clusters_returns_custom_max_results(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.MEDIUM)
expected_len = PageCount.LARGE
@@ -256,7 +256,7 @@ def test_list_clusters_returns_custom_max_results(ClusterBuilder):
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_list_clusters_returns_second_page_results(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.MEDIUM)
page1_len = PageCount.LARGE
@@ -269,7 +269,7 @@ def test_list_clusters_returns_second_page_results(ClusterBuilder):
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_list_clusters_returns_custom_second_page_results(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.MEDIUM)
page1_len = PageCount.LARGE
@@ -286,7 +286,7 @@ def test_list_clusters_returns_custom_second_page_results(ClusterBuilder):
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_create_cluster_throws_exception_when_cluster_exists(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.SMALL)
expected_exception = ResourceInUseException
@@ -305,7 +305,7 @@ def test_create_cluster_throws_exception_when_cluster_exists(ClusterBuilder):
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_create_cluster_generates_valid_cluster_arn(ClusterBuilder):
_, generated_test_data = ClusterBuilder()
expected_arn_values = [
@@ -325,7 +325,7 @@ def test_create_cluster_generates_valid_cluster_arn(ClusterBuilder):
@freeze_time(FROZEN_TIME)
-@mock_eks
+@mock_aws
def test_create_cluster_generates_valid_cluster_created_timestamp(ClusterBuilder):
_, generated_test_data = ClusterBuilder()
@@ -339,7 +339,7 @@ def test_create_cluster_generates_valid_cluster_created_timestamp(ClusterBuilder
assert result_time == FROZEN_TIME
-@mock_eks
+@mock_aws
def test_create_cluster_generates_valid_cluster_endpoint(ClusterBuilder):
_, generated_test_data = ClusterBuilder()
@@ -351,7 +351,7 @@ def test_create_cluster_generates_valid_cluster_endpoint(ClusterBuilder):
assert REGION in result_endpoint
-@mock_eks
+@mock_aws
def test_create_cluster_generates_valid_oidc_identity(ClusterBuilder):
_, generated_test_data = ClusterBuilder()
@@ -363,7 +363,7 @@ def test_create_cluster_generates_valid_oidc_identity(ClusterBuilder):
assert REGION in result_issuer
-@mock_eks
+@mock_aws
def test_create_cluster_saves_provided_parameters(ClusterBuilder):
_, generated_test_data = ClusterBuilder(minimal=False)
@@ -371,7 +371,7 @@ def test_create_cluster_saves_provided_parameters(ClusterBuilder):
assert generated_test_data.cluster_describe_output[key] == expected_value
-@mock_eks
+@mock_aws
def test_describe_cluster_throws_exception_when_cluster_not_found(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.SMALL)
expected_exception = ResourceNotFoundException
@@ -385,7 +385,7 @@ def test_describe_cluster_throws_exception_when_cluster_not_found(ClusterBuilder
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_delete_cluster_returns_deleted_cluster(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.SMALL, False)
@@ -397,7 +397,7 @@ def test_delete_cluster_returns_deleted_cluster(ClusterBuilder):
assert result[key] == expected_value
-@mock_eks
+@mock_aws
def test_delete_cluster_removes_deleted_cluster(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.SMALL, False)
@@ -408,7 +408,7 @@ def test_delete_cluster_removes_deleted_cluster(ClusterBuilder):
assert generated_test_data.existing_cluster_name not in result_cluster_list
-@mock_eks
+@mock_aws
def test_delete_cluster_throws_exception_when_cluster_not_found(ClusterBuilder):
client, generated_test_data = ClusterBuilder(BatchCountSize.SMALL)
expected_exception = ResourceNotFoundException
@@ -424,7 +424,7 @@ def test_delete_cluster_throws_exception_when_cluster_not_found(ClusterBuilder):
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_list_nodegroups_returns_empty_by_default(ClusterBuilder):
client, generated_test_data = ClusterBuilder()
@@ -435,7 +435,7 @@ def test_list_nodegroups_returns_empty_by_default(ClusterBuilder):
assert result == []
-@mock_eks
+@mock_aws
def test_list_nodegroups_returns_sorted_nodegroup_names(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder(BatchCountSize.SMALL)
expected_result = sorted(generated_test_data.nodegroup_names)
@@ -447,7 +447,7 @@ def test_list_nodegroups_returns_sorted_nodegroup_names(NodegroupBuilder):
assert_result_matches_expected_list(result, expected_result, BatchCountSize.SMALL)
-@mock_eks
+@mock_aws
def test_list_nodegroups_returns_default_max_results(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder(BatchCountSize.LARGE)
expected_len = DEFAULT_MAX_RESULTS
@@ -460,7 +460,7 @@ def test_list_nodegroups_returns_default_max_results(NodegroupBuilder):
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_list_nodegroups_returns_custom_max_results(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder(BatchCountSize.LARGE)
expected_len = BatchCountSize.LARGE
@@ -473,7 +473,7 @@ def test_list_nodegroups_returns_custom_max_results(NodegroupBuilder):
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_list_nodegroups_returns_second_page_results(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder(BatchCountSize.MEDIUM)
page1_len = PageCount.LARGE
@@ -490,7 +490,7 @@ def test_list_nodegroups_returns_second_page_results(NodegroupBuilder):
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_list_nodegroups_returns_custom_second_page_results(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder(BatchCountSize.MEDIUM)
page1_len = PageCount.LARGE
@@ -511,7 +511,7 @@ def test_list_nodegroups_returns_custom_second_page_results(NodegroupBuilder):
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_create_nodegroup_throws_exception_when_cluster_not_found():
client = boto3.client(SERVICE, region_name=REGION)
non_existent_cluster_name = mock_random.get_random_string()
@@ -528,7 +528,7 @@ def test_create_nodegroup_throws_exception_when_cluster_not_found():
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_create_nodegroup_throws_exception_when_nodegroup_already_exists(
NodegroupBuilder,
):
@@ -555,7 +555,7 @@ def test_create_nodegroup_throws_exception_when_nodegroup_already_exists(
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_create_nodegroup_throws_exception_when_cluster_not_active(NodegroupBuilder):
if settings.TEST_SERVER_MODE:
raise SkipTest("Cant patch Cluster attributes in server mode.")
@@ -582,7 +582,7 @@ def test_create_nodegroup_throws_exception_when_cluster_not_active(NodegroupBuil
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_create_nodegroup_generates_valid_nodegroup_arn(NodegroupBuilder):
_, generated_test_data = NodegroupBuilder()
expected_arn_values = [
@@ -604,7 +604,7 @@ def test_create_nodegroup_generates_valid_nodegroup_arn(NodegroupBuilder):
@freeze_time(FROZEN_TIME)
-@mock_eks
+@mock_aws
def test_create_nodegroup_generates_valid_nodegroup_created_timestamp(NodegroupBuilder):
_, generated_test_data = NodegroupBuilder()
@@ -619,7 +619,7 @@ def test_create_nodegroup_generates_valid_nodegroup_created_timestamp(NodegroupB
@freeze_time(FROZEN_TIME)
-@mock_eks
+@mock_aws
def test_create_nodegroup_generates_valid_nodegroup_modified_timestamp(
NodegroupBuilder,
):
@@ -635,7 +635,7 @@ def test_create_nodegroup_generates_valid_nodegroup_modified_timestamp(
assert result_time == FROZEN_TIME
-@mock_eks
+@mock_aws
def test_create_nodegroup_generates_valid_autoscaling_group_name(NodegroupBuilder):
_, generated_test_data = NodegroupBuilder()
result_resources = generated_test_data.nodegroup_describe_output[
@@ -649,7 +649,7 @@ def test_create_nodegroup_generates_valid_autoscaling_group_name(NodegroupBuilde
assert RegExTemplates.NODEGROUP_ASG_NAME_PATTERN.match(result_asg_name)
-@mock_eks
+@mock_aws
def test_create_nodegroup_generates_valid_security_group_name(NodegroupBuilder):
_, generated_test_data = NodegroupBuilder()
result_resources = generated_test_data.nodegroup_describe_output[
@@ -663,7 +663,7 @@ def test_create_nodegroup_generates_valid_security_group_name(NodegroupBuilder):
)
-@mock_eks
+@mock_aws
def test_create_nodegroup_saves_provided_parameters(NodegroupBuilder):
_, generated_test_data = NodegroupBuilder(minimal=False)
@@ -671,7 +671,7 @@ def test_create_nodegroup_saves_provided_parameters(NodegroupBuilder):
assert generated_test_data.nodegroup_describe_output[key] == expected_value
-@mock_eks
+@mock_aws
def test_describe_nodegroup_throws_exception_when_cluster_not_found(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder()
expected_exception = ResourceNotFoundException
@@ -688,7 +688,7 @@ def test_describe_nodegroup_throws_exception_when_cluster_not_found(NodegroupBui
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_describe_nodegroup_throws_exception_when_nodegroup_not_found(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder()
expected_exception = ResourceNotFoundException
@@ -705,7 +705,7 @@ def test_describe_nodegroup_throws_exception_when_nodegroup_not_found(NodegroupB
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_delete_cluster_throws_exception_when_nodegroups_exist(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder()
expected_exception = ResourceInUseException
@@ -719,7 +719,7 @@ def test_delete_cluster_throws_exception_when_nodegroups_exist(NodegroupBuilder)
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_delete_nodegroup_removes_deleted_nodegroup(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder(BatchCountSize.SMALL)
@@ -735,7 +735,7 @@ def test_delete_nodegroup_removes_deleted_nodegroup(NodegroupBuilder):
assert generated_test_data.existing_nodegroup_name not in result
-@mock_eks
+@mock_aws
def test_delete_nodegroup_returns_deleted_nodegroup(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder(BatchCountSize.SMALL, False)
@@ -748,7 +748,7 @@ def test_delete_nodegroup_returns_deleted_nodegroup(NodegroupBuilder):
assert result[key] == expected_value
-@mock_eks
+@mock_aws
def test_delete_nodegroup_throws_exception_when_cluster_not_found(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder()
expected_exception = ResourceNotFoundException
@@ -765,7 +765,7 @@ def test_delete_nodegroup_throws_exception_when_cluster_not_found(NodegroupBuild
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_delete_nodegroup_throws_exception_when_nodegroup_not_found(NodegroupBuilder):
client, generated_test_data = NodegroupBuilder()
expected_exception = ResourceNotFoundException
@@ -815,7 +815,7 @@ test_cases = [
"launch_template, instance_types, disk_size, remote_access, expected_result",
test_cases,
)
-@mock_eks
+@mock_aws
def test_create_nodegroup_handles_launch_template_combinations(
ClusterBuilder,
launch_template,
@@ -872,7 +872,7 @@ def test_create_nodegroup_handles_launch_template_combinations(
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_list_fargate_profile_returns_empty_by_default(ClusterBuilder):
client, generated_test_data = ClusterBuilder()
@@ -883,7 +883,7 @@ def test_list_fargate_profile_returns_empty_by_default(ClusterBuilder):
assert result == []
-@mock_eks
+@mock_aws
def test_list_fargate_profile_returns_sorted_fargate_profile_names(
FargateProfileBuilder,
):
@@ -897,7 +897,7 @@ def test_list_fargate_profile_returns_sorted_fargate_profile_names(
assert_result_matches_expected_list(result, expected_result, BatchCountSize.SMALL)
-@mock_eks
+@mock_aws
def test_list_fargate_profile_returns_default_max_results(FargateProfileBuilder):
client, generated_test_data = FargateProfileBuilder(BatchCountSize.LARGE)
expected_len = DEFAULT_MAX_RESULTS
@@ -910,7 +910,7 @@ def test_list_fargate_profile_returns_default_max_results(FargateProfileBuilder)
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_list_fargate_profile_returns_custom_max_results(FargateProfileBuilder):
client, generated_test_data = FargateProfileBuilder(BatchCountSize.LARGE)
expected_len = BatchCountSize.LARGE
@@ -923,7 +923,7 @@ def test_list_fargate_profile_returns_custom_max_results(FargateProfileBuilder):
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_list_fargate_profile_returns_second_page_results(FargateProfileBuilder):
client, generated_test_data = FargateProfileBuilder(BatchCountSize.MEDIUM)
page1_len = PageCount.LARGE
@@ -940,7 +940,7 @@ def test_list_fargate_profile_returns_second_page_results(FargateProfileBuilder)
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_list_fargate_profile_returns_custom_second_page_results(FargateProfileBuilder):
client, generated_test_data = FargateProfileBuilder(BatchCountSize.MEDIUM)
page1_len = PageCount.LARGE
@@ -961,7 +961,7 @@ def test_list_fargate_profile_returns_custom_second_page_results(FargateProfileB
assert_result_matches_expected_list(result, expected_result, expected_len)
-@mock_eks
+@mock_aws
def test_create_fargate_profile_throws_exception_when_cluster_not_found():
client = boto3.client(SERVICE, region_name=REGION)
non_existent_cluster_name = mock_random.get_random_string()
@@ -978,7 +978,7 @@ def test_create_fargate_profile_throws_exception_when_cluster_not_found():
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_create_fargate_profile_throws_exception_when_fargate_profile_already_exists(
FargateProfileBuilder,
):
@@ -1002,7 +1002,7 @@ def test_create_fargate_profile_throws_exception_when_fargate_profile_already_ex
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_create_fargate_profile_throws_exception_when_cluster_not_active(
FargateProfileBuilder,
):
@@ -1031,7 +1031,7 @@ def test_create_fargate_profile_throws_exception_when_cluster_not_active(
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_create_fargate_profile_generates_valid_profile_arn(FargateProfileBuilder):
_, generated_test_data = FargateProfileBuilder()
expected_arn_values = [
@@ -1053,7 +1053,7 @@ def test_create_fargate_profile_generates_valid_profile_arn(FargateProfileBuilde
@freeze_time(FROZEN_TIME)
-@mock_eks
+@mock_aws
def test_create_fargate_profile_generates_valid_created_timestamp(
FargateProfileBuilder,
):
@@ -1069,7 +1069,7 @@ def test_create_fargate_profile_generates_valid_created_timestamp(
assert result_time == FROZEN_TIME
-@mock_eks
+@mock_aws
def test_create_fargate_profile_saves_provided_parameters(FargateProfileBuilder):
_, generated_test_data = FargateProfileBuilder(minimal=False)
@@ -1077,7 +1077,7 @@ def test_create_fargate_profile_saves_provided_parameters(FargateProfileBuilder)
assert generated_test_data.fargate_describe_output[key] == expected_value
-@mock_eks
+@mock_aws
def test_describe_fargate_profile_throws_exception_when_cluster_not_found(
FargateProfileBuilder,
):
@@ -1096,7 +1096,7 @@ def test_describe_fargate_profile_throws_exception_when_cluster_not_found(
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_describe_fargate_profile_throws_exception_when_profile_not_found(
FargateProfileBuilder,
):
@@ -1115,7 +1115,7 @@ def test_describe_fargate_profile_throws_exception_when_profile_not_found(
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_delete_fargate_profile_removes_deleted_fargate_profile(FargateProfileBuilder):
client, generated_test_data = FargateProfileBuilder(BatchCountSize.SMALL)
@@ -1131,7 +1131,7 @@ def test_delete_fargate_profile_removes_deleted_fargate_profile(FargateProfileBu
assert generated_test_data.existing_fargate_profile_name not in result
-@mock_eks
+@mock_aws
def test_delete_fargate_profile_returns_deleted_fargate_profile(FargateProfileBuilder):
client, generated_test_data = FargateProfileBuilder(BatchCountSize.SMALL, False)
@@ -1144,7 +1144,7 @@ def test_delete_fargate_profile_returns_deleted_fargate_profile(FargateProfileBu
assert result[key] == expected_value
-@mock_eks
+@mock_aws
def test_delete_fargate_profile_throws_exception_when_cluster_not_found(
FargateProfileBuilder,
):
@@ -1163,7 +1163,7 @@ def test_delete_fargate_profile_throws_exception_when_cluster_not_found(
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_delete_fargate_profile_throws_exception_when_fargate_profile_not_found(
FargateProfileBuilder,
):
@@ -1182,7 +1182,7 @@ def test_delete_fargate_profile_throws_exception_when_fargate_profile_not_found(
assert_expected_exception(raised_exception, expected_exception, expected_msg)
-@mock_eks
+@mock_aws
def test_create_fargate_throws_exception_when_no_selectors_provided(ClusterBuilder):
client, generated_test_data = ClusterBuilder()
cluster_name = generated_test_data.existing_cluster_name
@@ -1319,7 +1319,7 @@ selector_formatting_test_cases = [
@pytest.mark.parametrize(
"selectors, expected_message, expected_result", selector_formatting_test_cases
)
-@mock_eks
+@mock_aws
def test_create_fargate_selectors(
ClusterBuilder, selectors, expected_message, expected_result
):
diff --git a/tests/test_eks/test_eks_constants.py b/tests/test_eks/test_eks_constants.py
index d7ef9e7f7..1a0b5b9b3 100644
--- a/tests/test_eks/test_eks_constants.py
+++ b/tests/test_eks/test_eks_constants.py
@@ -7,7 +7,6 @@ from enum import Enum
from boto3 import Session
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-from moto.eks import REGION as DEFAULT_REGION
DEFAULT_ENCODING = "utf-8"
DEFAULT_HTTP_HEADERS = {"Content-type": "application/json"}
@@ -15,7 +14,7 @@ DEFAULT_NAMESPACE = "namespace_1"
FROZEN_TIME = "2013-11-27T01:42:00Z"
MAX_FARGATE_LABELS = 5
PARTITIONS = Session().get_available_partitions()
-REGION = Session().region_name or DEFAULT_REGION
+REGION = "us-east-1"
SERVICE = "eks"
SUBNET_IDS = ["subnet-12345ab", "subnet-67890cd"]
diff --git a/tests/test_eks/test_eks_ec2.py b/tests/test_eks/test_eks_ec2.py
index 1b5ffd38b..d4c93ec4d 100644
--- a/tests/test_eks/test_eks_ec2.py
+++ b/tests/test_eks/test_eks_ec2.py
@@ -1,11 +1,11 @@
import boto3
-from moto import mock_ec2, mock_eks
+from moto import mock_aws
from .test_eks_constants import NODEROLE_ARN_VALUE, SUBNET_IDS
-@mock_eks
+@mock_aws
def test_passing_an_unknown_launchtemplate_is_supported():
eks = boto3.client("eks", "us-east-2")
eks.create_cluster(name="a", roleArn=NODEROLE_ARN_VALUE, resourcesVpcConfig={})
@@ -20,8 +20,7 @@ def test_passing_an_unknown_launchtemplate_is_supported():
assert group["launchTemplate"] == {"name": "random"}
-@mock_ec2
-@mock_eks
+@mock_aws
def test_passing_a_known_launchtemplate_by_name():
ec2 = boto3.client("ec2", region_name="us-east-2")
eks = boto3.client("eks", "us-east-2")
@@ -47,8 +46,7 @@ def test_passing_a_known_launchtemplate_by_name():
assert group["launchTemplate"] == {"name": "ltn", "id": lt_id}
-@mock_ec2
-@mock_eks
+@mock_aws
def test_passing_a_known_launchtemplate_by_id():
ec2 = boto3.client("ec2", region_name="us-east-2")
eks = boto3.client("eks", "us-east-2")
diff --git a/tests/test_eks/test_server.py b/tests/test_eks/test_server.py
index e8eb853eb..a1e071126 100644
--- a/tests/test_eks/test_server.py
+++ b/tests/test_eks/test_server.py
@@ -5,7 +5,7 @@ from copy import deepcopy
import pytest
import moto.server as server
-from moto import mock_eks, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.eks.exceptions import ResourceInUseException, ResourceNotFoundException
from moto.eks.models import (
@@ -20,7 +20,6 @@ from tests.test_eks.test_eks import all_arn_values_should_be_valid
from tests.test_eks.test_eks_constants import (
DEFAULT_ENCODING,
DEFAULT_HTTP_HEADERS,
- DEFAULT_REGION,
NODEROLE_ARN_KEY,
NODEROLE_ARN_VALUE,
PARTITIONS,
@@ -45,6 +44,7 @@ Test the different server responses
"""
NAME_LIST = ["foo", "bar", "baz", "qux"]
+DEFAULT_REGION = "us-east-1"
class TestCluster:
@@ -129,7 +129,7 @@ def fixture_create_nodegroup(test_client):
yield _execute
-@mock_eks
+@mock_aws
def test_eks_create_single_cluster(create_cluster):
result_cluster = create_cluster()
@@ -141,7 +141,7 @@ def test_eks_create_single_cluster(create_cluster):
)
-@mock_eks
+@mock_aws
def test_eks_create_multiple_clusters_with_same_name(test_client, create_cluster):
create_cluster()
expected_exception = ResourceInUseException
@@ -162,7 +162,7 @@ def test_eks_create_multiple_clusters_with_same_name(test_client, create_cluster
should_return_expected_exception(response, expected_exception, expected_data)
-@mock_eks
+@mock_aws
def test_eks_create_nodegroup_without_cluster(test_client):
expected_exception = ResourceNotFoundException
expected_msg = CLUSTER_NOT_FOUND_MSG.format(clusterName=TestCluster.cluster_name)
@@ -182,7 +182,7 @@ def test_eks_create_nodegroup_without_cluster(test_client):
should_return_expected_exception(response, expected_exception, expected_data)
-@mock_eks
+@mock_aws
def test_eks_create_nodegroup_on_existing_cluster(create_cluster, create_nodegroup):
create_cluster()
result_data = create_nodegroup()
@@ -197,7 +197,7 @@ def test_eks_create_nodegroup_on_existing_cluster(create_cluster, create_nodegro
)
-@mock_eks
+@mock_aws
def test_eks_create_multiple_nodegroups_with_same_name(
test_client, create_cluster, create_nodegroup
):
@@ -224,7 +224,7 @@ def test_eks_create_multiple_nodegroups_with_same_name(
should_return_expected_exception(response, expected_exception, expected_data)
-@mock_eks
+@mock_aws
def test_eks_list_clusters(test_client, create_cluster):
[create_cluster(name) for name in NAME_LIST]
@@ -242,7 +242,7 @@ def test_eks_list_clusters(test_client, create_cluster):
assert sorted(result_data) == sorted(NAME_LIST)
-@mock_eks
+@mock_aws
def test_eks_list_nodegroups(test_client, create_cluster, create_nodegroup):
create_cluster()
[create_nodegroup(name) for name in NAME_LIST]
@@ -263,7 +263,7 @@ def test_eks_list_nodegroups(test_client, create_cluster, create_nodegroup):
assert len(result_data) == len(NAME_LIST)
-@mock_eks
+@mock_aws
def test_eks_describe_existing_cluster(test_client, create_cluster):
create_cluster()
@@ -284,7 +284,7 @@ def test_eks_describe_existing_cluster(test_client, create_cluster):
)
-@mock_eks
+@mock_aws
def test_eks_describe_nonexisting_cluster(test_client):
expected_exception = ResourceNotFoundException
expected_msg = CLUSTER_NOT_FOUND_MSG.format(clusterName=TestCluster.cluster_name)
@@ -303,7 +303,7 @@ def test_eks_describe_nonexisting_cluster(test_client):
should_return_expected_exception(response, expected_exception, expected_data)
-@mock_eks
+@mock_aws
def test_eks_describe_existing_nodegroup(test_client, create_cluster, create_nodegroup):
create_cluster()
create_nodegroup()
@@ -330,7 +330,7 @@ def test_eks_describe_existing_nodegroup(test_client, create_cluster, create_nod
)
-@mock_eks
+@mock_aws
def test_eks_describe_nonexisting_nodegroup(test_client, create_cluster):
create_cluster()
expected_exception = ResourceNotFoundException
@@ -356,7 +356,7 @@ def test_eks_describe_nonexisting_nodegroup(test_client, create_cluster):
should_return_expected_exception(response, expected_exception, expected_data)
-@mock_eks
+@mock_aws
def test_eks_describe_nodegroup_nonexisting_cluster(test_client):
expected_exception = ResourceNotFoundException
expected_msg = CLUSTER_NOT_FOUND_MSG.format(clusterName=TestNodegroup.cluster_name)
@@ -378,7 +378,7 @@ def test_eks_describe_nodegroup_nonexisting_cluster(test_client):
should_return_expected_exception(response, expected_exception, expected_data)
-@mock_eks
+@mock_aws
def test_eks_delete_cluster(test_client, create_cluster):
create_cluster()
@@ -398,7 +398,7 @@ def test_eks_delete_cluster(test_client, create_cluster):
)
-@mock_eks
+@mock_aws
def test_eks_delete_nonexisting_cluster(test_client):
expected_exception = ResourceNotFoundException
expected_msg = CLUSTER_NOT_FOUND_MSG.format(clusterName=TestCluster.cluster_name)
@@ -417,7 +417,7 @@ def test_eks_delete_nonexisting_cluster(test_client):
should_return_expected_exception(response, expected_exception, expected_data)
-@mock_eks
+@mock_aws
def test_eks_delete_cluster_with_nodegroups(
test_client, create_cluster, create_nodegroup
):
@@ -439,7 +439,7 @@ def test_eks_delete_cluster_with_nodegroups(
should_return_expected_exception(response, expected_exception, expected_data)
-@mock_eks
+@mock_aws
def test_eks_delete_nodegroup(test_client, create_cluster, create_nodegroup):
create_cluster()
create_nodegroup()
@@ -466,7 +466,7 @@ def test_eks_delete_nodegroup(test_client, create_cluster, create_nodegroup):
)
-@mock_eks
+@mock_aws
def test_eks_delete_nonexisting_nodegroup(test_client, create_cluster):
create_cluster()
expected_exception = ResourceNotFoundException
@@ -492,7 +492,7 @@ def test_eks_delete_nonexisting_nodegroup(test_client, create_cluster):
should_return_expected_exception(response, expected_exception, expected_data)
-@mock_eks
+@mock_aws
def test_eks_delete_nodegroup_nonexisting_cluster(test_client):
expected_exception = ResourceNotFoundException
expected_msg = CLUSTER_NOT_FOUND_MSG.format(
diff --git a/tests/test_elasticache/test_elasticache.py b/tests/test_elasticache/test_elasticache.py
index 763157b77..5f77e7191 100644
--- a/tests/test_elasticache/test_elasticache.py
+++ b/tests/test_elasticache/test_elasticache.py
@@ -2,14 +2,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_elasticache
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_elasticache
+@mock_aws
def test_create_user_no_password_required():
client = boto3.client("elasticache", region_name="ap-southeast-1")
user_id = "user1"
@@ -35,7 +35,7 @@ def test_create_user_no_password_required():
)
-@mock_elasticache
+@mock_aws
def test_create_user_with_password_too_short():
client = boto3.client("elasticache", region_name="ap-southeast-1")
user_id = "user1"
@@ -52,7 +52,7 @@ def test_create_user_with_password_too_short():
assert err["Message"] == "Passwords length must be between 16-128 characters."
-@mock_elasticache
+@mock_aws
def test_create_user_with_password():
client = boto3.client("elasticache", region_name="ap-southeast-1")
user_id = "user1"
@@ -78,7 +78,7 @@ def test_create_user_with_password():
)
-@mock_elasticache
+@mock_aws
def test_create_user_without_password():
client = boto3.client("elasticache", region_name="ap-southeast-1")
with pytest.raises(ClientError) as exc:
@@ -93,7 +93,7 @@ def test_create_user_without_password():
)
-@mock_elasticache
+@mock_aws
def test_create_user_twice():
client = boto3.client("elasticache", region_name="ap-southeast-1")
user_id = "user1"
@@ -118,7 +118,7 @@ def test_create_user_twice():
assert err["Message"] == "User user1 already exists."
-@mock_elasticache
+@mock_aws
def test_delete_user_unknown():
client = boto3.client("elasticache", region_name="ap-southeast-1")
with pytest.raises(ClientError) as exc:
@@ -128,7 +128,7 @@ def test_delete_user_unknown():
assert err["Message"] == "User unknown not found."
-@mock_elasticache
+@mock_aws
def test_delete_user():
client = boto3.client("elasticache", region_name="ap-southeast-1")
@@ -152,7 +152,7 @@ def test_delete_user():
assert exc.value.response["Error"]["Code"] == "UserNotFound"
-@mock_elasticache
+@mock_aws
def test_describe_users_initial():
client = boto3.client("elasticache", region_name="us-east-2")
resp = client.describe_users()
@@ -171,7 +171,7 @@ def test_describe_users_initial():
}
-@mock_elasticache
+@mock_aws
def test_describe_users():
client = boto3.client("elasticache", region_name="ap-southeast-1")
@@ -199,7 +199,7 @@ def test_describe_users():
} in resp["Users"]
-@mock_elasticache
+@mock_aws
def test_describe_users_unknown_userid():
client = boto3.client("elasticache", region_name="ap-southeast-1")
@@ -210,7 +210,7 @@ def test_describe_users_unknown_userid():
assert err["Message"] == "User unknown not found."
-@mock_elasticache
+@mock_aws
def test_create_redis_cache_cluster():
client = boto3.client("elasticache", region_name="us-east-2")
@@ -236,7 +236,7 @@ def test_create_redis_cache_cluster():
assert test_redis_cache_cluster_exist
-@mock_elasticache
+@mock_aws
def test_create_memcached_cache_cluster():
client = boto3.client("elasticache", region_name="us-east-2")
@@ -262,7 +262,7 @@ def test_create_memcached_cache_cluster():
assert test_memcached_cache_cluster_exist
-@mock_elasticache
+@mock_aws
def test_create_duplicate_cache_cluster():
client = boto3.client("elasticache", region_name="us-east-2")
@@ -287,7 +287,7 @@ def test_create_duplicate_cache_cluster():
assert err["Message"] == f"Cache cluster {cache_cluster_id} already exists."
-@mock_elasticache
+@mock_aws
def test_describe_all_cache_clusters():
client = boto3.client("elasticache", region_name="us-east-2")
@@ -315,7 +315,7 @@ def test_describe_all_cache_clusters():
assert test_memcached_cache_cluster_exist
-@mock_elasticache
+@mock_aws
def test_describe_specific_cache_clusters():
client = boto3.client("elasticache", region_name="us-east-2")
@@ -349,7 +349,7 @@ def test_describe_specific_cache_clusters():
assert test_memcached_cache_cluster_exist
-@mock_elasticache
+@mock_aws
def test_describe_unknown_cache_cluster():
client = boto3.client("elasticache", region_name="us-east-2")
@@ -373,7 +373,7 @@ def test_describe_unknown_cache_cluster():
assert err["Message"] == f"Cache cluster {cache_cluster_id_unknown} not found."
-@mock_elasticache
+@mock_aws
def test_delete_cache_cluster():
client = boto3.client("elasticache", region_name="us-east-2")
@@ -395,7 +395,7 @@ def test_delete_cache_cluster():
assert resp["CacheClusters"][0]["CacheClusterStatus"] == "deleting"
-@mock_elasticache
+@mock_aws
def test_delete_unknown_cache_cluster():
client = boto3.client("elasticache", region_name="us-east-2")
diff --git a/tests/test_elasticbeanstalk/test_elasticbeanstalk.py b/tests/test_elasticbeanstalk/test_elasticbeanstalk.py
index 28c01b5a9..3d2a0c863 100644
--- a/tests/test_elasticbeanstalk/test_elasticbeanstalk.py
+++ b/tests/test_elasticbeanstalk/test_elasticbeanstalk.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_elasticbeanstalk
+from moto import mock_aws
-@mock_elasticbeanstalk
+@mock_aws
def test_create_application():
# Create Elastic Beanstalk Application
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
@@ -14,7 +14,7 @@ def test_create_application():
assert "myapp" in app["Application"]["ApplicationArn"]
-@mock_elasticbeanstalk
+@mock_aws
def test_create_application_dup():
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
conn.create_application(ApplicationName="myapp")
@@ -22,7 +22,7 @@ def test_create_application_dup():
conn.create_application(ApplicationName="myapp")
-@mock_elasticbeanstalk
+@mock_aws
def test_describe_applications():
# Create Elastic Beanstalk Application
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
@@ -34,7 +34,7 @@ def test_describe_applications():
assert "myapp" in apps["Applications"][0]["ApplicationArn"]
-@mock_elasticbeanstalk
+@mock_aws
def test_delete_application():
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
@@ -47,7 +47,7 @@ def test_delete_application():
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_elasticbeanstalk
+@mock_aws
def test_delete_unknown_application():
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
@@ -65,7 +65,7 @@ def test_delete_unknown_application():
)
-@mock_elasticbeanstalk
+@mock_aws
def test_create_environment():
# Create Elastic Beanstalk Environment
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
@@ -75,7 +75,7 @@ def test_create_environment():
assert "myapp/myenv" in env["EnvironmentArn"]
-@mock_elasticbeanstalk
+@mock_aws
def test_describe_environments():
# List Elastic Beanstalk Envs
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
@@ -104,7 +104,7 @@ def tags_list_to_dict(tag_list):
return tag_dict
-@mock_elasticbeanstalk
+@mock_aws
def test_create_environment_tags():
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
conn.create_application(ApplicationName="myapp")
@@ -120,7 +120,7 @@ def test_create_environment_tags():
assert tags_list_to_dict(tags["ResourceTags"]) == env_tags
-@mock_elasticbeanstalk
+@mock_aws
def test_update_tags():
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
conn.create_application(ApplicationName="myapp")
@@ -154,7 +154,7 @@ def test_update_tags():
assert tags_list_to_dict(tags["ResourceTags"]) == total_env_tags
-@mock_elasticbeanstalk
+@mock_aws
def test_list_available_solution_stacks():
conn = boto3.client("elasticbeanstalk", region_name="us-east-1")
stacks = conn.list_available_solution_stacks()
diff --git a/tests/test_elastictranscoder/test_elastictranscoder.py b/tests/test_elastictranscoder/test_elastictranscoder.py
index ca7d1e8b5..17fa8eadb 100644
--- a/tests/test_elastictranscoder/test_elastictranscoder.py
+++ b/tests/test_elastictranscoder/test_elastictranscoder.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_elastictranscoder
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_elastictranscoder
+@mock_aws
def test_create_simple_pipeline():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -44,7 +44,7 @@ def test_create_simple_pipeline():
assert response["Warnings"] == []
-@mock_elastictranscoder
+@mock_aws
def test_create_pipeline_with_content_config():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -81,7 +81,7 @@ def test_create_pipeline_with_content_config():
assert pipeline["ThumbnailConfig"]["Permissions"] == []
-@mock_elastictranscoder
+@mock_aws
def test_create_pipeline_with_outputbucket_and_content_config():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -100,7 +100,7 @@ def test_create_pipeline_with_outputbucket_and_content_config():
assert err["Message"] == "[OutputBucket and ContentConfig are mutually exclusive.]"
-@mock_elastictranscoder
+@mock_aws
def test_create_pipeline_without_thumbnail_config():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -121,7 +121,7 @@ def test_create_pipeline_without_thumbnail_config():
)
-@mock_elastictranscoder
+@mock_aws
def test_create_pipeline_without_role():
client = boto3.client("elastictranscoder", region_name="us-east-1")
@@ -132,7 +132,7 @@ def test_create_pipeline_without_role():
assert err["Message"] == "Role cannot be blank"
-@mock_elastictranscoder
+@mock_aws
def test_create_pipeline_with_invalid_role():
client = boto3.client("elastictranscoder", region_name="us-east-1")
@@ -145,7 +145,7 @@ def test_create_pipeline_with_invalid_role():
assert err["Message"] == "Role ARN is invalid: asdf"
-@mock_elastictranscoder
+@mock_aws
def test_create_pipeline_without_output():
client = boto3.client("elastictranscoder", region_name="us-east-1")
@@ -163,7 +163,7 @@ def test_create_pipeline_without_output():
)
-@mock_elastictranscoder
+@mock_aws
def test_list_pipelines():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -202,7 +202,7 @@ def test_list_pipelines():
assert pipeline["ThumbnailConfig"]["Permissions"] == []
-@mock_elastictranscoder
+@mock_aws
def test_read_pipeline():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -241,7 +241,7 @@ def test_read_pipeline():
assert pipeline["ThumbnailConfig"]["Permissions"] == []
-@mock_elastictranscoder
+@mock_aws
def test_read_unknown_pipeline_format():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -256,7 +256,7 @@ def test_read_unknown_pipeline_format():
)
-@mock_elastictranscoder
+@mock_aws
def test_read_nonexisting_pipeline_format():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -272,7 +272,7 @@ def test_read_nonexisting_pipeline_format():
)
-@mock_elastictranscoder
+@mock_aws
def test_update_pipeline_name():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -310,7 +310,7 @@ def test_update_pipeline_name():
assert pipeline["ThumbnailConfig"]["Permissions"] == []
-@mock_elastictranscoder
+@mock_aws
def test_update_pipeline_input_and_role():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -336,7 +336,7 @@ def test_update_pipeline_input_and_role():
assert pipeline["Role"] == newrole
-@mock_elastictranscoder
+@mock_aws
def test_update_pipeline_with_invalid_id():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -351,7 +351,7 @@ def test_update_pipeline_with_invalid_id():
)
-@mock_elastictranscoder
+@mock_aws
def test_update_nonexisting_pipeline():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
@@ -367,7 +367,7 @@ def test_update_nonexisting_pipeline():
)
-@mock_elastictranscoder
+@mock_aws
def test_delete_pipeline():
region = "us-east-1"
client = boto3.client("elastictranscoder", region_name=region)
diff --git a/tests/test_elastictranscoder/test_server.py b/tests/test_elastictranscoder/test_server.py
index b006dc889..3731f5557 100644
--- a/tests/test_elastictranscoder/test_server.py
+++ b/tests/test_elastictranscoder/test_server.py
@@ -1,12 +1,12 @@
import moto.server as server
-from moto import mock_elastictranscoder
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_elastictranscoder
+@mock_aws
def test_elastictranscoder_list():
backend = server.create_backend_app("elastictranscoder")
test_client = backend.test_client()
diff --git a/tests/test_elb/test_elb.py b/tests/test_elb/test_elb.py
index b57872741..a834a920f 100644
--- a/tests/test_elb/test_elb.py
+++ b/tests/test_elb/test_elb.py
@@ -4,15 +4,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_acm, mock_ec2, mock_elb, mock_iam
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
@pytest.mark.parametrize("region_name", ["us-east-1", "ap-south-1"])
@pytest.mark.parametrize("zones", [["a"], ["a", "b"]])
-@mock_elb
-@mock_ec2
+@mock_aws
def test_create_load_balancer(zones, region_name):
zones = [f"{region_name}{z}" for z in zones]
# Both regions and availability zones are parametrized
@@ -76,7 +75,7 @@ def test_create_load_balancer(zones, region_name):
}
-@mock_elb
+@mock_aws
def test_get_missing_elb():
client = boto3.client("elb", region_name="us-west-2")
with pytest.raises(ClientError) as ex:
@@ -86,7 +85,7 @@ def test_get_missing_elb():
assert err["Message"] == "The specified load balancer does not exist: unknown-lb"
-@mock_elb
+@mock_aws
def test_create_elb_in_multiple_region():
client_east = boto3.client("elb", region_name="us-east-2")
client_west = boto3.client("elb", region_name="us-west-2")
@@ -120,8 +119,7 @@ def test_create_elb_in_multiple_region():
assert name_east not in west_names
-@mock_acm
-@mock_elb
+@mock_aws
def test_create_load_balancer_with_certificate():
acm_client = boto3.client("acm", region_name="us-east-2")
acm_request_response = acm_client.request_certificate(
@@ -158,7 +156,7 @@ def test_create_load_balancer_with_certificate():
assert listener["SSLCertificateId"] == certificate_arn
-@mock_elb
+@mock_aws
def test_create_load_balancer_with_invalid_certificate():
client = boto3.client("elb", region_name="us-east-2")
@@ -181,7 +179,7 @@ def test_create_load_balancer_with_invalid_certificate():
assert err["Code"] == "CertificateNotFoundException"
-@mock_elb
+@mock_aws
def test_create_and_delete_load_balancer():
client = boto3.client("elb", region_name="us-east-1")
@@ -196,7 +194,7 @@ def test_create_and_delete_load_balancer():
assert len(client.describe_load_balancers()["LoadBalancerDescriptions"]) == 0
-@mock_elb
+@mock_aws
def test_create_load_balancer_with_no_listeners_defined():
client = boto3.client("elb", region_name="us-east-1")
@@ -208,8 +206,7 @@ def test_create_load_balancer_with_no_listeners_defined():
)
-@mock_ec2
-@mock_elb
+@mock_aws
def test_create_load_balancer_without_security_groups():
lb_name = str(uuid4())[0:6]
client = boto3.client("elb", region_name="us-east-1")
@@ -228,7 +225,7 @@ def test_create_load_balancer_without_security_groups():
assert sg["GroupName"].startswith("default_elb_")
-@mock_elb
+@mock_aws
def test_describe_paginated_balancers():
client = boto3.client("elb", region_name="us-east-1")
@@ -251,8 +248,7 @@ def test_describe_paginated_balancers():
assert "NextToken" not in resp2.keys()
-@mock_elb
-@mock_ec2
+@mock_aws
def test_apply_security_groups_to_load_balancer():
client = boto3.client("elb", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -286,7 +282,7 @@ def test_apply_security_groups_to_load_balancer():
)
-@mock_elb
+@mock_aws
def test_create_and_delete_listener():
client = boto3.client("elb", region_name="us-east-1")
@@ -318,7 +314,7 @@ def test_create_and_delete_listener():
assert len(balancer["ListenerDescriptions"]) == 1
-@mock_elb
+@mock_aws
@pytest.mark.parametrize("first,second", [["tcp", "http"], ["http", "TCP"]])
def test_create_duplicate_listener_different_protocols(first, second):
client = boto3.client("elb", region_name="us-east-1")
@@ -345,7 +341,7 @@ def test_create_duplicate_listener_different_protocols(first, second):
)
-@mock_elb
+@mock_aws
@pytest.mark.parametrize(
"first,second", [["tcp", "tcp"], ["tcp", "TcP"], ["http", "HTTP"]]
)
@@ -369,8 +365,7 @@ def test_create_duplicate_listener_same_details(first, second):
assert len(balancer["ListenerDescriptions"]) == 1
-@mock_acm
-@mock_elb
+@mock_aws
def test_create_lb_listener_with_ssl_certificate_from_acm():
acm_client = boto3.client("acm", region_name="eu-west-1")
acm_request_response = acm_client.request_certificate(
@@ -411,8 +406,7 @@ def test_create_lb_listener_with_ssl_certificate_from_acm():
assert listeners[1]["Listener"]["SSLCertificateId"] == certificate_arn
-@mock_iam
-@mock_elb
+@mock_aws
def test_create_lb_listener_with_ssl_certificate_from_iam():
iam_client = boto3.client("iam", region_name="eu-west-2")
iam_cert_response = iam_client.upload_server_certificate(
@@ -452,8 +446,7 @@ def test_create_lb_listener_with_ssl_certificate_from_iam():
assert listeners[1]["Listener"]["SSLCertificateId"] == certificate_arn
-@mock_acm
-@mock_elb
+@mock_aws
def test_create_lb_listener_with_invalid_ssl_certificate():
client = boto3.client("elb", region_name="eu-west-1")
@@ -479,8 +472,7 @@ def test_create_lb_listener_with_invalid_ssl_certificate():
assert err["Code"] == "CertificateNotFoundException"
-@mock_acm
-@mock_elb
+@mock_aws
def test_set_sslcertificate():
acm_client = boto3.client("acm", region_name="us-east-1")
acm_request_response = acm_client.request_certificate(
@@ -518,7 +510,7 @@ def test_set_sslcertificate():
assert listener["SSLCertificateId"] == certificate_arn
-@mock_elb
+@mock_aws
def test_get_load_balancers_by_name():
client = boto3.client("elb", region_name="us-east-1")
lb_name1 = str(uuid4())[0:6]
@@ -559,7 +551,7 @@ def test_get_load_balancers_by_name():
assert "The specified load balancer does not exist:" in err["Message"]
-@mock_elb
+@mock_aws
def test_delete_load_balancer():
client = boto3.client("elb", region_name="us-east-1")
lb_name1 = str(uuid4())[0:6]
@@ -590,7 +582,7 @@ def test_delete_load_balancer():
assert lb_name2 in lb_names
-@mock_elb
+@mock_aws
def test_create_health_check():
client = boto3.client("elb", region_name="us-east-1")
@@ -618,8 +610,7 @@ def test_create_health_check():
assert balancer["HealthCheck"]["UnhealthyThreshold"] == 5
-@mock_ec2
-@mock_elb
+@mock_aws
def test_register_instances():
ec2 = boto3.resource("ec2", region_name="us-east-1")
response = ec2.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=2, MaxCount=2)
@@ -641,8 +632,7 @@ def test_register_instances():
assert set(instance_ids) == set([instance_id1, instance_id2])
-@mock_ec2
-@mock_elb
+@mock_aws
def test_deregister_instances():
ec2 = boto3.resource("ec2", region_name="us-east-1")
response = ec2.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=2, MaxCount=2)
@@ -672,7 +662,7 @@ def test_deregister_instances():
assert balancer["Instances"][0]["InstanceId"] == instance_id2
-@mock_elb
+@mock_aws
def test_default_attributes():
lb_name = str(uuid4())[0:6]
@@ -692,7 +682,7 @@ def test_default_attributes():
assert attributes["ConnectionSettings"] == {"IdleTimeout": 60}
-@mock_elb
+@mock_aws
def test_cross_zone_load_balancing_attribute():
lb_name = str(uuid4())[0:6]
@@ -727,7 +717,7 @@ def test_cross_zone_load_balancing_attribute():
assert attributes["CrossZoneLoadBalancing"] == {"Enabled": False}
-@mock_elb
+@mock_aws
def test_connection_draining_attribute():
lb_name = str(uuid4())[0:6]
@@ -759,7 +749,7 @@ def test_connection_draining_attribute():
assert attributes["ConnectionDraining"] == {"Enabled": False, "Timeout": 300}
-@mock_elb
+@mock_aws
def test_access_log_attribute():
lb_name = str(uuid4())[0:6]
@@ -811,7 +801,7 @@ def test_access_log_attribute():
assert access_log == {"Enabled": False}
-@mock_elb
+@mock_aws
def test_connection_settings_attribute():
lb_name = str(uuid4())[0:6]
@@ -840,8 +830,7 @@ def test_connection_settings_attribute():
assert conn_settings == {"IdleTimeout": 123}
-@mock_ec2
-@mock_elb
+@mock_aws
def test_describe_instance_health():
elb = boto3.client("elb", region_name="us-east-1")
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -867,8 +856,7 @@ def test_describe_instance_health():
assert len(instances_health) == 2
-@mock_ec2
-@mock_elb
+@mock_aws
def test_describe_instance_health__with_instance_ids():
elb = boto3.client("elb", region_name="us-east-1")
ec2 = boto3.client("ec2", region_name="us-east-1")
@@ -910,7 +898,7 @@ def test_describe_instance_health__with_instance_ids():
assert instances_health[2]["State"] == "OutOfService"
-@mock_elb
+@mock_aws
def test_describe_instance_health_of_unknown_lb():
elb = boto3.client("elb", region_name="us-east-1")
@@ -921,7 +909,7 @@ def test_describe_instance_health_of_unknown_lb():
assert err["Message"] == "There is no ACTIVE Load Balancer named 'what'"
-@mock_elb
+@mock_aws
def test_add_remove_tags():
client = boto3.client("elb", region_name="us-east-1")
@@ -1038,7 +1026,7 @@ def test_add_remove_tags():
assert lb_tags["other-lb"]["other"] == "something"
-@mock_elb
+@mock_aws
def test_create_with_tags():
client = boto3.client("elb", region_name="us-east-1")
@@ -1058,7 +1046,7 @@ def test_create_with_tags():
assert tags["k"] == "v"
-@mock_elb
+@mock_aws
def test_modify_attributes():
client = boto3.client("elb", region_name="us-east-1")
@@ -1087,8 +1075,7 @@ def test_modify_attributes():
assert lb_attrs["LoadBalancerAttributes"]["ConnectionDraining"]["Timeout"] == 45
-@mock_ec2
-@mock_elb
+@mock_aws
def test_subnets():
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
@@ -1112,7 +1099,7 @@ def test_subnets():
}
-@mock_elb
+@mock_aws
def test_create_load_balancer_duplicate():
lb_name = str(uuid4())[0:6]
client = boto3.client("elb", region_name="us-east-1")
diff --git a/tests/test_elb/test_elb_availabilityzones.py b/tests/test_elb/test_elb_availabilityzones.py
index 428ae0941..7d1d90472 100644
--- a/tests/test_elb/test_elb_availabilityzones.py
+++ b/tests/test_elb/test_elb_availabilityzones.py
@@ -1,10 +1,9 @@
import boto3
-from moto import mock_ec2, mock_elb
+from moto import mock_aws
-@mock_elb
-@mock_ec2
+@mock_aws
def test_enable_and_disable_availability_zones():
client = boto3.client("elb", region_name="eu-north-1")
ec2 = boto3.resource("ec2", region_name="eu-north-1")
diff --git a/tests/test_elb/test_elb_cloudformation.py b/tests/test_elb/test_elb_cloudformation.py
index 1f522d001..c268e180e 100644
--- a/tests/test_elb/test_elb_cloudformation.py
+++ b/tests/test_elb/test_elb_cloudformation.py
@@ -2,13 +2,11 @@ import json
import boto3
-from moto import mock_cloudformation, mock_ec2, mock_elb
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
-@mock_ec2
-@mock_elb
-@mock_cloudformation
+@mock_aws
def test_stack_elb_integration_with_attached_ec2_instances():
elb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -50,8 +48,7 @@ def test_stack_elb_integration_with_attached_ec2_instances():
assert load_balancer["AvailabilityZones"] == ["us-west-1a"]
-@mock_elb
-@mock_cloudformation
+@mock_aws
def test_stack_elb_integration_with_health_check():
elb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@@ -95,8 +92,7 @@ def test_stack_elb_integration_with_health_check():
assert health_check["UnhealthyThreshold"] == 2
-@mock_elb
-@mock_cloudformation
+@mock_aws
def test_stack_elb_integration_with_update():
elb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
diff --git a/tests/test_elb/test_elb_policies.py b/tests/test_elb/test_elb_policies.py
index 858025571..e01cf982d 100644
--- a/tests/test_elb/test_elb_policies.py
+++ b/tests/test_elb/test_elb_policies.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_elb
+from moto import mock_aws
-@mock_elb
+@mock_aws
def test_create_lb_cookie_stickiness_policy():
lb_name = str(uuid4())[0:6]
@@ -37,7 +37,7 @@ def test_create_lb_cookie_stickiness_policy():
assert lbc_policies[0] == {"PolicyName": "pname", "CookieExpirationPeriod": 42}
-@mock_elb
+@mock_aws
def test_create_lb_cookie_stickiness_policy_no_expiry():
lb_name = str(uuid4())[0:6]
@@ -67,7 +67,7 @@ def test_create_lb_cookie_stickiness_policy_no_expiry():
assert lbc_policies[0] == {"PolicyName": "pname"}
-@mock_elb
+@mock_aws
def test_create_app_cookie_stickiness_policy():
lb_name = str(uuid4())[0:6]
@@ -97,7 +97,7 @@ def test_create_app_cookie_stickiness_policy():
assert lbc_policies[0] == {"CookieName": "cname", "PolicyName": "pname"}
-@mock_elb
+@mock_aws
def test_create_lb_policy():
lb_name = str(uuid4())[0:6]
@@ -122,7 +122,7 @@ def test_create_lb_policy():
assert policies["OtherPolicies"] == ["ProxyPolicy"]
-@mock_elb
+@mock_aws
def test_set_policies_of_listener():
lb_name = str(uuid4())[0:6]
@@ -163,7 +163,7 @@ def test_set_policies_of_listener():
assert https_l["PolicyNames"] == ["pname"]
-@mock_elb
+@mock_aws
def test_set_policies_of_backend_server():
lb_name = str(uuid4())[0:6]
@@ -193,7 +193,7 @@ def test_set_policies_of_backend_server():
assert desc[0] == {"InstancePort": 8081, "PolicyNames": ["pname"]}
-@mock_elb
+@mock_aws
def test_describe_load_balancer_policies__initial():
lb_name = str(uuid4())[0:6]
@@ -208,7 +208,7 @@ def test_describe_load_balancer_policies__initial():
assert resp["PolicyDescriptions"] == []
-@mock_elb
+@mock_aws
def test_describe_load_balancer_policies():
lb_name = str(uuid4())[0:6]
@@ -249,7 +249,7 @@ def test_describe_load_balancer_policies():
}
-@mock_elb
+@mock_aws
def test_describe_unknown_load_balancer_policy():
lb_name = str(uuid4())[0:6]
@@ -268,7 +268,7 @@ def test_describe_unknown_load_balancer_policy():
assert err["Code"] == "PolicyNotFound"
-@mock_elb
+@mock_aws
def test_delete_load_balancer_policies():
lb_name = str(uuid4())[0:6]
diff --git a/tests/test_elb/test_elb_subnets.py b/tests/test_elb/test_elb_subnets.py
index 5b31ad2e1..c378e16e9 100644
--- a/tests/test_elb/test_elb_subnets.py
+++ b/tests/test_elb/test_elb_subnets.py
@@ -1,10 +1,9 @@
import boto3
-from moto import mock_ec2, mock_elb
+from moto import mock_aws
-@mock_ec2
-@mock_elb
+@mock_aws
def test_elb_attach_load_balancer_to_subnets():
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
@@ -28,8 +27,7 @@ def test_elb_attach_load_balancer_to_subnets():
assert subnet2.id in lb["Subnets"]
-@mock_ec2
-@mock_elb
+@mock_aws
def test_elb_detach_load_balancer_to_subnets():
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
diff --git a/tests/test_elbv2/test_elbv2.py b/tests/test_elbv2/test_elbv2.py
index 4da6b059c..524ae5736 100644
--- a/tests/test_elbv2/test_elbv2.py
+++ b/tests/test_elbv2/test_elbv2.py
@@ -5,14 +5,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_acm, mock_ec2, mock_elbv2
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.elbv2 import elbv2_backends
from tests import EXAMPLE_AMI_ID
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_load_balancer():
response, _, security_group, subnet1, subnet2, conn = create_load_balancer()
@@ -63,8 +62,7 @@ def create_load_balancer():
return response, vpc, security_group, subnet1, subnet2, conn
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_elb_using_subnetmapping():
region = "us-west-1"
conn = boto3.client("elbv2", region_name=region)
@@ -95,8 +93,7 @@ def test_create_elb_using_subnetmapping():
assert {"ZoneName": "us-west-1b", "SubnetId": subnet2.id} in lb["AvailabilityZones"]
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_describe_load_balancers():
response, _, _, _, _, conn = create_load_balancer()
@@ -119,8 +116,7 @@ def test_describe_load_balancers():
conn.describe_load_balancers(Names=["nope"])
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_describe_listeners():
conn = boto3.client("elbv2", region_name="us-east-1")
@@ -133,8 +129,7 @@ def test_describe_listeners():
)
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_add_remove_tags():
_, _, _, _, _, conn = create_load_balancer()
@@ -221,8 +216,7 @@ def test_add_remove_tags():
assert tags["j"] == "c"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_elb_in_multiple_region():
for region in ["us-west-1", "us-west-2"]:
conn = boto3.client("elbv2", region_name=region)
@@ -253,8 +247,7 @@ def test_create_elb_in_multiple_region():
assert len(west_2_lbs["LoadBalancers"]) == 1
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_listeners_without_port():
response, vpc, _, _, _, conn = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -288,8 +281,7 @@ def test_create_listeners_without_port():
]
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_create_rule_forward_config_as_second_arg():
# https://github.com/getmoto/moto/issues/4123
# Necessary because there was some convoluted way of parsing arguments
@@ -365,8 +357,7 @@ def test_create_rule_forward_config_as_second_arg():
}
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_describe_paginated_balancers():
conn = boto3.client("elbv2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -399,8 +390,7 @@ def test_describe_paginated_balancers():
assert "NextToken" not in resp2.keys()
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_delete_load_balancer():
response, _, _, _, _, conn = create_load_balancer()
@@ -412,8 +402,7 @@ def test_delete_load_balancer():
assert len(balancers) == 0
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_register_targets():
conn = boto3.client("elbv2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -517,8 +506,7 @@ def test_register_targets():
assert_target_not_registered(target_custom_port)
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_stopped_instance_target():
target_group_port = 8080
@@ -600,8 +588,7 @@ def test_stopped_instance_target():
}
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_terminated_instance_target():
target_group_port = 8080
@@ -675,8 +662,7 @@ def test_terminated_instance_target():
assert len(response["TargetHealthDescriptions"]) == 0
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_rule_priority_in_use():
response, _, _, _, _, elbv2 = create_load_balancer()
@@ -702,8 +688,7 @@ def test_create_rule_priority_in_use():
assert err["Message"] == "The specified priority is in use."
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_modify_rule_conditions():
response, _, _, _, _, elbv2 = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -757,8 +742,7 @@ def test_modify_rule_conditions():
assert len(rule["Conditions"]) == 2
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_handle_listener_rules():
response, vpc, _, _, _, conn = create_load_balancer()
@@ -1107,7 +1091,7 @@ def test_handle_listener_rules():
)
-@mock_elbv2
+@mock_aws
def test_describe_account_limits():
client = boto3.client("elbv2", region_name="eu-central-1")
@@ -1116,7 +1100,7 @@ def test_describe_account_limits():
assert "Max" in resp["Limits"][0]
-@mock_elbv2
+@mock_aws
def test_describe_ssl_policies():
client = boto3.client("elbv2", region_name="eu-central-1")
@@ -1138,8 +1122,7 @@ def test_describe_ssl_policies():
assert len(resp["SslPolicies"]) == 2
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_set_ip_address_type():
response, _, security_group, subnet1, subnet2, client = create_load_balancer()
arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1166,8 +1149,7 @@ def test_set_ip_address_type():
assert err["Code"] == "ValidationError"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_set_security_groups():
client = boto3.client("elbv2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -1206,8 +1188,7 @@ def test_set_security_groups():
client.set_security_groups(LoadBalancerArn=arn, SecurityGroups=["non_existent"])
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_modify_load_balancer_attributes_idle_timeout():
response, _, _, _, _, client = create_load_balancer()
arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1228,8 +1209,7 @@ def test_modify_load_balancer_attributes_idle_timeout():
assert idle_timeout["Value"] == "600"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_modify_load_balancer_attributes_routing_http2_enabled():
response, _, _, _, _, client = create_load_balancer()
arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1248,8 +1228,7 @@ def test_modify_load_balancer_attributes_routing_http2_enabled():
assert routing_http2_enabled["Value"] == "false"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_modify_load_balancer_attributes_crosszone_enabled():
response, _, _, _, _, client = create_load_balancer()
arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1267,8 +1246,7 @@ def test_modify_load_balancer_attributes_crosszone_enabled():
assert {"Key": "load_balancing.cross_zone.enabled", "Value": "false"} in attrs
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_modify_load_balancer_attributes_routing_http_drop_invalid_header_fields_enabled():
response, _, _, _, _, client = create_load_balancer()
arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1291,8 +1269,7 @@ def test_modify_load_balancer_attributes_routing_http_drop_invalid_header_fields
assert routing_http_drop_invalid_header_fields_enabled["Value"] == "false"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_modify_load_balancer_attributes_connection_logs_s3():
response, _, _, _, _, client = create_load_balancer()
arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1313,9 +1290,7 @@ def test_modify_load_balancer_attributes_connection_logs_s3():
assert {"Key": "connection_logs.s3.prefix", "Value": "test_prefix"} in attrs
-@mock_elbv2
-@mock_ec2
-@mock_acm
+@mock_aws
def test_modify_listener_http_to_https():
client = boto3.client("elbv2", region_name="eu-central-1")
acm = boto3.client("acm", region_name="eu-central-1")
@@ -1444,9 +1419,7 @@ def test_modify_listener_http_to_https():
assert err["Message"] == "Protocol HTP is not supported"
-@mock_acm
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_modify_listener_of_https_target_group():
# Verify we can add a listener for a TargetGroup that is already HTTPS
client = boto3.client("elbv2", region_name="eu-central-1")
@@ -1508,7 +1481,7 @@ def test_modify_listener_of_https_target_group():
assert listener["Certificates"] == [{"CertificateArn": yahoo_arn}]
-@mock_elbv2
+@mock_aws
def test_add_unknown_listener_certificate():
client = boto3.client("elbv2", region_name="eu-central-1")
with pytest.raises(ClientError) as exc:
@@ -1519,7 +1492,7 @@ def test_add_unknown_listener_certificate():
assert err["Code"] == "ListenerNotFound"
-@mock_elbv2
+@mock_aws
def test_describe_unknown_listener_certificate():
client = boto3.client("elbv2", region_name="eu-central-1")
with pytest.raises(ClientError) as exc:
@@ -1528,9 +1501,7 @@ def test_describe_unknown_listener_certificate():
assert err["Code"] == "ListenerNotFound"
-@mock_acm
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_add_listener_certificate():
# Verify we can add a listener for a TargetGroup that is already HTTPS
client = boto3.client("elbv2", region_name="eu-central-1")
@@ -1591,8 +1562,7 @@ def test_add_listener_certificate():
assert len(certs) == 0
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_forward_config_action():
response, vpc, _, _, _, conn = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1629,8 +1599,7 @@ def test_forward_config_action():
assert describe_listener_actions == [expected_action]
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_forward_config_action__with_stickiness():
response, vpc, _, _, _, conn = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1666,8 +1635,7 @@ def test_forward_config_action__with_stickiness():
assert describe_listener_actions == [action]
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_redirect_action_listener_rule():
response, _, _, _, _, conn = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1716,8 +1684,7 @@ def test_redirect_action_listener_rule():
assert modify_listener_actions == [action]
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_cognito_action_listener_rule():
response, _, _, _, _, conn = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1758,8 +1725,7 @@ def test_cognito_action_listener_rule():
assert describe_listener_actions == action
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_oidc_action_listener__simple():
response, _, _, _, _, conn = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1801,8 +1767,7 @@ def test_oidc_action_listener__simple():
assert describe_listener_actions == action
-@mock_elbv2
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("use_secret", [True, False])
def test_oidc_action_listener(use_secret):
response, _, _, _, _, conn = create_load_balancer()
@@ -1852,8 +1817,7 @@ def test_oidc_action_listener(use_secret):
assert describe_listener_actions == action
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_fixed_response_action_listener_rule():
response, _, _, _, _, conn = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1893,8 +1857,7 @@ def test_fixed_response_action_listener_rule():
assert describe_listener_actions == action
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_fixed_response_action_listener_rule_validates_status_code():
response, _, _, _, _, conn = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1919,8 +1882,7 @@ def test_fixed_response_action_listener_rule_validates_status_code():
assert exc.value.response["Error"]["Code"] == "ValidationError"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_fixed_response_action_listener_rule_validates_content_type():
response, _, _, _, _, conn = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
@@ -1943,8 +1905,7 @@ def test_fixed_response_action_listener_rule_validates_content_type():
assert exc.value.response["Error"]["Code"] == "InvalidLoadBalancerAction"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_listener_with_alpn_policy():
response, _, _, _, _, conn = create_load_balancer()
load_balancer_arn = response["LoadBalancers"][0]["LoadBalancerArn"]
diff --git a/tests/test_elbv2/test_elbv2_cloudformation.py b/tests/test_elbv2/test_elbv2_cloudformation.py
index c5c125d8e..f4ae48248 100644
--- a/tests/test_elbv2/test_elbv2_cloudformation.py
+++ b/tests/test_elbv2/test_elbv2_cloudformation.py
@@ -2,12 +2,11 @@ import json
import boto3
-from moto import mock_cloudformation, mock_ec2, mock_elbv2
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_elbv2
-@mock_cloudformation
+@mock_aws
def test_redirect_action_listener_rule_cloudformation():
cnf_conn = boto3.client("cloudformation", region_name="us-east-1")
elbv2_client = boto3.client("elbv2", region_name="us-east-1")
@@ -87,8 +86,7 @@ def test_redirect_action_listener_rule_cloudformation():
]
-@mock_elbv2
-@mock_cloudformation
+@mock_aws
def test_cognito_action_listener_rule_cloudformation():
cnf_conn = boto3.client("cloudformation", region_name="us-east-1")
elbv2_client = boto3.client("elbv2", region_name="us-east-1")
@@ -172,9 +170,7 @@ def test_cognito_action_listener_rule_cloudformation():
]
-@mock_ec2
-@mock_elbv2
-@mock_cloudformation
+@mock_aws
def test_create_target_groups_through_cloudformation():
cfn_conn = boto3.client("cloudformation", region_name="us-east-1")
elbv2_client = boto3.client("elbv2", region_name="us-east-1")
@@ -248,8 +244,7 @@ def test_create_target_groups_through_cloudformation():
)
-@mock_elbv2
-@mock_cloudformation
+@mock_aws
def test_fixed_response_action_listener_rule_cloudformation():
cnf_conn = boto3.client("cloudformation", region_name="us-east-1")
elbv2_client = boto3.client("elbv2", region_name="us-east-1")
diff --git a/tests/test_elbv2/test_elbv2_integration.py b/tests/test_elbv2/test_elbv2_integration.py
index 578794b54..8a2d0cfa3 100644
--- a/tests/test_elbv2/test_elbv2_integration.py
+++ b/tests/test_elbv2/test_elbv2_integration.py
@@ -1,12 +1,9 @@
import boto3
-from moto import mock_acm, mock_ec2, mock_elbv2, mock_iam
+from moto import mock_aws
-@mock_acm
-@mock_iam
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_modify_listener_using_iam_certificate():
# Verify we can add a listener for a TargetGroup that is already HTTPS
client = boto3.client("elbv2", region_name="eu-central-1")
diff --git a/tests/test_elbv2/test_elbv2_listener_rule_tags.py b/tests/test_elbv2/test_elbv2_listener_rule_tags.py
index 2c5daa4fd..7a03da309 100644
--- a/tests/test_elbv2/test_elbv2_listener_rule_tags.py
+++ b/tests/test_elbv2/test_elbv2_listener_rule_tags.py
@@ -1,4 +1,4 @@
-from moto import mock_ec2, mock_elbv2
+from moto import mock_aws
from .test_elbv2 import create_load_balancer
@@ -9,8 +9,7 @@ default_action = {
}
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_listener_rule_with_tags():
response, _, _, _, _, elbv2 = create_load_balancer()
@@ -36,8 +35,7 @@ def test_create_listener_rule_with_tags():
assert tags == {"k1": "v1"}
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_listener_rule_add_remove_tags():
response, _, _, _, _, elbv2 = create_load_balancer()
diff --git a/tests/test_elbv2/test_elbv2_listener_rules.py b/tests/test_elbv2/test_elbv2_listener_rules.py
index bb841d783..654c055b5 100644
--- a/tests/test_elbv2/test_elbv2_listener_rules.py
+++ b/tests/test_elbv2/test_elbv2_listener_rules.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_elbv2
+from moto import mock_aws
default_action = {
"FixedResponseConfig": {"StatusCode": "200", "ContentType": "text/plain"},
@@ -69,8 +69,7 @@ def setup_target_group(boto_client):
return target_group_arn
-@mock_elbv2
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"condition",
[
@@ -136,8 +135,7 @@ def test_create_rule_condition(condition):
assert len(response["TagDescriptions"]) == 1
-@mock_elbv2
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"create_condition,modify_condition",
[
@@ -192,8 +190,7 @@ def test_modify_rule_condition(create_condition, modify_condition):
assert modified_rule["Conditions"] == [modify_condition]
-@mock_elbv2
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"condition,expected_message",
[
@@ -312,8 +309,7 @@ def test_create_rule_validate_condition(condition, expected_message):
assert err["Message"] == expected_message
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_describe_unknown_rule():
conn = boto3.client("elbv2", region_name="us-east-1")
@@ -324,8 +320,7 @@ def test_describe_unknown_rule():
assert err["Message"] == "One or more rules not found"
-@mock_elbv2
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize(
"action",
[
@@ -427,8 +422,7 @@ def test_create_rule_action(action):
assert rule["Actions"][0] == action
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_rule_action_forward_config():
conn = boto3.client("elbv2", region_name="us-east-1")
@@ -475,8 +469,7 @@ def test_create_rule_action_forward_config():
assert rule["Actions"][0] == action
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_rule_action_forward_target_group():
conn = boto3.client("elbv2", region_name="us-east-1")
diff --git a/tests/test_elbv2/test_elbv2_listener_tags.py b/tests/test_elbv2/test_elbv2_listener_tags.py
index a8dab0d9c..3b80537ce 100644
--- a/tests/test_elbv2/test_elbv2_listener_tags.py
+++ b/tests/test_elbv2/test_elbv2_listener_tags.py
@@ -1,10 +1,9 @@
-from moto import mock_ec2, mock_elbv2
+from moto import mock_aws
from .test_elbv2 import create_load_balancer
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_listener_with_tags():
response, _, _, _, _, elbv2 = create_load_balancer()
@@ -24,8 +23,7 @@ def test_create_listener_with_tags():
assert tags == {"k1": "v1"}
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_listener_add_remove_tags():
response, _, _, _, _, elbv2 = create_load_balancer()
diff --git a/tests/test_elbv2/test_elbv2_set_subnets.py b/tests/test_elbv2/test_elbv2_set_subnets.py
index 172a2ff0e..174e83318 100644
--- a/tests/test_elbv2/test_elbv2_set_subnets.py
+++ b/tests/test_elbv2/test_elbv2_set_subnets.py
@@ -1,10 +1,9 @@
import boto3
-from moto import mock_ec2, mock_elbv2
+from moto import mock_aws
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_set_subnets_errors():
client = boto3.client("elbv2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -40,8 +39,7 @@ def test_set_subnets_errors():
assert len(resp["LoadBalancers"][0]["AvailabilityZones"]) == 3
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_set_subnets__mapping():
client = boto3.client("elbv2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
diff --git a/tests/test_elbv2/test_elbv2_target_groups.py b/tests/test_elbv2/test_elbv2_target_groups.py
index a6c1014d5..eefbd4544 100644
--- a/tests/test_elbv2/test_elbv2_target_groups.py
+++ b/tests/test_elbv2/test_elbv2_target_groups.py
@@ -2,14 +2,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_elbv2
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .test_elbv2 import create_load_balancer
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_create_target_group_with_invalid_healthcheck_protocol():
_, vpc, _, _, _, conn = create_load_balancer()
# Can't create a target group with an invalid protocol
@@ -36,8 +35,7 @@ def test_create_target_group_with_invalid_healthcheck_protocol():
)
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_target_group_with_tags():
response, vpc, _, _, _, conn = create_load_balancer()
@@ -77,8 +75,7 @@ def test_create_target_group_with_tags():
assert tags == [{"Key": "key2", "Value": "val2"}]
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_target_group_and_listeners():
response, vpc, _, _, _, conn = create_load_balancer()
@@ -207,8 +204,7 @@ def test_create_target_group_and_listeners():
assert len(response["TargetGroups"]) == 0
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_target_group_without_non_required_parameters():
response, vpc, _, _, _, conn = create_load_balancer()
@@ -225,8 +221,7 @@ def test_create_target_group_without_non_required_parameters():
assert len(response.get("TargetGroups", [])) == 1
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_invalid_target_group_long_name():
conn = boto3.client("elbv2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -258,8 +253,7 @@ def test_create_invalid_target_group_long_name():
)
-@mock_elbv2
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("name", ["-name", "name-", "-name-", "Na--me"])
def test_create_invalid_target_group_invalid_characters(name):
conn = boto3.client("elbv2", region_name="us-east-1")
@@ -290,8 +284,7 @@ def test_create_invalid_target_group_invalid_characters(name):
)
-@mock_elbv2
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("name", ["example.com", "test@test"])
def test_create_invalid_target_group_alphanumeric_characters(name):
conn = boto3.client("elbv2", region_name="us-east-1")
@@ -322,8 +315,7 @@ def test_create_invalid_target_group_alphanumeric_characters(name):
)
-@mock_elbv2
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("name", ["name", "Name", "000"])
def test_create_valid_target_group_valid_names(name):
conn = boto3.client("elbv2", region_name="us-east-1")
@@ -347,8 +339,7 @@ def test_create_valid_target_group_valid_names(name):
)
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_target_group_attributes():
response, vpc, _, _, _, conn = create_load_balancer()
@@ -418,8 +409,7 @@ def test_target_group_attributes():
assert attributes["stickiness.app_cookie.cookie_name"] == "my_cookie"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_target_group_invalid_protocol():
elbv2 = boto3.client("elbv2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -450,7 +440,7 @@ def test_create_target_group_invalid_protocol():
)
-@mock_elbv2
+@mock_aws
def test_describe_invalid_target_group():
conn = boto3.client("elbv2", region_name="us-east-1")
@@ -462,8 +452,7 @@ def test_describe_invalid_target_group():
assert err["Message"] == "One or more target groups not found"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_describe_target_groups():
elbv2 = boto3.client("elbv2", region_name="us-east-1")
@@ -567,8 +556,7 @@ def test_describe_target_groups():
assert groups[1]["TargetGroupName"] == "d-target"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_describe_target_groups_with_empty_load_balancer():
response, _, _, _, _, conn = create_load_balancer()
@@ -581,8 +569,7 @@ def test_describe_target_groups_with_empty_load_balancer():
assert err["Message"] == "One or more target groups not found"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_modify_target_group():
client = boto3.client("elbv2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -630,8 +617,7 @@ def test_modify_target_group():
assert response["TargetGroups"][0]["UnhealthyThresholdCount"] == 4
-@mock_elbv2
-@mock_ec2
+@mock_aws
@pytest.mark.parametrize("target_type", ["instance", "ip", "lambda", "alb", "other"])
def test_create_target_group_with_target_type(target_type):
response, vpc, _, _, _, conn = create_load_balancer()
@@ -665,8 +651,7 @@ def test_create_target_group_with_target_type(target_type):
assert "VpcId" in group
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_delete_target_group_after_modifying_listener():
client = boto3.client("elbv2", region_name="us-east-1")
@@ -710,8 +695,7 @@ def test_delete_target_group_after_modifying_listener():
assert default_actions == [{"Type": "forward", "TargetGroupArn": target_group_arn2}]
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_listener_with_multiple_target_groups():
client = boto3.client("elbv2", region_name="us-east-1")
@@ -758,8 +742,7 @@ def test_create_listener_with_multiple_target_groups():
assert {"TargetGroupArn": target_group_arn2, "Weight": 0} in groups
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_create_listener_with_invalid_target_group():
response, _, _, _, _, conn = create_load_balancer()
@@ -784,8 +767,7 @@ def test_create_listener_with_invalid_target_group():
assert err["Message"] == "Target group 'unknown' not found"
-@mock_elbv2
-@mock_ec2
+@mock_aws
def test_delete_target_group_while_listener_still_exists():
client = boto3.client("elbv2", region_name="us-east-1")
@@ -831,8 +813,7 @@ def test_delete_target_group_while_listener_still_exists():
client.delete_target_group(TargetGroupArn=target_group_arn1)
-@mock_ec2
-@mock_elbv2
+@mock_aws
def test_create_target_group_validation_error():
elbv2 = boto3.client("elbv2", region_name="us-east-1")
_, vpc, _, _, _, _ = create_load_balancer()
@@ -944,8 +925,7 @@ def test_create_target_group_validation_error():
)
-@mock_ec2
-@mock_elbv2
+@mock_aws
@pytest.mark.parametrize(
"protocol_name, should_raise",
[
@@ -998,8 +978,7 @@ def test_create_target_group_healthcheck_validation(protocol_name, should_raise)
)
-@mock_ec2
-@mock_elbv2
+@mock_aws
@pytest.mark.parametrize(
"protocol, should_raise, stickiness_type, error_message",
[
diff --git a/tests/test_emr/test_emr_boto3.py b/tests/test_emr/test_emr_boto3.py
index 9a2008589..8bd73940c 100644
--- a/tests/test_emr/test_emr_boto3.py
+++ b/tests/test_emr/test_emr_boto3.py
@@ -7,7 +7,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_emr
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
run_job_flow_args = dict(
@@ -69,7 +69,7 @@ input_instance_groups = [
]
-@mock_emr
+@mock_aws
@pytest.mark.filterwarnings("ignore")
def test_describe_cluster():
region_name = "us-east-1"
@@ -189,7 +189,7 @@ def test_describe_cluster():
)
-@mock_emr
+@mock_aws
def test_describe_cluster_not_found():
conn = boto3.client("emr", region_name="us-east-1")
with pytest.raises(ClientError) as e:
@@ -198,7 +198,7 @@ def test_describe_cluster_not_found():
assert e.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_emr
+@mock_aws
def test_describe_job_flows():
client = boto3.client("emr", region_name="us-east-1")
args = deepcopy(run_job_flow_args)
@@ -251,7 +251,7 @@ def test_describe_job_flows():
assert len(resp["JobFlows"]) == 2
-@mock_emr
+@mock_aws
@pytest.mark.filterwarnings("ignore")
def test_describe_job_flow():
client = boto3.client("emr", region_name="us-east-1")
@@ -321,7 +321,7 @@ def test_describe_job_flow():
assert jf["VisibleToAllUsers"] is True
-@mock_emr
+@mock_aws
def test_list_clusters():
client = boto3.client("emr", region_name="us-east-1")
args = deepcopy(run_job_flow_args)
@@ -390,7 +390,7 @@ def test_list_clusters():
assert len(resp["Clusters"]) == 30
-@mock_emr
+@mock_aws
def test_run_job_flow():
region_name = "us-east-1"
client = boto3.client("emr", region_name=region_name)
@@ -417,7 +417,7 @@ def test_run_job_flow():
assert resp["Steps"] == []
-@mock_emr
+@mock_aws
def test_run_job_flow_with_invalid_params():
client = boto3.client("emr", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -429,7 +429,7 @@ def test_run_job_flow_with_invalid_params():
assert ex.value.response["Error"]["Code"] == "ValidationException"
-@mock_emr
+@mock_aws
def test_run_job_flow_in_multiple_regions():
regions = {}
for region in ["us-east-1", "eu-west-1"]:
@@ -445,14 +445,14 @@ def test_run_job_flow_in_multiple_regions():
assert resp["Cluster"]["Name"] == region
-@mock_emr
+@mock_aws
def test_run_job_flow_with_new_params():
client = boto3.client("emr", region_name="us-east-1")
resp = client.run_job_flow(**run_job_flow_args)
assert "JobFlowId" in resp
-@mock_emr
+@mock_aws
def test_run_job_flow_with_visible_to_all_users():
client = boto3.client("emr", region_name="us-east-1")
for expected in (True, False):
@@ -479,7 +479,7 @@ def _do_assertion_ebs_configuration(x, y):
assert comp_total_size == comp_total_size
-@mock_emr
+@mock_aws
def test_run_job_flow_with_instance_groups():
input_groups = dict((g["Name"], g) for g in input_instance_groups)
client = boto3.client("emr", region_name="us-east-1")
@@ -532,7 +532,7 @@ auto_scaling_policy = {
}
-@mock_emr
+@mock_aws
def test_run_job_flow_with_instance_groups_with_autoscaling():
input_groups = dict((g["Name"], g) for g in input_instance_groups)
@@ -558,7 +558,7 @@ def test_run_job_flow_with_instance_groups_with_autoscaling():
assert returned_policy == auto_scaling_policy_with_cluster_id
-@mock_emr
+@mock_aws
def test_put_remove_auto_scaling_policy():
region_name = "us-east-1"
client = boto3.client("emr", region_name=region_name)
@@ -619,7 +619,7 @@ def _patch_cluster_id_placeholder_in_autoscaling_policy(policy, cluster_id):
return policy_copy
-@mock_emr
+@mock_aws
def test_run_job_flow_with_custom_ami():
client = boto3.client("emr", region_name="us-east-1")
@@ -660,7 +660,7 @@ def test_run_job_flow_with_custom_ami():
assert resp["Cluster"]["CustomAmiId"] == "MyEmrCustomAmi"
-@mock_emr
+@mock_aws
def test_run_job_flow_with_step_concurrency():
client = boto3.client("emr", region_name="us-east-1")
args = deepcopy(run_job_flow_args)
@@ -672,7 +672,7 @@ def test_run_job_flow_with_step_concurrency():
assert resp["StepConcurrencyLevel"] == 2
-@mock_emr
+@mock_aws
def test_modify_cluster():
client = boto3.client("emr", region_name="us-east-1")
args = deepcopy(run_job_flow_args)
@@ -690,7 +690,7 @@ def test_modify_cluster():
assert resp["StepConcurrencyLevel"] == 4
-@mock_emr
+@mock_aws
def test_set_termination_protection():
client = boto3.client("emr", region_name="us-east-1")
args = deepcopy(run_job_flow_args)
@@ -708,7 +708,7 @@ def test_set_termination_protection():
assert resp["Cluster"]["TerminationProtected"] == expected
-@mock_emr
+@mock_aws
def test_terminate_protected_job_flow_raises_error():
client = boto3.client("emr", region_name="us-east-1")
resp = client.run_job_flow(**run_job_flow_args)
@@ -726,7 +726,7 @@ def test_terminate_protected_job_flow_raises_error():
)
-@mock_emr
+@mock_aws
def test_set_visible_to_all_users():
client = boto3.client("emr", region_name="us-east-1")
args = deepcopy(run_job_flow_args)
@@ -744,7 +744,7 @@ def test_set_visible_to_all_users():
assert resp["Cluster"]["VisibleToAllUsers"] == expected
-@mock_emr
+@mock_aws
def test_terminate_job_flows():
client = boto3.client("emr", region_name="us-east-1")
@@ -761,7 +761,7 @@ def test_terminate_job_flows():
# testing multiple end points for each feature
-@mock_emr
+@mock_aws
def test_bootstrap_actions():
bootstrap_actions = [
{
@@ -794,7 +794,7 @@ def test_bootstrap_actions():
assert x["ScriptPath"] == y["ScriptBootstrapAction"]["Path"]
-@mock_emr
+@mock_aws
def test_instances():
input_groups = dict((g["Name"], g) for g in input_instance_groups)
client = boto3.client("emr", region_name="us-east-1")
@@ -835,7 +835,7 @@ def test_instances():
)
-@mock_emr
+@mock_aws
def test_instance_groups():
input_groups = dict((g["Name"], g) for g in input_instance_groups)
@@ -926,7 +926,7 @@ def test_instance_groups():
assert igs["task-2"]["InstanceRunningCount"] == 3
-@mock_emr
+@mock_aws
def test_steps():
input_steps = [
{
@@ -1067,7 +1067,7 @@ def test_steps():
assert steps[0]["Id"] == step_id
-@mock_emr
+@mock_aws
def test_tags():
input_tags = [
{"Key": "newkey1", "Value": "newval1"},
@@ -1089,7 +1089,7 @@ def test_tags():
assert resp["Tags"] == []
-@mock_emr
+@mock_aws
def test_security_configurations():
client = boto3.client("emr", region_name="us-east-1")
@@ -1143,7 +1143,7 @@ def test_security_configurations():
)
-@mock_emr
+@mock_aws
def test_run_job_flow_with_invalid_number_of_master_nodes_raises_error():
client = boto3.client("emr", region_name="us-east-1")
params = dict(
@@ -1170,7 +1170,7 @@ def test_run_job_flow_with_invalid_number_of_master_nodes_raises_error():
)
-@mock_emr
+@mock_aws
def test_run_job_flow_with_multiple_master_nodes():
client = boto3.client("emr", region_name="us-east-1")
params = dict(
diff --git a/tests/test_emr/test_emr_integration.py b/tests/test_emr/test_emr_integration.py
index 62c4ca51c..6805ccc7d 100644
--- a/tests/test_emr/test_emr_integration.py
+++ b/tests/test_emr/test_emr_integration.py
@@ -1,17 +1,15 @@
import boto3
import pytest
-from moto import settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-from moto.ec2 import ec2_backends, mock_ec2
-from moto.emr import mock_emr
+from moto.ec2 import ec2_backends
from moto.emr.utils import EmrSecurityGroupManager
ec2_backend = ec2_backends[ACCOUNT_ID]["us-east-1"]
-@mock_emr
-@mock_ec2
+@mock_aws
def test_default_emr_security_groups_get_created_on_first_job_flow():
ec2 = boto3.resource("ec2", region_name="us-east-1")
ec2_client = boto3.client("ec2", region_name="us-east-1")
@@ -88,14 +86,13 @@ def test_default_emr_security_groups_get_created_on_first_job_flow():
@pytest.mark.skipif(
settings.TEST_SERVER_MODE, reason="Can't modify backend directly in server mode."
)
-class TestEmrSecurityGroupManager(object):
+class TestEmrSecurityGroupManager:
mocks = []
def setup_method(self):
- self.mocks = [mock_ec2()]
- for mock in self.mocks:
- mock.start()
+ self.mock = mock_aws()
+ self.mock.start()
ec2_client = boto3.client("ec2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -104,8 +101,7 @@ class TestEmrSecurityGroupManager(object):
self.ec2_client = ec2_client
def teardown_method(self):
- for mock in self.mocks:
- mock.stop()
+ self.mock.stop()
def _create_default_client_supplied_security_groups(self):
master = self.ec2.create_security_group(
@@ -137,13 +133,17 @@ class TestEmrSecurityGroupManager(object):
return self._describe_security_groups(group_names)
def test_emr_security_groups_get_created_if_non_existent(self):
- manager = EmrSecurityGroupManager(ec2_backend, self.vpc_id)
+ manager = EmrSecurityGroupManager(
+ ec2_backends[ACCOUNT_ID]["us-east-1"], self.vpc_id
+ )
assert len(self._default_emr_security_groups()) == 0
manager.manage_security_groups(None, None, None)
assert len(self._default_emr_security_groups()) == 3
def test_emr_security_groups_do_not_get_created_if_already_exist(self):
- manager = EmrSecurityGroupManager(ec2_backend, self.vpc_id)
+ manager = EmrSecurityGroupManager(
+ ec2_backends[ACCOUNT_ID]["us-east-1"], self.vpc_id
+ )
assert len(self._default_emr_security_groups()) == 0
manager.manage_security_groups(None, None, None)
emr_security_groups = self._default_emr_security_groups()
@@ -162,7 +162,9 @@ class TestEmrSecurityGroupManager(object):
client_slave,
client_service,
) = self._create_default_client_supplied_security_groups()
- manager = EmrSecurityGroupManager(ec2_backend, self.vpc_id)
+ manager = EmrSecurityGroupManager(
+ ec2_backends[ACCOUNT_ID]["us-east-1"], self.vpc_id
+ )
manager.manage_security_groups(
client_master.id, client_slave.id, client_service.id
)
@@ -175,7 +177,9 @@ class TestEmrSecurityGroupManager(object):
assert len(self._default_emr_security_groups()) == 0
def test_client_supplied_invalid_security_group_identifier_raises_error(self):
- manager = EmrSecurityGroupManager(ec2_backend, self.vpc_id)
+ manager = EmrSecurityGroupManager(
+ ec2_backends[ACCOUNT_ID]["us-east-1"], self.vpc_id
+ )
args_bad = [
("sg-invalid", None, None),
(None, "sg-invalid", None),
@@ -192,7 +196,9 @@ class TestEmrSecurityGroupManager(object):
client_slave,
client_service,
) = self._create_default_client_supplied_security_groups()
- manager = EmrSecurityGroupManager(ec2_backend, self.vpc_id)
+ manager = EmrSecurityGroupManager(
+ ec2_backends[ACCOUNT_ID]["us-east-1"], self.vpc_id
+ )
manager.manage_security_groups(
client_master.id, client_slave.id, client_service.id
)
diff --git a/tests/test_emrcontainers/test_emrcontainers.py b/tests/test_emrcontainers/test_emrcontainers.py
index 50d1deb35..3652c28f1 100644
--- a/tests/test_emrcontainers/test_emrcontainers.py
+++ b/tests/test_emrcontainers/test_emrcontainers.py
@@ -1,4 +1,3 @@
-"""Unit tests for emrcontainers-supported APIs."""
import re
from datetime import datetime, timedelta, timezone
from unittest import SkipTest
@@ -8,14 +7,15 @@ import boto3
import pytest
from botocore.exceptions import ClientError, ParamValidationError
-from moto import mock_emrcontainers, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-from moto.emrcontainers import REGION as DEFAULT_REGION
+
+DEFAULT_REGION = "us-east-1"
@pytest.fixture(scope="function", name="client")
def fixture_client():
- with mock_emrcontainers():
+ with mock_aws():
yield boto3.client("emr-containers", region_name=DEFAULT_REGION)
@@ -86,7 +86,7 @@ def fixture_job_factory(client, virtual_cluster_factory):
class TestCreateVirtualCluster:
@staticmethod
- @mock_emrcontainers
+ @mock_aws
def test_create_virtual_cluster(client):
resp = client.create_virtual_cluster(
name="test-emr-virtual-cluster",
@@ -108,7 +108,7 @@ class TestCreateVirtualCluster:
assert cluster_count == 1
@staticmethod
- @mock_emrcontainers
+ @mock_aws
def test_create_virtual_cluster_on_same_namespace(client):
client.create_virtual_cluster(
name="test-emr-virtual-cluster",
diff --git a/tests/test_emrserverless/test_emrserverless.py b/tests/test_emrserverless/test_emrserverless.py
index f93675310..3c32ed540 100644
--- a/tests/test_emrserverless/test_emrserverless.py
+++ b/tests/test_emrserverless/test_emrserverless.py
@@ -8,7 +8,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_emrserverless, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.emrserverless import REGION as DEFAULT_REGION
from moto.emrserverless import RELEASE_LABEL as DEFAULT_RELEASE_LABEL
@@ -21,7 +21,7 @@ def does_not_raise():
@pytest.fixture(scope="function", name="client")
def fixture_client():
- with mock_emrserverless():
+ with mock_aws():
yield boto3.client("emr-serverless", region_name=DEFAULT_REGION)
@@ -71,7 +71,7 @@ def fixture_application_factory(client):
class TestCreateApplication:
@staticmethod
- @mock_emrserverless
+ @mock_aws
def test_create_application(client):
resp = client.create_application(
name="test-emr-serverless-application",
@@ -87,7 +87,7 @@ class TestCreateApplication:
)
@staticmethod
- @mock_emrserverless
+ @mock_aws
def test_create_application_incorrect_type(client):
with pytest.raises(ClientError) as exc:
client.create_application(
@@ -102,7 +102,7 @@ class TestCreateApplication:
assert err["Message"] == "Unsupported engine SPARK3"
@staticmethod
- @mock_emrserverless
+ @mock_aws
def test_create_application_incorrect_release_label(client):
with pytest.raises(ClientError) as exc:
client.create_application(
diff --git a/tests/test_es/test_es.py b/tests/test_es/test_es.py
index c24e08977..b751a2b10 100644
--- a/tests/test_es/test_es.py
+++ b/tests/test_es/test_es.py
@@ -3,7 +3,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_es
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
@@ -12,7 +12,7 @@ from moto import mock_es
@pytest.mark.parametrize(
"name", ["getmoto.org", "search-is-$$$", "dev_or_test", "dev/test", "1love", "DEV"]
)
-@mock_es
+@mock_aws
def test_create_domain_invalid_name(name):
client = boto3.client("es", region_name="us-east-2")
with pytest.raises(ClientError) as exc:
@@ -25,7 +25,7 @@ def test_create_domain_invalid_name(name):
assert err["Code"] == "ValidationException"
-@mock_es
+@mock_aws
def test_create_elasticsearch_domain_minimal():
client = boto3.client("es", region_name="us-east-2")
resp = client.create_elasticsearch_domain(DomainName="motosearch")
@@ -40,7 +40,7 @@ def test_create_elasticsearch_domain_minimal():
assert "ElasticsearchVersion" not in domain
-@mock_es
+@mock_aws
def test_create_elasticsearch_domain():
client = boto3.client("es", region_name="us-east-2")
resp = client.create_elasticsearch_domain(
@@ -127,7 +127,7 @@ def test_create_elasticsearch_domain():
assert auto_tune["State"] == "ENABLED"
-@mock_es
+@mock_aws
def test_delete_elasticsearch_domain():
client = boto3.client("es", region_name="ap-southeast-1")
client.create_elasticsearch_domain(DomainName="motosearch")
@@ -136,7 +136,7 @@ def test_delete_elasticsearch_domain():
assert client.list_domain_names()["DomainNames"] == []
-@mock_es
+@mock_aws
def test_missing_delete_elasticsearch_domain():
client = boto3.client("es", region_name="ap-southeast-1")
with pytest.raises(ClientError) as exc:
@@ -150,7 +150,7 @@ def test_missing_delete_elasticsearch_domain():
assert err["Message"] == "Domain not found: unknown"
-@mock_es
+@mock_aws
def test_describe_invalid_domain():
client = boto3.client("es", region_name="us-east-2")
with pytest.raises(ClientError) as exc:
@@ -165,7 +165,7 @@ def test_describe_invalid_domain():
assert err["Code"] == "ValidationException"
-@mock_es
+@mock_aws
def test_describe_unknown_domain():
client = boto3.client("es", region_name="ap-southeast-1")
with pytest.raises(ClientError) as exc:
@@ -179,7 +179,7 @@ def test_describe_unknown_domain():
assert err["Message"] == "Domain not found: unknown"
-@mock_es
+@mock_aws
def test_describe_elasticsearch_domain():
client = boto3.client("es", region_name="ap-southeast-1")
client.create_elasticsearch_domain(DomainName="motosearch")
@@ -195,7 +195,7 @@ def test_describe_elasticsearch_domain():
assert "ElasticsearchVersion" not in domain
-@mock_es
+@mock_aws
def test_list_domain_names_initial():
client = boto3.client("es", region_name="eu-west-1")
resp = client.list_domain_names()
@@ -203,7 +203,7 @@ def test_list_domain_names_initial():
assert resp["DomainNames"] == []
-@mock_es
+@mock_aws
def test_list_domain_names_with_multiple_domains():
client = boto3.client("es", region_name="eu-west-1")
domain_names = [f"env{i}" for i in range(1, 5)]
diff --git a/tests/test_events/test_events.py b/tests/test_events/test_events.py
index ecd8e1bb8..9c8d2d422 100644
--- a/tests/test_events/test_events.py
+++ b/tests/test_events/test_events.py
@@ -8,10 +8,9 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_logs, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core.utils import iso_8601_datetime_without_milliseconds
-from moto.events import mock_events
RULES = [
{"Name": "test1", "ScheduleExpression": "rate(5 minutes)"},
@@ -83,7 +82,7 @@ def generate_environment(add_targets=True):
return client
-@mock_events
+@mock_aws
def test_put_rule():
client = boto3.client("events", "us-west-2")
assert len(client.list_rules()["Rules"]) == 0
@@ -105,7 +104,7 @@ def test_put_rule():
assert rules[0]["State"] == "ENABLED"
-@mock_events
+@mock_aws
def test_put_rule__where_event_bus_name_is_arn():
client = boto3.client("events", "us-west-2")
event_bus_name = "test-bus"
@@ -119,7 +118,7 @@ def test_put_rule__where_event_bus_name_is_arn():
assert rule_arn == f"arn:aws:events:us-west-2:{ACCOUNT_ID}:rule/test-bus/my-event"
-@mock_events
+@mock_aws
def test_put_rule_error_schedule_expression_custom_event_bus():
# given
client = boto3.client("events", "eu-central-1")
@@ -145,7 +144,7 @@ def test_put_rule_error_schedule_expression_custom_event_bus():
)
-@mock_events
+@mock_aws
def test_list_rules():
client = generate_environment()
response = client.list_rules()
@@ -153,7 +152,7 @@ def test_list_rules():
assert len(rules) == len(RULES)
-@mock_events
+@mock_aws
def test_list_rules_with_token():
client = generate_environment()
response = client.list_rules()
@@ -172,7 +171,7 @@ def test_list_rules_with_token():
assert len(rules) == 2
-@mock_events
+@mock_aws
def test_list_rules_with_prefix_and_token():
client = generate_environment()
response = client.list_rules(NamePrefix="test")
@@ -191,7 +190,7 @@ def test_list_rules_with_prefix_and_token():
assert len(rules) == 2
-@mock_events
+@mock_aws
def test_describe_rule():
rule_name = get_random_rule()["Name"]
client = generate_environment()
@@ -201,7 +200,7 @@ def test_describe_rule():
assert response["Arn"] == f"arn:aws:events:us-west-2:{ACCOUNT_ID}:rule/{rule_name}"
-@mock_events
+@mock_aws
def test_describe_rule_with_event_bus_name():
# given
client = boto3.client("events", "eu-central-1")
@@ -237,7 +236,7 @@ def test_describe_rule_with_event_bus_name():
assert "ScheduleExpression" not in response
-@mock_events
+@mock_aws
def test_enable_disable_rule():
rule_name = get_random_rule()["Name"]
client = generate_environment()
@@ -262,7 +261,7 @@ def test_enable_disable_rule():
assert err["Code"] == "ResourceNotFoundException"
-@mock_events
+@mock_aws
def test_disable_unknown_rule():
client = generate_environment()
@@ -272,7 +271,7 @@ def test_disable_unknown_rule():
assert err["Message"] == "Rule unknown does not exist."
-@mock_events
+@mock_aws
def test_list_rule_names_by_target():
test_1_target = TARGETS["test-target-1"]
test_2_target = TARGETS["test-target-2"]
@@ -289,7 +288,7 @@ def test_list_rule_names_by_target():
assert rule in test_2_target["Rules"]
-@mock_events
+@mock_aws
def test_list_rule_names_by_target_using_limit():
test_1_target = TARGETS["test-target-1"]
client = generate_environment()
@@ -305,7 +304,7 @@ def test_list_rule_names_by_target_using_limit():
assert len(response["RuleNames"]) == 1
-@mock_events
+@mock_aws
def test_delete_rule():
client = generate_environment(add_targets=False)
@@ -314,7 +313,7 @@ def test_delete_rule():
assert len(rules["Rules"]) == len(RULES) - 1
-@mock_events
+@mock_aws
def test_delete_rule_with_targets():
# given
client = generate_environment()
@@ -333,7 +332,7 @@ def test_delete_rule_with_targets():
)
-@mock_events
+@mock_aws
def test_delete_unknown_rule():
client = boto3.client("events", "us-west-1")
resp = client.delete_rule(Name="unknown")
@@ -342,7 +341,7 @@ def test_delete_unknown_rule():
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_events
+@mock_aws
def test_list_targets_by_rule():
rule_name = get_random_rule()["Name"]
client = generate_environment()
@@ -356,7 +355,7 @@ def test_list_targets_by_rule():
assert len(targets["Targets"]) == len(expected_targets)
-@mock_events
+@mock_aws
def test_list_targets_by_rule_for_different_event_bus():
client = generate_environment()
@@ -390,7 +389,7 @@ def test_list_targets_by_rule_for_different_event_bus():
assert [t["Id"] for t in targets] == ["newtarget"]
-@mock_events
+@mock_aws
def test_remove_targets():
rule_name = get_random_rule()["Name"]
client = generate_environment()
@@ -408,7 +407,7 @@ def test_remove_targets():
assert targets_before - 1 == targets_after
-@mock_events
+@mock_aws
def test_update_rule_with_targets():
client = boto3.client("events", "us-west-2")
client.put_rule(Name="test1", ScheduleExpression="rate(5 minutes)", EventPattern="")
@@ -435,7 +434,7 @@ def test_update_rule_with_targets():
assert targets[0].get("Id") == "test-target-1"
-@mock_events
+@mock_aws
def test_remove_targets_error_unknown_rule():
# given
client = boto3.client("events", "eu-central-1")
@@ -455,7 +454,7 @@ def test_remove_targets_error_unknown_rule():
)
-@mock_events
+@mock_aws
def test_put_targets():
client = boto3.client("events", "us-west-2")
rule_name = "my-event"
@@ -484,7 +483,7 @@ def test_put_targets():
assert targets[0]["Id"] == "test_id"
-@mock_events
+@mock_aws
def test_put_targets_error_invalid_arn():
# given
client = boto3.client("events", "eu-central-1")
@@ -516,7 +515,7 @@ def test_put_targets_error_invalid_arn():
)
-@mock_events
+@mock_aws
def test_put_targets_error_unknown_rule():
# given
client = boto3.client("events", "eu-central-1")
@@ -538,7 +537,7 @@ def test_put_targets_error_unknown_rule():
)
-@mock_events
+@mock_aws
def test_put_targets_error_missing_parameter_sqs_fifo():
# given
client = boto3.client("events", "eu-central-1")
@@ -566,7 +565,7 @@ def test_put_targets_error_missing_parameter_sqs_fifo():
)
-@mock_events
+@mock_aws
def test_permissions():
client = boto3.client("events", "eu-central-1")
@@ -589,7 +588,7 @@ def test_permissions():
assert resp_policy["Statement"][0]["Sid"] == "Account1"
-@mock_events
+@mock_aws
def test_permission_policy():
client = boto3.client("events", "eu-central-1")
@@ -613,7 +612,7 @@ def test_permission_policy():
assert resp_policy["Statement"][0]["Sid"] == "asdf"
-@mock_events
+@mock_aws
def test_put_permission_errors():
client = boto3.client("events", "us-east-1")
client.create_event_bus(Name="test-bus")
@@ -639,7 +638,7 @@ def test_put_permission_errors():
assert err["Message"] == "Provided value in parameter 'action' is not supported."
-@mock_events
+@mock_aws
def test_remove_permission_errors():
client = boto3.client("events", "us-east-1")
client.create_event_bus(Name="test-bus")
@@ -667,7 +666,7 @@ def test_remove_permission_errors():
assert err["Message"] == "Statement with the provided id does not exist."
-@mock_events
+@mock_aws
def test_put_events():
client = boto3.client("events", "eu-central-1")
@@ -691,7 +690,7 @@ def test_put_events():
assert any(["EventDetail should be of type dict" in msg for msg in messages])
-@mock_events
+@mock_aws
def test_put_events_error_too_many_entries():
# given
client = boto3.client("events", "eu-central-1")
@@ -720,7 +719,7 @@ def test_put_events_error_too_many_entries():
)
-@mock_events
+@mock_aws
def test_put_events_error_missing_argument_source():
# given
client = boto3.client("events", "eu-central-1")
@@ -737,7 +736,7 @@ def test_put_events_error_missing_argument_source():
}
-@mock_events
+@mock_aws
def test_put_events_error_missing_argument_detail_type():
# given
client = boto3.client("events", "eu-central-1")
@@ -754,7 +753,7 @@ def test_put_events_error_missing_argument_detail_type():
}
-@mock_events
+@mock_aws
def test_put_events_error_missing_argument_detail():
# given
client = boto3.client("events", "eu-central-1")
@@ -771,7 +770,7 @@ def test_put_events_error_missing_argument_detail():
}
-@mock_events
+@mock_aws
def test_put_events_error_invalid_json_detail():
# given
client = boto3.client("events", "eu-central-1")
@@ -790,7 +789,7 @@ def test_put_events_error_invalid_json_detail():
}
-@mock_events
+@mock_aws
def test_put_events_with_mixed_entries():
# given
client = boto3.client("events", "eu-central-1")
@@ -812,7 +811,7 @@ def test_put_events_with_mixed_entries():
assert len([entry for entry in response["Entries"] if "ErrorCode" in entry]) == 2
-@mock_events
+@mock_aws
def test_create_event_bus():
client = boto3.client("events", "us-east-1")
response = client.create_event_bus(Name="test-bus")
@@ -823,7 +822,7 @@ def test_create_event_bus():
)
-@mock_events
+@mock_aws
def test_create_event_bus_errors():
client = boto3.client("events", "us-east-1")
client.create_event_bus(Name="test-bus")
@@ -854,7 +853,7 @@ def test_create_event_bus_errors():
assert err["Message"] == "Event source aws.partner/test/test-bus does not exist."
-@mock_events
+@mock_aws
def test_describe_event_bus():
client = boto3.client("events", "us-east-1")
@@ -892,7 +891,7 @@ def test_describe_event_bus():
}
-@mock_events
+@mock_aws
def test_describe_event_bus_errors():
client = boto3.client("events", "us-east-1")
@@ -902,7 +901,7 @@ def test_describe_event_bus_errors():
assert err["Message"] == "Event bus non-existing does not exist."
-@mock_events
+@mock_aws
def test_list_event_buses():
client = boto3.client("events", "us-east-1")
client.create_event_bus(Name="test-bus-1")
@@ -951,7 +950,7 @@ def test_list_event_buses():
]
-@mock_events
+@mock_aws
def test_delete_event_bus():
client = boto3.client("events", "us-east-1")
client.create_event_bus(Name="test-bus")
@@ -974,7 +973,7 @@ def test_delete_event_bus():
client.delete_event_bus(Name="non-existing")
-@mock_events
+@mock_aws
def test_delete_event_bus_errors():
client = boto3.client("events", "us-east-1")
@@ -984,7 +983,7 @@ def test_delete_event_bus_errors():
assert err["Message"] == "Cannot delete event bus default."
-@mock_events
+@mock_aws
def test_create_rule_with_tags():
client = generate_environment()
rule_name = "test2"
@@ -994,7 +993,7 @@ def test_create_rule_with_tags():
assert actual == [{"Key": "tagk1", "Value": "tagv1"}]
-@mock_events
+@mock_aws
def test_delete_rule_with_tags():
client = generate_environment(add_targets=False)
rule_name = "test2"
@@ -1012,7 +1011,7 @@ def test_delete_rule_with_tags():
assert err["Message"] == "Rule test2 does not exist."
-@mock_events
+@mock_aws
def test_rule_tagging_happy():
client = generate_environment()
rule_name = "test1"
@@ -1036,7 +1035,7 @@ def test_rule_tagging_happy():
assert expected == actual
-@mock_events
+@mock_aws
def test_tag_resource_error_unknown_arn():
# given
client = boto3.client("events", "eu-central-1")
@@ -1059,7 +1058,7 @@ def test_tag_resource_error_unknown_arn():
)
-@mock_events
+@mock_aws
def test_untag_resource_error_unknown_arn():
# given
client = boto3.client("events", "eu-central-1")
@@ -1082,7 +1081,7 @@ def test_untag_resource_error_unknown_arn():
)
-@mock_events
+@mock_aws
def test_list_tags_for_resource_error_unknown_arn():
# given
client = boto3.client("events", "eu-central-1")
@@ -1104,7 +1103,7 @@ def test_list_tags_for_resource_error_unknown_arn():
)
-@mock_events
+@mock_aws
def test_create_archive():
# given
client = boto3.client("events", "eu-central-1")
@@ -1143,7 +1142,7 @@ def test_create_archive():
assert "ScheduleExpression" not in response
-@mock_events
+@mock_aws
def test_create_archive_custom_event_bus():
# given
client = boto3.client("events", "eu-central-1")
@@ -1171,7 +1170,7 @@ def test_create_archive_custom_event_bus():
assert response["State"] == "ENABLED"
-@mock_events
+@mock_aws
def test_create_archive_error_long_name():
# given
client = boto3.client("events", "eu-central-1")
@@ -1197,7 +1196,7 @@ def test_create_archive_error_long_name():
)
-@mock_events
+@mock_aws
def test_create_archive_error_invalid_event_pattern():
# given
client = boto3.client("events", "eu-central-1")
@@ -1223,7 +1222,7 @@ def test_create_archive_error_invalid_event_pattern():
)
-@mock_events
+@mock_aws
def test_create_archive_error_invalid_event_pattern_not_an_array():
# given
client = boto3.client("events", "eu-central-1")
@@ -1256,7 +1255,7 @@ def test_create_archive_error_invalid_event_pattern_not_an_array():
)
-@mock_events
+@mock_aws
def test_create_archive_error_unknown_event_bus():
# given
client = boto3.client("events", "eu-central-1")
@@ -1281,7 +1280,7 @@ def test_create_archive_error_unknown_event_bus():
)
-@mock_events
+@mock_aws
def test_create_archive_error_duplicate():
# given
client = boto3.client("events", "eu-central-1")
@@ -1301,7 +1300,7 @@ def test_create_archive_error_duplicate():
assert ex.response["Error"]["Message"] == "Archive test-archive already exists."
-@mock_events
+@mock_aws
def test_describe_archive():
# given
client = boto3.client("events", "eu-central-1")
@@ -1334,7 +1333,7 @@ def test_describe_archive():
assert response["State"] == "ENABLED"
-@mock_events
+@mock_aws
def test_describe_archive_error_unknown_archive():
# given
client = boto3.client("events", "eu-central-1")
@@ -1352,7 +1351,7 @@ def test_describe_archive_error_unknown_archive():
assert ex.response["Error"]["Message"] == f"Archive {name} does not exist."
-@mock_events
+@mock_aws
def test_list_archives():
# given
client = boto3.client("events", "eu-central-1")
@@ -1385,7 +1384,7 @@ def test_list_archives():
assert "EventPattern" not in archive
-@mock_events
+@mock_aws
def test_list_archives_with_name_prefix():
# given
client = boto3.client("events", "eu-central-1")
@@ -1401,7 +1400,7 @@ def test_list_archives_with_name_prefix():
assert archives[0]["ArchiveName"] == "test-archive"
-@mock_events
+@mock_aws
def test_list_archives_with_source_arn():
# given
client = boto3.client("events", "eu-central-1")
@@ -1418,7 +1417,7 @@ def test_list_archives_with_source_arn():
assert archives[0]["ArchiveName"] == "test"
-@mock_events
+@mock_aws
def test_list_archives_with_state():
# given
client = boto3.client("events", "eu-central-1")
@@ -1433,7 +1432,7 @@ def test_list_archives_with_state():
assert len(archives) == 0
-@mock_events
+@mock_aws
def test_list_archives_error_multiple_filters():
# given
client = boto3.client("events", "eu-central-1")
@@ -1453,7 +1452,7 @@ def test_list_archives_error_multiple_filters():
)
-@mock_events
+@mock_aws
def test_list_archives_error_invalid_state():
# given
client = boto3.client("events", "eu-central-1")
@@ -1473,7 +1472,7 @@ def test_list_archives_error_invalid_state():
)
-@mock_events
+@mock_aws
def test_update_archive():
# given
client = boto3.client("events", "eu-central-1")
@@ -1511,7 +1510,7 @@ def test_update_archive():
assert response["State"] == "ENABLED"
-@mock_events
+@mock_aws
def test_update_archive_error_invalid_event_pattern():
# given
client = boto3.client("events", "eu-central-1")
@@ -1536,7 +1535,7 @@ def test_update_archive_error_invalid_event_pattern():
)
-@mock_events
+@mock_aws
def test_update_archive_error_unknown_archive():
# given
client = boto3.client("events", "eu-central-1")
@@ -1554,7 +1553,7 @@ def test_update_archive_error_unknown_archive():
assert ex.response["Error"]["Message"] == f"Archive {name} does not exist."
-@mock_events
+@mock_aws
def test_delete_archive():
# given
client = boto3.client("events", "eu-central-1")
@@ -1572,7 +1571,7 @@ def test_delete_archive():
assert len(response) == 0
-@mock_events
+@mock_aws
def test_delete_archive_error_unknown_archive():
# given
client = boto3.client("events", "eu-central-1")
@@ -1590,7 +1589,7 @@ def test_delete_archive_error_unknown_archive():
assert ex.response["Error"]["Message"] == f"Archive {name} does not exist."
-@mock_events
+@mock_aws
def test_archive_actual_events():
# given
client = boto3.client("events", "eu-central-1")
@@ -1635,7 +1634,7 @@ def test_archive_actual_events():
assert response["SizeBytes"] > 0
-@mock_events
+@mock_aws
def test_archive_event_with_bus_arn():
# given
client = boto3.client("events", "eu-central-1")
@@ -1661,7 +1660,7 @@ def test_archive_event_with_bus_arn():
assert response["SizeBytes"] > 0
-@mock_events
+@mock_aws
def test_start_replay():
# given
client = boto3.client("events", "eu-central-1")
@@ -1689,7 +1688,7 @@ def test_start_replay():
assert response["State"] == "STARTING"
-@mock_events
+@mock_aws
def test_start_replay_error_unknown_event_bus():
# given
client = boto3.client("events", "eu-central-1")
@@ -1717,7 +1716,7 @@ def test_start_replay_error_unknown_event_bus():
)
-@mock_events
+@mock_aws
def test_start_replay_error_invalid_event_bus_arn():
# given
client = boto3.client("events", "eu-central-1")
@@ -1745,7 +1744,7 @@ def test_start_replay_error_invalid_event_bus_arn():
)
-@mock_events
+@mock_aws
def test_start_replay_error_unknown_archive():
# given
client = boto3.client("events", "eu-central-1")
@@ -1774,7 +1773,7 @@ def test_start_replay_error_unknown_archive():
)
-@mock_events
+@mock_aws
def test_start_replay_error_cross_event_bus():
# given
client = boto3.client("events", "eu-central-1")
@@ -1805,7 +1804,7 @@ def test_start_replay_error_cross_event_bus():
)
-@mock_events
+@mock_aws
def test_start_replay_error_invalid_end_time():
# given
client = boto3.client("events", "eu-central-1")
@@ -1835,7 +1834,7 @@ def test_start_replay_error_invalid_end_time():
)
-@mock_events
+@mock_aws
def test_start_replay_error_duplicate():
# given
client = boto3.client("events", "eu-central-1")
@@ -1870,7 +1869,7 @@ def test_start_replay_error_duplicate():
assert ex.response["Error"]["Message"] == f"Replay {name} already exists."
-@mock_events
+@mock_aws
def test_describe_replay():
# given
client = boto3.client("events", "eu-central-1")
@@ -1907,7 +1906,7 @@ def test_describe_replay():
assert response["State"] == "COMPLETED"
-@mock_events
+@mock_aws
def test_describe_replay_error_unknown_replay():
# given
client = boto3.client("events", "eu-central-1")
@@ -1925,7 +1924,7 @@ def test_describe_replay_error_unknown_replay():
assert ex.response["Error"]["Message"] == f"Replay {name} does not exist."
-@mock_events
+@mock_aws
def test_list_replays():
# given
client = boto3.client("events", "eu-central-1")
@@ -1958,7 +1957,7 @@ def test_list_replays():
assert replay["State"] == "COMPLETED"
-@mock_events
+@mock_aws
def test_list_replays_with_name_prefix():
# given
client = boto3.client("events", "eu-central-1")
@@ -1989,7 +1988,7 @@ def test_list_replays_with_name_prefix():
assert replays[0]["ReplayName"] == "test-replay"
-@mock_events
+@mock_aws
def test_list_replays_with_source_arn():
# given
client = boto3.client("events", "eu-central-1")
@@ -2019,7 +2018,7 @@ def test_list_replays_with_source_arn():
assert len(replays) == 2
-@mock_events
+@mock_aws
def test_list_replays_with_state():
# given
client = boto3.client("events", "eu-central-1")
@@ -2049,7 +2048,7 @@ def test_list_replays_with_state():
assert len(replays) == 0
-@mock_events
+@mock_aws
def test_list_replays_error_multiple_filters():
# given
client = boto3.client("events", "eu-central-1")
@@ -2069,7 +2068,7 @@ def test_list_replays_error_multiple_filters():
)
-@mock_events
+@mock_aws
def test_list_replays_error_invalid_state():
# given
client = boto3.client("events", "eu-central-1")
@@ -2089,7 +2088,7 @@ def test_list_replays_error_invalid_state():
)
-@mock_events
+@mock_aws
def test_cancel_replay():
# given
client = boto3.client("events", "eu-central-1")
@@ -2121,7 +2120,7 @@ def test_cancel_replay():
assert response["State"] == "CANCELLED"
-@mock_events
+@mock_aws
def test_cancel_replay_error_unknown_replay():
# given
client = boto3.client("events", "eu-central-1")
@@ -2139,7 +2138,7 @@ def test_cancel_replay_error_unknown_replay():
assert ex.response["Error"]["Message"] == f"Replay {name} does not exist."
-@mock_events
+@mock_aws
def test_cancel_replay_error_illegal_state():
# given
client = boto3.client("events", "eu-central-1")
@@ -2173,8 +2172,7 @@ def test_cancel_replay_error_illegal_state():
)
-@mock_events
-@mock_logs
+@mock_aws
def test_start_replay_send_to_log_group():
# given
client = boto3.client("events", "eu-central-1")
@@ -2245,7 +2243,7 @@ def test_start_replay_send_to_log_group():
assert event_replay["replay-name"] == "test-replay"
-@mock_events
+@mock_aws
def test_create_and_list_connections():
client = boto3.client("events", "eu-central-1")
@@ -2275,7 +2273,7 @@ def test_create_and_list_connections():
)
-@mock_events
+@mock_aws
def test_create_and_describe_connection():
client = boto3.client("events", "eu-central-1")
@@ -2297,7 +2295,7 @@ def test_create_and_describe_connection():
assert "CreationTime" in description
-@mock_events
+@mock_aws
def test_create_and_update_connection():
client = boto3.client("events", "eu-central-1")
@@ -2321,7 +2319,7 @@ def test_create_and_update_connection():
assert "CreationTime" in description
-@mock_events
+@mock_aws
def test_update_unknown_connection():
client = boto3.client("events", "eu-north-1")
@@ -2331,7 +2329,7 @@ def test_update_unknown_connection():
assert err["Message"] == "Connection 'unknown' does not exist."
-@mock_events
+@mock_aws
def test_delete_connection():
client = boto3.client("events", "eu-central-1")
@@ -2356,7 +2354,7 @@ def test_delete_connection():
assert len(conns) == 0
-@mock_events
+@mock_aws
def test_create_and_list_api_destinations():
client = boto3.client("events", "eu-central-1")
@@ -2411,7 +2409,7 @@ def test_create_and_list_api_destinations():
("HttpMethod", "GET", "PATCH"),
],
)
-@mock_events
+@mock_aws
def test_create_and_update_api_destination(key, initial_value, updated_value):
client = boto3.client("events", "eu-central-1")
@@ -2443,7 +2441,7 @@ def test_create_and_update_api_destination(key, initial_value, updated_value):
assert destination[key] == updated_value
-@mock_events
+@mock_aws
def test_delete_api_destination():
client = boto3.client("events", "eu-central-1")
@@ -2471,7 +2469,7 @@ def test_delete_api_destination():
assert len(client.list_api_destinations()["ApiDestinations"]) == 0
-@mock_events
+@mock_aws
def test_describe_unknown_api_destination():
client = boto3.client("events", "eu-central-1")
@@ -2481,7 +2479,7 @@ def test_describe_unknown_api_destination():
assert err["Message"] == "An api-destination 'unknown' does not exist."
-@mock_events
+@mock_aws
def test_delete_unknown_api_destination():
client = boto3.client("events", "eu-central-1")
@@ -2494,7 +2492,7 @@ def test_delete_unknown_api_destination():
# Scenarios for describe_connection
# Scenario 01: Success
# Scenario 02: Failure - Connection not present
-@mock_events
+@mock_aws
def test_describe_connection_success():
# Given
conn_name = "test_conn_name"
@@ -2523,7 +2521,7 @@ def test_describe_connection_success():
assert response["AuthParameters"] == expected_auth_param
-@mock_events
+@mock_aws
def test_describe_connection_not_present():
conn_name = "test_conn_name"
@@ -2539,7 +2537,7 @@ def test_describe_connection_not_present():
# Scenario 02: Failure - Connection not present
-@mock_events
+@mock_aws
def test_delete_connection_success():
# Given
conn_name = "test_conn_name"
@@ -2569,7 +2567,7 @@ def test_delete_connection_success():
_ = client.describe_connection(Name=conn_name)
-@mock_events
+@mock_aws
def test_delete_connection_not_present():
conn_name = "test_conn_name"
diff --git a/tests/test_events/test_events_cloudformation.py b/tests/test_events/test_events_cloudformation.py
index 711563564..a6d1a5c0a 100644
--- a/tests/test_events/test_events_cloudformation.py
+++ b/tests/test_events/test_events_cloudformation.py
@@ -6,7 +6,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudformation, mock_events
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
archive_template = Template(
@@ -70,8 +70,7 @@ empty = json.dumps(
)
-@mock_events
-@mock_cloudformation
+@mock_aws
def test_create_archive():
# given
cfn_client = boto3.client("cloudformation", region_name="eu-central-1")
@@ -93,8 +92,7 @@ def test_create_archive():
assert response["ArchiveArn"] == archive_arn
-@mock_events
-@mock_cloudformation
+@mock_aws
def test_update_archive():
# given
cfn_client = boto3.client("cloudformation", region_name="eu-central-1")
@@ -124,8 +122,7 @@ def test_update_archive():
assert response["Description"] == "test archive"
-@mock_events
-@mock_cloudformation
+@mock_aws
def test_delete_archive():
# given
cfn_client = boto3.client("cloudformation", region_name="eu-central-1")
@@ -143,8 +140,7 @@ def test_delete_archive():
assert len(response) == 0
-@mock_events
-@mock_cloudformation
+@mock_aws
def test_create_rule():
# given
cfn_client = boto3.client("cloudformation", region_name="eu-central-1")
@@ -167,8 +163,7 @@ def test_create_rule():
assert response["EventPattern"] == '{"detail-type": ["SomeDetailType"]}'
-@mock_events
-@mock_cloudformation
+@mock_aws
def test_delete_rule():
# given
cfn_client = boto3.client("cloudformation", region_name="eu-central-1")
diff --git a/tests/test_events/test_events_http_integration.py b/tests/test_events/test_events_http_integration.py
index fe5d9eed6..ba6beb076 100644
--- a/tests/test_events/test_events_http_integration.py
+++ b/tests/test_events/test_events_http_integration.py
@@ -5,10 +5,10 @@ from unittest import SkipTest, mock
import boto3
import responses
-from moto import mock_events, settings
+from moto import mock_aws, settings
-@mock_events
+@mock_aws
@mock.patch.dict(os.environ, {"MOTO_EVENTS_INVOKE_HTTP": "true"})
def test_invoke_http_request_on_event():
if settings.TEST_SERVER_MODE:
diff --git a/tests/test_events/test_events_integration.py b/tests/test_events/test_events_integration.py
index 6aee4c927..074c5b76b 100644
--- a/tests/test_events/test_events_integration.py
+++ b/tests/test_events/test_events_integration.py
@@ -5,13 +5,12 @@ from unittest import SkipTest, mock
import boto3
-from moto import mock_events, mock_logs, mock_sqs, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core.utils import iso_8601_datetime_without_milliseconds, utcnow
-@mock_events
-@mock_logs
+@mock_aws
def test_send_to_cw_log_group():
# given
client_events = boto3.client("events", "eu-central-1")
@@ -67,8 +66,7 @@ def test_send_to_cw_log_group():
assert message["detail"] == {"key": "value"}
-@mock_events
-@mock_sqs
+@mock_aws
def test_send_to_sqs_fifo_queue():
# given
client_events = boto3.client("events", "eu-central-1")
@@ -155,8 +153,7 @@ def test_send_to_sqs_fifo_queue():
assert "Messages" not in response
-@mock_events
-@mock_sqs
+@mock_aws
def test_send_to_sqs_queue():
# given
client_events = boto3.client("events", "eu-central-1")
@@ -205,8 +202,7 @@ def test_send_to_sqs_queue():
assert body["detail"] == {"key": "value"}
-@mock_events
-@mock_sqs
+@mock_aws
def test_send_to_sqs_queue_with_custom_event_bus():
# given
client_events = boto3.client("events", "eu-central-1")
@@ -250,8 +246,7 @@ def test_send_to_sqs_queue_with_custom_event_bus():
assert body["detail"] == {"key": "value"}
-@mock_events
-@mock_logs
+@mock_aws
def test_moto_matches_none_value_with_exists_filter():
pattern = {
"source": ["test-source"],
@@ -317,8 +312,7 @@ def test_moto_matches_none_value_with_exists_filter():
]
-@mock_events
-@mock_sqs
+@mock_aws
def test_put_events_event_bus_forwarding_rules():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cross-account test - easiest to just test in DecoratorMode")
diff --git a/tests/test_events/test_events_lambdatriggers_integration.py b/tests/test_events/test_events_lambdatriggers_integration.py
index 2f8842867..422df6b49 100644
--- a/tests/test_events/test_events_lambdatriggers_integration.py
+++ b/tests/test_events/test_events_lambdatriggers_integration.py
@@ -2,18 +2,14 @@ import json
import boto3
-from moto import mock_events, mock_iam, mock_lambda, mock_logs, mock_s3
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from ..markers import requires_docker
from ..test_awslambda.utilities import get_test_zip_file1, wait_for_log_msg
-@mock_events
-@mock_iam
-@mock_lambda
-@mock_logs
-@mock_s3
+@mock_aws
@requires_docker
def test_creating_bucket__invokes_lambda():
iam_client = boto3.client("iam", "us-east-1")
@@ -91,11 +87,7 @@ def test_creating_bucket__invokes_lambda():
assert event["resources"] == [f"arn:aws:s3:::{bucket_name}"]
-@mock_events
-@mock_iam
-@mock_lambda
-@mock_logs
-@mock_s3
+@mock_aws
def test_create_disabled_rule():
iam_client = boto3.client("iam", "us-east-1")
lambda_client = boto3.client("lambda", "us-east-1")
@@ -160,10 +152,7 @@ def test_create_disabled_rule():
assert msg_showed_up is False
-@mock_events
-@mock_iam
-@mock_logs
-@mock_s3
+@mock_aws
def test_create_rule_for_unsupported_target_arn():
iam_client = boto3.client("iam", "us-east-1")
events_client = boto3.client("events", "us-east-1")
@@ -219,11 +208,7 @@ def test_create_rule_for_unsupported_target_arn():
assert msg_showed_up is False
-@mock_events
-@mock_iam
-@mock_lambda
-@mock_logs
-@mock_s3
+@mock_aws
def test_creating_bucket__but_invoke_lambda_on_create_object():
iam_client = boto3.client("iam", "us-east-1")
lambda_client = boto3.client("lambda", "us-east-1")
@@ -285,9 +270,7 @@ def test_creating_bucket__but_invoke_lambda_on_create_object():
assert msg_showed_up is False
-@mock_events
-@mock_iam
-@mock_s3
+@mock_aws
def test_creating_bucket__succeeds_despite_unknown_lambda():
iam_client = boto3.client("iam", "us-east-1")
events_client = boto3.client("events", "us-east-1")
diff --git a/tests/test_events/test_events_partners_integration.py b/tests/test_events/test_events_partners_integration.py
index 684a33f9a..41349d542 100644
--- a/tests/test_events/test_events_partners_integration.py
+++ b/tests/test_events/test_events_partners_integration.py
@@ -5,10 +5,10 @@ from unittest import SkipTest, mock
import boto3
-from moto import mock_events, mock_logs, settings
+from moto import mock_aws, settings
-@mock_events
+@mock_aws
def test_create_partner_event_bus():
client_account = "111122223333"
client = boto3.client("events", "us-east-1")
@@ -23,7 +23,7 @@ def test_create_partner_event_bus():
assert resp["Name"] == "mypartner/actions/action1"
-@mock_events
+@mock_aws
def test_describe_partner_event_busses():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't change accounts easily in ServerMode")
@@ -54,8 +54,7 @@ def test_describe_partner_event_busses():
assert resp["State"] == "DELETED"
-@mock_events
-@mock_logs
+@mock_aws
def test_put_partner_events():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't change accounts easily in ServerMode")
diff --git a/tests/test_firehose/test_firehose.py b/tests/test_firehose/test_firehose.py
index 6271f8ccf..d079bf12d 100644
--- a/tests/test_firehose/test_firehose.py
+++ b/tests/test_firehose/test_firehose.py
@@ -1,4 +1,3 @@
-"""Unit tests specific to basic Firehose Delivery Stream-related APIs."""
import warnings
from unittest import SkipTest
@@ -6,7 +5,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_firehose, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.firehose.models import DeliveryStream
from moto.moto_api._internal import mock_random
@@ -22,7 +21,7 @@ def sample_s3_dest_config():
}
-@mock_firehose
+@mock_aws
def test_warnings():
"""Test features that raise a warning as they're unimplemented."""
if settings.TEST_SERVER_MODE:
@@ -69,7 +68,7 @@ def test_warnings():
)
-@mock_firehose
+@mock_aws
def test_create_delivery_stream_failures():
"""Test errors invoking create_delivery_stream()."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -159,7 +158,7 @@ def test_create_delivery_stream_failures():
)
-@mock_firehose
+@mock_aws
def test_delete_delivery_stream():
"""Test successful and failed invocations of delete_delivery_stream()."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -195,7 +194,7 @@ def test_delete_delivery_stream():
assert hoses["DeliveryStreamNames"] == []
-@mock_firehose
+@mock_aws
def test_describe_delivery_stream():
"""Test successful, failed invocations of describe_delivery_stream()."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -353,7 +352,7 @@ def test_describe_delivery_stream():
)
-@mock_firehose
+@mock_aws
def test_list_delivery_streams():
"""Test successful and failed invocations of list_delivery_streams()."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -431,7 +430,7 @@ def test_list_delivery_streams():
assert hoses["HasMoreDeliveryStreams"] is False
-@mock_firehose
+@mock_aws
def test_update_destination():
"""Test successful, failed invocations of update_destination()."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -492,7 +491,7 @@ def test_update_destination():
) in err["Message"]
-@mock_firehose
+@mock_aws
def test_lookup_name_from_arn():
"""Test delivery stream instance can be retrieved given ARN.
diff --git a/tests/test_firehose/test_firehose_destination_types.py b/tests/test_firehose/test_firehose_destination_types.py
index b02f2cfce..265395d52 100644
--- a/tests/test_firehose/test_firehose_destination_types.py
+++ b/tests/test_firehose/test_firehose_destination_types.py
@@ -1,7 +1,6 @@
-"""Unit tests verifying various delivery stream destination content."""
import boto3
-from moto import mock_firehose, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.moto_api._internal import mock_random
@@ -103,7 +102,7 @@ def create_http_delivery_stream(client, stream_name):
)
-@mock_firehose
+@mock_aws
def test_create_redshift_delivery_stream():
"""Verify fields of a Redshift delivery stream."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -153,7 +152,7 @@ def test_create_redshift_delivery_stream():
}
-@mock_firehose
+@mock_aws
def test_create_extended_s3_delivery_stream():
"""Verify fields of a S3 delivery stream."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -210,7 +209,7 @@ def test_create_extended_s3_delivery_stream():
}
-@mock_firehose
+@mock_aws
def test_create_elasticsearch_delivery_stream():
"""Verify fields of an Elasticsearch delivery stream."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -260,7 +259,7 @@ def test_create_elasticsearch_delivery_stream():
}
-@mock_firehose
+@mock_aws
def test_create_s3_delivery_stream():
"""Verify fields of an S3 delivery stream."""
client = boto3.client("firehose", region_name=TEST_REGION)
diff --git a/tests/test_firehose/test_firehose_encryption.py b/tests/test_firehose/test_firehose_encryption.py
index b4ac540c2..15e22d4d0 100644
--- a/tests/test_firehose/test_firehose_encryption.py
+++ b/tests/test_firehose/test_firehose_encryption.py
@@ -4,12 +4,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_firehose
+from moto import mock_aws
from .test_firehose import sample_s3_dest_config
-@mock_firehose
+@mock_aws
def test_firehose_without_encryption():
client = boto3.client("firehose", region_name="us-east-2")
name = str(uuid4())[0:6]
@@ -37,7 +37,7 @@ def test_firehose_without_encryption():
}
-@mock_firehose
+@mock_aws
def test_firehose_with_encryption():
client = boto3.client("firehose", region_name="us-east-2")
name = str(uuid4())[0:6]
@@ -62,7 +62,7 @@ def test_firehose_with_encryption():
assert stream["DeliveryStreamEncryptionConfiguration"]["Status"] == "DISABLED"
-@mock_firehose
+@mock_aws
def test_start_encryption_on_unknown_stream():
client = boto3.client("firehose", region_name="us-east-2")
@@ -76,7 +76,7 @@ def test_start_encryption_on_unknown_stream():
assert err["Message"] == "Firehose ? under account 123456789012 not found."
-@mock_firehose
+@mock_aws
def test_stop_encryption_on_unknown_stream():
client = boto3.client("firehose", region_name="us-east-2")
diff --git a/tests/test_firehose/test_firehose_put.py b/tests/test_firehose/test_firehose_put.py
index 59211c962..58140f301 100644
--- a/tests/test_firehose/test_firehose_put.py
+++ b/tests/test_firehose/test_firehose_put.py
@@ -1,7 +1,7 @@
"""Unit tests verifying put-related delivery stream APIs."""
import boto3
-from moto import mock_firehose, mock_s3
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.moto_api._internal import mock_random
from tests.test_firehose.test_firehose import TEST_REGION, sample_s3_dest_config
@@ -12,7 +12,7 @@ from tests.test_firehose.test_firehose_destination_types import (
S3_LOCATION_CONSTRAINT = "us-west-1"
-@mock_firehose
+@mock_aws
def test_put_record_redshift_destination():
"""Test invocations of put_record() to a Redshift destination.
@@ -29,7 +29,7 @@ def test_put_record_redshift_destination():
assert set(result.keys()) == {"RecordId", "Encrypted", "ResponseMetadata"}
-@mock_firehose
+@mock_aws
def test_put_record_batch_redshift_destination():
"""Test invocations of put_record_batch() to a Redshift destination.
@@ -54,7 +54,7 @@ def test_put_record_batch_redshift_destination():
assert set(response.keys()) == {"RecordId"}
-@mock_firehose
+@mock_aws
def test_put_record_http_destination():
"""Test invocations of put_record() to a Http destination."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -74,7 +74,7 @@ def test_put_record_http_destination():
assert set(result.keys()) == {"RecordId", "Encrypted", "ResponseMetadata"}
-@mock_firehose
+@mock_aws
def test_put_record_batch_http_destination():
"""Test invocations of put_record_batch() to a Http destination."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -102,8 +102,7 @@ def test_put_record_batch_http_destination():
assert set(response.keys()) == {"RecordId"}
-@mock_s3
-@mock_firehose
+@mock_aws
def test_put_record_batch_extended_s3_destination():
"""Test invocations of put_record_batch() to a S3 destination."""
client = boto3.client("firehose", region_name=TEST_REGION)
diff --git a/tests/test_firehose/test_firehose_tags.py b/tests/test_firehose/test_firehose_tags.py
index 43f595745..daef6eea9 100644
--- a/tests/test_firehose/test_firehose_tags.py
+++ b/tests/test_firehose/test_firehose_tags.py
@@ -3,14 +3,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_firehose
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.firehose.models import MAX_TAGS_PER_DELIVERY_STREAM
from moto.moto_api._internal import mock_random
from tests.test_firehose.test_firehose import TEST_REGION, sample_s3_dest_config
-@mock_firehose
+@mock_aws
def test_list_tags_for_delivery_stream():
"""Test invocations of list_tags_for_delivery_stream()."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -72,7 +72,7 @@ def test_list_tags_for_delivery_stream():
assert result["HasMoreTags"] is False
-@mock_firehose
+@mock_aws
def test_tag_delivery_stream():
"""Test successful, failed invocations of tag_delivery_stream()."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -133,7 +133,7 @@ def test_tag_delivery_stream():
assert results["Tags"] == added_tags
-@mock_firehose
+@mock_aws
def test_untag_delivery_stream():
"""Test successful, failed invocations of untag_delivery_stream()."""
client = boto3.client("firehose", region_name=TEST_REGION)
diff --git a/tests/test_firehose/test_http_destinations.py b/tests/test_firehose/test_http_destinations.py
index 4756c972c..e934a40c3 100644
--- a/tests/test_firehose/test_http_destinations.py
+++ b/tests/test_firehose/test_http_destinations.py
@@ -1,6 +1,6 @@
import boto3
-from moto import mock_firehose
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.moto_api._internal import mock_random
@@ -9,7 +9,7 @@ from .test_firehose_destination_types import create_http_delivery_stream
TEST_REGION = "us-west-1"
-@mock_firehose
+@mock_aws
def test_create_http_stream():
"""Verify fields of a HTTP delivery stream."""
client = boto3.client("firehose", region_name=TEST_REGION)
@@ -56,7 +56,7 @@ def test_create_http_stream():
}
-@mock_firehose
+@mock_aws
def test_update_s3_for_http_stream():
"""Verify fields of a HTTP delivery stream."""
client = boto3.client("firehose", region_name=TEST_REGION)
diff --git a/tests/test_forecast/test_forecast.py b/tests/test_forecast/test_forecast.py
index f2ae615c6..021ec5e69 100644
--- a/tests/test_forecast/test_forecast.py
+++ b/tests/test_forecast/test_forecast.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_forecast
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
region = "us-east-1"
@@ -19,7 +19,7 @@ valid_domains = [
@pytest.mark.parametrize("domain", valid_domains)
-@mock_forecast
+@mock_aws
def test_forecast_dataset_group_create(domain):
name = "example_dataset_group"
client = boto3.client("forecast", region_name=region)
@@ -30,7 +30,7 @@ def test_forecast_dataset_group_create(domain):
)
-@mock_forecast
+@mock_aws
def test_forecast_dataset_group_create_invalid_domain():
name = "example_dataset_group"
client = boto3.client("forecast", region_name=region)
@@ -48,7 +48,7 @@ def test_forecast_dataset_group_create_invalid_domain():
@pytest.mark.parametrize("name", [" ", "a" * 64])
-@mock_forecast
+@mock_aws
def test_forecast_dataset_group_create_invalid_name(name):
client = boto3.client("forecast", region_name=region)
@@ -61,7 +61,7 @@ def test_forecast_dataset_group_create_invalid_name(name):
) in exc.value.response["Error"]["Message"]
-@mock_forecast
+@mock_aws
def test_forecast_dataset_group_create_duplicate_fails():
client = boto3.client("forecast", region_name=region)
client.create_dataset_group(DatasetGroupName="name", Domain="RETAIL")
@@ -72,7 +72,7 @@ def test_forecast_dataset_group_create_duplicate_fails():
assert exc.value.response["Error"]["Code"] == "ResourceAlreadyExistsException"
-@mock_forecast
+@mock_aws
def test_forecast_dataset_group_list_default_empty():
client = boto3.client("forecast", region_name=region)
@@ -80,7 +80,7 @@ def test_forecast_dataset_group_list_default_empty():
assert resp["DatasetGroups"] == []
-@mock_forecast
+@mock_aws
def test_forecast_dataset_group_list_some():
client = boto3.client("forecast", region_name=region)
@@ -93,7 +93,7 @@ def test_forecast_dataset_group_list_some():
)
-@mock_forecast
+@mock_aws
def test_forecast_delete_dataset_group():
dataset_group_name = "name"
dataset_group_arn = (
@@ -104,7 +104,7 @@ def test_forecast_delete_dataset_group():
client.delete_dataset_group(DatasetGroupArn=dataset_group_arn)
-@mock_forecast
+@mock_aws
def test_forecast_delete_dataset_group_missing():
client = boto3.client("forecast", region_name=region)
missing_dsg_arn = f"arn:aws:forecast:{region}:{ACCOUNT_ID}:dataset-group/missing"
@@ -117,7 +117,7 @@ def test_forecast_delete_dataset_group_missing():
)
-@mock_forecast
+@mock_aws
def test_forecast_update_dataset_arns_empty():
dataset_group_name = "name"
dataset_group_arn = (
@@ -128,7 +128,7 @@ def test_forecast_update_dataset_arns_empty():
client.update_dataset_group(DatasetGroupArn=dataset_group_arn, DatasetArns=[])
-@mock_forecast
+@mock_aws
def test_forecast_update_dataset_group_not_found():
client = boto3.client("forecast", region_name=region)
dataset_group_arn = f"arn:aws:forecast:{region}:{ACCOUNT_ID}:dataset-group/test"
@@ -141,7 +141,7 @@ def test_forecast_update_dataset_group_not_found():
)
-@mock_forecast
+@mock_aws
def test_describe_dataset_group():
name = "test"
client = boto3.client("forecast", region_name=region)
@@ -153,7 +153,7 @@ def test_describe_dataset_group():
assert result.get("DatasetArns") == []
-@mock_forecast
+@mock_aws
def test_describe_dataset_group_missing():
client = boto3.client("forecast", region_name=region)
dataset_group_arn = f"arn:aws:forecast:{region}:{ACCOUNT_ID}:dataset-group/name"
@@ -166,7 +166,7 @@ def test_describe_dataset_group_missing():
)
-@mock_forecast
+@mock_aws
def test_create_dataset_group_missing_datasets():
client = boto3.client("forecast", region_name=region)
dataset_arn = f"arn:aws:forecast:{region}:{ACCOUNT_ID}:dataset-group/name"
@@ -180,7 +180,7 @@ def test_create_dataset_group_missing_datasets():
)
-@mock_forecast
+@mock_aws
def test_update_dataset_group_missing_datasets():
name = "test"
client = boto3.client("forecast", region_name=region)
diff --git a/tests/test_glacier/test_glacier_archives.py b/tests/test_glacier/test_glacier_archives.py
index 47bb973b8..ebba3ffcb 100644
--- a/tests/test_glacier/test_glacier_archives.py
+++ b/tests/test_glacier/test_glacier_archives.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_glacier
+from moto import mock_aws
-@mock_glacier
+@mock_aws
def test_upload_archive():
client = boto3.client("glacier", region_name="us-west-2")
client.create_vault(vaultName="asdf")
@@ -25,7 +25,7 @@ def test_upload_archive():
assert "archiveId" in res
-@mock_glacier
+@mock_aws
def test_upload_zip_archive():
client = boto3.client("glacier", region_name="us-west-2")
client.create_vault(vaultName="asdf")
@@ -40,7 +40,7 @@ def test_upload_zip_archive():
assert "checksum" in res
-@mock_glacier
+@mock_aws
def test_delete_archive():
client = boto3.client("glacier", region_name="us-west-2")
client.create_vault(vaultName="asdf")
diff --git a/tests/test_glacier/test_glacier_jobs.py b/tests/test_glacier/test_glacier_jobs.py
index a80d1d94f..740451040 100644
--- a/tests/test_glacier/test_glacier_jobs.py
+++ b/tests/test_glacier/test_glacier_jobs.py
@@ -2,11 +2,11 @@ import time
import boto3
-from moto import mock_glacier
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_glacier
+@mock_aws
def test_initiate_job():
client = boto3.client("glacier", region_name="us-west-2")
client.create_vault(vaultName="myname")
@@ -30,7 +30,7 @@ def test_initiate_job():
assert "location" in job
-@mock_glacier
+@mock_aws
def test_describe_job_boto3():
client = boto3.client("glacier", region_name="us-west-2")
client.create_vault(vaultName="myname")
@@ -58,7 +58,7 @@ def test_describe_job_boto3():
assert describe["Tier"] == "Standard"
-@mock_glacier
+@mock_aws
def test_list_jobs():
client = boto3.client("glacier", region_name="us-west-2")
client.create_vault(vaultName="myname")
@@ -101,7 +101,7 @@ def test_list_jobs():
assert "Tier" in job
-@mock_glacier
+@mock_aws
def test_get_job_output_boto3():
client = boto3.client("glacier", region_name="us-west-2")
client.create_vault(vaultName="myname")
diff --git a/tests/test_glacier/test_glacier_vaults.py b/tests/test_glacier/test_glacier_vaults.py
index 1886c05d9..a3a475ff6 100644
--- a/tests/test_glacier/test_glacier_vaults.py
+++ b/tests/test_glacier/test_glacier_vaults.py
@@ -4,11 +4,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_glacier
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_glacier
+@mock_aws
def test_describe_vault():
client = boto3.client("glacier", region_name="us-west-2")
@@ -25,7 +25,7 @@ def test_describe_vault():
)
-@mock_glacier
+@mock_aws
def test_delete_vault_boto3():
client = boto3.client("glacier", region_name="us-west-2")
@@ -39,7 +39,7 @@ def test_delete_vault_boto3():
assert err["Code"] == "VaultNotFound"
-@mock_glacier
+@mock_aws
def test_list_vaults():
client = boto3.client("glacier", region_name="us-west-2")
@@ -83,7 +83,7 @@ def test_list_vaults():
assert vault2_name in found_vaults
-@mock_glacier
+@mock_aws
def test_vault_name_with_special_characters():
vault_name = "Vault.name-with_Special.characters"
glacier = boto3.resource("glacier", region_name="us-west-2")
diff --git a/tests/test_glacier/test_server.py b/tests/test_glacier/test_server.py
index 6e71973ec..4302b4a7f 100644
--- a/tests/test_glacier/test_server.py
+++ b/tests/test_glacier/test_server.py
@@ -1,14 +1,14 @@
import json
import moto.server as server
-from moto import mock_glacier
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_glacier
+@mock_aws
def test_list_vaults():
backend = server.create_backend_app("glacier")
test_client = backend.test_client()
diff --git a/tests/test_glue/test_datacatalog.py b/tests/test_glue/test_datacatalog.py
index c90cfa1bb..739e44513 100644
--- a/tests/test_glue/test_datacatalog.py
+++ b/tests/test_glue/test_datacatalog.py
@@ -6,7 +6,7 @@ import pytest
from botocore.client import ClientError
from freezegun import freeze_time
-from moto import mock_glue, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from . import helpers
@@ -14,7 +14,7 @@ from . import helpers
FROZEN_CREATE_TIME = datetime(2015, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
-@mock_glue
+@mock_aws
@freeze_time(FROZEN_CREATE_TIME)
def test_create_database():
client = boto3.client("glue", region_name="us-east-1")
@@ -40,7 +40,7 @@ def test_create_database():
assert database.get("CatalogId") == database_catalog_id
-@mock_glue
+@mock_aws
def test_create_database_already_exists():
client = boto3.client("glue", region_name="us-east-1")
database_name = "cantcreatethisdatabasetwice"
@@ -52,7 +52,7 @@ def test_create_database_already_exists():
assert exc.value.response["Error"]["Code"] == "AlreadyExistsException"
-@mock_glue
+@mock_aws
def test_get_database_not_exits():
client = boto3.client("glue", region_name="us-east-1")
database_name = "nosuchdatabase"
@@ -66,7 +66,7 @@ def test_get_database_not_exits():
)
-@mock_glue
+@mock_aws
def test_get_databases():
client = boto3.client("glue", region_name="us-east-1")
response = client.get_databases()
@@ -88,7 +88,7 @@ def test_get_databases():
assert database_list[1]["CatalogId"] == ACCOUNT_ID
-@mock_glue
+@mock_aws
def test_update_database():
client = boto3.client("glue", region_name="us-east-1")
database_name = "existingdatabase"
@@ -119,7 +119,7 @@ def test_update_database():
assert database.get("LocationUri") == "s3://bucket/existingdatabase/"
-@mock_glue
+@mock_aws
def test_update_unknown_database():
client = boto3.client("glue", region_name="us-east-1")
@@ -130,7 +130,7 @@ def test_update_unknown_database():
assert err["Message"] == "Database x not found."
-@mock_glue
+@mock_aws
def test_delete_database():
client = boto3.client("glue", region_name="us-east-1")
database_name_1, database_name_2 = "firstdatabase", "seconddatabase"
@@ -146,7 +146,7 @@ def test_delete_database():
assert [db["Name"] for db in database_list] == [database_name_2]
-@mock_glue
+@mock_aws
def test_delete_unknown_database():
client = boto3.client("glue", region_name="us-east-1")
@@ -157,7 +157,7 @@ def test_delete_unknown_database():
assert err["Message"] == "Database x not found."
-@mock_glue
+@mock_aws
@freeze_time(FROZEN_CREATE_TIME)
def test_create_table():
client = boto3.client("glue", region_name="us-east-1")
@@ -179,7 +179,7 @@ def test_create_table():
assert table["PartitionKeys"] == table_input["PartitionKeys"]
-@mock_glue
+@mock_aws
def test_create_table_already_exists():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -194,7 +194,7 @@ def test_create_table_already_exists():
assert exc.value.response["Error"]["Code"] == "AlreadyExistsException"
-@mock_glue
+@mock_aws
def test_get_tables():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -224,7 +224,7 @@ def test_get_tables():
assert table["CatalogId"] == ACCOUNT_ID
-@mock_glue
+@mock_aws
def test_get_tables_expression():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -302,7 +302,7 @@ def test_get_tables_expression():
assert len(tables_star_expression6) == 2
-@mock_glue
+@mock_aws
def test_get_table_versions():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -366,7 +366,7 @@ def test_get_table_versions():
assert table["VersionId"] == "3"
-@mock_glue
+@mock_aws
def test_get_table_version_not_found():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -381,7 +381,7 @@ def test_get_table_version_not_found():
assert exc.value.response["Error"]["Message"] == "Version not found."
-@mock_glue
+@mock_aws
def test_get_table_version_invalid_input():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -395,7 +395,7 @@ def test_get_table_version_invalid_input():
assert exc.value.response["Error"]["Code"] == "InvalidInputException"
-@mock_glue
+@mock_aws
def test_delete_table_version():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -431,7 +431,7 @@ def test_delete_table_version():
assert [v["VersionId"] for v in vers] == ["1", "3"]
-@mock_glue
+@mock_aws
def test_get_table_not_exits():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -444,7 +444,7 @@ def test_get_table_not_exits():
assert exc.value.response["Error"]["Message"] == "Table myfirsttable not found."
-@mock_glue
+@mock_aws
def test_get_table_when_database_not_exits():
client = boto3.client("glue", region_name="us-east-1")
database_name = "nosuchdatabase"
@@ -458,7 +458,7 @@ def test_get_table_when_database_not_exits():
)
-@mock_glue
+@mock_aws
def test_delete_table():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -479,7 +479,7 @@ def test_delete_table():
assert exc.value.response["Error"]["Message"] == "Table myspecialtable not found."
-@mock_glue
+@mock_aws
def test_batch_delete_table():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -502,7 +502,7 @@ def test_batch_delete_table():
assert exc.value.response["Error"]["Message"] == "Table myspecialtable not found."
-@mock_glue
+@mock_aws
def test_get_partitions_empty():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -516,7 +516,7 @@ def test_get_partitions_empty():
assert len(response["Partitions"]) == 0
-@mock_glue
+@mock_aws
def test_create_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -550,7 +550,7 @@ def test_create_partition():
assert partition["CreationTime"] < after
-@mock_glue
+@mock_aws
def test_create_partition_already_exist():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -568,7 +568,7 @@ def test_create_partition_already_exist():
assert exc.value.response["Error"]["Code"] == "AlreadyExistsException"
-@mock_glue
+@mock_aws
def test_get_partition_not_found():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -585,7 +585,7 @@ def test_get_partition_not_found():
assert "partition" in exc.value.response["Error"]["Message"]
-@mock_glue
+@mock_aws
def test_batch_create_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -628,7 +628,7 @@ def test_batch_create_partition():
assert partition["CreationTime"] < after
-@mock_glue
+@mock_aws
def test_batch_create_partition_already_exist():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -655,7 +655,7 @@ def test_batch_create_partition_already_exist():
assert response["Errors"][0]["ErrorDetail"]["ErrorCode"] == "AlreadyExistsException"
-@mock_glue
+@mock_aws
def test_get_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -679,7 +679,7 @@ def test_get_partition():
assert partition["Values"] == values[1]
-@mock_glue
+@mock_aws
def test_batch_get_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -708,7 +708,7 @@ def test_batch_get_partition():
assert partition["Values"] == values[1]
-@mock_glue
+@mock_aws
def test_batch_get_partition_missing_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -740,7 +740,7 @@ def test_batch_get_partition_missing_partition():
assert partitions[1]["Values"] == values[2]
-@mock_glue
+@mock_aws
def test_update_partition_not_found_moving():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -762,7 +762,7 @@ def test_update_partition_not_found_moving():
assert "partition" in exc.value.response["Error"]["Message"]
-@mock_glue
+@mock_aws
def test_update_partition_not_found_change_in_place():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -781,7 +781,7 @@ def test_update_partition_not_found_change_in_place():
assert "partition" in exc.value.response["Error"]["Message"]
-@mock_glue
+@mock_aws
def test_update_partition_cannot_overwrite():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -803,7 +803,7 @@ def test_update_partition_cannot_overwrite():
assert exc.value.response["Error"]["Code"] == "AlreadyExistsException"
-@mock_glue
+@mock_aws
def test_update_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -834,7 +834,7 @@ def test_update_partition():
]
-@mock_glue
+@mock_aws
def test_update_partition_move():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -872,7 +872,7 @@ def test_update_partition_move():
]
-@mock_glue
+@mock_aws
def test_batch_update_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -929,7 +929,7 @@ def test_batch_update_partition():
]
-@mock_glue
+@mock_aws
def test_batch_update_partition_missing_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -984,7 +984,7 @@ def test_batch_update_partition_missing_partition():
assert response["Errors"][0]["PartitionValueList"] == ["2020-10-10"]
-@mock_glue
+@mock_aws
def test_delete_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -1007,7 +1007,7 @@ def test_delete_partition():
assert partitions == []
-@mock_glue
+@mock_aws
def test_delete_partition_bad_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -1024,7 +1024,7 @@ def test_delete_partition_bad_partition():
assert exc.value.response["Error"]["Code"] == "EntityNotFoundException"
-@mock_glue
+@mock_aws
def test_batch_delete_partition():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -1057,7 +1057,7 @@ def test_batch_delete_partition():
assert "Errors" not in response
-@mock_glue
+@mock_aws
def test_batch_delete_partition_with_bad_partitions():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -1098,7 +1098,7 @@ def test_batch_delete_partition_with_bad_partitions():
assert ["2018-11-03"] in error_partitions
-@mock_glue
+@mock_aws
@freeze_time(FROZEN_CREATE_TIME)
def test_create_crawler_scheduled():
client = boto3.client("glue", region_name="us-east-1")
@@ -1178,7 +1178,7 @@ def test_create_crawler_scheduled():
assert "LastCrawl" not in crawler
-@mock_glue
+@mock_aws
@freeze_time(FROZEN_CREATE_TIME)
def test_create_crawler_unscheduled():
client = boto3.client("glue", region_name="us-east-1")
@@ -1256,7 +1256,7 @@ def test_create_crawler_unscheduled():
assert "LastCrawl" not in crawler
-@mock_glue
+@mock_aws
def test_create_crawler_already_exists():
client = boto3.client("glue", region_name="us-east-1")
name = "my_crawler_name"
@@ -1268,7 +1268,7 @@ def test_create_crawler_already_exists():
assert exc.value.response["Error"]["Code"] == "AlreadyExistsException"
-@mock_glue
+@mock_aws
def test_get_crawler_not_exits():
client = boto3.client("glue", region_name="us-east-1")
name = "my_crawler_name"
@@ -1282,14 +1282,14 @@ def test_get_crawler_not_exits():
)
-@mock_glue
+@mock_aws
def test_get_crawlers_empty():
client = boto3.client("glue", region_name="us-east-1")
response = client.get_crawlers()
assert len(response["Crawlers"]) == 0
-@mock_glue
+@mock_aws
def test_get_crawlers_several_items():
client = boto3.client("glue", region_name="us-east-1")
name_1, name_2 = "my_crawler_name_1", "my_crawler_name_2"
@@ -1303,7 +1303,7 @@ def test_get_crawlers_several_items():
assert crawlers[1].get("Name") == name_2
-@mock_glue
+@mock_aws
def test_start_crawler():
client = boto3.client("glue", region_name="us-east-1")
name = "my_crawler_name"
@@ -1317,7 +1317,7 @@ def test_start_crawler():
assert crawler.get("State") == "RUNNING"
-@mock_glue
+@mock_aws
def test_start_crawler_should_raise_exception_if_already_running():
client = boto3.client("glue", region_name="us-east-1")
name = "my_crawler_name"
@@ -1330,7 +1330,7 @@ def test_start_crawler_should_raise_exception_if_already_running():
assert exc.value.response["Error"]["Code"] == "CrawlerRunningException"
-@mock_glue
+@mock_aws
def test_stop_crawler():
client = boto3.client("glue", region_name="us-east-1")
name = "my_crawler_name"
@@ -1345,7 +1345,7 @@ def test_stop_crawler():
assert crawler.get("State") == "STOPPING"
-@mock_glue
+@mock_aws
def test_stop_crawler_should_raise_exception_if_not_running():
client = boto3.client("glue", region_name="us-east-1")
name = "my_crawler_name"
@@ -1357,7 +1357,7 @@ def test_stop_crawler_should_raise_exception_if_not_running():
assert exc.value.response["Error"]["Code"] == "CrawlerNotRunningException"
-@mock_glue
+@mock_aws
def test_delete_crawler():
client = boto3.client("glue", region_name="us-east-1")
name = "my_crawler_name"
@@ -1376,7 +1376,7 @@ def test_delete_crawler():
)
-@mock_glue
+@mock_aws
def test_delete_crawler_not_exists():
client = boto3.client("glue", region_name="us-east-1")
name = "my_crawler_name"
diff --git a/tests/test_glue/test_glue.py b/tests/test_glue/test_glue.py
index 97868709c..2a767a07a 100644
--- a/tests/test_glue/test_glue.py
+++ b/tests/test_glue/test_glue.py
@@ -7,10 +7,10 @@ import pytest
from botocore.client import ClientError
from botocore.exceptions import ParamValidationError
-from moto import mock_glue
+from moto import mock_aws
-@mock_glue
+@mock_aws
def test_create_job():
client = create_glue_client()
job_name = str(uuid4())
@@ -20,7 +20,7 @@ def test_create_job():
assert response["Name"] == job_name
-@mock_glue
+@mock_aws
def test_delete_job():
client = create_glue_client()
job_name = create_test_job(client)
@@ -35,7 +35,7 @@ def test_delete_job():
assert exc.value.response["Error"]["Code"] == "EntityNotFoundException"
-@mock_glue
+@mock_aws
def test_create_job_default_argument_not_provided():
client = create_glue_client()
with pytest.raises(ParamValidationError) as exc:
@@ -44,7 +44,7 @@ def test_create_job_default_argument_not_provided():
assert exc.value.kwargs["report"] == 'Missing required parameter in input: "Name"'
-@mock_glue
+@mock_aws
def test_list_jobs():
client = create_glue_client()
expected_jobs = randint(1, 15)
@@ -54,7 +54,7 @@ def test_list_jobs():
assert "NextToken" not in response
-@mock_glue
+@mock_aws
def test_get_job_not_exists():
client = create_glue_client()
name = "my_job_name"
@@ -66,7 +66,7 @@ def test_get_job_not_exists():
assert exc.value.response["Error"]["Message"] == "Job my_job_name not found."
-@mock_glue
+@mock_aws
def test_get_job_exists():
client = create_glue_client()
job_attributes = {
@@ -127,7 +127,7 @@ def test_get_job_exists():
assert "SourceControlDetails" in job
-@mock_glue
+@mock_aws
def test_get_jobs_job_name_exists():
client = create_glue_client()
test_job_name = create_test_job(client)
@@ -136,7 +136,7 @@ def test_get_jobs_job_name_exists():
assert response["Jobs"][0]["Name"] == test_job_name
-@mock_glue
+@mock_aws
def test_get_jobs_with_max_results():
client = create_glue_client()
create_test_jobs(client, 4)
@@ -145,7 +145,7 @@ def test_get_jobs_with_max_results():
assert "NextToken" in response
-@mock_glue
+@mock_aws
def test_get_jobs_from_next_token():
client = create_glue_client()
create_test_jobs(client, 10)
@@ -154,7 +154,7 @@ def test_get_jobs_from_next_token():
assert len(response["Jobs"]) == 7
-@mock_glue
+@mock_aws
def test_get_jobs_with_max_results_greater_than_actual_results():
client = create_glue_client()
create_test_jobs(client, 4)
@@ -162,7 +162,7 @@ def test_get_jobs_with_max_results_greater_than_actual_results():
assert len(response["Jobs"]) == 4
-@mock_glue
+@mock_aws
def test_get_jobs_next_token_logic_does_not_create_infinite_loop():
client = create_glue_client()
create_test_jobs(client, 4)
@@ -174,7 +174,7 @@ def test_get_jobs_next_token_logic_does_not_create_infinite_loop():
assert not next_token
-@mock_glue
+@mock_aws
def test_list_jobs_with_max_results():
client = create_glue_client()
create_test_jobs(client, 4)
@@ -183,7 +183,7 @@ def test_list_jobs_with_max_results():
assert "NextToken" in response
-@mock_glue
+@mock_aws
def test_list_jobs_from_next_token():
client = create_glue_client()
create_test_jobs(client, 10)
@@ -192,7 +192,7 @@ def test_list_jobs_from_next_token():
assert len(response["JobNames"]) == 7
-@mock_glue
+@mock_aws
def test_list_jobs_with_max_results_greater_than_actual_results():
client = create_glue_client()
create_test_jobs(client, 4)
@@ -200,7 +200,7 @@ def test_list_jobs_with_max_results_greater_than_actual_results():
assert len(response["JobNames"]) == 4
-@mock_glue
+@mock_aws
def test_list_jobs_with_tags():
client = create_glue_client()
create_test_job(client)
@@ -209,7 +209,7 @@ def test_list_jobs_with_tags():
assert len(response["JobNames"]) == 1
-@mock_glue
+@mock_aws
def test_list_jobs_after_tagging():
client = create_glue_client()
job_name = create_test_job(client)
@@ -221,7 +221,7 @@ def test_list_jobs_after_tagging():
assert len(response["JobNames"]) == 1
-@mock_glue
+@mock_aws
def test_list_jobs_after_removing_tag():
client = create_glue_client()
job_name = create_test_job(client, {"key1": "value1"})
@@ -233,7 +233,7 @@ def test_list_jobs_after_removing_tag():
assert len(response["JobNames"]) == 0
-@mock_glue
+@mock_aws
def test_list_jobs_next_token_logic_does_not_create_infinite_loop():
client = create_glue_client()
create_test_jobs(client, 4)
@@ -245,7 +245,7 @@ def test_list_jobs_next_token_logic_does_not_create_infinite_loop():
assert not next_token
-@mock_glue
+@mock_aws
def test_batch_get_jobs():
client = create_glue_client()
job_name = create_test_job(client)
@@ -298,7 +298,7 @@ def create_test_crawlers(client, number_of_crawlers):
create_test_crawler(client)
-@mock_glue
+@mock_aws
def test_list_crawlers_with_max_results():
client = create_glue_client()
create_test_crawlers(client, 4)
@@ -307,7 +307,7 @@ def test_list_crawlers_with_max_results():
assert "NextToken" in response
-@mock_glue
+@mock_aws
def test_list_crawlers_from_next_token():
client = create_glue_client()
create_test_crawlers(client, 10)
@@ -316,7 +316,7 @@ def test_list_crawlers_from_next_token():
assert len(response["CrawlerNames"]) == 7
-@mock_glue
+@mock_aws
def test_list_crawlers_with_max_results_greater_than_actual_results():
client = create_glue_client()
create_test_crawlers(client, 4)
@@ -324,7 +324,7 @@ def test_list_crawlers_with_max_results_greater_than_actual_results():
assert len(response["CrawlerNames"]) == 4
-@mock_glue
+@mock_aws
def test_list_crawlers_with_tags():
client = create_glue_client()
create_test_crawler(client)
@@ -333,7 +333,7 @@ def test_list_crawlers_with_tags():
assert len(response["CrawlerNames"]) == 1
-@mock_glue
+@mock_aws
def test_list_crawlers_after_tagging():
client = create_glue_client()
crawler_name = create_test_crawler(client)
@@ -345,7 +345,7 @@ def test_list_crawlers_after_tagging():
assert len(response["CrawlerNames"]) == 1
-@mock_glue
+@mock_aws
def test_list_crawlers_after_removing_tag():
client = create_glue_client()
crawler_name = create_test_crawler(client, {"key1": "value1"})
@@ -357,7 +357,7 @@ def test_list_crawlers_after_removing_tag():
assert len(response["CrawlerNames"]) == 0
-@mock_glue
+@mock_aws
def test_list_crawlers_next_token_logic_does_not_create_infinite_loop():
client = create_glue_client()
create_test_crawlers(client, 4)
@@ -369,7 +369,7 @@ def test_list_crawlers_next_token_logic_does_not_create_infinite_loop():
assert not next_token
-@mock_glue
+@mock_aws
def test_get_tags_job():
client = create_glue_client()
job_name = create_test_job(client, {"key1": "value1", "key2": "value2"})
@@ -380,7 +380,7 @@ def test_get_tags_job():
assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
-@mock_glue
+@mock_aws
def test_get_tags_jobs_no_tags():
client = create_glue_client()
job_name = create_test_job(client)
@@ -391,7 +391,7 @@ def test_get_tags_jobs_no_tags():
assert resp["Tags"] == {}
-@mock_glue
+@mock_aws
def test_tag_glue_job():
client = create_glue_client()
job_name = create_test_job(client)
@@ -406,7 +406,7 @@ def test_tag_glue_job():
assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
-@mock_glue
+@mock_aws
def test_untag_glue_job():
client = create_glue_client()
job_name = create_test_job(client)
@@ -424,7 +424,7 @@ def test_untag_glue_job():
assert resp["Tags"] == {"key1": "value1", "key3": "value3"}
-@mock_glue
+@mock_aws
def test_get_tags_crawler():
client = create_glue_client()
crawler_name = create_test_crawler(client, {"key1": "value1", "key2": "value2"})
@@ -435,7 +435,7 @@ def test_get_tags_crawler():
assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
-@mock_glue
+@mock_aws
def test_get_tags_crawler_no_tags():
client = create_glue_client()
crawler_name = create_test_crawler(client)
@@ -446,7 +446,7 @@ def test_get_tags_crawler_no_tags():
assert resp["Tags"] == {}
-@mock_glue
+@mock_aws
def test_tag_glue_crawler():
client = create_glue_client()
crawler_name = create_test_crawler(client)
@@ -461,7 +461,7 @@ def test_tag_glue_crawler():
assert resp["Tags"] == {"key1": "value1", "key2": "value2"}
-@mock_glue
+@mock_aws
def test_untag_glue_crawler():
client = create_glue_client()
crawler_name = create_test_crawler(client)
@@ -479,7 +479,7 @@ def test_untag_glue_crawler():
assert resp["Tags"] == {"key1": "value1", "key3": "value3"}
-@mock_glue
+@mock_aws
def test_batch_get_crawlers():
client = create_glue_client()
crawler_name = create_test_crawler(client)
@@ -492,7 +492,7 @@ def test_batch_get_crawlers():
assert len(response["CrawlersNotFound"]) == 1
-@mock_glue
+@mock_aws
def test_create_trigger():
client = create_glue_client()
job_name = create_test_job(client)
@@ -510,7 +510,7 @@ def test_create_trigger():
assert response["Name"] == trigger_name
-@mock_glue
+@mock_aws
def test_get_trigger_on_demand():
client = create_glue_client()
job_name = create_test_job(client)
@@ -533,7 +533,7 @@ def test_get_trigger_on_demand():
assert trigger["Actions"] == [{"JobName": job_name}]
-@mock_glue
+@mock_aws
def test_get_trigger_scheduled():
client = create_glue_client()
job_name = create_test_job(client)
@@ -558,7 +558,7 @@ def test_get_trigger_scheduled():
assert trigger["Actions"] == [{"JobName": job_name}]
-@mock_glue
+@mock_aws
def test_get_trigger_conditional():
client = create_glue_client()
crawler_name = create_test_crawler(client)
@@ -610,7 +610,7 @@ def create_test_trigger(client, tags=None):
return trigger_name
-@mock_glue
+@mock_aws
def test_get_triggers_trigger_name_exists():
client = create_glue_client()
trigger_name = create_test_trigger(client)
@@ -619,7 +619,7 @@ def test_get_triggers_trigger_name_exists():
assert response["Triggers"][0]["Name"] == trigger_name
-@mock_glue
+@mock_aws
def test_get_triggers_dependent_job_name():
client = create_glue_client()
@@ -641,7 +641,7 @@ def test_get_triggers_dependent_job_name():
assert response["Triggers"][0]["Name"] == trigger_name
-@mock_glue
+@mock_aws
def test_start_trigger():
client = create_glue_client()
job_name = create_test_job(client)
@@ -668,7 +668,7 @@ def test_start_trigger():
assert trigger["State"] == "ACTIVATED"
-@mock_glue
+@mock_aws
def test_stop_trigger():
client = create_glue_client()
job_name = create_test_job(client)
@@ -696,7 +696,7 @@ def test_stop_trigger():
assert trigger["State"] == "DEACTIVATED"
-@mock_glue
+@mock_aws
def test_list_triggers():
client = create_glue_client()
trigger_name = create_test_trigger(client)
@@ -705,7 +705,7 @@ def test_list_triggers():
assert "NextToken" not in response
-@mock_glue
+@mock_aws
def test_list_triggers_dependent_job_name():
client = create_glue_client()
@@ -731,7 +731,7 @@ def test_list_triggers_dependent_job_name():
assert response["TriggerNames"] == [trigger_name]
-@mock_glue
+@mock_aws
def test_list_triggers_tags():
client = create_glue_client()
@@ -760,7 +760,7 @@ def test_list_triggers_tags():
assert response["TriggerNames"] == [trigger_name]
-@mock_glue
+@mock_aws
def test_batch_get_triggers():
client = create_glue_client()
trigger_name = create_test_trigger(client)
@@ -773,7 +773,7 @@ def test_batch_get_triggers():
assert len(response["TriggersNotFound"]) == 1
-@mock_glue
+@mock_aws
def test_delete_trigger():
client = create_glue_client()
trigger_name = create_test_trigger(client)
@@ -814,7 +814,7 @@ def create_test_session(client):
return session_id
-@mock_glue
+@mock_aws
def test_create_session():
client = create_glue_client()
session_id = create_test_session(client)
@@ -823,7 +823,7 @@ def test_create_session():
assert resp["Session"]["Id"] == session_id
-@mock_glue
+@mock_aws
def test_get_session():
client = create_glue_client()
session_id = create_test_session(client)
@@ -832,7 +832,7 @@ def test_get_session():
assert resp["Session"]["Id"] == session_id
-@mock_glue
+@mock_aws
def test_list_sessions():
client = create_glue_client()
session_id = create_test_session(client)
@@ -841,7 +841,7 @@ def test_list_sessions():
assert session_id in resp["Ids"]
-@mock_glue
+@mock_aws
def test_delete_session():
client = create_glue_client()
session_id = create_test_session(client)
@@ -853,7 +853,7 @@ def test_delete_session():
assert session_id not in resp["Ids"]
-@mock_glue
+@mock_aws
def test_stop_session():
client = create_glue_client()
session_id = create_test_session(client)
diff --git a/tests/test_glue/test_glue_job_runs.py b/tests/test_glue/test_glue_job_runs.py
index 2e8afad09..7fffe162c 100644
--- a/tests/test_glue/test_glue_job_runs.py
+++ b/tests/test_glue/test_glue_job_runs.py
@@ -3,13 +3,13 @@ from unittest import SkipTest
import pytest
from botocore.client import ClientError
-from moto import mock_glue, settings
+from moto import mock_aws, settings
from moto.moto_api import state_manager
from .test_glue import create_glue_client, create_test_job
-@mock_glue
+@mock_aws
def test_start_job_run():
client = create_glue_client()
job_name = create_test_job(client)
@@ -17,7 +17,7 @@ def test_start_job_run():
assert response["JobRunId"]
-@mock_glue
+@mock_aws
def test_start_job_run__multiple_runs_allowed():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set transition directly in ServerMode")
@@ -50,7 +50,7 @@ def test_start_job_run__multiple_runs_allowed():
)
-@mock_glue
+@mock_aws
def test_start_job_run__single_run_allowed():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set transition directly in ServerMode")
@@ -71,7 +71,7 @@ def test_start_job_run__single_run_allowed():
)
-@mock_glue
+@mock_aws
def test_get_job_run():
state_manager.unset_transition("glue::job_run")
client = create_glue_client()
@@ -102,7 +102,7 @@ def test_get_job_run():
assert response["JobRun"]["GlueVersion"]
-@mock_glue
+@mock_aws
def test_get_job_run_that_doesnt_exist():
client = create_glue_client()
job_name = create_test_job(client)
@@ -112,7 +112,7 @@ def test_get_job_run_that_doesnt_exist():
assert err["Code"] == "EntityNotFoundException"
-@mock_glue
+@mock_aws
def test_job_run_transition():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set transition directly in ServerMode")
diff --git a/tests/test_glue/test_partition_filter.py b/tests/test_glue/test_partition_filter.py
index 18a219029..0d55a8705 100644
--- a/tests/test_glue/test_partition_filter.py
+++ b/tests/test_glue/test_partition_filter.py
@@ -4,12 +4,12 @@ import boto3
import pytest
from botocore.client import ClientError
-from moto import mock_glue, settings
+from moto import mock_aws, settings
from . import helpers
-@mock_glue
+@mock_aws
def test_get_partitions_expression_unknown_column():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -35,7 +35,7 @@ def test_get_partitions_expression_unknown_column():
assert "Unknown column 'unknown_col'" in exc.value.response["Error"]["Message"]
-@mock_glue
+@mock_aws
def test_get_partitions_expression_int_column():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -96,7 +96,7 @@ def test_get_partitions_expression_int_column():
)
-@mock_glue
+@mock_aws
def test_get_partitions_expression_decimal_column():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -152,7 +152,7 @@ def test_get_partitions_expression_decimal_column():
)
-@mock_glue
+@mock_aws
def test_get_partitions_expression_string_column():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -203,7 +203,7 @@ def test_get_partitions_expression_string_column():
assert "Unknown column 'unknown_col'" in exc.value.response["Error"]["Message"]
-@mock_glue
+@mock_aws
def test_get_partitions_expression_date_column():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -257,7 +257,7 @@ def test_get_partitions_expression_date_column():
)
-@mock_glue
+@mock_aws
def test_get_partitions_expression_timestamp_column():
client = boto3.client("glue", region_name="us-east-1")
database_name = "myspecialdatabase"
@@ -327,7 +327,7 @@ def test_get_partitions_expression_timestamp_column():
)
-@mock_glue
+@mock_aws
def test_get_partition_expression_warnings_and_exceptions():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cannot catch warnings in server mode")
diff --git a/tests/test_glue/test_schema_registry.py b/tests/test_glue/test_schema_registry.py
index 1554f618a..1475b8727 100644
--- a/tests/test_glue/test_schema_registry.py
+++ b/tests/test_glue/test_schema_registry.py
@@ -1,9 +1,8 @@
-"""Unit tests for glue-schema-registry-supported APIs."""
import boto3
import pytest
from botocore.client import ClientError
-from moto import mock_glue
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from . import helpers
@@ -43,7 +42,7 @@ from .fixtures.schema_registry import (
@pytest.fixture(name="client")
def fixture_client():
- with mock_glue():
+ with mock_aws():
yield boto3.client("glue", region_name="us-east-1")
diff --git a/tests/test_greengrass/test_greengrass_core.py b/tests/test_greengrass/test_greengrass_core.py
index 250372fa2..1201dc498 100644
--- a/tests/test_greengrass/test_greengrass_core.py
+++ b/tests/test_greengrass/test_greengrass_core.py
@@ -3,13 +3,13 @@ import freezegun
import pytest
from botocore.client import ClientError
-from moto import mock_greengrass
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.settings import TEST_SERVER_MODE
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_core_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -35,7 +35,7 @@ def test_create_core_definition():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_core_definitions():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -64,7 +64,7 @@ def test_list_core_definitions():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_core_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -99,7 +99,7 @@ def test_get_core_definition():
assert get_res["LastUpdatedTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_delete_core_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -126,7 +126,7 @@ def test_delete_core_definition():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_update_core_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -148,7 +148,7 @@ def test_update_core_definition():
assert get_res["Name"] == updated_core_name
-@mock_greengrass
+@mock_aws
def test_update_core_definition_with_empty_name():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -172,7 +172,7 @@ def test_update_core_definition_with_empty_name():
assert err["Code"] == "InvalidContainerDefinitionException"
-@mock_greengrass
+@mock_aws
def test_update_core_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -185,7 +185,7 @@ def test_update_core_definition_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_core_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
v1_cores = [
@@ -223,7 +223,7 @@ def test_create_core_definition_version():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_core_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
initial_version = {
@@ -255,7 +255,7 @@ def test_get_core_definition_version():
assert "Version" in core_def_ver_res
-@mock_greengrass
+@mock_aws
def test_get_core_definition_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -269,7 +269,7 @@ def test_get_core_definition_version_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_get_core_definition_version_with_invalid_version_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
core_def_res = client.create_core_definition(
@@ -299,7 +299,7 @@ def test_get_core_definition_version_with_invalid_version_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_core_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
initial_version = {
@@ -331,7 +331,7 @@ def test_list_core_definition_version():
assert "Version" in core_def_ver
-@mock_greengrass
+@mock_aws
def test_list_core_definition_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
diff --git a/tests/test_greengrass/test_greengrass_deployment.py b/tests/test_greengrass/test_greengrass_deployment.py
index aa1ae367b..80f1ddbb2 100644
--- a/tests/test_greengrass/test_greengrass_deployment.py
+++ b/tests/test_greengrass/test_greengrass_deployment.py
@@ -5,12 +5,12 @@ import freezegun
import pytest
from botocore.client import ClientError
-from moto import mock_greengrass
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.settings import TEST_SERVER_MODE
-@mock_greengrass
+@mock_aws
def test_create_deployment():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -40,7 +40,7 @@ def test_create_deployment():
assert res["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_greengrass
+@mock_aws
def test_re_deployment_with_no_deployment_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -76,7 +76,7 @@ def test_re_deployment_with_no_deployment_id():
assert err["Code"] == "InvalidInputException"
-@mock_greengrass
+@mock_aws
def test_re_deployment_with_invalid_deployment_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -111,7 +111,7 @@ def test_re_deployment_with_invalid_deployment_id():
assert err["Code"] == "InvalidInputException"
-@mock_greengrass
+@mock_aws
def test_create_deployment_with_no_core_group():
client = boto3.client("greengrass", region_name="ap-northeast-1")
create_group_res = client.create_group(Name="TestGroup")
@@ -137,7 +137,7 @@ def test_create_deployment_with_no_core_group():
)
-@mock_greengrass
+@mock_aws
def test_create_deployment_with_invalid_group_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -154,7 +154,7 @@ def test_create_deployment_with_invalid_group_id():
)
-@mock_greengrass
+@mock_aws
def test_create_deployment_with_invalid_group_version_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -191,7 +191,7 @@ def test_create_deployment_with_invalid_group_version_id():
)
-@mock_greengrass
+@mock_aws
def test_create_deployment_with_invalid_deployment_type():
client = boto3.client("greengrass", region_name="ap-northeast-1")
create_group_res = client.create_group(Name="TestGroup")
@@ -215,7 +215,7 @@ def test_create_deployment_with_invalid_deployment_type():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_deployments():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -257,7 +257,7 @@ def test_list_deployments():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_deployment_status():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -295,7 +295,7 @@ def test_get_deployment_status():
assert res["UpdatedAt"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_deployment_status_with_invalid_deployment_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
create_group_res = client.create_group(Name="TestGroup")
@@ -310,7 +310,7 @@ def test_get_deployment_status_with_invalid_deployment_id():
assert err["Code"] == "InvalidInputException"
-@mock_greengrass
+@mock_aws
def test_get_deployment_status_with_invalid_group_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -352,7 +352,7 @@ def test_get_deployment_status_with_invalid_group_id():
reason="Can't handle path that contains $ in server mode.So ResetGroup api can't use in server mode",
)
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_reset_deployments():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -400,7 +400,7 @@ def test_reset_deployments():
TEST_SERVER_MODE,
reason="Can't handle path that contains $ in server mode.So ResetGroup api can't use in server mode",
)
-@mock_greengrass
+@mock_aws
def test_reset_deployments_with_invalid_group_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -415,7 +415,7 @@ def test_reset_deployments_with_invalid_group_id():
TEST_SERVER_MODE,
reason="Can't handle path that contains $ in server mode.So ResetGroup api can't use in server mode",
)
-@mock_greengrass
+@mock_aws
def test_reset_deployments_with_never_deployed_group():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
@@ -449,7 +449,7 @@ def test_reset_deployments_with_never_deployed_group():
TEST_SERVER_MODE,
reason="Can't handle path that contains $ in server mode.So ResetGroup api can't use in server mode",
)
-@mock_greengrass
+@mock_aws
def test_reset_deployments_with_already_reset_group():
client = boto3.client("greengrass", region_name="ap-northeast-1")
cores = [
diff --git a/tests/test_greengrass/test_greengrass_device.py b/tests/test_greengrass/test_greengrass_device.py
index a4b719821..86124a05c 100644
--- a/tests/test_greengrass/test_greengrass_device.py
+++ b/tests/test_greengrass/test_greengrass_device.py
@@ -3,13 +3,13 @@ import freezegun
import pytest
from botocore.client import ClientError
-from moto import mock_greengrass
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.settings import TEST_SERVER_MODE
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_device_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -38,7 +38,7 @@ def test_create_device_definition():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_device_definitions():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -70,7 +70,7 @@ def test_list_device_definitions():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_device_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -106,7 +106,7 @@ def test_get_device_definition():
assert get_res["LastUpdatedTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_device_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -119,7 +119,7 @@ def test_get_device_definition_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_device_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
v1_devices = [
@@ -159,7 +159,7 @@ def test_create_device_definition_version():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_device_definition_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
devices = [
@@ -184,7 +184,7 @@ def test_create_device_definition_version_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_delete_device_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
devices = [
@@ -205,7 +205,7 @@ def test_delete_device_definition():
assert del_res["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_greengrass
+@mock_aws
def test_delete_device_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -218,7 +218,7 @@ def test_delete_device_definition_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_update_device_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
devices = [
@@ -245,7 +245,7 @@ def test_update_device_definition():
assert get_res["Name"] == updated_device_name
-@mock_greengrass
+@mock_aws
def test_update_device_definition_with_empty_name():
client = boto3.client("greengrass", region_name="ap-northeast-1")
devices = [
@@ -270,7 +270,7 @@ def test_update_device_definition_with_empty_name():
assert err["Code"] == "InvalidContainerDefinitionException"
-@mock_greengrass
+@mock_aws
def test_update_device_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -284,7 +284,7 @@ def test_update_device_definition_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_device_definition_versions():
client = boto3.client("greengrass", region_name="ap-northeast-1")
devices = [
@@ -318,7 +318,7 @@ def test_list_device_definition_versions():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_device_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
devices = [
@@ -351,7 +351,7 @@ def test_get_device_definition_version():
assert "Version" in core_def_ver_res
-@mock_greengrass
+@mock_aws
def test_get_device_definition_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -364,7 +364,7 @@ def test_get_device_definition_version_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_get_device_definition_version_with_invalid_version_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
devices = [
diff --git a/tests/test_greengrass/test_greengrass_functions.py b/tests/test_greengrass/test_greengrass_functions.py
index 7dc5e7e0a..01ff63971 100644
--- a/tests/test_greengrass/test_greengrass_functions.py
+++ b/tests/test_greengrass/test_greengrass_functions.py
@@ -3,12 +3,12 @@ import freezegun
import pytest
from botocore.client import ClientError
-from moto import mock_greengrass
+from moto import mock_aws
from moto.settings import TEST_SERVER_MODE
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_function_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -40,7 +40,7 @@ def test_create_function_definition():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_function_definitions():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -74,7 +74,7 @@ def test_list_function_definitions():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_function_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -115,7 +115,7 @@ def test_get_function_definition():
assert get_res["LastUpdatedTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_function_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -127,7 +127,7 @@ def test_get_function_definition_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_delete_function_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -153,7 +153,7 @@ def test_delete_function_definition():
assert del_res["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_greengrass
+@mock_aws
def test_delete_function_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -166,7 +166,7 @@ def test_delete_function_definition_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_update_function_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -198,7 +198,7 @@ def test_update_function_definition():
assert get_res["Name"] == updated_func_name
-@mock_greengrass
+@mock_aws
def test_update_function_definition_with_empty_name():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -228,7 +228,7 @@ def test_update_function_definition_with_empty_name():
assert err["Code"] == "InvalidContainerDefinitionException"
-@mock_greengrass
+@mock_aws
def test_update_function_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -242,7 +242,7 @@ def test_update_function_definition_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_function_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
v1_functions = [
@@ -289,7 +289,7 @@ def test_create_function_definition_version():
assert func_def_ver_res["CreationTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_create_function_definition_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
functions = [
@@ -315,7 +315,7 @@ def test_create_function_definition_version_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_function_definition_versions():
client = boto3.client("greengrass", region_name="ap-northeast-1")
functions = [
@@ -352,7 +352,7 @@ def test_list_function_definition_versions():
assert "Version" in device_def_ver
-@mock_greengrass
+@mock_aws
def test_list_function_definition_versions_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -366,7 +366,7 @@ def test_list_function_definition_versions_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_function_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
functions = [
@@ -404,7 +404,7 @@ def test_get_function_definition_version():
assert func_def_ver_res["CreationTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_function_definition_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -418,7 +418,7 @@ def test_get_function_definition_version_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_get_function_definition_version_with_invalid_version_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
functions = [
diff --git a/tests/test_greengrass/test_greengrass_groups.py b/tests/test_greengrass/test_greengrass_groups.py
index 6e8cd082c..d20cbf4fe 100644
--- a/tests/test_greengrass/test_greengrass_groups.py
+++ b/tests/test_greengrass/test_greengrass_groups.py
@@ -3,13 +3,13 @@ import freezegun
import pytest
from botocore.exceptions import ClientError
-from moto import mock_greengrass
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.settings import TEST_SERVER_MODE
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_group():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_core_ver = {
@@ -45,7 +45,7 @@ def test_create_group():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_groups():
client = boto3.client("greengrass", region_name="ap-northeast-1")
grp_name = "TestGroup"
@@ -66,7 +66,7 @@ def test_list_groups():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_group():
client = boto3.client("greengrass", region_name="ap-northeast-1")
grp_name = "TestGroup"
@@ -90,7 +90,7 @@ def test_get_group():
assert get_res["LastUpdatedTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_group_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -100,7 +100,7 @@ def test_get_group_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_delete_group():
client = boto3.client("greengrass", region_name="ap-northeast-1")
create_res = client.create_group(Name="TestGroup")
@@ -110,7 +110,7 @@ def test_delete_group():
assert del_res["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_greengrass
+@mock_aws
def test_delete_group_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -121,7 +121,7 @@ def test_delete_group_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_update_group():
client = boto3.client("greengrass", region_name="ap-northeast-1")
create_res = client.create_group(Name="TestGroup")
@@ -135,7 +135,7 @@ def test_update_group():
assert get_res["Name"] == updated_group_name
-@mock_greengrass
+@mock_aws
def test_update_group_with_empty_name():
client = boto3.client("greengrass", region_name="ap-northeast-1")
create_res = client.create_group(Name="TestGroup")
@@ -149,7 +149,7 @@ def test_update_group_with_empty_name():
assert err["Code"] == "InvalidContainerDefinitionException"
-@mock_greengrass
+@mock_aws
def test_update_group_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -161,7 +161,7 @@ def test_update_group_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_group_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
create_grp_res = client.create_group(Name="TestGroup")
@@ -177,7 +177,7 @@ def test_create_group_version():
assert group_ver_res["CreationTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_create_group_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -243,7 +243,7 @@ def test_create_group_version_with_invalid_id():
),
],
)
-@mock_greengrass
+@mock_aws
def test_create_group_version_with_invalid_version_arn(
def_ver_key_name, arn, error_message
):
@@ -265,7 +265,7 @@ def test_create_group_version_with_invalid_version_arn(
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_group_versions():
client = boto3.client("greengrass", region_name="ap-northeast-1")
create_res = client.create_group(Name="TestGroup")
@@ -284,7 +284,7 @@ def test_list_group_versions():
assert group_ver["CreationTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_list_group_versions_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -296,7 +296,7 @@ def test_list_group_versions_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_group_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_core_ver = {
@@ -412,7 +412,7 @@ def test_get_group_version():
assert group_ver_res["CreationTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_group_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -426,7 +426,7 @@ def test_get_group_version_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_get_group_version_with_invalid_version_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
create_res = client.create_group(Name="TestGroup")
@@ -448,7 +448,7 @@ def test_get_group_version_with_invalid_version_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_associate_role_to_group():
client = boto3.client("greengrass", region_name="ap-northeast-1")
res = client.associate_role_to_group(
@@ -461,7 +461,7 @@ def test_associate_role_to_group():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_associated_role():
client = boto3.client("greengrass", region_name="ap-northeast-1")
group_id = "abc002c8-1093-485e-9324-3baadf38e582"
@@ -477,7 +477,7 @@ def test_get_associated_role():
assert res["AssociatedAt"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_associated_role_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -489,7 +489,7 @@ def test_get_associated_role_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_disassociate_role_from_group():
client = boto3.client("greengrass", region_name="ap-northeast-1")
group_id = "abc002c8-1093-485e-9324-3baadf38e582"
@@ -513,7 +513,7 @@ def test_disassociate_role_from_group():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_disassociate_role_from_group_with_none_exists_group_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
group_id = "abc002c8-1093-485e-9324-3baadf38e582"
diff --git a/tests/test_greengrass/test_greengrass_resource.py b/tests/test_greengrass/test_greengrass_resource.py
index b176432b0..60e95106b 100644
--- a/tests/test_greengrass/test_greengrass_resource.py
+++ b/tests/test_greengrass/test_greengrass_resource.py
@@ -3,12 +3,12 @@ import freezegun
import pytest
from botocore.client import ClientError
-from moto import mock_greengrass
+from moto import mock_aws
from moto.settings import TEST_SERVER_MODE
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_resource_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -41,7 +41,7 @@ def test_create_resource_definition():
assert res["LastUpdatedTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_create_resource_definition_with_invalid_volume_resource():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -70,7 +70,7 @@ def test_create_resource_definition_with_invalid_volume_resource():
assert err["Code"] == "400"
-@mock_greengrass
+@mock_aws
def test_create_resource_definition_with_invalid_local_device_resource():
client = boto3.client("greengrass", region_name="ap-northeast-1")
source_path = "/foo/bar"
@@ -99,7 +99,7 @@ def test_create_resource_definition_with_invalid_local_device_resource():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_resource_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
v1_resources = [
@@ -148,7 +148,7 @@ def test_create_resource_definition_version():
assert device_def_ver_res["CreationTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_create_resources_definition_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
resources = [
@@ -174,7 +174,7 @@ def test_create_resources_definition_version_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_create_resources_definition_version_with_volume_resource():
client = boto3.client("greengrass", region_name="ap-northeast-1")
v1_resources = [
@@ -222,7 +222,7 @@ def test_create_resources_definition_version_with_volume_resource():
assert err["Code"] == "400"
-@mock_greengrass
+@mock_aws
def test_create_resources_definition_version_with_invalid_local_device_resource():
client = boto3.client("greengrass", region_name="ap-northeast-1")
v1_resources = [
@@ -266,7 +266,7 @@ def test_create_resources_definition_version_with_invalid_local_device_resource(
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_resources():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -310,7 +310,7 @@ def test_list_resources():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_resource_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -351,7 +351,7 @@ def test_get_resource_definition():
assert get_res["LastUpdatedTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_resource_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -363,7 +363,7 @@ def test_get_resource_definition_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_delete_resource_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -390,7 +390,7 @@ def test_delete_resource_definition():
assert del_res["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_greengrass
+@mock_aws
def test_delete_resource_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -403,7 +403,7 @@ def test_delete_resource_definition_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_update_resource_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -435,7 +435,7 @@ def test_update_resource_definition():
assert get_res["Name"] == updated_resource_name
-@mock_greengrass
+@mock_aws
def test_update_device_definition_with_empty_name():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -465,7 +465,7 @@ def test_update_device_definition_with_empty_name():
assert err["Code"] == "InvalidInputException"
-@mock_greengrass
+@mock_aws
def test_update_resource_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -479,7 +479,7 @@ def test_update_resource_definition_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_resource_definition_versions():
client = boto3.client("greengrass", region_name="ap-northeast-1")
resources = [
@@ -516,7 +516,7 @@ def test_list_resource_definition_versions():
assert device_def_ver["CreationTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_list_resource_definition_versions_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -529,7 +529,7 @@ def test_list_resource_definition_versions_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_resource_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
resources = [
@@ -567,7 +567,7 @@ def test_get_resource_definition_version():
assert resource_def_ver_res["CreationTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_resource_definition_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -580,7 +580,7 @@ def test_get_resource_definition_version_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_get_resource_definition_version_with_invalid_version_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
resources = [
diff --git a/tests/test_greengrass/test_greengrass_subscriptions.py b/tests/test_greengrass/test_greengrass_subscriptions.py
index e3cddbbe7..f85d5f292 100644
--- a/tests/test_greengrass/test_greengrass_subscriptions.py
+++ b/tests/test_greengrass/test_greengrass_subscriptions.py
@@ -3,7 +3,7 @@ import freezegun
import pytest
from botocore.client import ClientError
-from moto import mock_greengrass
+from moto import mock_aws
from moto.settings import TEST_SERVER_MODE
@@ -17,7 +17,7 @@ from moto.settings import TEST_SERVER_MODE
],
)
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_subscription_definition(target):
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -46,7 +46,7 @@ def test_create_subscription_definition(target):
assert res["LastUpdatedTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_create_subscription_definition_with_invalid_target():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -72,7 +72,7 @@ def test_create_subscription_definition_with_invalid_target():
assert err["Code"] == "400"
-@mock_greengrass
+@mock_aws
def test_create_subscription_definition_with_invalid_source():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -99,7 +99,7 @@ def test_create_subscription_definition_with_invalid_source():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_subscription_definitions():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -132,7 +132,7 @@ def test_list_subscription_definitions():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_subscription_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -171,7 +171,7 @@ def test_get_subscription_definition():
assert get_res["LastUpdatedTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_subscription_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
with pytest.raises(ClientError) as ex:
@@ -184,7 +184,7 @@ def test_get_subscription_definition_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_delete_subscription_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -208,7 +208,7 @@ def test_delete_subscription_definition():
assert del_res["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_greengrass
+@mock_aws
def test_update_subscription_definition():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -238,7 +238,7 @@ def test_update_subscription_definition():
assert get_res["Name"] == updated_subscription_name
-@mock_greengrass
+@mock_aws
def test_update_subscription_definition_with_empty_name():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -265,7 +265,7 @@ def test_update_subscription_definition_with_empty_name():
assert err["Code"] == "InvalidContainerDefinitionException"
-@mock_greengrass
+@mock_aws
def test_update_subscription_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -278,7 +278,7 @@ def test_update_subscription_definition_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_delete_subscription_definition_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -292,7 +292,7 @@ def test_delete_subscription_definition_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_create_subscription_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
v1_subscriptions = [
@@ -333,7 +333,7 @@ def test_create_subscription_definition_version():
)
-@mock_greengrass
+@mock_aws
def test_create_subscription_definition_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
subscriptions = [
@@ -355,7 +355,7 @@ def test_create_subscription_definition_version_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_create_subscription_definition_version_with_invalid_target():
client = boto3.client("greengrass", region_name="ap-northeast-1")
v1_subscriptions = [
@@ -395,7 +395,7 @@ def test_create_subscription_definition_version_with_invalid_target():
assert err["Code"] == "400"
-@mock_greengrass
+@mock_aws
def test_create_subscription_definition_version_with_invalid_source():
client = boto3.client("greengrass", region_name="ap-northeast-1")
v1_subscriptions = [
@@ -436,7 +436,7 @@ def test_create_subscription_definition_version_with_invalid_source():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_list_subscription_definition_versions():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -470,7 +470,7 @@ def test_list_subscription_definition_versions():
assert subscription_def_ver["CreationTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_list_subscription_definition_versions_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -484,7 +484,7 @@ def test_list_subscription_definition_versions_with_invalid_id():
@freezegun.freeze_time("2022-06-01 12:00:00")
-@mock_greengrass
+@mock_aws
def test_get_subscription_definition_version():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
@@ -519,7 +519,7 @@ def test_get_subscription_definition_version():
assert func_def_ver_res["CreationTimestamp"] == "2022-06-01T12:00:00.000Z"
-@mock_greengrass
+@mock_aws
def test_get_subscription_definition_version_with_invalid_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
@@ -533,7 +533,7 @@ def test_get_subscription_definition_version_with_invalid_id():
assert err["Code"] == "IdNotFoundException"
-@mock_greengrass
+@mock_aws
def test_get_subscription_definition_version_with_invalid_version_id():
client = boto3.client("greengrass", region_name="ap-northeast-1")
init_ver = {
diff --git a/tests/test_guardduty/test_guardduty.py b/tests/test_guardduty/test_guardduty.py
index 98d7bc9d9..aab40d6c2 100644
--- a/tests/test_guardduty/test_guardduty.py
+++ b/tests/test_guardduty/test_guardduty.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_guardduty
+from moto import mock_aws
-@mock_guardduty
+@mock_aws
def test_create_detector():
client = boto3.client("guardduty", region_name="us-east-1")
response = client.create_detector(
@@ -19,7 +19,7 @@ def test_create_detector():
assert response["DetectorId"] is not None
-@mock_guardduty
+@mock_aws
def test_create_detector_with_minimal_params():
client = boto3.client("guardduty", region_name="us-east-1")
response = client.create_detector(Enable=True)
@@ -27,7 +27,7 @@ def test_create_detector_with_minimal_params():
assert response["DetectorId"] is not None
-@mock_guardduty
+@mock_aws
def test_get_detector_with_s3():
client = boto3.client("guardduty", region_name="us-east-1")
detector_id = client.create_detector(
@@ -44,7 +44,7 @@ def test_get_detector_with_s3():
assert "CreatedAt" in resp
-@mock_guardduty
+@mock_aws
def test_get_detector_with_all_data_sources():
client = boto3.client("guardduty", region_name="us-east-1")
detector_id = client.create_detector(
@@ -65,7 +65,7 @@ def test_get_detector_with_all_data_sources():
assert "CreatedAt" in resp
-@mock_guardduty
+@mock_aws
def test_update_detector():
client = boto3.client("guardduty", region_name="us-east-1")
detector_id = client.create_detector(
@@ -91,7 +91,7 @@ def test_update_detector():
assert resp["DataSources"]["Kubernetes"]["AuditLogs"] == {"Status": "DISABLED"}
-@mock_guardduty
+@mock_aws
def test_list_detectors_initial():
client = boto3.client("guardduty", region_name="us-east-1")
@@ -99,7 +99,7 @@ def test_list_detectors_initial():
assert response["DetectorIds"] == []
-@mock_guardduty
+@mock_aws
def test_list_detectors():
client = boto3.client("guardduty", region_name="us-east-1")
d1 = client.create_detector(
@@ -115,7 +115,7 @@ def test_list_detectors():
assert set(response["DetectorIds"]) == {d1, d2}
-@mock_guardduty
+@mock_aws
def test_delete_detector():
client = boto3.client("guardduty", region_name="us-east-1")
detector_id = client.create_detector(
diff --git a/tests/test_guardduty/test_guardduty_filters.py b/tests/test_guardduty/test_guardduty_filters.py
index 84dc97ac9..c7a963bd2 100644
--- a/tests/test_guardduty/test_guardduty_filters.py
+++ b/tests/test_guardduty/test_guardduty_filters.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_guardduty
+from moto import mock_aws
-@mock_guardduty
+@mock_aws
def test_create_filter():
client = boto3.client("guardduty", region_name="us-east-1")
detector_id = client.create_detector(Enable=True)["DetectorId"]
@@ -18,7 +18,7 @@ def test_create_filter():
assert resp["Name"] == "my first filter"
-@mock_guardduty
+@mock_aws
def test_create_filter__defaults():
client = boto3.client("guardduty", region_name="us-east-1")
detector_id = client.create_detector(Enable=True)["DetectorId"]
@@ -33,7 +33,7 @@ def test_create_filter__defaults():
assert resp["Rank"] == 1
-@mock_guardduty
+@mock_aws
def test_get_filter():
client = boto3.client("guardduty", region_name="us-east-1")
detector_id = client.create_detector(Enable=True)["DetectorId"]
@@ -49,7 +49,7 @@ def test_get_filter():
assert resp["FindingCriteria"] == {"Criterion": {"x": {"Eq": ["y"]}}}
-@mock_guardduty
+@mock_aws
def test_update_filter():
client = boto3.client("guardduty", region_name="us-east-1")
detector_id = client.create_detector(Enable=True)["DetectorId"]
@@ -77,7 +77,7 @@ def test_update_filter():
assert resp["FindingCriteria"] == {"Criterion": {"x": {"Eq": ["y"]}}}
-@mock_guardduty
+@mock_aws
def test_delete_filter():
client = boto3.client("guardduty", region_name="us-east-1")
detector_id = client.create_detector(Enable=True)["DetectorId"]
diff --git a/tests/test_guardduty/test_guardduty_organization.py b/tests/test_guardduty/test_guardduty_organization.py
index e523f490e..9f2a5331b 100644
--- a/tests/test_guardduty/test_guardduty_organization.py
+++ b/tests/test_guardduty/test_guardduty_organization.py
@@ -1,16 +1,16 @@
import boto3
-from moto import mock_guardduty
+from moto import mock_aws
-@mock_guardduty
+@mock_aws
def test_enable_organization_admin_account():
client = boto3.client("guardduty", region_name="us-east-1")
resp = client.enable_organization_admin_account(AdminAccountId="")
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_guardduty
+@mock_aws
def test_list_organization_admin_accounts():
client = boto3.client("guardduty", region_name="us-east-1")
client.enable_organization_admin_account(AdminAccountId="someaccount")
diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py
index 9ca18be89..e2eccced1 100644
--- a/tests/test_iam/test_iam.py
+++ b/tests/test_iam/test_iam.py
@@ -9,7 +9,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_config, mock_iam, settings
+from moto import mock_aws, settings
from moto.backends import get_backend
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core.utils import utcnow
@@ -85,7 +85,7 @@ MOCK_STS_EC2_POLICY_DOCUMENT = """{
}"""
-@mock_iam
+@mock_aws
def test_get_role__should_throw__when_role_does_not_exist():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -95,7 +95,7 @@ def test_get_role__should_throw__when_role_does_not_exist():
assert "not found" in err["Message"]
-@mock_iam
+@mock_aws
def test_get_role__should_contain_last_used():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_role(
@@ -117,7 +117,7 @@ def test_get_role__should_contain_last_used():
assert roleLastUsed["Region"] == region
-@mock_iam
+@mock_aws
def test_get_instance_profile__should_throw__when_instance_profile_does_not_exist():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -127,7 +127,7 @@ def test_get_instance_profile__should_throw__when_instance_profile_does_not_exis
assert "not found" in err["Message"]
-@mock_iam
+@mock_aws
def test_create_role_and_instance_profile():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_instance_profile(InstanceProfileName="my-profile", Path="my-path")
@@ -160,7 +160,7 @@ def test_create_role_and_instance_profile():
assert profile["InstanceProfile"]["Path"] == "/"
-@mock_iam
+@mock_aws
def test_create_instance_profile_should_throw_when_name_is_not_unique():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_instance_profile(InstanceProfileName="unique-instance-profile")
@@ -168,7 +168,7 @@ def test_create_instance_profile_should_throw_when_name_is_not_unique():
conn.create_instance_profile(InstanceProfileName="unique-instance-profile")
-@mock_iam
+@mock_aws
def test_create_add_additional_roles_to_instance_profile_error():
# Setup
@@ -198,7 +198,7 @@ def test_create_add_additional_roles_to_instance_profile_error():
)
-@mock_iam
+@mock_aws
def test_remove_role_from_instance_profile():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_instance_profile(InstanceProfileName="my-profile", Path="my-path")
@@ -224,7 +224,7 @@ def test_remove_role_from_instance_profile():
assert len(profile["Roles"]) == 0
-@mock_iam()
+@mock_aws()
def test_delete_instance_profile():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_role(
@@ -244,7 +244,7 @@ def test_delete_instance_profile():
conn.get_instance_profile(InstanceProfileName="my-profile")
-@mock_iam()
+@mock_aws()
def test_get_login_profile():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_user(UserName="my-user")
@@ -254,7 +254,7 @@ def test_get_login_profile():
assert response["LoginProfile"]["UserName"] == "my-user"
-@mock_iam()
+@mock_aws()
def test_update_login_profile():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_user(UserName="my-user")
@@ -269,7 +269,7 @@ def test_update_login_profile():
assert response["LoginProfile"].get("PasswordResetRequired") is True
-@mock_iam()
+@mock_aws()
def test_delete_role():
conn = boto3.client("iam", region_name="us-east-1")
@@ -332,7 +332,7 @@ def test_delete_role():
conn.get_role(RoleName="my-role")
-@mock_iam
+@mock_aws
def test_list_instance_profiles():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_instance_profile(InstanceProfileName="my-profile", Path="my-path")
@@ -351,7 +351,7 @@ def test_list_instance_profiles():
assert profiles[0]["Roles"][0]["RoleName"] == "my-role"
-@mock_iam
+@mock_aws
def test_list_instance_profiles_for_role():
conn = boto3.client("iam", region_name="us-east-1")
@@ -390,7 +390,7 @@ def test_list_instance_profiles_for_role():
assert len(profile_list) == 0
-@mock_iam
+@mock_aws
def test_list_role_policies():
conn = boto3.client("iam", region_name="us-east-1")
@@ -420,7 +420,7 @@ def test_list_role_policies():
assert err["Message"] == "The role policy with name test policy cannot be found."
-@mock_iam
+@mock_aws
def test_put_role_policy():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_role(
@@ -434,7 +434,7 @@ def test_put_role_policy():
assert policy["PolicyDocument"] == json.loads(MOCK_POLICY)
-@mock_iam
+@mock_aws
def test_get_role_policy():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_role(
@@ -444,7 +444,7 @@ def test_get_role_policy():
conn.get_role_policy(RoleName="my-role", PolicyName="does-not-exist")
-@mock_iam
+@mock_aws
def test_update_assume_role_invalid_policy():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_role(
@@ -457,7 +457,7 @@ def test_update_assume_role_invalid_policy():
assert "Syntax errors in policy." in err["Message"]
-@mock_iam
+@mock_aws
def test_update_assume_role_valid_policy():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_role(
@@ -472,7 +472,7 @@ def test_update_assume_role_valid_policy():
)
-@mock_iam
+@mock_aws
def test_update_assume_role_invalid_policy_bad_action():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_role(
@@ -505,7 +505,7 @@ def test_update_assume_role_invalid_policy_bad_action():
)
-@mock_iam
+@mock_aws
def test_update_assume_role_invalid_policy_with_resource():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_role(
@@ -536,7 +536,7 @@ def test_update_assume_role_invalid_policy_with_resource():
assert "Has prohibited field Resource." in err["Message"]
-@mock_iam
+@mock_aws
def test_create_policy():
conn = boto3.client("iam", region_name="us-east-1")
response = conn.create_policy(
@@ -548,7 +548,7 @@ def test_create_policy():
)
-@mock_iam
+@mock_aws
def test_create_policy_already_exists():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestCreatePolicy", PolicyDocument=MOCK_POLICY)
@@ -559,7 +559,7 @@ def test_create_policy_already_exists():
assert "TestCreatePolicy" in ex.value.response["Error"]["Message"]
-@mock_iam
+@mock_aws
def test_delete_policy():
conn = boto3.client("iam", region_name="us-east-1")
response = conn.create_policy(
@@ -572,7 +572,7 @@ def test_delete_policy():
assert conn.list_policies(Scope="Local")["Policies"] == []
-@mock_iam
+@mock_aws
def test_create_policy_versions():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError):
@@ -601,7 +601,7 @@ def test_create_policy_versions():
assert version.get("PolicyVersion")["IsDefaultVersion"] is False
-@mock_iam
+@mock_aws
def test_create_many_policy_versions():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(
@@ -619,7 +619,7 @@ def test_create_many_policy_versions():
)
-@mock_iam
+@mock_aws
def test_set_default_policy_version():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(
@@ -696,7 +696,7 @@ def test_set_default_policy_version():
)
-@mock_iam
+@mock_aws
def test_get_policy():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestGetPolicy", PolicyDocument=MOCK_POLICY)
@@ -706,7 +706,7 @@ def test_get_policy():
assert policy["Policy"]["Arn"] == f"arn:aws:iam::{ACCOUNT_ID}:policy/TestGetPolicy"
-@mock_iam
+@mock_aws
def test_get_aws_managed_policy():
conn = boto3.client("iam", region_name="us-east-1")
managed_policy_arn = "arn:aws:iam::aws:policy/IAMUserChangePassword"
@@ -721,7 +721,7 @@ def test_get_aws_managed_policy():
)
-@mock_iam
+@mock_aws
def test_get_policy_version():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestGetPolicyVersion", PolicyDocument=MOCK_POLICY)
@@ -742,7 +742,7 @@ def test_get_policy_version():
assert retrieved.get("PolicyVersion")["IsDefaultVersion"] is False
-@mock_iam
+@mock_aws
def test_get_aws_managed_policy_version():
conn = boto3.client("iam", region_name="us-east-1")
managed_policy_arn = (
@@ -763,7 +763,7 @@ def test_get_aws_managed_policy_version():
assert isinstance(retrieved["PolicyVersion"]["Document"], dict)
-@mock_iam
+@mock_aws
def test_get_aws_managed_policy_v6_version():
conn = boto3.client("iam", region_name="us-east-1")
managed_policy_arn = "arn:aws:iam::aws:policy/job-function/SystemAdministrator"
@@ -778,7 +778,7 @@ def test_get_aws_managed_policy_v6_version():
assert isinstance(retrieved["PolicyVersion"]["Document"], dict)
-@mock_iam
+@mock_aws
def test_list_policy_versions():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError):
@@ -809,7 +809,7 @@ def test_list_policy_versions():
assert versions["Versions"][2]["IsDefaultVersion"] is False
-@mock_iam
+@mock_aws
def test_delete_policy_version():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestDeletePolicyVersion", PolicyDocument=MOCK_POLICY)
@@ -832,7 +832,7 @@ def test_delete_policy_version():
assert len(versions["Versions"]) == 1
-@mock_iam
+@mock_aws
def test_delete_default_policy_version():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestDeletePolicyVersion", PolicyDocument=MOCK_POLICY)
@@ -847,7 +847,7 @@ def test_delete_default_policy_version():
)
-@mock_iam()
+@mock_aws()
def test_create_policy_with_tags():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(
@@ -872,7 +872,7 @@ def test_create_policy_with_tags():
assert policy["Description"] == "testing"
-@mock_iam()
+@mock_aws()
def test_create_policy_with_empty_tag_value():
conn = boto3.client("iam", region_name="us-east-1")
@@ -890,7 +890,7 @@ def test_create_policy_with_empty_tag_value():
assert tags["Tags"][0]["Value"] == ""
-@mock_iam()
+@mock_aws()
def test_create_policy_with_too_many_tags():
conn = boto3.client("iam", region_name="us-east-1")
@@ -910,7 +910,7 @@ def test_create_policy_with_too_many_tags():
)
-@mock_iam()
+@mock_aws()
def test_create_policy_with_duplicate_tag():
conn = boto3.client("iam", region_name="us-east-1")
@@ -927,7 +927,7 @@ def test_create_policy_with_duplicate_tag():
)
-@mock_iam()
+@mock_aws()
def test_create_policy_with_duplicate_tag_different_casing():
conn = boto3.client("iam", region_name="us-east-1")
@@ -944,7 +944,7 @@ def test_create_policy_with_duplicate_tag_different_casing():
)
-@mock_iam()
+@mock_aws()
def test_create_policy_with_tag_containing_large_key():
conn = boto3.client("iam", region_name="us-east-1")
@@ -961,7 +961,7 @@ def test_create_policy_with_tag_containing_large_key():
)
-@mock_iam()
+@mock_aws()
def test_create_policy_with_tag_containing_large_value():
conn = boto3.client("iam", region_name="us-east-1")
@@ -978,7 +978,7 @@ def test_create_policy_with_tag_containing_large_value():
)
-@mock_iam()
+@mock_aws()
def test_create_policy_with_tag_containing_invalid_character():
conn = boto3.client("iam", region_name="us-east-1")
@@ -995,7 +995,7 @@ def test_create_policy_with_tag_containing_invalid_character():
)
-@mock_iam()
+@mock_aws()
def test_create_policy_with_no_tags():
"""Tests both the tag_policy and get_policy_tags capability"""
conn = boto3.client("iam", region_name="us-east-1")
@@ -1008,7 +1008,7 @@ def test_create_policy_with_no_tags():
assert not policy.get("Tags")
-@mock_iam()
+@mock_aws()
def test_get_policy_with_tags():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1031,7 +1031,7 @@ def test_get_policy_with_tags():
assert policy["Tags"][1]["Value"] == "someothervalue"
-@mock_iam()
+@mock_aws()
def test_list_policy_tags():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1056,7 +1056,7 @@ def test_list_policy_tags():
assert not tags.get("Marker")
-@mock_iam()
+@mock_aws()
def test_list_policy_tags_pagination():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1090,7 +1090,7 @@ def test_list_policy_tags_pagination():
assert not tags.get("Marker")
-@mock_iam()
+@mock_aws()
def test_updating_existing_tag():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1115,7 +1115,7 @@ def test_updating_existing_tag():
assert tags["Tags"][0]["Value"] == "somenewvalue"
-@mock_iam()
+@mock_aws()
def test_updating_existing_tag_with_empty_value():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1140,7 +1140,7 @@ def test_updating_existing_tag_with_empty_value():
assert tags["Tags"][0]["Value"] == ""
-@mock_iam()
+@mock_aws()
def test_updating_existing_tagged_policy_with_too_many_tags():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1167,7 +1167,7 @@ def test_updating_existing_tagged_policy_with_too_many_tags():
)
-@mock_iam()
+@mock_aws()
def test_updating_existing_tagged_policy_with_duplicate_tag():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1191,7 +1191,7 @@ def test_updating_existing_tagged_policy_with_duplicate_tag():
)
-@mock_iam()
+@mock_aws()
def test_updating_existing_tagged_policy_with_duplicate_tag_different_casing():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1215,7 +1215,7 @@ def test_updating_existing_tagged_policy_with_duplicate_tag_different_casing():
)
-@mock_iam()
+@mock_aws()
def test_updating_existing_tagged_policy_with_large_key():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1239,7 +1239,7 @@ def test_updating_existing_tagged_policy_with_large_key():
)
-@mock_iam()
+@mock_aws()
def test_updating_existing_tagged_policy_with_large_value():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1263,7 +1263,7 @@ def test_updating_existing_tagged_policy_with_large_value():
)
-@mock_iam()
+@mock_aws()
def test_updating_existing_tagged_policy_with_invalid_character():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1287,7 +1287,7 @@ def test_updating_existing_tagged_policy_with_invalid_character():
)
-@mock_iam()
+@mock_aws()
def test_tag_non_existant_policy():
conn = boto3.client("iam", region_name="us-east-1")
@@ -1299,7 +1299,7 @@ def test_tag_non_existant_policy():
)
-@mock_iam
+@mock_aws
def test_untag_policy():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(PolicyName="TestUnTagPolicy", PolicyDocument=MOCK_POLICY)
@@ -1380,7 +1380,7 @@ def test_untag_policy():
)
-@mock_iam
+@mock_aws
def test_create_user_boto():
conn = boto3.client("iam", region_name="us-east-1")
u = conn.create_user(UserName="my-user")["User"]
@@ -1397,7 +1397,7 @@ def test_create_user_boto():
assert err["Message"] == "User my-user already exists"
-@mock_iam
+@mock_aws
def test_get_user():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -1416,7 +1416,7 @@ def test_get_user():
assert isinstance(u["CreateDate"], datetime)
-@mock_iam()
+@mock_aws()
def test_update_user():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(conn.exceptions.NoSuchEntityException):
@@ -1429,7 +1429,7 @@ def test_update_user():
conn.get_user(UserName="my-user")
-@mock_iam
+@mock_aws
def test_get_current_user():
"""If no user is specific, IAM returns the current user"""
conn = boto3.client("iam", region_name="us-east-1")
@@ -1437,7 +1437,7 @@ def test_get_current_user():
assert user["UserName"] == "default_user"
-@mock_iam()
+@mock_aws()
def test_list_users():
path_prefix = "/"
max_items = 10
@@ -1457,7 +1457,7 @@ def test_list_users():
assert user["Path"] == "myUser"
-@mock_iam()
+@mock_aws()
def test_user_policies():
policy_name = "UserManagedPolicy"
user_name = "my-user"
@@ -1480,7 +1480,7 @@ def test_user_policies():
assert len(policies["PolicyNames"]) == 0
-@mock_iam
+@mock_aws
def test_create_login_profile_with_unknown_user():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -1490,7 +1490,7 @@ def test_create_login_profile_with_unknown_user():
assert err["Message"] == "The user with name my-user cannot be found."
-@mock_iam
+@mock_aws
def test_delete_login_profile_with_unknown_user():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -1500,7 +1500,7 @@ def test_delete_login_profile_with_unknown_user():
assert err["Message"] == "The user with name my-user cannot be found."
-@mock_iam
+@mock_aws
def test_delete_nonexistent_login_profile():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_user(UserName="my-user")
@@ -1511,7 +1511,7 @@ def test_delete_nonexistent_login_profile():
assert err["Message"] == "Login profile for my-user not found"
-@mock_iam
+@mock_aws
def test_delete_login_profile():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_user(UserName="my-user")
@@ -1522,7 +1522,7 @@ def test_delete_login_profile():
conn.get_login_profile(UserName="my-user")
-@mock_iam
+@mock_aws
def test_create_access_key():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError):
@@ -1546,7 +1546,7 @@ def test_create_access_key():
assert access_key["AccessKeyId"].startswith("AKIA")
-@mock_iam
+@mock_aws
def test_limit_access_key_per_user():
conn = boto3.client("iam", region_name=DEFAULT_REGION_NAME)
user_name = "test-user"
@@ -1562,7 +1562,7 @@ def test_limit_access_key_per_user():
assert err["Message"] == "Cannot exceed quota for AccessKeysPerUser: 2"
-@mock_iam
+@mock_aws
def test_list_access_keys():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_user(UserName="my-user")
@@ -1585,7 +1585,7 @@ def test_list_access_keys():
)
-@mock_iam
+@mock_aws
def test_delete_access_key():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_user(UserName="my-user")
@@ -1595,7 +1595,7 @@ def test_delete_access_key():
conn.delete_access_key(AccessKeyId=key["AccessKeyId"])
-@mock_iam()
+@mock_aws()
def test_mfa_devices():
# Test enable device
conn = boto3.client("iam", region_name="us-east-1")
@@ -1618,7 +1618,7 @@ def test_mfa_devices():
assert len(response["MFADevices"]) == 0
-@mock_iam
+@mock_aws
def test_create_virtual_mfa_device():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_virtual_mfa_device(VirtualMFADeviceName="test-device")
@@ -1648,7 +1648,7 @@ def test_create_virtual_mfa_device():
assert isinstance(device["QRCodePNG"], bytes)
-@mock_iam
+@mock_aws
def test_create_virtual_mfa_device_errors():
client = boto3.client("iam", region_name="us-east-1")
client.create_virtual_mfa_device(VirtualMFADeviceName="test-device")
@@ -1692,7 +1692,7 @@ def test_create_virtual_mfa_device_errors():
)
-@mock_iam
+@mock_aws
def test_delete_virtual_mfa_device():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_virtual_mfa_device(VirtualMFADeviceName="test-device")
@@ -1706,7 +1706,7 @@ def test_delete_virtual_mfa_device():
assert response["IsTruncated"] is False
-@mock_iam
+@mock_aws
def test_delete_virtual_mfa_device_errors():
client = boto3.client("iam", region_name="us-east-1")
@@ -1720,7 +1720,7 @@ def test_delete_virtual_mfa_device_errors():
)
-@mock_iam
+@mock_aws
def test_list_virtual_mfa_devices():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_virtual_mfa_device(VirtualMFADeviceName="test-device")
@@ -1766,7 +1766,7 @@ def test_list_virtual_mfa_devices():
assert response["IsTruncated"] is False
-@mock_iam
+@mock_aws
def test_list_virtual_mfa_devices_errors():
client = boto3.client("iam", region_name="us-east-1")
client.create_virtual_mfa_device(VirtualMFADeviceName="test-device")
@@ -1777,7 +1777,7 @@ def test_list_virtual_mfa_devices_errors():
assert err["Message"] == "Invalid Marker."
-@mock_iam
+@mock_aws
def test_enable_virtual_mfa_device():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_virtual_mfa_device(VirtualMFADeviceName="test-device")
@@ -1822,7 +1822,7 @@ def test_enable_virtual_mfa_device():
assert response["IsTruncated"] is False
-@mock_iam()
+@mock_aws()
def test_delete_user():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(conn.exceptions.NoSuchEntityException):
@@ -1861,7 +1861,7 @@ def test_delete_user():
conn.get_user(UserName="my-user")
-@mock_iam
+@mock_aws
def test_generate_credential_report():
conn = boto3.client("iam", region_name="us-east-1")
result = conn.generate_credential_report()
@@ -1870,7 +1870,7 @@ def test_generate_credential_report():
assert result["State"] == "COMPLETE"
-@mock_iam
+@mock_aws
def test_get_credential_report():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_user(UserName="my-user")
@@ -1884,7 +1884,7 @@ def test_get_credential_report():
assert "my-user" in report
-@mock_iam
+@mock_aws
def test_get_credential_report_content():
conn = boto3.client("iam", region_name="us-east-1")
username = "my-user"
@@ -1927,7 +1927,7 @@ def test_get_credential_report_content():
assert user["password_last_used"] == "no_information"
-@mock_iam
+@mock_aws
def test_get_access_key_last_used_when_used():
iam = boto3.resource("iam", region_name="us-east-1")
client = iam.meta.client
@@ -1953,7 +1953,7 @@ def test_get_access_key_last_used_when_used():
assert resp["AccessKeyLastUsed"]["Region"] == "us-east-1"
-@mock_iam
+@mock_aws
def test_managed_policy():
conn = boto3.client("iam", region_name="us-west-1")
@@ -2044,7 +2044,7 @@ def test_managed_policy():
assert err["Message"] == "Policy arn:aws:iam::aws:policy/Nonexistent was not found."
-@mock_iam
+@mock_aws
def test_create_login_profile__duplicate():
conn = boto3.client("iam", region_name="us-east-1")
@@ -2058,7 +2058,7 @@ def test_create_login_profile__duplicate():
assert err["Message"] is None
-@mock_iam()
+@mock_aws()
def test_attach_detach_user_policy():
iam = boto3.resource("iam", region_name="us-east-1")
client = boto3.client("iam", region_name="us-east-1")
@@ -2098,7 +2098,7 @@ def test_attach_detach_user_policy():
assert len(resp["AttachedPolicies"]) == 0
-@mock_iam()
+@mock_aws()
def test_attach_detach_role_policy():
iam = boto3.resource("iam", region_name="us-east-1")
client = boto3.client("iam", region_name="us-east-1")
@@ -2138,7 +2138,7 @@ def test_attach_detach_role_policy():
assert len(resp["AttachedPolicies"]) == 0
-@mock_iam()
+@mock_aws()
def test_only_detach_user_policy():
iam = boto3.resource("iam", region_name="us-east-1")
client = boto3.client("iam", region_name="us-east-1")
@@ -2163,7 +2163,7 @@ def test_only_detach_user_policy():
assert err["Message"] == f"Policy {policy.arn} was not found."
-@mock_iam()
+@mock_aws()
def test_only_detach_group_policy():
iam = boto3.resource("iam", region_name="us-east-1")
client = boto3.client("iam", region_name="us-east-1")
@@ -2188,7 +2188,7 @@ def test_only_detach_group_policy():
assert err["Message"] == f"Policy {policy.arn} was not found."
-@mock_iam()
+@mock_aws()
def test_only_detach_role_policy():
iam = boto3.resource("iam", region_name="us-east-1")
client = boto3.client("iam", region_name="us-east-1")
@@ -2213,7 +2213,7 @@ def test_only_detach_role_policy():
assert err["Message"] == f"Policy {policy.arn} was not found."
-@mock_iam
+@mock_aws
def test_update_access_key():
iam = boto3.resource("iam", region_name="us-east-1")
client = iam.meta.client
@@ -2234,7 +2234,7 @@ def test_update_access_key():
assert resp["AccessKeyMetadata"][0]["Status"] == "Active"
-@mock_iam
+@mock_aws
def test_get_access_key_last_used_when_unused():
iam = boto3.resource("iam", region_name="us-east-1")
client = iam.meta.client
@@ -2250,7 +2250,7 @@ def test_get_access_key_last_used_when_unused():
assert resp["UserName"] == create_key_response["UserName"]
-@mock_iam
+@mock_aws
def test_upload_ssh_public_key():
iam = boto3.resource("iam", region_name="us-east-1")
client = iam.meta.client
@@ -2269,7 +2269,7 @@ def test_upload_ssh_public_key():
assert 0 <= ((utcnow() - pubkey["UploadDate"].replace(tzinfo=None)).seconds) < 10
-@mock_iam
+@mock_aws
def test_get_ssh_public_key():
iam = boto3.resource("iam", region_name="us-east-1")
client = iam.meta.client
@@ -2291,7 +2291,7 @@ def test_get_ssh_public_key():
assert resp["SSHPublicKey"]["SSHPublicKeyBody"] == public_key
-@mock_iam
+@mock_aws
def test_list_ssh_public_keys():
iam = boto3.resource("iam", region_name="us-east-1")
client = iam.meta.client
@@ -2310,7 +2310,7 @@ def test_list_ssh_public_keys():
assert resp["SSHPublicKeys"][0]["SSHPublicKeyId"] == ssh_public_key_id
-@mock_iam
+@mock_aws
def test_update_ssh_public_key():
iam = boto3.resource("iam", region_name="us-east-1")
client = iam.meta.client
@@ -2337,7 +2337,7 @@ def test_update_ssh_public_key():
assert resp["SSHPublicKey"]["Status"] == "Inactive"
-@mock_iam
+@mock_aws
def test_delete_ssh_public_key():
iam = boto3.resource("iam", region_name="us-east-1")
client = iam.meta.client
@@ -2364,7 +2364,7 @@ def test_delete_ssh_public_key():
assert len(resp["SSHPublicKeys"]) == 0
-@mock_iam
+@mock_aws
def test_get_account_authorization_details():
test_policy = json.dumps(
{
@@ -2531,7 +2531,7 @@ def test_get_account_authorization_details():
assert len(result["Policies"]) > 1
-@mock_iam
+@mock_aws
def test_signing_certs():
client = boto3.client("iam", region_name="us-east-1")
@@ -2599,7 +2599,7 @@ def test_signing_certs():
client.delete_signing_certificate(UserName="notauser", CertificateId=cert_id)
-@mock_iam()
+@mock_aws()
def test_create_saml_provider():
conn = boto3.client("iam", region_name="us-east-1")
response = conn.create_saml_provider(
@@ -2611,7 +2611,7 @@ def test_create_saml_provider():
)
-@mock_iam()
+@mock_aws()
def test_get_saml_provider():
conn = boto3.client("iam", region_name="us-east-1")
saml_provider_create = conn.create_saml_provider(
@@ -2623,7 +2623,7 @@ def test_get_saml_provider():
assert response["SAMLMetadataDocument"] == "a" * 1024
-@mock_iam()
+@mock_aws()
def test_list_saml_providers():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_saml_provider(Name="TestSAMLProvider", SAMLMetadataDocument="a" * 1024)
@@ -2634,7 +2634,7 @@ def test_list_saml_providers():
)
-@mock_iam()
+@mock_aws()
def test_delete_saml_provider():
conn = boto3.client("iam", region_name="us-east-1")
saml_provider_create = conn.create_saml_provider(
@@ -2661,7 +2661,7 @@ def test_delete_saml_provider():
assert not resp["Certificates"]
-@mock_iam()
+@mock_aws()
def test_create_role_defaults():
"""Tests default values"""
conn = boto3.client("iam", region_name="us-east-1")
@@ -2674,7 +2674,7 @@ def test_create_role_defaults():
assert role.get("Description") is None
-@mock_iam()
+@mock_aws()
def test_create_role_with_tags():
"""Tests both the tag_role and get_role_tags capability"""
conn = boto3.client("iam", region_name="us-east-1")
@@ -2783,7 +2783,7 @@ def test_create_role_with_tags():
)
-@mock_iam()
+@mock_aws()
def test_tag_role():
"""Tests both the tag_role and get_role_tags capability"""
conn = boto3.client("iam", region_name="us-east-1")
@@ -2914,7 +2914,7 @@ def test_tag_role():
conn.tag_role(RoleName="notarole", Tags=[{"Key": "some", "Value": "value"}])
-@mock_iam
+@mock_aws
def test_untag_role():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_role(RoleName="my-role", AssumeRolePolicyDocument="{}")
@@ -2973,7 +2973,7 @@ def test_untag_role():
conn.untag_role(RoleName="notarole", TagKeys=["somevalue"])
-@mock_iam()
+@mock_aws()
def test_update_role_description():
conn = boto3.client("iam", region_name="us-east-1")
@@ -2988,7 +2988,7 @@ def test_update_role_description():
assert response["Role"]["RoleName"] == "my-role"
-@mock_iam()
+@mock_aws()
def test_update_role():
conn = boto3.client("iam", region_name="us-east-1")
@@ -3002,7 +3002,7 @@ def test_update_role():
assert len(response.keys()) == 1
-@mock_iam()
+@mock_aws()
def test_update_role_defaults():
conn = boto3.client("iam", region_name="us-east-1")
@@ -3024,7 +3024,7 @@ def test_update_role_defaults():
assert role.get("Description") is None
-@mock_iam()
+@mock_aws()
def test_list_entities_for_policy():
test_policy = json.dumps(
{
@@ -3137,7 +3137,7 @@ def test_list_entities_for_policy():
assert "RoleId" in response["PolicyRoles"][0]
-@mock_iam()
+@mock_aws()
def test_create_role_no_path():
conn = boto3.client("iam", region_name="us-east-1")
resp = conn.create_role(
@@ -3148,7 +3148,7 @@ def test_create_role_no_path():
assert resp["Role"]["Description"] == "test"
-@mock_iam()
+@mock_aws()
def test_create_role_with_permissions_boundary():
conn = boto3.client("iam", region_name="us-east-1")
boundary = f"arn:aws:iam::{ACCOUNT_ID}:policy/boundary"
@@ -3190,7 +3190,7 @@ def test_create_role_with_permissions_boundary():
assert conn.list_roles()["Roles"][0].get("PermissionsBoundary") == expected
-@mock_iam
+@mock_aws
def test_create_role_with_same_name_should_fail():
iam = boto3.client("iam", region_name="us-east-1")
test_role_name = str(uuid4())
@@ -3211,7 +3211,7 @@ def test_create_role_with_same_name_should_fail():
)
-@mock_iam
+@mock_aws
def test_create_policy_with_same_name_should_fail():
iam = boto3.client("iam", region_name="us-east-1")
test_policy_name = str(uuid4())
@@ -3226,7 +3226,7 @@ def test_create_policy_with_same_name_should_fail():
)
-@mock_iam
+@mock_aws
def test_update_account_password_policy():
client = boto3.client("iam", region_name="us-east-1")
@@ -3245,7 +3245,7 @@ def test_update_account_password_policy():
}
-@mock_iam
+@mock_aws
def test_update_account_password_policy_errors():
client = boto3.client("iam", region_name="us-east-1")
@@ -3260,7 +3260,7 @@ def test_update_account_password_policy_errors():
)
-@mock_iam
+@mock_aws
def test_get_account_password_policy():
client = boto3.client("iam", region_name="us-east-1")
client.update_account_password_policy(
@@ -3291,7 +3291,7 @@ def test_get_account_password_policy():
}
-@mock_iam
+@mock_aws
def test_get_account_password_policy_errors():
client = boto3.client("iam", region_name="us-east-1")
@@ -3304,7 +3304,7 @@ def test_get_account_password_policy_errors():
)
-@mock_iam
+@mock_aws
def test_delete_account_password_policy():
client = boto3.client("iam", region_name="us-east-1")
client.update_account_password_policy()
@@ -3324,7 +3324,7 @@ def test_delete_account_password_policy():
)
-@mock_iam
+@mock_aws
def test_get_account_summary():
client = boto3.client("iam", region_name="us-east-1")
iam = boto3.resource("iam", region_name="us-east-1")
@@ -3438,7 +3438,7 @@ def test_get_account_summary():
}
-@mock_iam()
+@mock_aws()
def test_list_user_tags():
"""Tests both setting a tags on a user in create_user and list_user_tags"""
conn = boto3.client("iam", region_name="us-east-1")
@@ -3469,7 +3469,7 @@ def test_list_user_tags():
assert response["IsTruncated"] is False
-@mock_iam()
+@mock_aws()
def test_delete_role_with_instance_profiles_present():
iam = boto3.client("iam", region_name="us-east-1")
@@ -3488,7 +3488,7 @@ def test_delete_role_with_instance_profiles_present():
assert "Role2" not in role_names
-@mock_iam
+@mock_aws
def test_delete_account_password_policy_errors():
client = boto3.client("iam", region_name="us-east-1")
@@ -3500,7 +3500,7 @@ def test_delete_account_password_policy_errors():
)
-@mock_iam
+@mock_aws
def test_role_list_config_discovered_resources():
from moto.iam.config import role_config_query
@@ -3579,7 +3579,7 @@ def test_role_list_config_discovered_resources():
assert len(both_filter_bad) == 0
-@mock_iam
+@mock_aws
def test_role_config_dict():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Using backend directly - no point in testing ServerMode")
@@ -3860,8 +3860,7 @@ def test_role_config_dict():
]
-@mock_iam
-@mock_config
+@mock_aws
def test_role_config_client():
from moto.iam.utils import random_role_id
@@ -4099,7 +4098,7 @@ def test_role_config_client():
)
-@mock_iam
+@mock_aws
def test_policy_list_config_discovered_resources():
from moto.iam.config import policy_config_query
@@ -4190,7 +4189,7 @@ def test_policy_list_config_discovered_resources():
assert len(both_filter_bad) == 0
-@mock_iam
+@mock_aws
def test_policy_config_dict():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Using backend directly - no point in testing ServerMode")
@@ -4306,8 +4305,7 @@ def test_policy_config_dict():
assert policy["supplementaryConfiguration"] == {}
-@mock_iam
-@mock_config
+@mock_aws
def test_policy_config_client():
from moto.iam.utils import random_policy_id
@@ -4522,7 +4520,7 @@ def test_policy_config_client():
)
-@mock_iam()
+@mock_aws()
def test_list_roles_with_more_than_100_roles_no_max_items_defaults_to_100():
iam = boto3.client("iam", region_name="us-east-1")
for i in range(150):
@@ -4536,7 +4534,7 @@ def test_list_roles_with_more_than_100_roles_no_max_items_defaults_to_100():
assert len(roles) == 100
-@mock_iam()
+@mock_aws()
def test_list_roles_max_item_and_marker_values_adhered():
iam = boto3.client("iam", region_name="us-east-1")
for i in range(10):
@@ -4556,7 +4554,7 @@ def test_list_roles_max_item_and_marker_values_adhered():
assert len(roles) == 8
-@mock_iam()
+@mock_aws()
def test_list_roles_path_prefix_value_adhered():
iam = boto3.client("iam", region_name="us-east-1")
iam.create_role(
@@ -4575,7 +4573,7 @@ def test_list_roles_path_prefix_value_adhered():
assert roles[0]["RoleName"] == "test_role_with_path"
-@mock_iam()
+@mock_aws()
def test_list_roles_none_found_returns_empty_list():
iam = boto3.client("iam", region_name="us-east-1")
@@ -4596,7 +4594,7 @@ def test_list_roles_none_found_returns_empty_list():
assert len(roles) == 0
-@mock_iam()
+@mock_aws()
def test_list_roles():
conn = boto3.client("iam", region_name="us-east-1")
for desc in ["", "desc"]:
@@ -4622,7 +4620,7 @@ def test_list_roles():
assert all([role["MaxSessionDuration"] for role in all_roles])
-@mock_iam()
+@mock_aws()
def test_create_user_with_tags():
conn = boto3.client("iam", region_name="us-east-1")
user_name = "test-user"
@@ -4640,7 +4638,7 @@ def test_create_user_with_tags():
assert "Tags" not in resp["User"]
-@mock_iam
+@mock_aws
def test_tag_user():
# given
client = boto3.client("iam", region_name="eu-central-1")
@@ -4659,7 +4657,7 @@ def test_tag_user():
assert sorted(response["Tags"], key=lambda item: item["Key"]) == tags
-@mock_iam
+@mock_aws
def test_tag_user_error_unknown_user_name():
# given
client = boto3.client("iam", region_name="eu-central-1")
@@ -4679,7 +4677,7 @@ def test_tag_user_error_unknown_user_name():
)
-@mock_iam
+@mock_aws
def test_untag_user():
# given
client = boto3.client("iam", region_name="eu-central-1")
@@ -4697,7 +4695,7 @@ def test_untag_user():
assert response["Tags"] == [{"Key": "key", "Value": "value"}]
-@mock_iam
+@mock_aws
def test_untag_user_error_unknown_user_name():
# given
client = boto3.client("iam", region_name="eu-central-1")
@@ -4717,7 +4715,7 @@ def test_untag_user_error_unknown_user_name():
)
-@mock_iam
+@mock_aws
@pytest.mark.parametrize(
"service,cased",
[
@@ -4740,7 +4738,7 @@ def test_create_service_linked_role(service, cased):
assert resp["RoleName"] == f"AWSServiceRoleFor{cased}"
-@mock_iam
+@mock_aws
def test_create_service_linked_role__with_suffix():
client = boto3.client("iam", region_name="eu-central-1")
@@ -4762,7 +4760,7 @@ def test_create_service_linked_role__with_suffix():
]
-@mock_iam
+@mock_aws
def test_delete_service_linked_role():
client = boto3.client("iam", region_name="eu-central-1")
diff --git a/tests/test_iam/test_iam_access_integration.py b/tests/test_iam/test_iam_access_integration.py
index 4fb2db769..51a525322 100644
--- a/tests/test_iam/test_iam_access_integration.py
+++ b/tests/test_iam/test_iam_access_integration.py
@@ -5,13 +5,12 @@ from unittest import SkipTest
import boto3
from dateutil.parser import parse
-from moto import mock_ec2, mock_iam, mock_sts, settings
+from moto import mock_aws, settings
from moto.iam.models import IAMBackend, iam_backends
from tests import DEFAULT_ACCOUNT_ID
-@mock_ec2
-@mock_iam
+@mock_aws
def test_invoking_ec2_mark_access_key_as_used():
c_iam = boto3.client("iam", region_name="us-east-1")
c_iam.create_user(Path="my/path", UserName="fakeUser")
@@ -33,8 +32,7 @@ def test_invoking_ec2_mark_access_key_as_used():
assert last_used["Region"] == "us-east-2"
-@mock_iam
-@mock_sts
+@mock_aws
def test_mark_role_as_last_used():
role_name = "role_name_created_jan_1st"
iam = boto3.client("iam", "us-east-1")
@@ -66,8 +64,7 @@ def test_mark_role_as_last_used():
assert iam.get_role(role_name).last_used is not None
-@mock_ec2
-@mock_iam
+@mock_aws
def test_get_credential_report_content__set_last_used_automatically():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("No point testing this in ServerMode")
diff --git a/tests/test_iam/test_iam_account_aliases.py b/tests/test_iam/test_iam_account_aliases.py
index afba06a70..0aeabccad 100644
--- a/tests/test_iam/test_iam_account_aliases.py
+++ b/tests/test_iam/test_iam_account_aliases.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_iam
+from moto import mock_aws
-@mock_iam()
+@mock_aws()
def test_account_aliases():
client = boto3.client("iam", region_name="us-east-1")
diff --git a/tests/test_iam/test_iam_cloudformation.py b/tests/test_iam/test_iam_cloudformation.py
index 09d3a9b55..aae856d18 100644
--- a/tests/test_iam/test_iam_cloudformation.py
+++ b/tests/test_iam/test_iam_cloudformation.py
@@ -5,7 +5,7 @@ import pytest
import yaml
from botocore.exceptions import ClientError
-from moto import mock_autoscaling, mock_cloudformation, mock_iam, mock_s3, mock_sts
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
@@ -62,8 +62,7 @@ Resources:
# AWS::IAM::User Tests
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_user():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -89,8 +88,7 @@ Resources:
assert provisioned_resource["PhysicalResourceId"] == user_name
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_update_user_no_interruption():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -129,8 +127,7 @@ Resources:
assert user["Path"] == path
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_update_user_replacement():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -172,8 +169,7 @@ Resources:
iam_client.get_user(UserName=new_user_name)
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_update_drop_user():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -234,8 +230,7 @@ Resources:
assert e.value.response["Error"]["Code"] == "NoSuchEntity"
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_delete_user():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -264,8 +259,7 @@ Resources:
assert e.value.response["Error"]["Code"] == "NoSuchEntity"
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_delete_user_having_generated_name():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -294,8 +288,7 @@ Resources:
assert e.value.response["Error"]["Code"] == "NoSuchEntity"
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_user_get_attr():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -336,8 +329,7 @@ Outputs:
# AWS::IAM::ManagedPolicy Tests
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_managed_policy():
iam_client = boto3.client("iam", region_name="us-east-1")
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -380,8 +372,7 @@ Resources:
assert policy["Path"] == "/"
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_managed_policy_with_additional_properties():
iam_client = boto3.client("iam", region_name="us-east-1")
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -425,8 +416,7 @@ Resources:
assert policy["PolicyName"] == name
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_managed_policy_attached_to_a_group():
iam_client = boto3.client("iam", region_name="us-east-1")
group_name = "MyGroup"
@@ -474,8 +464,7 @@ Resources:
assert "GroupId" in response["PolicyGroups"][0]
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_managed_policy_attached_to_a_user():
iam_client = boto3.client("iam", region_name="us-east-1")
user_name = "MyUser"
@@ -523,8 +512,7 @@ Resources:
assert "UserId" in response["PolicyUsers"][0]
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_managed_policy_attached_to_a_role():
iam_client = boto3.client("iam", region_name="us-east-1")
role_name = "MyRole"
@@ -573,9 +561,7 @@ Resources:
# AWS::IAM::Policy Tests
-@mock_s3
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_user_policy():
iam_client = boto3.client("iam", region_name="us-east-1")
user_name = "MyUser"
@@ -623,9 +609,7 @@ Resources:
assert policy["PolicyDocument"] == original_policy_document
-@mock_s3
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_update_user_policy():
iam_client = boto3.client("iam", region_name="us-east-1")
user_name_1 = "MyUser1"
@@ -711,9 +695,7 @@ Resources:
iam_client.get_user_policy(UserName=user_name_1, PolicyName=policy_name)
-@mock_s3
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_delete_user_policy_having_generated_name():
iam_client = boto3.client("iam", region_name="us-east-1")
user_name = "MyUser"
@@ -765,9 +747,7 @@ Resources:
iam_client.get_user_policy(UserName=user_name, PolicyName=policy_name)
-@mock_s3
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_role_policy():
iam_client = boto3.client("iam", region_name="us-east-1")
role_name = "MyRole"
@@ -815,9 +795,7 @@ Resources:
assert policy["PolicyDocument"] == original_policy_document
-@mock_s3
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_update_role_policy():
iam_client = boto3.client("iam", region_name="us-east-1")
role_name_1 = "MyRole1"
@@ -903,9 +881,7 @@ Resources:
iam_client.get_role_policy(RoleName=role_name_1, PolicyName=policy_name)
-@mock_s3
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_delete_role_policy_having_generated_name():
iam_client = boto3.client("iam", region_name="us-east-1")
role_name = "MyRole"
@@ -958,9 +934,7 @@ Resources:
assert exc.value.response["Error"]["Code"] == "NoSuchEntity"
-@mock_s3
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_group_policy():
iam_client = boto3.client("iam", region_name="us-east-1")
group_name = "MyGroup"
@@ -1008,9 +982,7 @@ Resources:
assert policy["PolicyDocument"] == original_policy_document
-@mock_s3
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_update_group_policy():
iam_client = boto3.client("iam", region_name="us-east-1")
group_name_1 = "MyGroup1"
@@ -1097,9 +1069,7 @@ Resources:
assert exc.value.response["Error"]["Code"] == "NoSuchEntity"
-@mock_s3
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_delete_group_policy_having_generated_name():
iam_client = boto3.client("iam", region_name="us-east-1")
group_name = "MyGroup"
@@ -1153,8 +1123,7 @@ Resources:
# AWS::IAM::User AccessKeys
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_user_with_access_key():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -1197,9 +1166,7 @@ Resources:
assert access_keys["AccessKeyMetadata"][0]["UserName"] == user_name
-@mock_sts
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_access_key_get_attr():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -1255,8 +1222,7 @@ Outputs:
pass
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_delete_users_access_key():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -1312,8 +1278,7 @@ def test_iam_cloudformation_delete_users_access_key():
assert exc.value.response["Error"]["Code"] == "NoSuchEntity"
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_update_users_access_key_no_interruption():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -1369,8 +1334,7 @@ Resources:
assert access_keys["AccessKeyMetadata"][0]["Status"] == "Inactive"
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_update_users_access_key_replacement():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -1435,8 +1399,7 @@ Resources:
assert access_key_id != access_keys["AccessKeyMetadata"][0]["AccessKeyId"]
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_role():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -1459,8 +1422,7 @@ def test_iam_cloudformation_create_role():
assert len(iam_client.list_roles()["Roles"]) == 0
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_cloudformation_create_role_and_instance_profile():
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -1493,9 +1455,7 @@ def test_iam_cloudformation_create_role_and_instance_profile():
assert len(iam_client.list_roles()["Roles"]) == 0
-@mock_autoscaling
-@mock_iam
-@mock_cloudformation
+@mock_aws
def test_iam_roles():
iam_template = {
"AWSTemplateFormatVersion": "2010-09-09",
diff --git a/tests/test_iam/test_iam_groups.py b/tests/test_iam/test_iam_groups.py
index f526bf756..eedc4cccf 100644
--- a/tests/test_iam/test_iam_groups.py
+++ b/tests/test_iam/test_iam_groups.py
@@ -7,7 +7,7 @@ from botocore.exceptions import ClientError
from dateutil.tz import tzlocal
from freezegun import freeze_time
-from moto import mock_iam, settings
+from moto import mock_aws, settings
from moto.backends import get_backend
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core.utils import utcnow
@@ -25,7 +25,7 @@ MOCK_POLICY = """
"""
-@mock_iam
+@mock_aws
def test_create_group():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -36,7 +36,7 @@ def test_create_group():
assert err["Message"] is None
-@mock_iam
+@mock_aws
def test_get_group():
conn = boto3.client("iam", region_name="us-east-1")
created = conn.create_group(GroupName="my-group")["Group"]
@@ -56,7 +56,7 @@ def test_get_group():
assert err["Message"] == "Group not-group not found"
-@mock_iam()
+@mock_aws()
def test_get_group_current():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -78,7 +78,7 @@ def test_get_group_current():
)
-@mock_iam
+@mock_aws
def test_get_all_groups():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group1")
@@ -89,7 +89,7 @@ def test_get_all_groups():
assert all([g["CreateDate"] for g in groups])
-@mock_iam
+@mock_aws
def test_add_unknown_user_to_group():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -99,7 +99,7 @@ def test_add_unknown_user_to_group():
assert err["Message"] == "The user with name my-user cannot be found."
-@mock_iam
+@mock_aws
def test_add_user_to_unknown_group():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_user(UserName="my-user")
@@ -110,7 +110,7 @@ def test_add_user_to_unknown_group():
assert err["Message"] == "Group my-group not found"
-@mock_iam
+@mock_aws
def test_add_user_to_group():
# Setup
frozen_time = datetime(2023, 5, 20, 10, 20, 30, tzinfo=tzlocal())
@@ -142,7 +142,7 @@ def test_add_user_to_group():
assert result["Users"][0]["PasswordLastUsed"] == frozen_time
-@mock_iam
+@mock_aws
def test_remove_user_from_unknown_group():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -152,7 +152,7 @@ def test_remove_user_from_unknown_group():
assert err["Message"] == "Group my-group not found"
-@mock_iam
+@mock_aws
def test_remove_nonattached_user_from_group():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -164,7 +164,7 @@ def test_remove_nonattached_user_from_group():
assert err["Message"] == "User my-user not in group my-group"
-@mock_iam
+@mock_aws
def test_remove_user_from_group():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -173,7 +173,7 @@ def test_remove_user_from_group():
conn.remove_user_from_group(GroupName="my-group", UserName="my-user")
-@mock_iam
+@mock_aws
def test_add_user_should_be_idempotent():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -190,7 +190,7 @@ def test_add_user_should_be_idempotent():
assert len(conn.list_groups_for_user(UserName="my-user")["Groups"]) == 0
-@mock_iam
+@mock_aws
def test_get_groups_for_user():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group1")
@@ -204,7 +204,7 @@ def test_get_groups_for_user():
assert len(groups) == 2
-@mock_iam
+@mock_aws
def test_put_group_policy():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -213,7 +213,7 @@ def test_put_group_policy():
)
-@mock_iam
+@mock_aws
def test_attach_group_policies():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -238,7 +238,7 @@ def test_attach_group_policies():
)
-@mock_iam
+@mock_aws
def test_get_group_policy():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -257,7 +257,7 @@ def test_get_group_policy():
assert policy["PolicyDocument"] == json.loads(MOCK_POLICY)
-@mock_iam()
+@mock_aws()
def test_list_group_policies():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -270,7 +270,7 @@ def test_list_group_policies():
]
-@mock_iam
+@mock_aws
def test_delete_group():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -281,7 +281,7 @@ def test_delete_group():
assert conn.list_groups()["Groups"] == []
-@mock_iam
+@mock_aws
def test_delete_unknown_group():
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError) as err:
@@ -293,7 +293,7 @@ def test_delete_unknown_group():
)
-@mock_iam
+@mock_aws
def test_update_group_name():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group")
@@ -313,7 +313,7 @@ def test_update_group_name():
assert ":group/new-group" in result["Arn"]
-@mock_iam
+@mock_aws
def test_update_group_name_that_has_a_path():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group", Path="/path")
@@ -325,7 +325,7 @@ def test_update_group_name_that_has_a_path():
assert new["Path"] == "/path"
-@mock_iam
+@mock_aws
def test_update_group_path():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="my-group", Path="/path")
@@ -339,7 +339,7 @@ def test_update_group_path():
assert new["Path"] == "/new-path"
-@mock_iam
+@mock_aws
def test_update_group_that_does_not_exist():
conn = boto3.client("iam", region_name="us-east-1")
@@ -350,7 +350,7 @@ def test_update_group_that_does_not_exist():
assert err["Message"] == "The group with name nonexisting cannot be found."
-@mock_iam
+@mock_aws
def test_update_group_with_existing_name():
conn = boto3.client("iam", region_name="us-east-1")
conn.create_group(GroupName="existing1")
diff --git a/tests/test_iam/test_iam_oidc.py b/tests/test_iam/test_iam_oidc.py
index 174f9349f..b7c526e57 100644
--- a/tests/test_iam/test_iam_oidc.py
+++ b/tests/test_iam/test_iam_oidc.py
@@ -4,11 +4,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iam
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_iam
+@mock_aws
def test_create_open_id_connect_provider():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -49,7 +49,7 @@ def test_create_open_id_connect_provider():
)
-@mock_iam
+@mock_aws
def test_create_open_id_connect_provider_with_tags():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -66,7 +66,7 @@ def test_create_open_id_connect_provider_with_tags():
@pytest.mark.parametrize("url", ["example.org", "example"])
-@mock_iam
+@mock_aws
def test_create_open_id_connect_provider_invalid_url(url):
client = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError) as e:
@@ -75,7 +75,7 @@ def test_create_open_id_connect_provider_invalid_url(url):
assert "Invalid Open ID Connect Provider URL" in msg
-@mock_iam
+@mock_aws
def test_create_open_id_connect_provider_errors():
client = boto3.client("iam", region_name="us-east-1")
client.create_open_id_connect_provider(Url="https://example.com", ThumbprintList=[])
@@ -88,7 +88,7 @@ def test_create_open_id_connect_provider_errors():
assert err["Message"] == "Unknown"
-@mock_iam
+@mock_aws
def test_create_open_id_connect_provider_too_many_entries():
client = boto3.client("iam", region_name="us-east-1")
@@ -108,7 +108,7 @@ def test_create_open_id_connect_provider_too_many_entries():
assert "Thumbprint list must contain fewer than 5 entries." in msg
-@mock_iam
+@mock_aws
def test_create_open_id_connect_provider_quota_error():
client = boto3.client("iam", region_name="us-east-1")
@@ -123,7 +123,7 @@ def test_create_open_id_connect_provider_quota_error():
assert "Cannot exceed quota for ClientIdsPerOpenIdConnectProvider: 100" in msg
-@mock_iam
+@mock_aws
def test_create_open_id_connect_provider_multiple_errors():
client = boto3.client("iam", region_name="us-east-1")
@@ -148,7 +148,7 @@ def test_create_open_id_connect_provider_multiple_errors():
assert "Member must have length less than or equal to 255" in msg
-@mock_iam
+@mock_aws
def test_delete_open_id_connect_provider():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -167,7 +167,7 @@ def test_delete_open_id_connect_provider():
client.delete_open_id_connect_provider(OpenIDConnectProviderArn=open_id_arn)
-@mock_iam
+@mock_aws
def test_get_open_id_connect_provider():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -183,7 +183,7 @@ def test_get_open_id_connect_provider():
assert isinstance(response["CreateDate"], datetime)
-@mock_iam
+@mock_aws
def test_update_open_id_connect_provider():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -203,7 +203,7 @@ def test_update_open_id_connect_provider():
assert "d" * 40 in response["ThumbprintList"]
-@mock_iam
+@mock_aws
def test_get_open_id_connect_provider_errors():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -218,7 +218,7 @@ def test_get_open_id_connect_provider_errors():
assert err["Message"] == f"OpenIDConnect Provider not found for arn {unknown_arn}"
-@mock_iam
+@mock_aws
def test_list_open_id_connect_providers():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -245,7 +245,7 @@ def test_list_open_id_connect_providers():
]
-@mock_iam
+@mock_aws
def test_tag_open_id_connect_provider():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -263,7 +263,7 @@ def test_tag_open_id_connect_provider():
assert {"Key": "k2", "Value": "v2"} in response["Tags"]
-@mock_iam
+@mock_aws
def test_untag_open_id_connect_provider():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -283,7 +283,7 @@ def test_untag_open_id_connect_provider():
assert {"Key": "k1", "Value": "v1"} in response["Tags"]
-@mock_iam
+@mock_aws
def test_list_open_id_connect_provider_tags():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -301,7 +301,7 @@ def test_list_open_id_connect_provider_tags():
assert {"Key": "k2", "Value": "v2"} in response["Tags"]
-@mock_iam
+@mock_aws
def test_list_open_id_connect_provider_tags__paginated():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
@@ -331,7 +331,7 @@ def test_list_open_id_connect_provider_tags__paginated():
assert "Marker" not in response
-@mock_iam
+@mock_aws
def test_list_open_id_connect_provider_tags__maxitems():
client = boto3.client("iam", region_name="us-east-1")
response = client.create_open_id_connect_provider(
diff --git a/tests/test_iam/test_iam_password_last_used.py b/tests/test_iam/test_iam_password_last_used.py
index 8940fd102..c4b7b38a8 100644
--- a/tests/test_iam/test_iam_password_last_used.py
+++ b/tests/test_iam/test_iam_password_last_used.py
@@ -2,13 +2,13 @@ from unittest import SkipTest
import boto3
-from moto import mock_iam, settings
+from moto import mock_aws, settings
from moto.backends import get_backend
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core.utils import utcnow
-@mock_iam
+@mock_aws
def test_password_last_used():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set password_last_used in ServerMode")
diff --git a/tests/test_iam/test_iam_policies.py b/tests/test_iam/test_iam_policies.py
index 66ccbc503..9872a7ad5 100644
--- a/tests/test_iam/test_iam_policies.py
+++ b/tests/test_iam/test_iam_policies.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iam
+from moto import mock_aws
invalid_policy_document_test_cases = [
{
@@ -1626,7 +1626,7 @@ valid_policy_documents = [
@pytest.mark.parametrize("invalid_policy_document", invalid_policy_document_test_cases)
-@mock_iam
+@mock_aws
def test_create_policy_with_invalid_policy_document(invalid_policy_document):
conn = boto3.client("iam", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -1641,7 +1641,7 @@ def test_create_policy_with_invalid_policy_document(invalid_policy_document):
@pytest.mark.parametrize("valid_policy_document", valid_policy_documents)
-@mock_iam
+@mock_aws
def test_create_policy_with_valid_policy_document(valid_policy_document):
conn = boto3.client("iam", region_name="us-east-1")
conn.create_policy(
diff --git a/tests/test_iam/test_iam_resets.py b/tests/test_iam/test_iam_resets.py
index dc63f204f..91508f778 100644
--- a/tests/test_iam/test_iam_resets.py
+++ b/tests/test_iam/test_iam_resets.py
@@ -2,12 +2,12 @@ import json
import boto3
-from moto import mock_iam
+from moto import mock_aws
# Test IAM User Inline Policy
def test_policies_are_not_kept_after_mock_ends():
- with mock_iam():
+ with mock_aws():
iam_client = boto3.client("iam", "us-east-1")
role_name = "test"
assume_role_policy_document = {
@@ -34,6 +34,6 @@ def test_policies_are_not_kept_after_mock_ends():
assert iam_policies[0]["Arn"] == "arn:aws:iam::aws:policy/ReadOnlyAccess"
assert iam_client.list_roles()["Roles"][0]["RoleName"] == "test"
- with mock_iam():
+ with mock_aws():
resp = iam_client.list_policies(Scope="AWS", OnlyAttached=True)
assert len(resp["Policies"]) == 0
diff --git a/tests/test_iam/test_iam_server_certificates.py b/tests/test_iam/test_iam_server_certificates.py
index e5fdffa6c..9dde3ee5a 100644
--- a/tests/test_iam/test_iam_server_certificates.py
+++ b/tests/test_iam/test_iam_server_certificates.py
@@ -4,11 +4,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iam
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_iam
+@mock_aws
def test_get_all_server_certs():
conn = boto3.client("iam", region_name="us-east-1")
@@ -24,7 +24,7 @@ def test_get_all_server_certs():
assert cert1["Arn"] == f"arn:aws:iam::{ACCOUNT_ID}:server-certificate/certname"
-@mock_iam
+@mock_aws
def test_get_server_cert_doesnt_exist():
conn = boto3.client("iam", region_name="us-east-1")
@@ -38,7 +38,7 @@ def test_get_server_cert_doesnt_exist():
)
-@mock_iam
+@mock_aws
def test_get_server_cert():
conn = boto3.client("iam", region_name="us-east-1")
@@ -62,7 +62,7 @@ def test_get_server_cert():
assert isinstance(metadata["Expiration"], datetime)
-@mock_iam
+@mock_aws
def test_delete_server_cert():
conn = boto3.client("iam", region_name="us-east-1")
@@ -83,7 +83,7 @@ def test_delete_server_cert():
)
-@mock_iam
+@mock_aws
def test_delete_unknown_server_cert():
conn = boto3.client("iam", region_name="us-east-1")
diff --git a/tests/test_identitystore/test_identitystore.py b/tests/test_identitystore/test_identitystore.py
index 1c565cc6f..bac5ef428 100644
--- a/tests/test_identitystore/test_identitystore.py
+++ b/tests/test_identitystore/test_identitystore.py
@@ -1,4 +1,3 @@
-"""Unit tests for identitystore-supported APIs."""
import random
import string
from uuid import UUID, uuid4
@@ -7,7 +6,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_identitystore
+from moto import mock_aws
from moto.moto_api._internal import mock_random
# See our Development Tips on writing tests for hints on how to write good tests:
@@ -19,7 +18,7 @@ def get_identity_store_id() -> str:
return f"d-{rand}"
-@mock_identitystore
+@mock_aws
def test_create_group():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -32,7 +31,7 @@ def test_create_group():
assert UUID(create_resp["GroupId"])
-@mock_identitystore
+@mock_aws
def test_create_group_duplicate_name():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -64,7 +63,7 @@ def test_create_group_duplicate_name():
assert err.response["Reason"] == "UNIQUENESS_CONSTRAINT_VIOLATION"
-@mock_identitystore
+@mock_aws
def test_group_multiple_identity_stores():
identity_store_id = get_identity_store_id()
identity_store_id2 = get_identity_store_id()
@@ -79,7 +78,7 @@ def test_group_multiple_identity_stores():
assert not __group_exists(client, group2[0], store_id=identity_store_id)
-@mock_identitystore
+@mock_aws
def test_create_group_membership():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -111,7 +110,7 @@ def test_create_group_membership():
assert list_response["GroupMemberships"][0]["MemberId"]["UserId"] == user_id
-@mock_identitystore
+@mock_aws
def test_create_duplicate_username():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -146,7 +145,7 @@ def test_create_duplicate_username():
assert err.response["Reason"] == "UNIQUENESS_CONSTRAINT_VIOLATION"
-@mock_identitystore
+@mock_aws
def test_create_username_no_username():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -166,7 +165,7 @@ def test_create_username_no_username():
assert err.response["Message"] == "userName is a required attribute"
-@mock_identitystore
+@mock_aws
def test_create_username_missing_required_attributes():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -194,7 +193,7 @@ def test_create_username_missing_required_attributes():
)
-@mock_identitystore
+@mock_aws
@pytest.mark.parametrize(
"field, missing", [("GivenName", "familyname"), ("FamilyName", "givenname")]
)
@@ -225,7 +224,7 @@ def test_create_username_missing_required_name_field(field, missing):
assert err.response["Message"] == f"{missing}: The attribute {missing} is required"
-@mock_identitystore
+@mock_aws
def test_create_describe_sparse_user():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -248,7 +247,7 @@ def test_create_describe_sparse_user():
assert user_resp["Name"]["FamilyName"] == "family_name"
-@mock_identitystore
+@mock_aws
def test_create_describe_full_user():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -343,7 +342,7 @@ def test_create_describe_full_user():
assert user_resp["Timezone"] == "timezone"
-@mock_identitystore
+@mock_aws
def test_describe_user_doesnt_exist():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -362,7 +361,7 @@ def test_describe_user_doesnt_exist():
assert "RequestId" in err.response
-@mock_identitystore
+@mock_aws
def test_get_group_id():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -389,7 +388,7 @@ def test_get_group_id():
assert response["GroupId"] == group_id
-@mock_identitystore
+@mock_aws
def test_get_group_id_does_not_exist():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -412,7 +411,7 @@ def test_get_group_id_does_not_exist():
assert "RequestId" in err.response
-@mock_identitystore
+@mock_aws
def test_list_groups():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -465,7 +464,7 @@ def test_list_groups():
assert groups == expected_groups
-@mock_identitystore
+@mock_aws
def test_list_groups_filter():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -504,7 +503,7 @@ def test_list_groups_filter():
assert len(no_groups) == 0
-@mock_identitystore
+@mock_aws
def test_list_group_memberships():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -560,7 +559,7 @@ def test_list_group_memberships():
next_token = list_response["NextToken"]
-@mock_identitystore
+@mock_aws
def test_list_group_memberships_for_member():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -622,7 +621,7 @@ def __check_membership_list_values(members, expected):
assert members[i]["MemberId"]["UserId"] == expected[i][1]
-@mock_identitystore
+@mock_aws
def test_list_users():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -665,7 +664,7 @@ def test_list_users():
assert users == expected_users
-@mock_identitystore
+@mock_aws
def test_list_users_filter():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -705,7 +704,7 @@ def test_list_users_filter():
assert len(no_users) == 0
-@mock_identitystore
+@mock_aws
def test_delete_group():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -720,7 +719,7 @@ def test_delete_group():
assert not __group_exists(client, test_group[0], identity_store_id)
-@mock_identitystore
+@mock_aws
def test_delete_group_doesnt_exist():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -734,7 +733,7 @@ def test_delete_group_doesnt_exist():
assert not __group_exists(client, bogus_id, identity_store_id)
-@mock_identitystore
+@mock_aws
def test_delete_group_membership():
client = boto3.client("identitystore", region_name="eu-west-1")
identity_store_id = get_identity_store_id()
@@ -764,7 +763,7 @@ def test_delete_group_membership():
assert len(response["GroupMemberships"]) == 0
-@mock_identitystore
+@mock_aws
def test_delete_user():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -778,7 +777,7 @@ def test_delete_user():
assert err.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_identitystore
+@mock_aws
def test_delete_user_doesnt_exist():
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -789,7 +788,7 @@ def test_delete_user_doesnt_exist():
)
-@mock_identitystore
+@mock_aws
def test_create_describe_group() -> None:
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
@@ -806,7 +805,7 @@ def test_create_describe_group() -> None:
assert client_response["IdentityStoreId"] == identity_store_id
-@mock_identitystore
+@mock_aws
def test_describe_group_doesnt_exist() -> None:
client = boto3.client("identitystore", region_name="us-east-2")
identity_store_id = get_identity_store_id()
diff --git a/tests/test_inspector2/test_inspector2.py b/tests/test_inspector2/test_inspector2.py
index 52ff5a020..82f4c6e8c 100644
--- a/tests/test_inspector2/test_inspector2.py
+++ b/tests/test_inspector2/test_inspector2.py
@@ -1,12 +1,12 @@
import boto3
-from moto import mock_inspector2
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_inspector2
+@mock_aws
def test_create_filter():
client = boto3.client("inspector2", region_name="us-east-2")
resp = client.create_filter(
@@ -21,7 +21,7 @@ def test_create_filter():
assert "arn" in resp
-@mock_inspector2
+@mock_aws
def test_list_filters():
client = boto3.client("inspector2", region_name="ap-southeast-1")
assert client.list_filters()["filters"] == []
diff --git a/tests/test_inspector2/test_inspector2_admin_accounts.py b/tests/test_inspector2/test_inspector2_admin_accounts.py
index d8e6a7174..6b2c380b7 100644
--- a/tests/test_inspector2/test_inspector2_admin_accounts.py
+++ b/tests/test_inspector2/test_inspector2_admin_accounts.py
@@ -1,12 +1,12 @@
import boto3
-from moto import mock_inspector2
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_inspector2
+@mock_aws
def test_deleted_accounts():
client = boto3.client("inspector2", region_name="us-east-1")
diff --git a/tests/test_inspector2/test_inspector2_enable.py b/tests/test_inspector2/test_inspector2_enable.py
index 9dc152a23..a861c323e 100644
--- a/tests/test_inspector2/test_inspector2_enable.py
+++ b/tests/test_inspector2/test_inspector2_enable.py
@@ -1,13 +1,13 @@
import boto3
-from moto import mock_inspector2
+from moto import mock_aws
from tests import DEFAULT_ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_inspector2
+@mock_aws
def test_organization_configuration():
client = boto3.client("inspector2", region_name="us-west-1")
diff --git a/tests/test_inspector2/test_inspector2_findings.py b/tests/test_inspector2/test_inspector2_findings.py
index dbaa01213..bb09996b8 100644
--- a/tests/test_inspector2/test_inspector2_findings.py
+++ b/tests/test_inspector2/test_inspector2_findings.py
@@ -1,10 +1,10 @@
import boto3
import requests
-from moto import mock_inspector2, settings
+from moto import mock_aws, settings
-@mock_inspector2
+@mock_aws
def test_set_findings():
base_url = (
"localhost:5000" if settings.TEST_SERVER_MODE else "motoapi.amazonaws.com"
diff --git a/tests/test_inspector2/test_inspector2_members.py b/tests/test_inspector2/test_inspector2_members.py
index 5be4595fe..902e45ad9 100644
--- a/tests/test_inspector2/test_inspector2_members.py
+++ b/tests/test_inspector2/test_inspector2_members.py
@@ -1,13 +1,13 @@
import boto3
-from moto import mock_inspector2
+from moto import mock_aws
from tests import DEFAULT_ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_inspector2
+@mock_aws
def test_members():
client = boto3.client("inspector2", region_name="us-east-1")
diff --git a/tests/test_inspector2/test_inspector2_organization.py b/tests/test_inspector2/test_inspector2_organization.py
index b37590c05..fed133956 100644
--- a/tests/test_inspector2/test_inspector2_organization.py
+++ b/tests/test_inspector2/test_inspector2_organization.py
@@ -1,12 +1,12 @@
import boto3
-from moto import mock_inspector2
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_inspector2
+@mock_aws
def test_organization_configuration():
client = boto3.client("inspector2", region_name="us-west-1")
diff --git a/tests/test_inspector2/test_inspector2_tags.py b/tests/test_inspector2/test_inspector2_tags.py
index 4897b3a91..a9223e6ce 100644
--- a/tests/test_inspector2/test_inspector2_tags.py
+++ b/tests/test_inspector2/test_inspector2_tags.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_inspector2
+from moto import mock_aws
-@mock_inspector2
+@mock_aws
def test_tag_resource():
client = boto3.client("inspector2", region_name="ap-southeast-1")
arn = client.create_filter(
@@ -27,7 +27,7 @@ def test_tag_resource():
assert client.list_tags_for_resource(resourceArn=arn)["tags"] == {"k2": "v2"}
-@mock_inspector2
+@mock_aws
def test_tag_filter():
client = boto3.client("inspector2", region_name="ap-southeast-1")
arn = client.create_filter(
diff --git a/tests/test_iot/test_iot.py b/tests/test_iot/test_iot.py
index 030fd6a92..c5656d783 100644
--- a/tests/test_iot/test_iot.py
+++ b/tests/test_iot/test_iot.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iot
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_iot
+@mock_aws
def test_endpoints():
region_name = "ap-northeast-1"
client = boto3.client("iot", region_name=region_name)
@@ -35,7 +35,7 @@ def test_endpoints():
assert err["Code"] == "InvalidRequestException"
-@mock_iot
+@mock_aws
def test_principal_policy():
client = boto3.client("iot", region_name="ap-northeast-1")
policy_name = "my-policy"
@@ -77,7 +77,7 @@ def test_principal_policy():
assert e.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_iot
+@mock_aws
def test_principal_policy_deprecated():
client = boto3.client("iot", region_name="ap-northeast-1")
policy_name = "my-policy"
@@ -109,7 +109,7 @@ def test_principal_policy_deprecated():
assert len(res["principals"]) == 0
-@mock_iot
+@mock_aws
def test_principal_thing():
client = boto3.client("iot", region_name="ap-northeast-1")
thing_name = "my-thing"
diff --git a/tests/test_iot/test_iot_ca_certificates.py b/tests/test_iot/test_iot_ca_certificates.py
index f84324a49..9b75b7be7 100644
--- a/tests/test_iot/test_iot_ca_certificates.py
+++ b/tests/test_iot/test_iot_ca_certificates.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iot
+from moto import mock_aws
-@mock_iot
+@mock_aws
def test_register_ca_certificate_simple():
client = boto3.client("iot", region_name="us-east-1")
@@ -18,7 +18,7 @@ def test_register_ca_certificate_simple():
assert "certificateId" in resp
-@mock_iot
+@mock_aws
def test_describe_ca_certificate_unknown():
client = boto3.client("iot", region_name="us-east-2")
@@ -28,7 +28,7 @@ def test_describe_ca_certificate_unknown():
assert err["Code"] == "ResourceNotFoundException"
-@mock_iot
+@mock_aws
def test_describe_ca_certificate_simple():
client = boto3.client("iot", region_name="us-east-1")
@@ -47,7 +47,7 @@ def test_describe_ca_certificate_simple():
assert description["certificatePem"] == "ca_certificate"
-@mock_iot
+@mock_aws
def test_describe_ca_certificate_advanced():
client = boto3.client("iot", region_name="us-east-1")
@@ -74,7 +74,7 @@ def test_describe_ca_certificate_advanced():
assert config["roleArn"] == "aws:iot:arn:role/asdfqwerwe"
-@mock_iot
+@mock_aws
def test_list_certificates_by_ca():
client = boto3.client("iot", region_name="us-east-1")
@@ -111,7 +111,7 @@ def test_list_certificates_by_ca():
assert len(certs["certificates"]) == 1
-@mock_iot
+@mock_aws
def test_delete_ca_certificate():
client = boto3.client("iot", region_name="us-east-1")
@@ -128,7 +128,7 @@ def test_delete_ca_certificate():
assert err["Code"] == "ResourceNotFoundException"
-@mock_iot
+@mock_aws
def test_update_ca_certificate__status():
client = boto3.client("iot", region_name="us-east-1")
cert_id = client.register_ca_certificate(
@@ -147,7 +147,7 @@ def test_update_ca_certificate__status():
}
-@mock_iot
+@mock_aws
def test_update_ca_certificate__config():
client = boto3.client("iot", region_name="us-east-1")
cert_id = client.register_ca_certificate(
@@ -168,7 +168,7 @@ def test_update_ca_certificate__config():
}
-@mock_iot
+@mock_aws
def test_get_registration_code():
client = boto3.client("iot", region_name="us-west-1")
diff --git a/tests/test_iot/test_iot_certificates.py b/tests/test_iot/test_iot_certificates.py
index 8773c2ed9..248758126 100644
--- a/tests/test_iot/test_iot_certificates.py
+++ b/tests/test_iot/test_iot_certificates.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iot
+from moto import mock_aws
-@mock_iot
+@mock_aws
def test_certificate_id_generation_deterministic():
# Creating the same certificate twice should result in the same certificate ID
client = boto3.client("iot", region_name="us-east-1")
@@ -19,7 +19,7 @@ def test_certificate_id_generation_deterministic():
client.delete_certificate(certificateId=cert2["certificateId"])
-@mock_iot
+@mock_aws
def test_create_certificate_from_csr():
csr = "-----BEGIN CERTIFICATE REQUEST-----\nMIICijCCAXICAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx\nITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBAMSUg2mO7mYnhvYUB55K0/ay9WLLgPjOHnbduyCv\nN+udkJaZc+A65ux9LvVo33VHDTlV2Ms9H/42on902WtuS3BNuxdXfD068CpN2lb6\nbSAeuKc6Fdu4BIP2bFYKCyejqBoOmTEhYA8bOM1Wu/pRsq1PkAmcGkvw3mlRx45E\nB2LRicWcg3YEleEBGyLYohyeMu0pnlsc7zsu5T4bwrjetdbDPVbzgu0Mf/evU9hJ\nG/IisXNxQhzPh/DTQsKZSNddZ4bmkAQrRN1nmNXD6QoxBiVyjjgKGrPnX+hz4ugm\naaN9CsOO/cad1E3C0KiI0BQCjxRb80wOpI4utz4pEcY97sUCAwEAAaAAMA0GCSqG\nSIb3DQEBBQUAA4IBAQC64L4JHvwxdxmnXT9Lv12p5CGx99d7VOXQXy29b1yH9cJ+\nFaQ2TH377uOdorSCS4bK7eje9/HLsCNgqftR0EruwSNnukF695BWN8e/AJSZe0vA\n3J/llZ6G7MWuOIhCswsOxqNnM1htu3o6ujXVrgBMeMgQy2tfylWfI7SGR6UmtLYF\nZrPaqXdkpt47ROJNCm2Oht1B0J3QEOmbIp/2XMxrfknzwH6se/CjuliiXVPYxrtO\n5hbZcRqjhugb8FWtaLirqh3Q3+1UIJ+CW0ZczsblP7DNdqqt8YQZpWVIqR64mSXV\nAjq/cupsJST9fey8chcNSTt4nKxOGs3OgXu1ftgy\n-----END CERTIFICATE REQUEST-----\n"
client = boto3.client("iot", region_name="us-east-2")
@@ -35,7 +35,7 @@ def test_create_certificate_from_csr():
assert len(client.list_certificates()["certificates"]) == 2
-@mock_iot
+@mock_aws
def test_create_key_and_certificate():
client = boto3.client("iot", region_name="us-east-1")
cert = client.create_keys_and_certificate(setAsActive=True)
@@ -46,7 +46,7 @@ def test_create_key_and_certificate():
assert cert["keyPair"]["PrivateKey"].startswith("-----BEGIN RSA PRIVATE KEY-----")
-@mock_iot
+@mock_aws
def test_describe_certificate_by_id():
client = boto3.client("iot", region_name="us-east-1")
cert = client.create_keys_and_certificate(setAsActive=True)
@@ -64,7 +64,7 @@ def test_describe_certificate_by_id():
assert cert_desc["status"] == "ACTIVE"
-@mock_iot
+@mock_aws
def test_list_certificates():
client = boto3.client("iot", region_name="us-east-1")
cert = client.create_keys_and_certificate(setAsActive=True)
@@ -83,7 +83,7 @@ def test_list_certificates():
assert cert_desc["status"] == "REVOKED"
-@mock_iot
+@mock_aws
def test_update_certificate():
client = boto3.client("iot", region_name="us-east-1")
cert = client.create_keys_and_certificate(setAsActive=True)
@@ -96,7 +96,7 @@ def test_update_certificate():
@pytest.mark.parametrize("status", ["REVOKED", "INACTIVE"])
-@mock_iot
+@mock_aws
def test_delete_certificate_with_status(status):
client = boto3.client("iot", region_name="us-east-1")
cert = client.create_keys_and_certificate(setAsActive=True)
@@ -110,7 +110,7 @@ def test_delete_certificate_with_status(status):
assert res["certificates"] == []
-@mock_iot
+@mock_aws
def test_register_certificate_without_ca():
client = boto3.client("iot", region_name="us-east-1")
cert = client.create_keys_and_certificate(setAsActive=True)
@@ -141,7 +141,7 @@ def test_register_certificate_without_ca():
assert "certificates" in res
-@mock_iot
+@mock_aws
def test_create_certificate_validation():
# Test we can't create a cert that already exists
client = boto3.client("iot", region_name="us-east-1")
@@ -168,7 +168,7 @@ def test_create_certificate_validation():
)
-@mock_iot
+@mock_aws
def test_delete_certificate_validation():
doc = """{
"Version": "2012-10-17",
@@ -229,7 +229,7 @@ def test_delete_certificate_validation():
assert len(res["certificates"]) == 0
-@mock_iot
+@mock_aws
def test_delete_certificate_force():
policy_name = "my-policy"
client = boto3.client("iot", "us-east-1")
@@ -254,7 +254,7 @@ def test_delete_certificate_force():
assert len(res["certificates"]) == 0
-@mock_iot
+@mock_aws
def test_delete_thing_with_certificate_validation():
client = boto3.client("iot", region_name="ap-northeast-1")
cert = client.create_keys_and_certificate(setAsActive=True)
@@ -286,7 +286,7 @@ def test_delete_thing_with_certificate_validation():
assert res["certificates"][0]["status"] == "REVOKED"
-@mock_iot
+@mock_aws
def test_certs_create_inactive():
client = boto3.client("iot", region_name="ap-northeast-1")
cert = client.create_keys_and_certificate(setAsActive=False)
diff --git a/tests/test_iot/test_iot_deprecate_thing_type.py b/tests/test_iot/test_iot_deprecate_thing_type.py
index 95b7dd3ab..8ffadb027 100644
--- a/tests/test_iot/test_iot_deprecate_thing_type.py
+++ b/tests/test_iot/test_iot_deprecate_thing_type.py
@@ -1,10 +1,10 @@
import boto3
import pytest
-from moto import mock_iot
+from moto import mock_aws
-@mock_iot
+@mock_aws
def test_deprecate_undeprecate_thing_type():
client = boto3.client("iot", region_name="ap-northeast-1")
thing_type_name = "my-type-name"
@@ -26,7 +26,7 @@ def test_deprecate_undeprecate_thing_type():
assert res["thingTypeMetadata"]["deprecated"] is False
-@mock_iot
+@mock_aws
def test_deprecate_thing_type_not_exist():
client = boto3.client("iot", region_name="ap-northeast-1")
thing_type_name = "my-type-name"
@@ -34,7 +34,7 @@ def test_deprecate_thing_type_not_exist():
client.deprecate_thing_type(thingTypeName=thing_type_name, undoDeprecate=False)
-@mock_iot
+@mock_aws
def test_create_thing_with_deprecated_type():
client = boto3.client("iot", region_name="ap-northeast-1")
thing_type_name = "my-type-name"
@@ -47,7 +47,7 @@ def test_create_thing_with_deprecated_type():
client.create_thing(thingName="thing-name", thingTypeName=thing_type_name)
-@mock_iot
+@mock_aws
def test_update_thing_with_deprecated_type():
client = boto3.client("iot", region_name="ap-northeast-1")
thing_type_name = "my-type-name"
diff --git a/tests/test_iot/test_iot_domain_configuration.py b/tests/test_iot/test_iot_domain_configuration.py
index b2f93600c..d4ad95aab 100644
--- a/tests/test_iot/test_iot_domain_configuration.py
+++ b/tests/test_iot/test_iot_domain_configuration.py
@@ -1,10 +1,10 @@
import boto3
import pytest
-from moto import mock_iot
+from moto import mock_aws
-@mock_iot
+@mock_aws
def test_create_domain_configuration_only_name():
client = boto3.client("iot", region_name="us-east-1")
domain_config = client.create_domain_configuration(
@@ -14,7 +14,7 @@ def test_create_domain_configuration_only_name():
assert domain_config["domainConfigurationArn"] is not None
-@mock_iot
+@mock_aws
def test_create_duplicate_domain_configuration_fails():
client = boto3.client("iot", region_name="us-east-1")
domain_config = client.create_domain_configuration(
@@ -29,7 +29,7 @@ def test_create_duplicate_domain_configuration_fails():
assert err["Message"] == "Domain configuration with given name already exists."
-@mock_iot
+@mock_aws
def test_create_domain_configuration_full_params():
client = boto3.client("iot", region_name="us-east-1")
domain_config = client.create_domain_configuration(
@@ -47,7 +47,7 @@ def test_create_domain_configuration_full_params():
assert domain_config["domainConfigurationArn"] is not None
-@mock_iot
+@mock_aws
def test_create_domain_configuration_invalid_service_type():
client = boto3.client("iot", region_name="us-east-1")
with pytest.raises(client.exceptions.InvalidRequestException) as exc:
@@ -62,7 +62,7 @@ def test_create_domain_configuration_invalid_service_type():
)
-@mock_iot
+@mock_aws
def test_describe_nonexistent_domain_configuration():
client = boto3.client("iot", region_name="us-east-1")
with pytest.raises(client.exceptions.ResourceNotFoundException) as exc:
@@ -72,7 +72,7 @@ def test_describe_nonexistent_domain_configuration():
assert err["Message"] == "The specified resource does not exist."
-@mock_iot
+@mock_aws
def test_describe_domain_configuration():
client = boto3.client("iot", region_name="us-east-1")
@@ -100,7 +100,7 @@ def test_describe_domain_configuration():
assert described_config["lastStatusChangeDate"]
-@mock_iot
+@mock_aws
def test_update_domain_configuration():
client = boto3.client("iot", region_name="us-east-1")
client.create_domain_configuration(
@@ -128,7 +128,7 @@ def test_update_domain_configuration():
assert updated["domainConfigurationStatus"] == "DISABLED"
-@mock_iot
+@mock_aws
def test_update_domain_configuration_remove_authorizer_type():
client = boto3.client("iot", region_name="us-east-1")
client.create_domain_configuration(
@@ -149,7 +149,7 @@ def test_update_domain_configuration_remove_authorizer_type():
assert "authorizerConfig" not in config
-@mock_iot
+@mock_aws
def test_update_nonexistent_domain_configuration():
client = boto3.client("iot", region_name="us-east-1")
with pytest.raises(client.exceptions.ResourceNotFoundException) as exc:
@@ -159,7 +159,7 @@ def test_update_nonexistent_domain_configuration():
assert err["Message"] == "The specified resource does not exist."
-@mock_iot
+@mock_aws
def test_list_domain_configuration():
client = boto3.client("iot", region_name="us-east-1")
client.create_domain_configuration(domainConfigurationName="testConfig1")
@@ -170,7 +170,7 @@ def test_list_domain_configuration():
assert domain_configs[1]["domainConfigurationName"] == "testConfig2"
-@mock_iot
+@mock_aws
def test_delete_domain_configuration():
client = boto3.client("iot", region_name="us-east-1")
client.create_domain_configuration(domainConfigurationName="testConfig")
@@ -181,7 +181,7 @@ def test_delete_domain_configuration():
assert len(domain_configs["domainConfigurations"]) == 0
-@mock_iot
+@mock_aws
def test_delete_nonexistent_domain_configuration():
client = boto3.client("iot", region_name="us-east-1")
with pytest.raises(client.exceptions.ResourceNotFoundException) as exc:
diff --git a/tests/test_iot/test_iot_job_executions.py b/tests/test_iot/test_iot_job_executions.py
index 8295aa5e5..13df3302c 100644
--- a/tests/test_iot/test_iot_job_executions.py
+++ b/tests/test_iot/test_iot_job_executions.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iot
+from moto import mock_aws
-@mock_iot
+@mock_aws
def test_describe_job_execution():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -72,7 +72,7 @@ def test_describe_job_execution():
assert error_code == "ResourceNotFoundException"
-@mock_iot
+@mock_aws
def test_cancel_job_execution():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -108,7 +108,7 @@ def test_cancel_job_execution():
assert job_execution["execution"]["status"] == "CANCELED"
-@mock_iot
+@mock_aws
def test_delete_job_execution():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -146,7 +146,7 @@ def test_delete_job_execution():
assert error_code == "ResourceNotFoundException"
-@mock_iot
+@mock_aws
def test_list_job_executions_for_job():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -183,7 +183,7 @@ def test_list_job_executions_for_job():
assert job_execution["executionSummaries"][0]["thingArn"] == thing["thingArn"]
-@mock_iot
+@mock_aws
def test_list_job_executions_for_thing():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -222,7 +222,7 @@ def test_list_job_executions_for_thing():
assert job_execution["executionSummaries"][0]["jobId"] == job_id
-@mock_iot
+@mock_aws
def test_list_job_executions_for_thing_paginated():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
diff --git a/tests/test_iot/test_iot_jobs.py b/tests/test_iot/test_iot_jobs.py
index b939f43e7..4a4a2be16 100644
--- a/tests/test_iot/test_iot_jobs.py
+++ b/tests/test_iot/test_iot_jobs.py
@@ -2,10 +2,10 @@ import json
import boto3
-from moto import mock_iot
+from moto import mock_aws
-@mock_iot
+@mock_aws
def test_create_job():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -39,7 +39,7 @@ def test_create_job():
assert "description" in job
-@mock_iot
+@mock_aws
def test_list_jobs():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -96,7 +96,7 @@ def test_list_jobs():
assert jobs["jobs"][1]["jobId"] == job_id + "1"
-@mock_iot
+@mock_aws
def test_describe_job():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -142,7 +142,7 @@ def test_describe_job():
assert job["jobExecutionsRolloutConfig"]["maximumPerMinute"] == 10
-@mock_iot
+@mock_aws
def test_describe_job_1():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -186,7 +186,7 @@ def test_describe_job_1():
assert job["jobExecutionsRolloutConfig"]["maximumPerMinute"] == 10
-@mock_iot
+@mock_aws
def test_delete_job():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -219,7 +219,7 @@ def test_delete_job():
assert client.list_jobs()["jobs"] == []
-@mock_iot
+@mock_aws
def test_cancel_job():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -259,7 +259,7 @@ def test_cancel_job():
assert job["comment"] == "You are"
-@mock_iot
+@mock_aws
def test_get_job_document_with_document_source():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
@@ -288,7 +288,7 @@ def test_get_job_document_with_document_source():
assert job_document["document"] == ""
-@mock_iot
+@mock_aws
def test_get_job_document_with_document():
client = boto3.client("iot", region_name="eu-west-1")
name = "my-thing"
diff --git a/tests/test_iot/test_iot_policies.py b/tests/test_iot/test_iot_policies.py
index 1d954b6e4..1eb4ea5a8 100644
--- a/tests/test_iot/test_iot_policies.py
+++ b/tests/test_iot/test_iot_policies.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cognitoidentity, mock_iot
+from moto import mock_aws
@pytest.fixture(name="region_name")
@@ -14,7 +14,7 @@ def fixture_region_name():
@pytest.fixture(name="iot_client")
def fixture_iot_client(region_name):
- with mock_iot():
+ with mock_aws():
yield boto3.client("iot", region_name=region_name)
@@ -39,7 +39,7 @@ def test_attach_policy(iot_client, policy):
assert res["policies"][0]["policyName"] == "my-policy"
-@mock_cognitoidentity
+@mock_aws
def test_attach_policy_to_identity(region_name, iot_client, policy):
cognito_identity_client = boto3.client("cognito-identity", region_name=region_name)
identity_pool_name = "test_identity_pool"
diff --git a/tests/test_iot/test_iot_search.py b/tests/test_iot/test_iot_search.py
index 6422ad34d..367d6ff4e 100644
--- a/tests/test_iot/test_iot_search.py
+++ b/tests/test_iot/test_iot_search.py
@@ -1,10 +1,10 @@
import boto3
import pytest
-from moto import mock_iot
+from moto import mock_aws
-@mock_iot
+@mock_aws
@pytest.mark.parametrize(
"query_string,results",
[
@@ -33,7 +33,7 @@ def test_search_things(query_string, results):
assert thing["connectivity"] == {"connected": True}
-@mock_iot
+@mock_aws
@pytest.mark.parametrize(
"query_string,results",
[["attributes.attr0:abc", {"abc"}], ["attributes.attr1:abc", set()]],
diff --git a/tests/test_iot/test_iot_thing_groups.py b/tests/test_iot/test_iot_thing_groups.py
index ac82ac3e5..d7ee9a978 100644
--- a/tests/test_iot/test_iot_thing_groups.py
+++ b/tests/test_iot/test_iot_thing_groups.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iot
+from moto import mock_aws
def generate_thing_group_tree(iot_client, tree_dict, _parent=None):
@@ -54,7 +54,7 @@ class TestListThingGroup:
group_name_1b: {},
}
- @mock_iot
+ @mock_aws
def test_should_list_all_groups(self):
# setup
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -64,7 +64,7 @@ class TestListThingGroup:
assert "thingGroups" in resp
assert len(resp["thingGroups"]) == 8
- @mock_iot
+ @mock_aws
def test_should_list_all_groups_non_recursively(self):
# setup
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -74,7 +74,7 @@ class TestListThingGroup:
assert "thingGroups" in resp
assert len(resp["thingGroups"]) == 2
- @mock_iot
+ @mock_aws
def test_should_list_all_groups_filtered_by_parent(self):
# setup
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -93,7 +93,7 @@ class TestListThingGroup:
client.list_thing_groups(parentGroup="inexistant-group-name")
assert e.value.response["Error"]["Code"] == "ResourceNotFoundException"
- @mock_iot
+ @mock_aws
def test_should_list_all_groups_filtered_by_parent_non_recursively(self):
# setup
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -106,7 +106,7 @@ class TestListThingGroup:
assert "thingGroups" in resp
assert len(resp["thingGroups"]) == 2
- @mock_iot
+ @mock_aws
def test_should_list_all_groups_filtered_by_name_prefix(self):
# setup
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -122,7 +122,7 @@ class TestListThingGroup:
assert "thingGroups" in resp
assert len(resp["thingGroups"]) == 0
- @mock_iot
+ @mock_aws
def test_should_list_all_groups_filtered_by_name_prefix_non_recursively(self):
# setup
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -139,7 +139,7 @@ class TestListThingGroup:
assert "thingGroups" in resp
assert len(resp["thingGroups"]) == 0
- @mock_iot
+ @mock_aws
def test_should_list_all_groups_filtered_by_name_prefix_and_parent(self):
# setup
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -163,7 +163,7 @@ class TestListThingGroup:
assert len(resp["thingGroups"]) == 0
-@mock_iot
+@mock_aws
def test_delete_thing_group():
client = boto3.client("iot", region_name="ap-northeast-1")
group_name_1a = "my-group:name-1a"
@@ -196,7 +196,7 @@ def test_delete_thing_group():
assert res["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_iot
+@mock_aws
def test_describe_thing_group_metadata_hierarchy():
client = boto3.client("iot", region_name="ap-northeast-1")
group_name_1a = "my-group:name-1a"
@@ -310,7 +310,7 @@ def test_describe_thing_group_metadata_hierarchy():
assert "version" in desc3d
-@mock_iot
+@mock_aws
def test_thing_groups():
client = boto3.client("iot", region_name="ap-northeast-1")
group_name = "my-group:name"
@@ -378,7 +378,7 @@ def test_thing_groups():
assert "key1" not in res_props
-@mock_iot
+@mock_aws
def test_thing_group_relations():
client = boto3.client("iot", region_name="ap-northeast-1")
name = "my-thing"
@@ -443,7 +443,7 @@ def test_thing_group_relations():
assert len(things["things"]) == 0
-@mock_iot
+@mock_aws
def test_thing_group_already_exists_with_different_properties_raises():
client = boto3.client("iot", region_name="ap-northeast-1")
thing_group_name = "my-group-name"
@@ -459,7 +459,7 @@ def test_thing_group_already_exists_with_different_properties_raises():
client.create_thing_group(thingGroupName=thing_group_name)
-@mock_iot
+@mock_aws
def test_thing_group_already_exists_with_same_properties_returned():
client = boto3.client("iot", region_name="ap-northeast-1")
thing_group_name = "my-group-name"
@@ -476,7 +476,7 @@ def test_thing_group_already_exists_with_same_properties_returned():
assert thing_group == current_thing_group
-@mock_iot
+@mock_aws
def test_thing_group_updates_description():
client = boto3.client("iot", region_name="ap-northeast-1")
name = "my-thing-group"
@@ -497,7 +497,7 @@ def test_thing_group_updates_description():
)
-@mock_iot
+@mock_aws
def test_thing_group_update_with_no_previous_attributes_no_merge():
client = boto3.client("iot", region_name="ap-northeast-1")
name = "my-group-name"
@@ -521,7 +521,7 @@ def test_thing_group_update_with_no_previous_attributes_no_merge():
] == {"key1": "val01"}
-@mock_iot
+@mock_aws
def test_thing_group_update_with_no_previous_attributes_with_merge():
client = boto3.client("iot", region_name="ap-northeast-1")
name = "my-group-name"
@@ -545,7 +545,7 @@ def test_thing_group_update_with_no_previous_attributes_with_merge():
] == {"key1": "val01"}
-@mock_iot
+@mock_aws
def test_thing_group_updated_with_empty_attributes_no_merge_no_attributes_added():
client = boto3.client("iot", region_name="ap-northeast-1")
name = "my-group-name"
diff --git a/tests/test_iot/test_iot_thing_types.py b/tests/test_iot/test_iot_thing_types.py
index 83cede6fe..0e0719b52 100644
--- a/tests/test_iot/test_iot_thing_types.py
+++ b/tests/test_iot/test_iot_thing_types.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_iot
+from moto import mock_aws
-@mock_iot
+@mock_aws
def test_create_thing_type():
client = boto3.client("iot", region_name="ap-northeast-1")
type_name = "my-type-name"
@@ -13,7 +13,7 @@ def test_create_thing_type():
assert type_name in thing_type["thingTypeArn"]
-@mock_iot
+@mock_aws
def test_describe_thing_type():
client = boto3.client("iot", region_name="ap-northeast-1")
type_name = "my-type-name"
@@ -27,7 +27,7 @@ def test_describe_thing_type():
assert type_name in thing_type["thingTypeArn"]
-@mock_iot
+@mock_aws
def test_list_thing_types():
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -47,7 +47,7 @@ def test_list_thing_types():
assert thing_types["thingTypes"][-1]["thingTypeName"] == "100"
-@mock_iot
+@mock_aws
def test_list_thing_types_with_typename_filter():
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -71,7 +71,7 @@ def test_list_thing_types_with_typename_filter():
assert thing_types["thingTypes"][-1]["thingTypeName"] == "thingTypeNameGroup"
-@mock_iot
+@mock_aws
def test_delete_thing_type():
client = boto3.client("iot", region_name="ap-northeast-1")
type_name = "my-type-name"
diff --git a/tests/test_iot/test_iot_things.py b/tests/test_iot/test_iot_things.py
index a922787b8..9415d92a9 100644
--- a/tests/test_iot/test_iot_things.py
+++ b/tests/test_iot/test_iot_things.py
@@ -1,10 +1,10 @@
import boto3
-from moto import mock_iot
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_iot
+@mock_aws
def test_create_thing():
client = boto3.client("iot", region_name="ap-northeast-1")
name = "my-thing"
@@ -20,7 +20,7 @@ def test_create_thing():
assert res["things"][0]["thingArn"] == thing["thingArn"]
-@mock_iot
+@mock_aws
def test_create_thing_with_type():
client = boto3.client("iot", region_name="ap-northeast-1")
name = "my-thing"
@@ -41,7 +41,7 @@ def test_create_thing_with_type():
assert thing["thingTypeName"] == type_name
-@mock_iot
+@mock_aws
def test_update_thing():
client = boto3.client("iot", region_name="ap-northeast-1")
name = "my-thing"
@@ -97,7 +97,7 @@ def test_update_thing():
assert res["things"][0]["attributes"] == {}
-@mock_iot
+@mock_aws
def test_describe_thing():
client = boto3.client("iot", region_name="ap-northeast-1")
name = "my-thing"
@@ -113,7 +113,7 @@ def test_describe_thing():
assert thing["version"] == 1
-@mock_iot
+@mock_aws
def test_delete_thing():
client = boto3.client("iot", region_name="ap-northeast-1")
name = "my-thing"
@@ -127,7 +127,7 @@ def test_delete_thing():
assert len(res["things"]) == 0
-@mock_iot
+@mock_aws
def test_list_things_with_next_token():
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -188,7 +188,7 @@ def test_list_things_with_next_token():
)
-@mock_iot
+@mock_aws
def test_list_things_with_attribute_and_thing_type_filter_and_next_token():
client = boto3.client("iot", region_name="ap-northeast-1")
client.create_thing_type(thingTypeName="my-thing-type")
diff --git a/tests/test_iot/test_iot_topic_rules.py b/tests/test_iot/test_iot_topic_rules.py
index d8003e883..89a425e22 100644
--- a/tests/test_iot/test_iot_topic_rules.py
+++ b/tests/test_iot/test_iot_topic_rules.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iot
+from moto import mock_aws
name = "my-rule"
payload = {
@@ -19,7 +19,7 @@ payload = {
}
-@mock_iot
+@mock_aws
def test_topic_rule_create():
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -32,7 +32,7 @@ def test_topic_rule_create():
assert error_code == "ResourceAlreadyExistsException"
-@mock_iot
+@mock_aws
def test_topic_rule_list():
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -53,7 +53,7 @@ def test_topic_rule_list():
assert rule["topicPattern"] == "topic/*"
-@mock_iot
+@mock_aws
def test_topic_rule_get():
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -79,7 +79,7 @@ def test_topic_rule_get():
assert rrule["sql"] == payload["sql"]
-@mock_iot
+@mock_aws
def test_topic_rule_replace():
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -100,7 +100,7 @@ def test_topic_rule_replace():
assert rule["rule"]["description"] == my_payload["description"]
-@mock_iot
+@mock_aws
def test_topic_rule_disable():
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -119,7 +119,7 @@ def test_topic_rule_disable():
assert rule["rule"]["ruleDisabled"] is True
-@mock_iot
+@mock_aws
def test_topic_rule_enable():
client = boto3.client("iot", region_name="ap-northeast-1")
@@ -140,7 +140,7 @@ def test_topic_rule_enable():
assert rule["rule"]["ruleDisabled"] is False
-@mock_iot
+@mock_aws
def test_topic_rule_delete():
client = boto3.client("iot", region_name="ap-northeast-1")
diff --git a/tests/test_iot/test_server.py b/tests/test_iot/test_server.py
index 9aefb9493..6415af4dd 100644
--- a/tests/test_iot/test_server.py
+++ b/tests/test_iot/test_server.py
@@ -4,14 +4,14 @@ from urllib.parse import quote
import pytest
import moto.server as server
-from moto import mock_iot
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_iot
+@mock_aws
def test_iot_list():
backend = server.create_backend_app("iot")
test_client = backend.test_client()
@@ -28,7 +28,7 @@ def test_iot_list():
pytest.param(False, id="Target Arn in Path is *not* URL encoded"),
],
)
-@mock_iot
+@mock_aws
def test_list_attached_policies(url_encode_arn):
backend = server.create_backend_app("iot")
test_client = backend.test_client()
diff --git a/tests/test_iotdata/test_iotdata.py b/tests/test_iotdata/test_iotdata.py
index 009e5a6d7..73a5e4d1b 100644
--- a/tests/test_iotdata/test_iotdata.py
+++ b/tests/test_iotdata/test_iotdata.py
@@ -5,12 +5,11 @@ import pytest
from botocore.exceptions import ClientError
import moto.iotdata.models
-from moto import mock_iot, mock_iotdata, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_iot
-@mock_iotdata
+@mock_aws
def test_basic():
iot_client = boto3.client("iot", region_name="ap-northeast-1")
client = boto3.client("iot-data", region_name="ap-northeast-1")
@@ -43,8 +42,7 @@ def test_basic():
client.get_thing_shadow(thingName=name)
-@mock_iot
-@mock_iotdata
+@mock_aws
def test_update():
iot_client = boto3.client("iot", region_name="ap-northeast-1")
client = boto3.client("iot-data", region_name="ap-northeast-1")
@@ -94,8 +92,7 @@ def test_update():
assert ex.value.response["Error"]["Message"] == "Version conflict"
-@mock_iot
-@mock_iotdata
+@mock_aws
def test_create_named_shadows():
iot_client = boto3.client("iot", region_name="ap-northeast-1")
client = boto3.client("iot-data", region_name="ap-northeast-1")
@@ -149,7 +146,7 @@ def test_create_named_shadows():
)
-@mock_iotdata
+@mock_aws
def test_publish():
region_name = "ap-northeast-1"
client = boto3.client("iot-data", region_name=region_name)
@@ -165,8 +162,7 @@ def test_publish():
assert ("test/topic3", b"\xbf") in mock_backend.published_payloads
-@mock_iot
-@mock_iotdata
+@mock_aws
def test_delete_field_from_device_shadow():
test_thing_name = "TestThing"
diff --git a/tests/test_iotdata/test_server.py b/tests/test_iotdata/test_server.py
index 4386e1bde..a6a9d595c 100644
--- a/tests/test_iotdata/test_server.py
+++ b/tests/test_iotdata/test_server.py
@@ -3,14 +3,14 @@ from urllib.parse import quote
import pytest
import moto.server as server
-from moto import mock_iotdata
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_iotdata
+@mock_aws
def test_iotdata_list():
backend = server.create_backend_app("iot-data")
test_client = backend.test_client()
@@ -28,7 +28,7 @@ def test_iotdata_list():
pytest.param(False, id="Topic in Path is *not* URL encoded"),
],
)
-@mock_iotdata
+@mock_aws
def test_publish(url_encode_topic):
backend = server.create_backend_app("iot-data")
test_client = backend.test_client()
diff --git a/tests/test_ivs/test_ivs.py b/tests/test_ivs/test_ivs.py
index 0ca8b44f3..15b2ded0e 100644
--- a/tests/test_ivs/test_ivs.py
+++ b/tests/test_ivs/test_ivs.py
@@ -1,21 +1,20 @@
-"""Unit tests for ivs-supported APIs."""
from re import fullmatch
import boto3
from botocore.exceptions import ClientError
from pytest import raises
-from moto import mock_ivs
+from moto import mock_aws
-@mock_ivs
+@mock_aws
def test_create_channel_with_name():
client = boto3.client("ivs", region_name="eu-west-1")
create_response = client.create_channel(name="foo")
assert create_response["channel"]["name"] == "foo"
-@mock_ivs
+@mock_aws
def test_create_channel_defaults():
client = boto3.client("ivs", region_name="eu-west-1")
create_response = client.create_channel(name="foo")
@@ -29,7 +28,7 @@ def test_create_channel_defaults():
assert create_response["streamKey"]["tags"] == {}
-@mock_ivs
+@mock_aws
def test_create_channel_generated_values():
client = boto3.client("ivs", region_name="eu-west-1")
create_response = client.create_channel(name="foo")
@@ -45,7 +44,7 @@ def test_create_channel_generated_values():
assert fullmatch(r"sk_.*", create_response["streamKey"]["value"])
-@mock_ivs
+@mock_aws
def test_create_channel_with_name_and_recording_configuration():
client = boto3.client("ivs", region_name="eu-west-1")
create_response = client.create_channel(
@@ -56,14 +55,14 @@ def test_create_channel_with_name_and_recording_configuration():
assert create_response["channel"]["recordingConfigurationArn"] == "blah"
-@mock_ivs
+@mock_aws
def test_list_channels_empty():
client = boto3.client("ivs", region_name="eu-west-1")
list_response = client.list_channels()
assert list_response["channels"] == []
-@mock_ivs
+@mock_aws
def test_list_channels_one():
client = boto3.client("ivs", region_name="eu-west-1")
client.create_channel(name="foo")
@@ -72,7 +71,7 @@ def test_list_channels_one():
assert list_response["channels"][0]["name"] == "foo"
-@mock_ivs
+@mock_aws
def test_list_channels_two():
client = boto3.client("ivs", region_name="eu-west-1")
client.create_channel(name="foo")
@@ -86,7 +85,7 @@ def test_list_channels_two():
assert list_response["channels"][1]["name"] == "bar"
-@mock_ivs
+@mock_aws
def test_list_channels_by_name():
client = boto3.client("ivs", region_name="eu-west-1")
client.create_channel(name="foo")
@@ -99,7 +98,7 @@ def test_list_channels_by_name():
assert list_response["channels"][0]["name"] == "foo"
-@mock_ivs
+@mock_aws
def test_list_channels_by_recording_configuration():
client = boto3.client("ivs", region_name="eu-west-1")
client.create_channel(name="foo")
@@ -112,7 +111,7 @@ def test_list_channels_by_recording_configuration():
assert list_response["channels"][0]["name"] == "bar"
-@mock_ivs
+@mock_aws
def test_list_channels_pagination():
client = boto3.client("ivs", region_name="eu-west-1")
client.create_channel(name="foo")
@@ -127,7 +126,7 @@ def test_list_channels_pagination():
assert "nextToken" not in second_list_response
-@mock_ivs
+@mock_aws
def test_get_channel_exists():
client = boto3.client("ivs", region_name="eu-west-1")
create_response = client.create_channel(name="foo")
@@ -135,7 +134,7 @@ def test_get_channel_exists():
assert get_response["channel"]["name"] == "foo"
-@mock_ivs
+@mock_aws
def test_get_channel_not_exists():
client = boto3.client("ivs", region_name="eu-west-1")
with raises(ClientError) as exc:
@@ -143,7 +142,7 @@ def test_get_channel_not_exists():
assert exc.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_ivs
+@mock_aws
def test_batch_get_channel():
client = boto3.client("ivs", region_name="eu-west-1")
create_response = client.create_channel(name="foo")
@@ -154,7 +153,7 @@ def test_batch_get_channel():
assert batch_get_response["channels"][0]["name"] == "foo"
-@mock_ivs
+@mock_aws
def test_update_channel_exists():
client = boto3.client("ivs", region_name="eu-west-1")
create_response = client.create_channel(
@@ -169,7 +168,7 @@ def test_update_channel_exists():
assert update_response["channel"]["recordingConfigurationArn"] == "blah"
-@mock_ivs
+@mock_aws
def test_update_channel_not_exists():
client = boto3.client("ivs", region_name="eu-west-1")
with raises(ClientError) as exc:
@@ -177,7 +176,7 @@ def test_update_channel_not_exists():
assert exc.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_ivs
+@mock_aws
def test_delete_channel_exists():
client = boto3.client("ivs", region_name="eu-west-1")
create_response = client.create_channel(name="foo")
@@ -186,7 +185,7 @@ def test_delete_channel_exists():
assert list_response["channels"] == []
-@mock_ivs
+@mock_aws
def test_delete_channel_not_exists():
client = boto3.client("ivs", region_name="eu-west-1")
with raises(ClientError) as exc:
diff --git a/tests/test_kinesis/test_kinesis.py b/tests/test_kinesis/test_kinesis.py
index 6ba2f181d..954e2baad 100644
--- a/tests/test_kinesis/test_kinesis.py
+++ b/tests/test_kinesis/test_kinesis.py
@@ -6,12 +6,12 @@ import pytest
from botocore.exceptions import ClientError
from dateutil.tz import tzlocal
-from moto import mock_kinesis
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core.utils import utcnow
-@mock_kinesis
+@mock_aws
def test_stream_creation_on_demand():
client = boto3.client("kinesis", region_name="eu-west-1")
client.create_stream(
@@ -37,7 +37,7 @@ def test_stream_creation_on_demand():
)
-@mock_kinesis
+@mock_aws
def test_update_stream_mode():
client = boto3.client("kinesis", region_name="eu-west-1")
client.create_stream(
@@ -56,7 +56,7 @@ def test_update_stream_mode():
assert stream["StreamModeDetails"] == {"StreamMode": "PROVISIONED"}
-@mock_kinesis
+@mock_aws
def test_describe_non_existent_stream():
client = boto3.client("kinesis", region_name="us-west-2")
with pytest.raises(ClientError) as exc:
@@ -66,7 +66,7 @@ def test_describe_non_existent_stream():
assert err["Message"] == "Stream not-a-stream under account 123456789012 not found."
-@mock_kinesis
+@mock_aws
def test_list_and_delete_stream():
client = boto3.client("kinesis", region_name="us-west-2")
assert len(client.list_streams()["StreamNames"]) == 0
@@ -83,7 +83,7 @@ def test_list_and_delete_stream():
assert len(client.list_streams()["StreamNames"]) == 0
-@mock_kinesis
+@mock_aws
def test_delete_unknown_stream():
client = boto3.client("kinesis", region_name="us-west-2")
with pytest.raises(ClientError) as exc:
@@ -93,7 +93,7 @@ def test_delete_unknown_stream():
assert err["Message"] == "Stream not-a-stream under account 123456789012 not found."
-@mock_kinesis
+@mock_aws
def test_list_many_streams():
conn = boto3.client("kinesis", region_name="us-west-2")
@@ -112,7 +112,7 @@ def test_list_many_streams():
assert has_more_streams is False
-@mock_kinesis
+@mock_aws
def test_describe_stream_summary():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream_summary"
@@ -137,7 +137,7 @@ def test_describe_stream_summary():
assert stream["StreamName"] == stream_name
-@mock_kinesis
+@mock_aws
def test_basic_shard_iterator():
client = boto3.client("kinesis", region_name="us-west-1")
@@ -156,7 +156,7 @@ def test_basic_shard_iterator():
assert resp["MillisBehindLatest"] == 0
-@mock_kinesis
+@mock_aws
def test_basic_shard_iterator_by_stream_arn():
client = boto3.client("kinesis", region_name="us-west-1")
@@ -179,7 +179,7 @@ def test_basic_shard_iterator_by_stream_arn():
assert resp["MillisBehindLatest"] == 0
-@mock_kinesis
+@mock_aws
def test_get_invalid_shard_iterator():
client = boto3.client("kinesis", region_name="us-west-1")
@@ -200,7 +200,7 @@ def test_get_invalid_shard_iterator():
)
-@mock_kinesis
+@mock_aws
def test_put_records():
client = boto3.client("kinesis", region_name="eu-west-2")
@@ -232,7 +232,7 @@ def test_put_records():
assert record["SequenceNumber"] == "1"
-@mock_kinesis
+@mock_aws
def test_get_records_limit():
client = boto3.client("kinesis", region_name="eu-west-2")
@@ -262,7 +262,7 @@ def test_get_records_limit():
assert len(response["Records"]) == 2
-@mock_kinesis
+@mock_aws
def test_get_records_at_sequence_number():
client = boto3.client("kinesis", region_name="eu-west-2")
stream_name = "my_stream_summary"
@@ -301,7 +301,7 @@ def test_get_records_at_sequence_number():
assert resp["Records"][0]["Data"] == b"data_2"
-@mock_kinesis
+@mock_aws
def test_get_records_after_sequence_number():
client = boto3.client("kinesis", region_name="eu-west-2")
stream_name = "my_stream_summary"
@@ -341,7 +341,7 @@ def test_get_records_after_sequence_number():
assert resp["MillisBehindLatest"] == 0
-@mock_kinesis
+@mock_aws
def test_get_records_latest():
client = boto3.client("kinesis", region_name="eu-west-2")
stream_name = "my_stream_summary"
@@ -387,7 +387,7 @@ def test_get_records_latest():
assert resp["MillisBehindLatest"] == 0
-@mock_kinesis
+@mock_aws
def test_get_records_at_timestamp():
# AT_TIMESTAMP - Read the first record at or after the specified timestamp
conn = boto3.client("kinesis", region_name="us-west-2")
@@ -431,7 +431,7 @@ def test_get_records_at_timestamp():
assert response["MillisBehindLatest"] == 0
-@mock_kinesis
+@mock_aws
def test_get_records_at_very_old_timestamp():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -460,7 +460,7 @@ def test_get_records_at_very_old_timestamp():
assert response["MillisBehindLatest"] == 0
-@mock_kinesis
+@mock_aws
def test_get_records_timestamp_filtering():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -490,7 +490,7 @@ def test_get_records_timestamp_filtering():
assert response["MillisBehindLatest"] == 0
-@mock_kinesis
+@mock_aws
def test_get_records_millis_behind_latest():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -512,7 +512,7 @@ def test_get_records_millis_behind_latest():
assert response["MillisBehindLatest"] > 0
-@mock_kinesis
+@mock_aws
def test_get_records_at_very_new_timestamp():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -542,7 +542,7 @@ def test_get_records_at_very_new_timestamp():
assert response["MillisBehindLatest"] == 0
-@mock_kinesis
+@mock_aws
def test_get_records_from_empty_stream_at_timestamp():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -567,7 +567,7 @@ def test_get_records_from_empty_stream_at_timestamp():
assert response["MillisBehindLatest"] == 0
-@mock_kinesis
+@mock_aws
def test_valid_increase_stream_retention_period():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -581,7 +581,7 @@ def test_valid_increase_stream_retention_period():
assert response["StreamDescription"]["RetentionPeriodHours"] == 40
-@mock_kinesis
+@mock_aws
def test_invalid_increase_stream_retention_period():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -601,7 +601,7 @@ def test_invalid_increase_stream_retention_period():
)
-@mock_kinesis
+@mock_aws
def test_invalid_increase_stream_retention_too_low():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -619,7 +619,7 @@ def test_invalid_increase_stream_retention_too_low():
)
-@mock_kinesis
+@mock_aws
def test_invalid_increase_stream_retention_too_high():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -637,7 +637,7 @@ def test_invalid_increase_stream_retention_too_high():
)
-@mock_kinesis
+@mock_aws
def test_valid_decrease_stream_retention_period():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "decrease_stream"
@@ -661,7 +661,7 @@ def test_valid_decrease_stream_retention_period():
assert response["StreamDescription"]["RetentionPeriodHours"] == 26
-@mock_kinesis
+@mock_aws
def test_decrease_stream_retention_period_upwards():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "decrease_stream"
@@ -679,7 +679,7 @@ def test_decrease_stream_retention_period_upwards():
)
-@mock_kinesis
+@mock_aws
def test_decrease_stream_retention_period_too_low():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "decrease_stream"
@@ -697,7 +697,7 @@ def test_decrease_stream_retention_period_too_low():
)
-@mock_kinesis
+@mock_aws
def test_decrease_stream_retention_period_too_high():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "decrease_stream"
@@ -715,7 +715,7 @@ def test_decrease_stream_retention_period_too_high():
)
-@mock_kinesis
+@mock_aws
def test_invalid_shard_iterator_type():
client = boto3.client("kinesis", region_name="eu-west-2")
stream_name = "my_stream_summary"
@@ -732,7 +732,7 @@ def test_invalid_shard_iterator_type():
assert err["Message"] == "Invalid ShardIteratorType: invalid-type"
-@mock_kinesis
+@mock_aws
def test_add_list_remove_tags():
client = boto3.client("kinesis", region_name="eu-west-2")
stream_name = "my_stream_summary"
@@ -772,7 +772,7 @@ def test_add_list_remove_tags():
assert {"Key": "tag5", "Value": "val5"} in tags
-@mock_kinesis
+@mock_aws
def test_merge_shards():
client = boto3.client("kinesis", region_name="eu-west-2")
stream_name = "my_stream_summary"
@@ -847,7 +847,7 @@ def test_merge_shards():
} in active_shards
-@mock_kinesis
+@mock_aws
def test_merge_shards_invalid_arg():
client = boto3.client("kinesis", region_name="eu-west-2")
stream_name = "my_stream_summary"
diff --git a/tests/test_kinesis/test_kinesis_boto3.py b/tests/test_kinesis/test_kinesis_boto3.py
index 300882553..70ef19c3a 100644
--- a/tests/test_kinesis/test_kinesis_boto3.py
+++ b/tests/test_kinesis/test_kinesis_boto3.py
@@ -2,13 +2,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_kinesis
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .test_kinesis import get_stream_arn
-@mock_kinesis
+@mock_aws
def test_describe_stream_limit_parameter():
client = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -38,7 +38,7 @@ def test_describe_stream_limit_parameter():
assert with_filter["HasMoreShards"] is False
-@mock_kinesis
+@mock_aws
def test_list_shards():
conn = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -72,7 +72,7 @@ def test_list_shards():
assert "StartingSequenceNumber" in shard["SequenceNumberRange"]
-@mock_kinesis
+@mock_aws
def test_list_shards_paging():
client = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my_stream"
@@ -119,7 +119,7 @@ def test_list_shards_paging():
assert "NextToken" not in resp
-@mock_kinesis
+@mock_aws
def test_create_shard():
client = boto3.client("kinesis", region_name="us-west-2")
client.create_stream(StreamName="my-stream", ShardCount=2)
@@ -148,7 +148,7 @@ def test_create_shard():
assert "EndingSequenceNumber" not in shards[0]["SequenceNumberRange"]
-@mock_kinesis
+@mock_aws
def test_split_shard_with_invalid_name():
client = boto3.client("kinesis", region_name="us-west-2")
client.create_stream(StreamName="my-stream", ShardCount=2)
@@ -167,7 +167,7 @@ def test_split_shard_with_invalid_name():
)
-@mock_kinesis
+@mock_aws
def test_split_shard_with_unknown_name():
client = boto3.client("kinesis", region_name="us-west-2")
client.create_stream(StreamName="my-stream", ShardCount=2)
@@ -186,7 +186,7 @@ def test_split_shard_with_unknown_name():
)
-@mock_kinesis
+@mock_aws
def test_split_shard_invalid_hashkey():
client = boto3.client("kinesis", region_name="us-west-2")
client.create_stream(StreamName="my-stream", ShardCount=2)
@@ -205,7 +205,7 @@ def test_split_shard_invalid_hashkey():
)
-@mock_kinesis
+@mock_aws
def test_split_shard_hashkey_out_of_bounds():
client = boto3.client("kinesis", region_name="us-west-2")
client.create_stream(StreamName="my-stream", ShardCount=2)
@@ -224,7 +224,7 @@ def test_split_shard_hashkey_out_of_bounds():
)
-@mock_kinesis
+@mock_aws
def test_split_shard():
client = boto3.client("kinesis", region_name="us-west-2")
stream_name = "my-stream"
@@ -279,7 +279,7 @@ def test_split_shard():
assert "EndingSequenceNumber" not in shards[3]["SequenceNumberRange"]
-@mock_kinesis
+@mock_aws
def test_split_shard_that_was_split_before():
client = boto3.client("kinesis", region_name="us-west-2")
client.create_stream(StreamName="my-stream", ShardCount=2)
@@ -305,7 +305,7 @@ def test_split_shard_that_was_split_before():
)
-@mock_kinesis
+@mock_aws
@pytest.mark.parametrize(
"initial,target,expected_total",
[(2, 4, 6), (4, 5, 15), (10, 13, 37), (4, 2, 6), (5, 3, 7), (10, 3, 17)],
diff --git a/tests/test_kinesis/test_kinesis_cloudformation.py b/tests/test_kinesis/test_kinesis_cloudformation.py
index 6b7961a8b..36455c7f8 100644
--- a/tests/test_kinesis/test_kinesis_cloudformation.py
+++ b/tests/test_kinesis/test_kinesis_cloudformation.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_cloudformation, mock_kinesis
+from moto import mock_aws
-@mock_cloudformation
+@mock_aws
def test_kinesis_cloudformation_create_stream():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
@@ -20,8 +20,7 @@ def test_kinesis_cloudformation_create_stream():
assert len(provisioned_resource["PhysicalResourceId"]) > 0
-@mock_cloudformation
-@mock_kinesis
+@mock_aws
def test_kinesis_cloudformation_get_attr():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
@@ -58,8 +57,7 @@ Outputs:
assert output_stream_arn == stream_description["StreamARN"]
-@mock_cloudformation
-@mock_kinesis
+@mock_aws
def test_kinesis_cloudformation_update():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
@@ -142,8 +140,7 @@ Resources:
assert shards_provisioned == 6
-@mock_cloudformation
-@mock_kinesis
+@mock_aws
def test_kinesis_cloudformation_delete():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
diff --git a/tests/test_kinesis/test_kinesis_encryption.py b/tests/test_kinesis/test_kinesis_encryption.py
index a2739cf06..ec950c889 100644
--- a/tests/test_kinesis/test_kinesis_encryption.py
+++ b/tests/test_kinesis/test_kinesis_encryption.py
@@ -1,11 +1,11 @@
import boto3
-from moto import mock_kinesis
+from moto import mock_aws
from .test_kinesis import get_stream_arn
-@mock_kinesis
+@mock_aws
def test_enable_encryption():
client = boto3.client("kinesis", region_name="us-west-2")
client.create_stream(StreamName="my-stream", ShardCount=2)
@@ -25,7 +25,7 @@ def test_enable_encryption():
assert desc["KeyId"] == "n/a"
-@mock_kinesis
+@mock_aws
def test_disable_encryption():
client = boto3.client("kinesis", region_name="us-west-2")
client.create_stream(StreamName="my-stream", ShardCount=2)
@@ -48,7 +48,7 @@ def test_disable_encryption():
assert "KeyId" not in desc
-@mock_kinesis
+@mock_aws
def test_disable_encryption__using_arns():
client = boto3.client("kinesis", region_name="us-west-2")
client.create_stream(StreamName="my-stream", ShardCount=2)
diff --git a/tests/test_kinesis/test_kinesis_monitoring.py b/tests/test_kinesis/test_kinesis_monitoring.py
index e7248ff82..e57500cf6 100644
--- a/tests/test_kinesis/test_kinesis_monitoring.py
+++ b/tests/test_kinesis/test_kinesis_monitoring.py
@@ -1,12 +1,12 @@
import boto3
-from moto import mock_kinesis
+from moto import mock_aws
from tests import DEFAULT_ACCOUNT_ID
from .test_kinesis import get_stream_arn
-@mock_kinesis
+@mock_aws
def test_enable_enhanced_monitoring_all():
client = boto3.client("kinesis", region_name="us-east-1")
stream_name = "my_stream_summary"
@@ -25,7 +25,7 @@ def test_enable_enhanced_monitoring_all():
)
-@mock_kinesis
+@mock_aws
def test_enable_enhanced_monitoring_is_persisted():
client = boto3.client("kinesis", region_name="us-east-1")
stream_name = "my_stream_summary"
@@ -40,7 +40,7 @@ def test_enable_enhanced_monitoring_is_persisted():
assert set(metrics) == {"IncomingBytes", "OutgoingBytes"}
-@mock_kinesis
+@mock_aws
def test_enable_enhanced_monitoring_in_steps():
client = boto3.client("kinesis", region_name="us-east-1")
stream_name = "my_stream_summary"
@@ -70,7 +70,7 @@ def test_enable_enhanced_monitoring_in_steps():
assert "WriteProvisionedThroughputExceeded" in metrics
-@mock_kinesis
+@mock_aws
def test_disable_enhanced_monitoring():
client = boto3.client("kinesis", region_name="us-east-1")
stream_name = "my_stream_summary"
@@ -118,7 +118,7 @@ def test_disable_enhanced_monitoring():
assert len(resp["DesiredShardLevelMetrics"]) == 1
-@mock_kinesis
+@mock_aws
def test_disable_enhanced_monitoring_all():
client = boto3.client("kinesis", region_name="us-east-1")
stream_name = "my_stream_summary"
diff --git a/tests/test_kinesis/test_kinesis_stream_consumers.py b/tests/test_kinesis/test_kinesis_stream_consumers.py
index 9cd81bf09..3c6089a92 100644
--- a/tests/test_kinesis/test_kinesis_stream_consumers.py
+++ b/tests/test_kinesis/test_kinesis_stream_consumers.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_kinesis
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
@@ -13,7 +13,7 @@ def create_stream(client):
return stream["StreamARN"]
-@mock_kinesis
+@mock_aws
def test_list_stream_consumers():
client = boto3.client("kinesis", region_name="eu-west-1")
stream_arn = create_stream(client)
@@ -23,7 +23,7 @@ def test_list_stream_consumers():
assert resp["Consumers"] == []
-@mock_kinesis
+@mock_aws
def test_register_stream_consumer():
client = boto3.client("kinesis", region_name="eu-west-1")
stream_arn = create_stream(client)
@@ -56,7 +56,7 @@ def test_register_stream_consumer():
assert "ConsumerCreationTimestamp" in consumer
-@mock_kinesis
+@mock_aws
def test_describe_stream_consumer_by_name():
client = boto3.client("kinesis", region_name="us-east-2")
stream_arn = create_stream(client)
@@ -75,7 +75,7 @@ def test_describe_stream_consumer_by_name():
assert consumer["StreamARN"] == stream_arn
-@mock_kinesis
+@mock_aws
def test_describe_stream_consumer_by_arn():
client = boto3.client("kinesis", region_name="us-east-2")
stream_arn = create_stream(client)
@@ -95,7 +95,7 @@ def test_describe_stream_consumer_by_arn():
assert consumer["StreamARN"] == stream_arn
-@mock_kinesis
+@mock_aws
def test_describe_stream_consumer_unknown():
client = boto3.client("kinesis", region_name="us-east-2")
create_stream(client)
@@ -108,7 +108,7 @@ def test_describe_stream_consumer_unknown():
assert err["Message"] == f"Consumer {unknown_arn}, account {ACCOUNT_ID} not found."
-@mock_kinesis
+@mock_aws
def test_deregister_stream_consumer_by_name():
client = boto3.client("kinesis", region_name="ap-southeast-1")
stream_arn = create_stream(client)
@@ -123,7 +123,7 @@ def test_deregister_stream_consumer_by_name():
assert len(client.list_stream_consumers(StreamARN=stream_arn)["Consumers"]) == 1
-@mock_kinesis
+@mock_aws
def test_deregister_stream_consumer_by_arn():
client = boto3.client("kinesis", region_name="ap-southeast-1")
stream_arn = create_stream(client)
diff --git a/tests/test_kinesis/test_kinesis_stream_limits.py b/tests/test_kinesis/test_kinesis_stream_limits.py
index 3918c4ebd..eec395c5d 100644
--- a/tests/test_kinesis/test_kinesis_stream_limits.py
+++ b/tests/test_kinesis/test_kinesis_stream_limits.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_kinesis
+from moto import mock_aws
ONE_MB = 2**20
-@mock_kinesis
+@mock_aws
def test_record_data_exceeds_1mb():
client = boto3.client("kinesis", region_name="us-east-1")
client.create_stream(StreamName="my_stream", ShardCount=1)
@@ -24,7 +24,7 @@ def test_record_data_exceeds_1mb():
)
-@mock_kinesis
+@mock_aws
def test_record_data_and_partition_key_exceeds_1mb():
client = boto3.client("kinesis", region_name="us-east-1")
client.create_stream(StreamName="my_stream", ShardCount=1)
@@ -45,7 +45,7 @@ def test_record_data_and_partition_key_exceeds_1mb():
)
-@mock_kinesis
+@mock_aws
def test_record_data_and_partition_key_exactly_1mb():
client = boto3.client("kinesis", region_name="us-east-1")
client.create_stream(StreamName="my_stream", ShardCount=1)
@@ -60,7 +60,7 @@ def test_record_data_and_partition_key_exactly_1mb():
)
-@mock_kinesis
+@mock_aws
def test_record_data_and_partition_key_smaller_than_1mb():
client = boto3.client("kinesis", region_name="us-east-1")
client.create_stream(StreamName="my_stream", ShardCount=1)
@@ -74,7 +74,7 @@ def test_record_data_and_partition_key_smaller_than_1mb():
)
-@mock_kinesis
+@mock_aws
def test_total_record_data_exceeds_5mb():
client = boto3.client("kinesis", region_name="us-east-1")
client.create_stream(StreamName="my_stream", ShardCount=1)
@@ -88,7 +88,7 @@ def test_total_record_data_exceeds_5mb():
assert err["Message"] == "Records size exceeds 5 MB limit"
-@mock_kinesis
+@mock_aws
def test_total_record_data_exact_5mb():
client = boto3.client("kinesis", region_name="us-east-1")
client.create_stream(StreamName="my_stream", ShardCount=1)
@@ -101,7 +101,7 @@ def test_total_record_data_exact_5mb():
)
-@mock_kinesis
+@mock_aws
def test_too_many_records():
client = boto3.client("kinesis", region_name="us-east-1")
client.create_stream(StreamName="my_stream", ShardCount=1)
diff --git a/tests/test_kinesis/test_server.py b/tests/test_kinesis/test_server.py
index 0222991a5..8eb20016e 100644
--- a/tests/test_kinesis/test_server.py
+++ b/tests/test_kinesis/test_server.py
@@ -1,10 +1,10 @@
import json
import moto.server as server
-from moto import mock_kinesis
+from moto import mock_aws
-@mock_kinesis
+@mock_aws
def test_list_streams():
backend = server.create_backend_app("kinesis")
test_client = backend.test_client()
diff --git a/tests/test_kinesisvideo/test_kinesisvideo.py b/tests/test_kinesisvideo/test_kinesisvideo.py
index 0798cbc6e..9a707fc9a 100644
--- a/tests/test_kinesisvideo/test_kinesisvideo.py
+++ b/tests/test_kinesisvideo/test_kinesisvideo.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_kinesisvideo
+from moto import mock_aws
-@mock_kinesisvideo
+@mock_aws
def test_create_stream():
client = boto3.client("kinesisvideo", region_name="ap-northeast-1")
stream_name = "my-stream"
@@ -16,7 +16,7 @@ def test_create_stream():
assert stream_name in res["StreamARN"]
-@mock_kinesisvideo
+@mock_aws
def test_create_stream_with_same_name():
client = boto3.client("kinesisvideo", region_name="ap-northeast-1")
stream_name = "my-stream"
@@ -29,7 +29,7 @@ def test_create_stream_with_same_name():
client.create_stream(StreamName=stream_name, DeviceName=device_name)
-@mock_kinesisvideo
+@mock_aws
def test_describe_stream():
client = boto3.client("kinesisvideo", region_name="ap-northeast-1")
stream_name = "my-stream"
@@ -58,7 +58,7 @@ def test_describe_stream():
assert stream_info["DeviceName"] == device_name
-@mock_kinesisvideo
+@mock_aws
def test_describe_stream_with_name_not_exist():
client = boto3.client("kinesisvideo", region_name="ap-northeast-1")
stream_name_not_exist = "not-exist-stream"
@@ -68,7 +68,7 @@ def test_describe_stream_with_name_not_exist():
client.describe_stream(StreamName=stream_name_not_exist)
-@mock_kinesisvideo
+@mock_aws
def test_list_streams():
client = boto3.client("kinesisvideo", region_name="ap-northeast-1")
stream_name = "my-stream"
@@ -84,7 +84,7 @@ def test_list_streams():
assert len(streams) == 2
-@mock_kinesisvideo
+@mock_aws
def test_delete_stream():
client = boto3.client("kinesisvideo", region_name="ap-northeast-1")
stream_name = "my-stream"
@@ -102,7 +102,7 @@ def test_delete_stream():
assert len(streams) == 1
-@mock_kinesisvideo
+@mock_aws
def test_delete_stream_with_arn_not_exist():
client = boto3.client("kinesisvideo", region_name="ap-northeast-1")
stream_name = "my-stream"
@@ -121,7 +121,7 @@ def test_delete_stream_with_arn_not_exist():
client.delete_stream(StreamARN=stream_arn_not_exist)
-@mock_kinesisvideo
+@mock_aws
def test_data_endpoint():
client = boto3.client("kinesisvideo", region_name="ap-northeast-1")
stream_name = "my-stream"
diff --git a/tests/test_kinesisvideo/test_server.py b/tests/test_kinesisvideo/test_server.py
index dbd7584f8..95571df86 100644
--- a/tests/test_kinesisvideo/test_server.py
+++ b/tests/test_kinesisvideo/test_server.py
@@ -1,12 +1,12 @@
import moto.server as server
-from moto import mock_kinesisvideo
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_kinesisvideo
+@mock_aws
def test_kinesisvideo_server_is_up():
backend = server.create_backend_app("kinesisvideo")
test_client = backend.test_client()
diff --git a/tests/test_kinesisvideoarchivedmedia/test_kinesisvideoarchivedmedia.py b/tests/test_kinesisvideoarchivedmedia/test_kinesisvideoarchivedmedia.py
index ced33ab69..ce8ba9e1a 100644
--- a/tests/test_kinesisvideoarchivedmedia/test_kinesisvideoarchivedmedia.py
+++ b/tests/test_kinesisvideoarchivedmedia/test_kinesisvideoarchivedmedia.py
@@ -2,12 +2,11 @@ from datetime import timedelta
import boto3
-from moto import mock_kinesisvideo, mock_kinesisvideoarchivedmedia
+from moto import mock_aws
from moto.core.utils import utcnow
-@mock_kinesisvideo
-@mock_kinesisvideoarchivedmedia
+@mock_aws
def test_get_hls_streaming_session_url():
region_name = "ap-northeast-1"
kvs_client = boto3.client("kinesisvideo", region_name=region_name)
@@ -29,8 +28,7 @@ def test_get_hls_streaming_session_url():
)
-@mock_kinesisvideo
-@mock_kinesisvideoarchivedmedia
+@mock_aws
def test_get_dash_streaming_session_url():
region_name = "ap-northeast-1"
kvs_client = boto3.client("kinesisvideo", region_name=region_name)
@@ -52,8 +50,7 @@ def test_get_dash_streaming_session_url():
)
-@mock_kinesisvideo
-@mock_kinesisvideoarchivedmedia
+@mock_aws
def test_get_clip():
region_name = "ap-northeast-1"
kvs_client = boto3.client("kinesisvideo", region_name=region_name)
diff --git a/tests/test_kinesisvideoarchivedmedia/test_server.py b/tests/test_kinesisvideoarchivedmedia/test_server.py
index e3341f6c4..60bcbff64 100644
--- a/tests/test_kinesisvideoarchivedmedia/test_server.py
+++ b/tests/test_kinesisvideoarchivedmedia/test_server.py
@@ -1,12 +1,8 @@
import moto.server as server
-from moto import mock_kinesisvideoarchivedmedia
-
-"""
-Test the different server responses
-"""
+from moto import mock_aws
-@mock_kinesisvideoarchivedmedia
+@mock_aws
def test_kinesisvideoarchivedmedia_server_is_up():
backend = server.create_backend_app("kinesis-video-archived-media")
test_client = backend.test_client()
diff --git a/tests/test_kms/__init__.py b/tests/test_kms/__init__.py
index b52dd9f4e..3e557fa3b 100644
--- a/tests/test_kms/__init__.py
+++ b/tests/test_kms/__init__.py
@@ -1,7 +1,7 @@
import os
from functools import wraps
-from moto import mock_kms
+from moto import mock_aws
def kms_aws_verified(func):
@@ -22,7 +22,7 @@ def kms_aws_verified(func):
if allow_aws_request:
return func()
else:
- with mock_kms():
+ with mock_aws():
return func()
return pagination_wrapper
diff --git a/tests/test_kms/test_kms_boto3.py b/tests/test_kms/test_kms_boto3.py
index bcdfeded1..9e4c69179 100644
--- a/tests/test_kms/test_kms_boto3.py
+++ b/tests/test_kms/test_kms_boto3.py
@@ -14,7 +14,7 @@ from cryptography.hazmat.primitives.asymmetric import ec, rsa
from dateutil.tz import tzutc
from freezegun import freeze_time
-from moto import mock_kms
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
PLAINTEXT_VECTORS = [
@@ -31,7 +31,7 @@ def _get_encoded_value(plaintext):
return plaintext.encode("utf-8")
-@mock_kms
+@mock_aws
def test_create_key_without_description():
conn = boto3.client("kms", region_name="us-east-1")
metadata = conn.create_key(Policy="my policy")["KeyMetadata"]
@@ -42,7 +42,7 @@ def test_create_key_without_description():
assert metadata["Description"] == ""
-@mock_kms
+@mock_aws
def test_create_key_with_invalid_key_spec():
conn = boto3.client("kms", region_name="us-east-1")
unsupported_key_spec = "NotSupportedKeySpec"
@@ -57,7 +57,7 @@ def test_create_key_with_invalid_key_spec():
).format(key_spec=unsupported_key_spec)
-@mock_kms
+@mock_aws
def test_create_key():
conn = boto3.client("kms", region_name="us-east-1")
key = conn.create_key(
@@ -119,7 +119,7 @@ def test_create_key():
assert key["KeyMetadata"]["SigningAlgorithms"] == ["ECDSA_SHA_512"]
-@mock_kms
+@mock_aws
def test_create_multi_region_key():
conn = boto3.client("kms", region_name="us-east-1")
key = conn.create_key(
@@ -134,7 +134,7 @@ def test_create_multi_region_key():
assert key["KeyMetadata"]["MultiRegion"] is True
-@mock_kms
+@mock_aws
def test_non_multi_region_keys_should_not_have_multi_region_properties():
conn = boto3.client("kms", region_name="us-east-1")
key = conn.create_key(
@@ -149,7 +149,7 @@ def test_non_multi_region_keys_should_not_have_multi_region_properties():
assert key["KeyMetadata"]["MultiRegion"] is False
-@mock_kms
+@mock_aws
def test_replicate_key():
region_to_replicate_from = "us-east-1"
region_to_replicate_to = "us-west-1"
@@ -180,7 +180,7 @@ def test_replicate_key():
assert "ReplicaPolicy" in replica_response
-@mock_kms
+@mock_aws
def test_create_key_deprecated_master_custom_key_spec():
conn = boto3.client("kms", region_name="us-east-1")
key = conn.create_key(KeyUsage="SIGN_VERIFY", CustomerMasterKeySpec="ECC_NIST_P521")
@@ -193,7 +193,7 @@ def test_create_key_deprecated_master_custom_key_spec():
@pytest.mark.parametrize("id_or_arn", ["KeyId", "Arn"])
-@mock_kms
+@mock_aws
def test_describe_key(id_or_arn):
client = boto3.client("kms", region_name="us-east-1")
response = client.create_key(Description="my key", KeyUsage="ENCRYPT_DECRYPT")
@@ -215,7 +215,7 @@ def test_describe_key(id_or_arn):
assert "SigningAlgorithms" not in response["KeyMetadata"]
-@mock_kms
+@mock_aws
def test_get_key_policy_default():
# given
client = boto3.client("kms", region_name="us-east-1")
@@ -240,7 +240,7 @@ def test_get_key_policy_default():
}
-@mock_kms
+@mock_aws
def test_describe_key_via_alias():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client, description="my key")
@@ -251,7 +251,7 @@ def test_describe_key_via_alias():
assert alias_key["KeyMetadata"]["Description"] == "my key"
-@mock_kms
+@mock_aws
def test__create_alias__can_create_multiple_aliases_for_same_key_id():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -271,7 +271,7 @@ def test__create_alias__can_create_multiple_aliases_for_same_key_id():
} in aliases
-@mock_kms
+@mock_aws
def test_list_aliases():
region = "us-west-1"
client = boto3.client("kms", region_name=region)
@@ -298,7 +298,7 @@ def test_list_aliases():
} in aliases
-@mock_kms
+@mock_aws
def test_list_aliases_for_key_id():
region = "us-west-1"
client = boto3.client("kms", region_name=region)
@@ -317,7 +317,7 @@ def test_list_aliases_for_key_id():
} in aliases
-@mock_kms
+@mock_aws
def test_list_aliases_for_key_arn():
region = "us-west-1"
client = boto3.client("kms", region_name=region)
@@ -349,7 +349,7 @@ def test_list_aliases_for_key_arn():
"invalid",
],
)
-@mock_kms
+@mock_aws
def test_describe_key_via_alias_invalid_alias(key_id):
client = boto3.client("kms", region_name="us-east-1")
@@ -357,7 +357,7 @@ def test_describe_key_via_alias_invalid_alias(key_id):
client.describe_key(KeyId=key_id)
-@mock_kms
+@mock_aws
def test_list_keys():
client = boto3.client("kms", region_name="us-east-1")
with mock.patch.object(rsa, "generate_private_key", return_value=""):
@@ -371,7 +371,7 @@ def test_list_keys():
@pytest.mark.parametrize("id_or_arn", ["KeyId", "Arn"])
-@mock_kms
+@mock_aws
def test_enable_key_rotation(id_or_arn):
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client, id_or_arn=id_or_arn)
@@ -385,7 +385,7 @@ def test_enable_key_rotation(id_or_arn):
assert client.get_key_rotation_status(KeyId=key_id)["KeyRotationEnabled"] is False
-@mock_kms
+@mock_aws
def test_enable_key_rotation_with_alias_name_should_fail():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -398,7 +398,7 @@ def test_enable_key_rotation_with_alias_name_should_fail():
assert err["Message"] == "Invalid keyId alias/my-alias"
-@mock_kms
+@mock_aws
def test_generate_data_key():
kms = boto3.client("kms", region_name="us-west-2")
@@ -428,7 +428,7 @@ def test_generate_data_key():
"arn:aws:kms:us-east-1:012345678912:key/d25652e4-d2d2-49f7-929a-671ccda580c6",
],
)
-@mock_kms
+@mock_aws
def test_invalid_key_ids(key_id):
client = boto3.client("kms", region_name="us-east-1")
@@ -436,7 +436,7 @@ def test_invalid_key_ids(key_id):
client.generate_data_key(KeyId=key_id, NumberOfBytes=5)
-@mock_kms
+@mock_aws
def test_disable_key():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -447,7 +447,7 @@ def test_disable_key():
assert result["KeyMetadata"]["KeyState"] == "Disabled"
-@mock_kms
+@mock_aws
def test_enable_key():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -459,7 +459,7 @@ def test_enable_key():
assert result["KeyMetadata"]["KeyState"] == "Enabled"
-@mock_kms
+@mock_aws
def test_schedule_key_deletion():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -481,7 +481,7 @@ def test_schedule_key_deletion():
assert "DeletionDate" in result["KeyMetadata"]
-@mock_kms
+@mock_aws
def test_schedule_key_deletion_custom():
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(Description="schedule-key-deletion")
@@ -507,7 +507,7 @@ def test_schedule_key_deletion_custom():
assert "DeletionDate" in result["KeyMetadata"]
-@mock_kms
+@mock_aws
def test_cancel_key_deletion():
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(Description="cancel-key-deletion")
@@ -521,7 +521,7 @@ def test_cancel_key_deletion():
assert "DeletionDate" not in result["KeyMetadata"]
-@mock_kms
+@mock_aws
def test_update_key_description():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -530,7 +530,7 @@ def test_update_key_description():
assert "ResponseMetadata" in result
-@mock_kms
+@mock_aws
def test_tag_resource():
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(Description="cancel-key-deletion")
@@ -545,7 +545,7 @@ def test_tag_resource():
assert len(response.keys()) == 1
-@mock_kms
+@mock_aws
def test_list_resource_tags():
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(Description="cancel-key-deletion")
@@ -561,7 +561,7 @@ def test_list_resource_tags():
assert response["Tags"][0]["TagValue"] == "string"
-@mock_kms
+@mock_aws
def test_list_resource_tags_with_arn():
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(Description="cancel-key-deletion")
@@ -575,7 +575,7 @@ def test_list_resource_tags_with_arn():
assert response["Tags"][0]["TagValue"] == "string"
-@mock_kms
+@mock_aws
def test_unknown_tag_methods():
client = boto3.client("kms", region_name="us-east-1")
@@ -598,7 +598,7 @@ def test_unknown_tag_methods():
assert err["Code"] == "NotFoundException"
-@mock_kms
+@mock_aws
def test_list_resource_tags_after_untagging():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -627,7 +627,7 @@ def test_list_resource_tags_after_untagging():
(dict(NumberOfBytes=1024), 1024),
),
)
-@mock_kms
+@mock_aws
def test_generate_data_key_sizes(kwargs, expected_key_length):
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -637,7 +637,7 @@ def test_generate_data_key_sizes(kwargs, expected_key_length):
assert len(response["Plaintext"]) == expected_key_length
-@mock_kms
+@mock_aws
def test_generate_data_key_decrypt():
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(Description="generate-data-key-decrypt")
@@ -659,7 +659,7 @@ def test_generate_data_key_decrypt():
dict(),
],
)
-@mock_kms
+@mock_aws
def test_generate_data_key_invalid_size_params(kwargs):
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(Description="generate-data-key-size")
@@ -677,7 +677,7 @@ def test_generate_data_key_invalid_size_params(kwargs):
"arn:aws:kms:us-east-1:012345678912:key/d25652e4-d2d2-49f7-929a-671ccda580c6",
],
)
-@mock_kms
+@mock_aws
def test_generate_data_key_invalid_key(key_id):
client = boto3.client("kms", region_name="us-east-1")
@@ -694,7 +694,7 @@ def test_generate_data_key_invalid_key(key_id):
("arn:aws:kms:us-east-1:012345678912:key/", True),
],
)
-@mock_kms
+@mock_aws
def test_generate_data_key_all_valid_key_ids(prefix, append_key_id):
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key()
@@ -709,7 +709,7 @@ def test_generate_data_key_all_valid_key_ids(prefix, append_key_id):
assert resp["KeyId"] == f"arn:aws:kms:us-east-1:123456789012:key/{key_id}"
-@mock_kms
+@mock_aws
def test_generate_data_key_without_plaintext_decrypt():
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(Description="generate-data-key-decrypt")
@@ -722,7 +722,7 @@ def test_generate_data_key_without_plaintext_decrypt():
@pytest.mark.parametrize("number_of_bytes", [12, 44, 91, 1, 1024])
-@mock_kms
+@mock_aws
def test_generate_random(number_of_bytes):
client = boto3.client("kms", region_name="us-west-2")
@@ -736,7 +736,7 @@ def test_generate_random(number_of_bytes):
"number_of_bytes,error_type",
[(2048, botocore.exceptions.ClientError), (1025, botocore.exceptions.ClientError)],
)
-@mock_kms
+@mock_aws
def test_generate_random_invalid_number_of_bytes(number_of_bytes, error_type):
client = boto3.client("kms", region_name="us-west-2")
@@ -744,7 +744,7 @@ def test_generate_random_invalid_number_of_bytes(number_of_bytes, error_type):
client.generate_random(NumberOfBytes=number_of_bytes)
-@mock_kms
+@mock_aws
def test_enable_key_rotation_key_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -752,7 +752,7 @@ def test_enable_key_rotation_key_not_found():
client.enable_key_rotation(KeyId="12366f9b-1230-123d-123e-123e6ae60c02")
-@mock_kms
+@mock_aws
def test_disable_key_rotation_key_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -760,7 +760,7 @@ def test_disable_key_rotation_key_not_found():
client.disable_key_rotation(KeyId="12366f9b-1230-123d-123e-123e6ae60c02")
-@mock_kms
+@mock_aws
def test_enable_key_key_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -768,7 +768,7 @@ def test_enable_key_key_not_found():
client.enable_key(KeyId="12366f9b-1230-123d-123e-123e6ae60c02")
-@mock_kms
+@mock_aws
def test_disable_key_key_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -776,7 +776,7 @@ def test_disable_key_key_not_found():
client.disable_key(KeyId="12366f9b-1230-123d-123e-123e6ae60c02")
-@mock_kms
+@mock_aws
def test_cancel_key_deletion_key_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -784,7 +784,7 @@ def test_cancel_key_deletion_key_not_found():
client.cancel_key_deletion(KeyId="12366f9b-1230-123d-123e-123e6ae60c02")
-@mock_kms
+@mock_aws
def test_schedule_key_deletion_key_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -792,7 +792,7 @@ def test_schedule_key_deletion_key_not_found():
client.schedule_key_deletion(KeyId="12366f9b-1230-123d-123e-123e6ae60c02")
-@mock_kms
+@mock_aws
def test_get_key_rotation_status_key_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -800,7 +800,7 @@ def test_get_key_rotation_status_key_not_found():
client.get_key_rotation_status(KeyId="12366f9b-1230-123d-123e-123e6ae60c02")
-@mock_kms
+@mock_aws
def test_get_key_policy_key_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -810,7 +810,7 @@ def test_get_key_policy_key_not_found():
)
-@mock_kms
+@mock_aws
def test_list_key_policies_key_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -818,7 +818,7 @@ def test_list_key_policies_key_not_found():
client.list_key_policies(KeyId="12366f9b-1230-123d-123e-123e6ae60c02")
-@mock_kms
+@mock_aws
def test_put_key_policy_key_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -831,7 +831,7 @@ def test_put_key_policy_key_not_found():
@pytest.mark.parametrize("id_or_arn", ["KeyId", "Arn"])
-@mock_kms
+@mock_aws
def test_get_key_policy(id_or_arn):
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(Description="key1", Policy="my awesome key policy")
@@ -845,7 +845,7 @@ def test_get_key_policy(id_or_arn):
@pytest.mark.parametrize("id_or_arn", ["KeyId", "Arn"])
-@mock_kms
+@mock_aws
def test_put_key_policy(id_or_arn):
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client, id_or_arn)
@@ -856,7 +856,7 @@ def test_put_key_policy(id_or_arn):
assert response["Policy"] == "policy 2.0"
-@mock_kms
+@mock_aws
def test_put_key_policy_using_alias_shouldnt_work():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client, policy="my policy")
@@ -874,7 +874,7 @@ def test_put_key_policy_using_alias_shouldnt_work():
assert response["Policy"] == "my policy"
-@mock_kms
+@mock_aws
def test_list_key_policies():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -887,7 +887,7 @@ def test_list_key_policies():
"reserved_alias",
["alias/aws/ebs", "alias/aws/s3", "alias/aws/redshift", "alias/aws/rds"],
)
-@mock_kms
+@mock_aws
def test__create_alias__raises_if_reserved_alias(reserved_alias):
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -902,7 +902,7 @@ def test__create_alias__raises_if_reserved_alias(reserved_alias):
@pytest.mark.parametrize(
"name", ["alias/my-alias!", "alias/my-alias$", "alias/my-alias@"]
)
-@mock_kms
+@mock_aws
def test__create_alias__raises_if_alias_has_restricted_characters(name):
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -917,7 +917,7 @@ def test__create_alias__raises_if_alias_has_restricted_characters(name):
)
-@mock_kms
+@mock_aws
def test__create_alias__raises_if_alias_has_restricted_characters_semicolon():
# Similar test as above, but with different error msg
client = boto3.client("kms", region_name="us-east-1")
@@ -931,7 +931,7 @@ def test__create_alias__raises_if_alias_has_restricted_characters_semicolon():
@pytest.mark.parametrize("name", ["alias/my-alias_/", "alias/my_alias-/"])
-@mock_kms
+@mock_aws
def test__create_alias__accepted_characters(name):
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -939,7 +939,7 @@ def test__create_alias__accepted_characters(name):
client.create_alias(AliasName=name, TargetKeyId=key_id)
-@mock_kms
+@mock_aws
def test__create_alias__raises_if_target_key_id_is_existing_alias():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -954,7 +954,7 @@ def test__create_alias__raises_if_target_key_id_is_existing_alias():
assert err["Message"] == "Aliases must refer to keys. Not aliases"
-@mock_kms
+@mock_aws
def test__create_alias__raises_if_wrong_prefix():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -966,7 +966,7 @@ def test__create_alias__raises_if_wrong_prefix():
assert err["Message"] == "Invalid identifier"
-@mock_kms
+@mock_aws
def test__create_alias__raises_if_duplicate():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_simple_key(client)
@@ -984,7 +984,7 @@ def test__create_alias__raises_if_duplicate():
)
-@mock_kms
+@mock_aws
def test__delete_alias():
client = boto3.client("kms", region_name="us-east-1")
@@ -1000,7 +1000,7 @@ def test__delete_alias():
client.create_alias(AliasName="alias/a1", TargetKeyId=key_id)
-@mock_kms
+@mock_aws
def test__delete_alias__raises_if_wrong_prefix():
client = boto3.client("kms", region_name="us-east-1")
@@ -1011,7 +1011,7 @@ def test__delete_alias__raises_if_wrong_prefix():
assert err["Message"] == "Invalid identifier"
-@mock_kms
+@mock_aws
def test__delete_alias__raises_if_alias_is_not_found():
client = boto3.client("kms", region_name="us-east-1")
@@ -1041,7 +1041,7 @@ def _check_tags(key_id, created_tags, client):
assert sort(expected) == sort(actual)
-@mock_kms
+@mock_aws
def test_key_tag_on_create_key_happy():
client = boto3.client("kms", region_name="us-east-1")
@@ -1053,7 +1053,7 @@ def test_key_tag_on_create_key_happy():
_check_tags(key["KeyMetadata"]["KeyId"], tags, client)
-@mock_kms
+@mock_aws
def test_key_tag_on_create_key_on_arn_happy():
client = boto3.client("kms", region_name="us-east-1")
@@ -1065,7 +1065,7 @@ def test_key_tag_on_create_key_on_arn_happy():
_check_tags(key["KeyMetadata"]["Arn"], tags, client)
-@mock_kms
+@mock_aws
def test_key_tag_added_happy():
client = boto3.client("kms", region_name="us-east-1")
@@ -1078,7 +1078,7 @@ def test_key_tag_added_happy():
_check_tags(key_id, tags, client)
-@mock_kms
+@mock_aws
def test_key_tag_added_arn_based_happy():
client = boto3.client("kms", region_name="us-east-1")
@@ -1092,7 +1092,7 @@ def test_key_tag_added_arn_based_happy():
@pytest.mark.parametrize("plaintext", PLAINTEXT_VECTORS)
-@mock_kms
+@mock_aws
def test_sign_happy(plaintext):
client = boto3.client("kms", region_name="us-west-2")
@@ -1112,7 +1112,7 @@ def test_sign_happy(plaintext):
assert sign_response["KeyId"] == key_arn
-@mock_kms
+@mock_aws
def test_sign_invalid_signing_algorithm():
client = boto3.client("kms", region_name="us-west-2")
@@ -1134,7 +1134,7 @@ def test_sign_invalid_signing_algorithm():
)
-@mock_kms
+@mock_aws
def test_sign_and_verify_ignoring_grant_tokens():
client = boto3.client("kms", region_name="us-west-2")
@@ -1166,7 +1166,7 @@ def test_sign_and_verify_ignoring_grant_tokens():
assert verify_response["SignatureValid"] is True
-@mock_kms
+@mock_aws
@pytest.mark.parametrize(
"key_spec, signing_algorithm",
list(
@@ -1213,7 +1213,7 @@ def test_sign_and_verify_digest_message_type_RSA(key_spec, signing_algorithm):
assert verify_response["SignatureValid"] is True
-@mock_kms
+@mock_aws
@pytest.mark.parametrize(
"signing_algorithm, another_signing_algorithm",
list(
@@ -1267,7 +1267,7 @@ def test_fail_verify_digest_message_type_RSA(
assert verify_response["SignatureValid"] is False
-@mock_kms
+@mock_aws
@pytest.mark.parametrize(
"key_spec, signing_algorithm",
[
@@ -1307,7 +1307,7 @@ def test_sign_and_verify_digest_message_type_ECDSA(key_spec, signing_algorithm):
assert verify_response["SignatureValid"] is True
-@mock_kms
+@mock_aws
@pytest.mark.parametrize(
"key_spec, signing_algorithm, valid_signing_algorithms",
[
@@ -1351,7 +1351,7 @@ def test_invalid_signing_algorithm_for_key_spec_type_ECDSA(
)
-@mock_kms
+@mock_aws
@pytest.mark.parametrize(
"key_spec, signing_algorithm",
[
@@ -1394,7 +1394,7 @@ def test_fail_verify_digest_message_type_ECDSA(key_spec, signing_algorithm):
assert verify_response["SignatureValid"] is False
-@mock_kms
+@mock_aws
def test_sign_invalid_key_usage():
client = boto3.client("kms", region_name="us-west-2")
@@ -1416,7 +1416,7 @@ def test_sign_invalid_key_usage():
)
-@mock_kms
+@mock_aws
def test_sign_invalid_message():
client = boto3.client("kms", region_name="us-west-2")
@@ -1439,7 +1439,7 @@ def test_sign_invalid_message():
@pytest.mark.parametrize("plaintext", PLAINTEXT_VECTORS)
-@mock_kms
+@mock_aws
def test_verify_happy(plaintext):
client = boto3.client("kms", region_name="us-west-2")
@@ -1468,7 +1468,7 @@ def test_verify_happy(plaintext):
assert verify_response["SignatureValid"] is True
-@mock_kms
+@mock_aws
def test_verify_happy_with_invalid_signature():
client = boto3.client("kms", region_name="us-west-2")
@@ -1491,7 +1491,7 @@ def test_verify_happy_with_invalid_signature():
assert verify_response["SignatureValid"] is False
-@mock_kms
+@mock_aws
def test_verify_invalid_signing_algorithm():
client = boto3.client("kms", region_name="us-west-2")
@@ -1519,7 +1519,7 @@ def test_verify_invalid_signing_algorithm():
)
-@mock_kms
+@mock_aws
def test_verify_invalid_message():
client = boto3.client("kms", region_name="us-west-2")
@@ -1545,7 +1545,7 @@ def test_verify_invalid_message():
)
-@mock_kms
+@mock_aws
def test_verify_empty_signature():
client = boto3.client("kms", region_name="us-west-2")
@@ -1573,7 +1573,7 @@ def test_verify_empty_signature():
)
-@mock_kms
+@mock_aws
def test_get_public_key():
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(KeyUsage="SIGN_VERIFY", KeySpec="RSA_2048")
@@ -1598,7 +1598,7 @@ def create_simple_key(client, id_or_arn="KeyId", description=None, policy=None):
return client.create_key(**params)["KeyMetadata"][id_or_arn]
-@mock_kms
+@mock_aws
def test_ensure_key_can_be_verified_manually():
signing_algorithm: str = "ECDSA_SHA_256"
kms_client = boto3.client("kms", region_name="us-east-1")
diff --git a/tests/test_kms/test_kms_encrypt.py b/tests/test_kms/test_kms_encrypt.py
index 1ad83cffd..5994f0943 100644
--- a/tests/test_kms/test_kms_encrypt.py
+++ b/tests/test_kms/test_kms_encrypt.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_kms
+from moto import mock_aws
from . import kms_aws_verified
from .test_kms_boto3 import PLAINTEXT_VECTORS, _get_encoded_value
@@ -43,7 +43,7 @@ def test_encrypt_key_with_large_content():
@pytest.mark.parametrize("plaintext", PLAINTEXT_VECTORS)
-@mock_kms
+@mock_aws
def test_encrypt(plaintext):
client = boto3.client("kms", region_name="us-west-2")
@@ -61,7 +61,7 @@ def test_encrypt(plaintext):
assert response["KeyId"] == key_arn
-@mock_kms
+@mock_aws
def test_encrypt_using_alias_name():
kms = boto3.client("kms", region_name="us-east-1")
key_details = kms.create_key()
@@ -73,7 +73,7 @@ def test_encrypt_using_alias_name():
kms.decrypt(CiphertextBlob=resp["CiphertextBlob"])
-@mock_kms
+@mock_aws
def test_encrypt_using_alias_arn():
kms = boto3.client("kms", region_name="us-east-1")
key_details = kms.create_key()
@@ -86,7 +86,7 @@ def test_encrypt_using_alias_arn():
kms.encrypt(KeyId=my_alias["AliasArn"], Plaintext="hello")
-@mock_kms
+@mock_aws
def test_encrypt_using_key_arn():
kms = boto3.client("kms", region_name="us-east-1")
key_details = kms.create_key()
@@ -96,7 +96,7 @@ def test_encrypt_using_key_arn():
kms.encrypt(KeyId=key_details["KeyMetadata"]["Arn"], Plaintext="hello")
-@mock_kms
+@mock_aws
def test_re_encrypt_using_aliases():
client = boto3.client("kms", region_name="us-west-2")
@@ -115,7 +115,7 @@ def test_re_encrypt_using_aliases():
@pytest.mark.parametrize("plaintext", PLAINTEXT_VECTORS)
-@mock_kms
+@mock_aws
def test_decrypt(plaintext):
client = boto3.client("kms", region_name="us-west-2")
@@ -141,7 +141,7 @@ def test_decrypt(plaintext):
@pytest.mark.parametrize("plaintext", PLAINTEXT_VECTORS)
-@mock_kms
+@mock_aws
def test_kms_encrypt(plaintext):
client = boto3.client("kms", region_name="us-east-1")
key = client.create_key(Description="key")
@@ -152,7 +152,7 @@ def test_kms_encrypt(plaintext):
@pytest.mark.parametrize("plaintext", PLAINTEXT_VECTORS)
-@mock_kms
+@mock_aws
def test_re_encrypt_decrypt(plaintext):
client = boto3.client("kms", region_name="us-west-2")
@@ -198,7 +198,7 @@ def test_re_encrypt_decrypt(plaintext):
assert decrypt_response_1["Plaintext"] == decrypt_response_2["Plaintext"]
-@mock_kms
+@mock_aws
def test_re_encrypt_to_invalid_destination():
client = boto3.client("kms", region_name="us-west-2")
diff --git a/tests/test_kms/test_kms_grants.py b/tests/test_kms/test_kms_grants.py
index 29a54fb17..8d8012177 100644
--- a/tests/test_kms/test_kms_grants.py
+++ b/tests/test_kms/test_kms_grants.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from cryptography.hazmat.primitives.asymmetric import rsa
-from moto import mock_kms
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
grantee_principal = (
@@ -12,7 +12,7 @@ grantee_principal = (
)
-@mock_kms
+@mock_aws
def test_create_grant():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_key(client)
@@ -27,7 +27,7 @@ def test_create_grant():
assert "GrantToken" in resp
-@mock_kms
+@mock_aws
def test_list_grants():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_key(client)
@@ -79,7 +79,7 @@ def test_list_grants():
assert len(grants) == 0
-@mock_kms
+@mock_aws
def test_list_retirable_grants():
client = boto3.client("kms", region_name="us-east-1")
key_id1 = create_key(client)
@@ -118,7 +118,7 @@ def test_list_retirable_grants():
assert grants[0]["GrantId"] == grant2_key2
-@mock_kms
+@mock_aws
def test_revoke_grant():
client = boto3.client("kms", region_name="us-east-1")
@@ -138,7 +138,7 @@ def test_revoke_grant():
assert len(client.list_grants(KeyId=key_id)["Grants"]) == 0
-@mock_kms
+@mock_aws
def test_revoke_grant_raises_when_grant_does_not_exist():
client = boto3.client("kms", region_name="us-east-1")
key_id = create_key(client)
@@ -154,7 +154,7 @@ def test_revoke_grant_raises_when_grant_does_not_exist():
)
-@mock_kms
+@mock_aws
def test_retire_grant_by_token():
client = boto3.client("kms", region_name="us-east-1")
@@ -173,7 +173,7 @@ def test_retire_grant_by_token():
assert len(client.list_grants(KeyId=key_id)["Grants"]) == 2
-@mock_kms
+@mock_aws
def test_retire_grant_by_grant_id():
client = boto3.client("kms", region_name="us-east-1")
diff --git a/tests/test_kms/test_kms_policy_enforcement.py b/tests/test_kms/test_kms_policy_enforcement.py
index ea9dcb605..9f77f11bf 100644
--- a/tests/test_kms/test_kms_policy_enforcement.py
+++ b/tests/test_kms/test_kms_policy_enforcement.py
@@ -6,13 +6,13 @@ import pytest
from botocore.exceptions import ClientError
from cryptography.hazmat.primitives.asymmetric import rsa
-from moto import mock_kms
+from moto import mock_aws
from moto.kms.exceptions import AccessDeniedException
from moto.kms.models import Key
from moto.kms.policy_validator import validate_policy
-@mock_kms
+@mock_aws
class TestKMSPolicyEnforcement:
def setup_method(self, *args) -> None: # pylint: disable=unused-argument
self.client = boto3.client("kms", "us-east-1")
diff --git a/tests/test_kms/test_server.py b/tests/test_kms/test_server.py
index 5927564da..515635845 100644
--- a/tests/test_kms/test_server.py
+++ b/tests/test_kms/test_server.py
@@ -1,14 +1,14 @@
import json
import moto.server as server
-from moto import mock_kms
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_kms
+@mock_aws
def test_list_keys():
backend = server.create_backend_app("kms")
test_client = backend.test_client()
diff --git a/tests/test_lakeformation/__init__.py b/tests/test_lakeformation/__init__.py
index a7c38a5c7..5b6d3ac0e 100644
--- a/tests/test_lakeformation/__init__.py
+++ b/tests/test_lakeformation/__init__.py
@@ -4,7 +4,7 @@ from uuid import uuid4
import boto3
-from moto import mock_glue, mock_lakeformation, mock_s3, mock_sts
+from moto import mock_aws
def lakeformation_aws_verified(func):
@@ -13,16 +13,13 @@ def lakeformation_aws_verified(func):
Can be run against AWS at any time by setting:
MOTO_TEST_ALLOW_AWS_REQUEST=true
- If this environment variable is not set, the function runs in a `mock_lakeformation`/`mock_sts`/`mock_s3` context.
+ If this environment variable is not set, the function runs in a `mock_aws` context.
Note that LakeFormation is not enabled by default - visit the AWS Console to permit access to the user who executes these tests.
"""
@wraps(func)
def pagination_wrapper():
- glue = boto3.client("glue", region_name="eu-west-2")
- lf = boto3.client("lakeformation", region_name="eu-west-2")
- s3 = boto3.client("s3", region_name="us-east-1")
bucket_name = str(uuid4())
allow_aws_request = (
@@ -30,13 +27,17 @@ def lakeformation_aws_verified(func):
)
if allow_aws_request:
- resp = create_glue_infra_and_test(bucket_name, s3, glue, lf)
+ resp = create_glue_infra_and_test(bucket_name)
else:
- with mock_glue(), mock_lakeformation(), mock_s3(), mock_sts():
- resp = create_glue_infra_and_test(bucket_name, s3, glue, lf)
+ with mock_aws():
+ resp = create_glue_infra_and_test(bucket_name)
return resp
- def create_glue_infra_and_test(bucket_name, s3, glue, lf):
+ def create_glue_infra_and_test(bucket_name):
+ glue = boto3.client("glue", region_name="eu-west-2")
+ lf = boto3.client("lakeformation", region_name="eu-west-2")
+ s3 = boto3.client("s3", region_name="us-east-1")
+
s3.create_bucket(Bucket=bucket_name)
s3.put_bucket_tagging(
Bucket=bucket_name,
diff --git a/tests/test_lakeformation/test_lakeformation.py b/tests/test_lakeformation/test_lakeformation.py
index 305e596e1..57b934e8f 100644
--- a/tests/test_lakeformation/test_lakeformation.py
+++ b/tests/test_lakeformation/test_lakeformation.py
@@ -5,13 +5,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_lakeformation
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_lakeformation
+@mock_aws
def test_register_resource():
client = boto3.client("lakeformation", region_name="us-east-2")
resp = client.register_resource(ResourceArn="some arn", RoleArn="another arn")
@@ -22,7 +22,7 @@ def test_register_resource():
client.register_resource(ResourceArn="some arn", RoleArn="another arn")
-@mock_lakeformation
+@mock_aws
def test_describe_resource():
client = boto3.client("lakeformation", region_name="us-east-2")
client.register_resource(ResourceArn="some arn", RoleArn="role arn")
@@ -32,7 +32,7 @@ def test_describe_resource():
assert resp["ResourceInfo"] == {"ResourceArn": "some arn", "RoleArn": "role arn"}
-@mock_lakeformation
+@mock_aws
def test_deregister_resource():
client = boto3.client("lakeformation", region_name="us-east-2")
client.register_resource(ResourceArn="some arn")
@@ -49,7 +49,7 @@ def test_deregister_resource():
assert err["Code"] == "EntityNotFoundException"
-@mock_lakeformation
+@mock_aws
def test_list_resources():
client = boto3.client("lakeformation", region_name="us-east-2")
@@ -63,7 +63,7 @@ def test_list_resources():
assert len(resp["ResourceInfoList"]) == 2
-@mock_lakeformation
+@mock_aws
def test_data_lake_settings():
client = boto3.client("lakeformation", region_name="us-east-2")
resp = client.get_data_lake_settings()
@@ -93,7 +93,7 @@ def test_data_lake_settings():
assert resp["DataLakeSettings"] == settings
-@mock_lakeformation
+@mock_aws
def test_grant_permissions():
client = boto3.client("lakeformation", region_name="us-east-2")
@@ -115,7 +115,7 @@ def test_grant_permissions():
]
-@mock_lakeformation
+@mock_aws
def test_grant_permissions_idempotent():
client = boto3.client("lakeformation", region_name="us-east-2")
@@ -138,7 +138,7 @@ def test_grant_permissions_idempotent():
]
-@mock_lakeformation
+@mock_aws
def test_grant_permissions_staggered():
client = boto3.client("lakeformation", region_name="us-east-2")
client.grant_permissions(
@@ -159,7 +159,7 @@ def test_grant_permissions_staggered():
)
-@mock_lakeformation
+@mock_aws
def test_list_permissions():
client = boto3.client("lakeformation", region_name="eu-west-2")
@@ -185,7 +185,7 @@ def test_list_permissions():
]
-@mock_lakeformation
+@mock_aws
def test_list_permissions_invalid_input():
client = boto3.client("lakeformation", region_name="eu-west-2")
@@ -309,7 +309,7 @@ def data_location_response(
return response
-@mock_lakeformation
+@mock_aws
def test_list_permissions_filtered_for_catalog_id():
client = boto3.client("lakeformation", region_name="eu-west-2")
catalog_id_1 = "000000000000"
@@ -335,7 +335,7 @@ def test_list_permissions_filtered_for_catalog_id():
assert permissions == [catalog_response(principal=principal_2)]
-@mock_lakeformation
+@mock_aws
def test_list_permissions_filtered_for_resource_type():
client = boto3.client("lakeformation", region_name="eu-west-2")
catalog_id = "000000000000"
@@ -375,7 +375,7 @@ def test_list_permissions_filtered_for_resource_type():
]
-@mock_lakeformation
+@mock_aws
def test_list_permissions_filtered_for_resource_db():
client = boto3.client("lakeformation", region_name="eu-west-2")
catalog_id = "000000000000"
@@ -406,7 +406,7 @@ def test_list_permissions_filtered_for_resource_db():
]
-@mock_lakeformation
+@mock_aws
def test_list_permissions_filtered_for_resource_table():
client = boto3.client("lakeformation", region_name="eu-west-2")
catalog_id = "000000000000"
@@ -453,7 +453,7 @@ def test_list_permissions_filtered_for_resource_table():
]
-@mock_lakeformation
+@mock_aws
def test_list_permissions_filtered_for_resource_data_location():
client = boto3.client("lakeformation", region_name="eu-west-2")
catalog_id = "000000000000"
@@ -492,7 +492,7 @@ def test_list_permissions_filtered_for_resource_data_location():
]
-@mock_lakeformation
+@mock_aws
def test_revoke_permissions():
client = boto3.client("lakeformation", region_name="eu-west-2")
@@ -534,7 +534,7 @@ def test_revoke_permissions():
)
-@mock_lakeformation
+@mock_aws
def test_revoke_permissions_unknown_catalog_id():
client = boto3.client("lakeformation", region_name="eu-west-2")
@@ -559,7 +559,7 @@ def test_revoke_permissions_unknown_catalog_id():
assert len(["PrincipalResourcePermissions"]) == 1
-@mock_lakeformation
+@mock_aws
def test_list_data_cells_filter():
client = boto3.client("lakeformation", region_name="eu-west-2")
@@ -567,7 +567,7 @@ def test_list_data_cells_filter():
assert resp["DataCellsFilters"] == []
-@mock_lakeformation
+@mock_aws
def test_batch_revoke_permissions():
client = boto3.client("lakeformation", region_name="eu-west-2")
diff --git a/tests/test_logs/test_export_tasks.py b/tests/test_logs/test_export_tasks.py
index dafadbd50..8790adabf 100644
--- a/tests/test_logs/test_export_tasks.py
+++ b/tests/test_logs/test_export_tasks.py
@@ -8,7 +8,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_logs, mock_s3, mock_sts, settings
+from moto import mock_aws, settings
from moto.core.utils import unix_time_millis
TEST_REGION = "us-east-1" if settings.TEST_SERVER_MODE else "us-west-2"
@@ -53,7 +53,7 @@ def account_id():
identity = boto3.client("sts", region_name="us-east-1").get_caller_identity()
yield identity["Account"]
else:
- with mock_sts():
+ with mock_aws():
identity = boto3.client(
"sts", region_name="us-east-1"
).get_caller_identity()
@@ -65,7 +65,7 @@ def logs():
if allow_aws_request:
yield boto3.client("logs", region_name="us-east-1")
else:
- with mock_logs():
+ with mock_aws():
yield boto3.client("logs", region_name="us-east-1")
@@ -74,7 +74,7 @@ def s3():
if allow_aws_request:
yield boto3.client("s3", region_name="us-east-1")
else:
- with mock_s3():
+ with mock_aws():
yield boto3.client("s3", region_name="us-east-1")
diff --git a/tests/test_logs/test_integration.py b/tests/test_logs/test_integration.py
index f8e6d64fa..2d1604f04 100644
--- a/tests/test_logs/test_integration.py
+++ b/tests/test_logs/test_integration.py
@@ -9,13 +9,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_firehose, mock_iam, mock_kinesis, mock_lambda, mock_logs, mock_s3
+from moto import mock_aws
from moto.core.utils import unix_time_millis
from tests.markers import requires_docker
-@mock_lambda
-@mock_logs
+@mock_aws
def test_put_subscription_filter_update():
# given
region_name = "us-east-1"
@@ -103,8 +102,7 @@ def test_put_subscription_filter_update():
assert ex.response["Error"]["Message"] == "Resource limit exceeded."
-@mock_lambda
-@mock_logs
+@mock_aws
@pytest.mark.network
@requires_docker
def test_put_subscription_filter_with_lambda():
@@ -188,8 +186,7 @@ def test_put_subscription_filter_with_lambda():
assert log_events[1]["timestamp"] == ts_1
-@mock_lambda
-@mock_logs
+@mock_aws
@pytest.mark.network
@requires_docker
def test_subscription_filter_applies_to_new_streams():
@@ -260,9 +257,7 @@ def test_subscription_filter_applies_to_new_streams():
assert log_events[1]["timestamp"] == ts_1
-@mock_s3
-@mock_firehose
-@mock_logs
+@mock_aws
@pytest.mark.network
def test_put_subscription_filter_with_firehose():
# given
@@ -351,9 +346,7 @@ def test_put_subscription_filter_with_firehose():
assert log_events[1]["timestamp"] == ts_1
-@mock_iam
-@mock_logs
-@mock_kinesis
+@mock_aws
def test_put_subscription_filter_with_kinesis():
logs = boto3.client("logs", "ap-southeast-2")
logs.create_log_group(logGroupName="lg1")
@@ -407,8 +400,7 @@ def test_put_subscription_filter_with_kinesis():
assert nr_of_records == 1
-@mock_lambda
-@mock_logs
+@mock_aws
def test_delete_subscription_filter():
# given
region_name = "us-east-1"
@@ -442,8 +434,7 @@ def test_delete_subscription_filter():
assert len(response["subscriptionFilters"]) == 0
-@mock_lambda
-@mock_logs
+@mock_aws
def test_delete_subscription_filter_errors():
# given
region_name = "us-east-1"
@@ -499,8 +490,7 @@ def test_delete_subscription_filter_errors():
)
-@mock_lambda
-@mock_logs
+@mock_aws
def test_put_subscription_filter_errors():
# given
client_lambda = boto3.client("lambda", "us-east-1")
@@ -584,7 +574,7 @@ def test_put_subscription_filter_errors():
def _get_role_name(region_name):
- with mock_iam():
+ with mock_aws():
iam = boto3.client("iam", region_name=region_name)
try:
return iam.get_role(RoleName="test-role")["Role"]["Arn"]
diff --git a/tests/test_logs/test_logs.py b/tests/test_logs/test_logs.py
index 1e741717a..2f1f0c5e6 100644
--- a/tests/test_logs/test_logs.py
+++ b/tests/test_logs/test_logs.py
@@ -6,7 +6,7 @@ import pytest
from botocore.exceptions import ClientError
from freezegun import freeze_time
-from moto import mock_logs, settings
+from moto import mock_aws, settings
from moto.core.utils import unix_time_millis, utcnow
from moto.logs.models import MAX_RESOURCE_POLICIES_PER_REGION
@@ -47,7 +47,7 @@ access_policy_doc = json.dumps(
)
-@mock_logs
+@mock_aws
def test_describe_metric_filters_happy_prefix():
conn = boto3.client("logs", "us-west-2")
@@ -63,7 +63,7 @@ def test_describe_metric_filters_happy_prefix():
assert response["metricFilters"][1]["filterName"] == "filterName2"
-@mock_logs
+@mock_aws
def test_describe_metric_filters_happy_log_group_name():
conn = boto3.client("logs", "us-west-2")
@@ -78,7 +78,7 @@ def test_describe_metric_filters_happy_log_group_name():
assert response["metricFilters"][0]["logGroupName"] == "logGroupName2"
-@mock_logs
+@mock_aws
def test_describe_metric_filters_happy_metric_name():
conn = boto3.client("logs", "us-west-2")
@@ -97,7 +97,7 @@ def test_describe_metric_filters_happy_metric_name():
assert metrics[0]["metricNamespace"] == "metricNamespace1"
-@mock_logs
+@mock_aws
def test_put_metric_filters_validation():
conn = boto3.client("logs", "us-west-2")
@@ -137,7 +137,7 @@ def test_put_metric_filters_validation():
assert response["Error"]["Code"] == "InvalidParameterException"
-@mock_logs
+@mock_aws
def test_describe_metric_filters_validation():
conn = boto3.client("logs", "us-west-2")
@@ -165,7 +165,7 @@ def test_describe_metric_filters_validation():
assert response["Error"]["Code"] == "InvalidParameterException"
-@mock_logs
+@mock_aws
def test_describe_metric_filters_multiple_happy():
conn = boto3.client("logs", "us-west-2")
@@ -186,7 +186,7 @@ def test_describe_metric_filters_multiple_happy():
assert response["metricFilters"][0]["filterName"] == "filterName1"
-@mock_logs
+@mock_aws
def test_delete_metric_filter():
client = boto3.client("logs", "us-west-2")
@@ -216,7 +216,7 @@ def test_delete_metric_filter():
assert response["metricFilters"] == []
-@mock_logs
+@mock_aws
@pytest.mark.parametrize(
"filter_name, failing_constraint",
[
@@ -241,7 +241,7 @@ def test_delete_metric_filter_invalid_filter_name(filter_name, failing_constrain
assert failing_constraint in response["Error"]["Message"]
-@mock_logs
+@mock_aws
@pytest.mark.parametrize(
"log_group_name, failing_constraint",
[
@@ -268,7 +268,7 @@ def test_delete_metric_filter_invalid_log_group_name(
assert failing_constraint in response["Error"]["Message"]
-@mock_logs
+@mock_aws
def test_destinations():
conn = boto3.client("logs", "us-west-2")
destination_name = "test-destination"
@@ -422,7 +422,7 @@ def build_describe_case(
}
-@mock_logs
+@mock_aws
@pytest.mark.parametrize(
"kms_key_id",
[
@@ -453,7 +453,7 @@ def test_create_log_group(kms_key_id):
assert log_group["kmsKeyId"] == kms_key_id
-@mock_logs
+@mock_aws
def test_exceptions():
conn = boto3.client("logs", TEST_REGION)
log_group_name = "dummy"
@@ -485,7 +485,7 @@ def test_exceptions():
assert error["Message"] == "The specified log stream does not exist."
-@mock_logs
+@mock_aws
def test_put_logs():
conn = boto3.client("logs", TEST_REGION)
log_group_name = "dummy"
@@ -509,7 +509,7 @@ def test_put_logs():
assert len(events) == 2
-@mock_logs
+@mock_aws
def test_put_log_events_in_wrong_order():
conn = boto3.client("logs", "us-east-1")
log_group_name = "test"
@@ -540,7 +540,7 @@ def test_put_log_events_in_wrong_order():
)
-@mock_logs
+@mock_aws
@pytest.mark.parametrize("days_ago", [15, 400])
def test_put_log_events_in_the_past(days_ago):
conn = boto3.client("logs", "us-east-1")
@@ -559,7 +559,7 @@ def test_put_log_events_in_the_past(days_ago):
assert resp["rejectedLogEventsInfo"] == {"tooOldLogEventEndIndex": 0}
-@mock_logs
+@mock_aws
@pytest.mark.parametrize("minutes", [181, 300, 999999])
def test_put_log_events_in_the_future(minutes):
conn = boto3.client("logs", "us-east-1")
@@ -578,7 +578,7 @@ def test_put_log_events_in_the_future(minutes):
assert resp["rejectedLogEventsInfo"] == {"tooNewLogEventStartIndex": 0}
-@mock_logs
+@mock_aws
def test_put_retention_policy():
conn = boto3.client("logs", TEST_REGION)
log_group_name = "dummy"
@@ -593,7 +593,7 @@ def test_put_retention_policy():
conn.delete_log_group(logGroupName=log_group_name)
-@mock_logs
+@mock_aws
def test_delete_log_stream():
logs = boto3.client("logs", TEST_REGION)
logs.create_log_group(logGroupName="logGroup")
@@ -605,7 +605,7 @@ def test_delete_log_stream():
assert resp["logStreams"] == []
-@mock_logs
+@mock_aws
def test_delete_retention_policy():
conn = boto3.client("logs", TEST_REGION)
log_group_name = "dummy"
@@ -626,7 +626,7 @@ def test_delete_retention_policy():
conn.delete_log_group(logGroupName=log_group_name)
-@mock_logs
+@mock_aws
def test_put_resource_policy():
client = boto3.client("logs", TEST_REGION)
@@ -672,7 +672,7 @@ def test_put_resource_policy():
assert created_time < policy_info["lastUpdatedTime"] <= int(unix_time_millis())
-@mock_logs
+@mock_aws
def test_put_resource_policy_too_many():
client = boto3.client("logs", TEST_REGION)
@@ -700,7 +700,7 @@ def test_put_resource_policy_too_many():
)
-@mock_logs
+@mock_aws
def test_delete_resource_policy():
client = boto3.client("logs", TEST_REGION)
@@ -733,7 +733,7 @@ def test_delete_resource_policy():
)
-@mock_logs
+@mock_aws
def test_describe_resource_policies():
client = boto3.client("logs", TEST_REGION)
@@ -759,7 +759,7 @@ def test_describe_resource_policies():
assert policy["lastUpdatedTime"] <= now_millis
-@mock_logs
+@mock_aws
def test_get_log_events():
client = boto3.client("logs", TEST_REGION)
log_group_name = "test"
@@ -852,7 +852,7 @@ def test_get_log_events():
)
-@mock_logs
+@mock_aws
def test_get_log_events_with_start_from_head():
client = boto3.client("logs", TEST_REGION)
log_group_name = "test"
@@ -948,7 +948,7 @@ def test_get_log_events_with_start_from_head():
)
-@mock_logs
+@mock_aws
def test_get_log_events_errors():
client = boto3.client("logs", TEST_REGION)
log_group_name = "test"
@@ -985,7 +985,7 @@ def test_get_log_events_errors():
)
-@mock_logs
+@mock_aws
def test_list_tags_log_group():
conn = boto3.client("logs", TEST_REGION)
log_group_name = "dummy"
@@ -1003,7 +1003,7 @@ def test_list_tags_log_group():
conn.delete_log_group(logGroupName=log_group_name)
-@mock_logs
+@mock_aws
def test_tag_log_group():
conn = boto3.client("logs", TEST_REGION)
log_group_name = "dummy"
@@ -1027,7 +1027,7 @@ def test_tag_log_group():
conn.delete_log_group(logGroupName=log_group_name)
-@mock_logs
+@mock_aws
def test_untag_log_group():
conn = boto3.client("logs", TEST_REGION)
log_group_name = "dummy"
@@ -1047,7 +1047,7 @@ def test_untag_log_group():
conn.delete_log_group(logGroupName=log_group_name)
-@mock_logs
+@mock_aws
def test_describe_subscription_filters():
# given
client = boto3.client("logs", "us-east-1")
@@ -1061,7 +1061,7 @@ def test_describe_subscription_filters():
assert len(response["subscriptionFilters"]) == 0
-@mock_logs
+@mock_aws
def test_describe_subscription_filters_errors():
# given
client = boto3.client("logs", "us-east-1")
@@ -1081,7 +1081,7 @@ def test_describe_subscription_filters_errors():
)
-@mock_logs
+@mock_aws
def test_describe_log_groups_paging():
client = boto3.client("logs", "us-east-1")
@@ -1117,7 +1117,7 @@ def test_describe_log_groups_paging():
assert "nextToken" not in resp
-@mock_logs
+@mock_aws
def test_describe_log_streams_simple_paging():
client = boto3.client("logs", "us-east-1")
@@ -1169,7 +1169,7 @@ def test_describe_log_streams_simple_paging():
assert "nextToken" not in resp
-@mock_logs
+@mock_aws
def test_describe_log_streams_paging():
client = boto3.client("logs", "us-east-1")
@@ -1229,7 +1229,7 @@ def test_describe_log_streams_paging():
@pytest.mark.parametrize("nr_of_events", [10001, 1000000])
-@mock_logs
+@mock_aws
def test_get_too_many_log_events(nr_of_events):
client = boto3.client("logs", "us-east-1")
log_group_name = "dummy"
@@ -1254,7 +1254,7 @@ def test_get_too_many_log_events(nr_of_events):
@pytest.mark.parametrize("nr_of_events", [10001, 1000000])
-@mock_logs
+@mock_aws
def test_filter_too_many_log_events(nr_of_events):
client = boto3.client("logs", "us-east-1")
log_group_name = "dummy"
@@ -1279,7 +1279,7 @@ def test_filter_too_many_log_events(nr_of_events):
@pytest.mark.parametrize("nr_of_groups", [51, 100])
-@mock_logs
+@mock_aws
def test_describe_too_many_log_groups(nr_of_groups):
client = boto3.client("logs", "us-east-1")
with pytest.raises(ClientError) as ex:
@@ -1295,7 +1295,7 @@ def test_describe_too_many_log_groups(nr_of_groups):
@pytest.mark.parametrize("nr_of_streams", [51, 100])
-@mock_logs
+@mock_aws
def test_describe_too_many_log_streams(nr_of_streams):
client = boto3.client("logs", "us-east-1")
log_group_name = "dummy"
@@ -1313,7 +1313,7 @@ def test_describe_too_many_log_streams(nr_of_streams):
@pytest.mark.parametrize("length", [513, 1000])
-@mock_logs
+@mock_aws
def test_create_log_group_invalid_name_length(length):
log_group_name = "a" * length
client = boto3.client("logs", "us-east-1")
@@ -1330,7 +1330,7 @@ def test_create_log_group_invalid_name_length(length):
@pytest.mark.parametrize("invalid_orderby", ["", "sth", "LogStreamname"])
-@mock_logs
+@mock_aws
def test_describe_log_streams_invalid_order_by(invalid_orderby):
client = boto3.client("logs", "us-east-1")
log_group_name = "dummy"
@@ -1352,7 +1352,7 @@ def test_describe_log_streams_invalid_order_by(invalid_orderby):
)
-@mock_logs
+@mock_aws
def test_describe_log_streams_no_prefix():
"""
From the docs: If orderBy is LastEventTime , you cannot specify [logStreamNamePrefix]
diff --git a/tests/test_logs/test_logs_cloudformation.py b/tests/test_logs/test_logs_cloudformation.py
index 016581aff..2edb8f9ef 100644
--- a/tests/test_logs/test_logs_cloudformation.py
+++ b/tests/test_logs/test_logs_cloudformation.py
@@ -2,11 +2,10 @@ import json
import boto3
-from moto import mock_cloudformation, mock_logs
+from moto import mock_aws
-@mock_logs
-@mock_cloudformation
+@mock_aws
def test_tagging():
logs_client = boto3.client("logs", region_name="us-east-1")
cf_client = boto3.client("cloudformation", region_name="us-east-1")
diff --git a/tests/test_logs/test_logs_filter.py b/tests/test_logs/test_logs_filter.py
index 786021be1..44c9251dc 100644
--- a/tests/test_logs/test_logs_filter.py
+++ b/tests/test_logs/test_logs_filter.py
@@ -3,7 +3,7 @@ from unittest import TestCase
import boto3
-from moto import mock_logs
+from moto import mock_aws
from moto.core.utils import unix_time_millis, utcnow
TEST_REGION = "eu-west-1"
@@ -20,7 +20,7 @@ class TestLogFilter(TestCase):
)
-@mock_logs
+@mock_aws
class TestLogFilterParameters(TestLogFilter):
def setUp(self) -> None:
super().setUp()
@@ -132,7 +132,7 @@ class TestLogFilterParameters(TestLogFilter):
assert "nextToken" not in res
-@mock_logs
+@mock_aws
class TestLogsFilterPattern(TestLogFilter):
def setUp(self) -> None:
super().setUp()
diff --git a/tests/test_logs/test_logs_query/test_boto3.py b/tests/test_logs/test_logs_query/test_boto3.py
index 2ce964ffa..85ca61a63 100644
--- a/tests/test_logs/test_logs_query/test_boto3.py
+++ b/tests/test_logs/test_logs_query/test_boto3.py
@@ -5,11 +5,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_logs
+from moto import mock_aws
from moto.core.utils import unix_time, unix_time_millis, utcnow
-@mock_logs
+@mock_aws
def test_start_query__unknown_log_group():
client = boto3.client("logs", "us-east-1")
@@ -39,7 +39,7 @@ def test_start_query__unknown_log_group():
assert err["Message"] == "The specified log group does not exist."
-@mock_logs
+@mock_aws
def test_get_query_results():
client = boto3.client("logs", "us-east-1")
log_group_name = "test"
@@ -108,7 +108,7 @@ def test_get_query_results():
assert messages == ["event nr 2", "event nr 1"]
-@mock_logs
+@mock_aws
def test_describe_completed_query():
client = boto3.client("logs", "us-east-1")
@@ -139,7 +139,7 @@ def test_describe_completed_query():
assert len(queries) == 0
-@mock_logs
+@mock_aws
def test_describe_queries_on_log_group_without_any():
client = boto3.client("logs", "us-east-1")
diff --git a/tests/test_logs/test_logs_tags.py b/tests/test_logs/test_logs_tags.py
index acef5da1f..c3988e7ed 100644
--- a/tests/test_logs/test_logs_tags.py
+++ b/tests/test_logs/test_logs_tags.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_logs
+from moto import mock_aws
-@mock_logs
+@mock_aws
def test_destination_tags():
logs = boto3.client("logs", "us-west-2")
destination_name = "test-destination"
@@ -20,7 +20,7 @@ def test_destination_tags():
_verify_tag_operations(destination_arn, logs)
-@mock_logs
+@mock_aws
def test_log_groups_tags():
logs = boto3.client("logs", "us-west-2")
log_group_name = "test"
diff --git a/tests/test_managedblockchain/test_managedblockchain_invitations.py b/tests/test_managedblockchain/test_managedblockchain_invitations.py
index 433de475a..000ffb48c 100644
--- a/tests/test_managedblockchain/test_managedblockchain_invitations.py
+++ b/tests/test_managedblockchain/test_managedblockchain_invitations.py
@@ -2,13 +2,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_managedblockchain
+from moto import mock_aws
from . import helpers
class TestManagedBlockchainInvitations:
- mock = mock_managedblockchain()
+ mock = mock_aws()
@classmethod
def setup_class(cls):
diff --git a/tests/test_managedblockchain/test_managedblockchain_members.py b/tests/test_managedblockchain/test_managedblockchain_members.py
index 9a7497112..fe8842cff 100644
--- a/tests/test_managedblockchain/test_managedblockchain_members.py
+++ b/tests/test_managedblockchain/test_managedblockchain_members.py
@@ -3,12 +3,12 @@ import pytest
from botocore.config import Config
from botocore.exceptions import ClientError, ParamValidationError
-from moto import mock_managedblockchain
+from moto import mock_aws
from . import helpers
-@mock_managedblockchain
+@mock_aws
def test_create_another_member():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -93,7 +93,7 @@ def test_create_another_member():
assert cloudwatch["Enabled"] == logconfignewenabled
-@mock_managedblockchain
+@mock_aws
def test_create_another_member_withopts():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -198,7 +198,7 @@ def test_create_another_member_withopts():
assert response["Invitations"][0]["NetworkSummary"]["Status"] == "DELETED"
-@mock_managedblockchain
+@mock_aws
def test_invite_and_remove_member():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -280,7 +280,7 @@ def test_invite_and_remove_member():
assert foundmember2 is True
-@mock_managedblockchain
+@mock_aws
def test_create_too_many_members():
# This test throws a ResourceLimitException, with HTTP status code 429
# Boto3 automatically retries a request with that status code up to 5 times
@@ -367,7 +367,7 @@ def test_create_too_many_members():
assert "is the maximum number of members allowed in a" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_another_member_alreadyhave():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -418,7 +418,7 @@ def test_create_another_member_alreadyhave():
)
-@mock_managedblockchain
+@mock_aws
def test_create_another_member_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -435,7 +435,7 @@ def test_create_another_member_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_another_member_badinvitation():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -462,7 +462,7 @@ def test_create_another_member_badinvitation():
assert "Invitation in-ABCDEFGHIJKLMNOP0123456789 not valid" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_another_member_adminpassword():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -577,7 +577,7 @@ def test_create_another_member_adminpassword():
assert "Invalid request body" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_list_members_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -588,7 +588,7 @@ def test_list_members_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_get_member_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -602,7 +602,7 @@ def test_get_member_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_get_member_badmember():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -623,7 +623,7 @@ def test_get_member_badmember():
assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_delete_member_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -637,7 +637,7 @@ def test_delete_member_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_delete_member_badmember():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -660,7 +660,7 @@ def test_delete_member_badmember():
assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_update_member_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -677,7 +677,7 @@ def test_update_member_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_update_member_badmember():
conn = boto3.client("managedblockchain", region_name="us-east-1")
diff --git a/tests/test_managedblockchain/test_managedblockchain_networks.py b/tests/test_managedblockchain/test_managedblockchain_networks.py
index 24aaafab8..b0754c84a 100644
--- a/tests/test_managedblockchain/test_managedblockchain_networks.py
+++ b/tests/test_managedblockchain/test_managedblockchain_networks.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_managedblockchain
+from moto import mock_aws
from . import helpers
-@mock_managedblockchain
+@mock_aws
def test_create_network():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -36,7 +36,7 @@ def test_create_network():
assert response["Network"]["Name"] == "testnetwork1"
-@mock_managedblockchain
+@mock_aws
def test_create_network_with_description():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -61,7 +61,7 @@ def test_create_network_with_description():
assert response["Network"]["Description"] == "Test Network 1"
-@mock_managedblockchain
+@mock_aws
def test_create_network_noframework():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -80,7 +80,7 @@ def test_create_network_noframework():
assert "Invalid request body" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_network_badframeworkver():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -102,7 +102,7 @@ def test_create_network_badframeworkver():
)
-@mock_managedblockchain
+@mock_aws
def test_create_network_badedition():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -123,7 +123,7 @@ def test_create_network_badedition():
assert "Invalid request body" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_get_network_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
diff --git a/tests/test_managedblockchain/test_managedblockchain_nodes.py b/tests/test_managedblockchain/test_managedblockchain_nodes.py
index c8ab6c272..c5a6489a9 100644
--- a/tests/test_managedblockchain/test_managedblockchain_nodes.py
+++ b/tests/test_managedblockchain/test_managedblockchain_nodes.py
@@ -3,12 +3,12 @@ import pytest
from botocore.config import Config
from botocore.exceptions import ClientError
-from moto import mock_managedblockchain
+from moto import mock_aws
from . import helpers
-@mock_managedblockchain
+@mock_aws
def test_create_node():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -78,7 +78,7 @@ def test_create_node():
assert f"Node {node_id} not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_node_standard_edition():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -145,7 +145,7 @@ def test_create_node_standard_edition():
assert f"Member {member_id} not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_too_many_nodes():
# This test throws a ResourceLimitException, with HTTP status code 429
# Boto3 automatically retries a request with that status code up to 5 times
@@ -196,7 +196,7 @@ def test_create_too_many_nodes():
assert f"Maximum number of nodes exceeded in member {member_id}" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_node_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -211,7 +211,7 @@ def test_create_node_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_node_badmember():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -236,7 +236,7 @@ def test_create_node_badmember():
assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_node_badnodeconfig():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -289,7 +289,7 @@ def test_create_node_badnodeconfig():
assert "Availability Zone is not valid" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_list_nodes_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -303,7 +303,7 @@ def test_list_nodes_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_list_nodes_badmember():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -324,7 +324,7 @@ def test_list_nodes_badmember():
assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_get_node_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -339,7 +339,7 @@ def test_get_node_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_get_node_badmember():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -364,7 +364,7 @@ def test_get_node_badmember():
assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_get_node_badnode():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -391,7 +391,7 @@ def test_get_node_badnode():
assert "Node nd-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_delete_node_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -406,7 +406,7 @@ def test_delete_node_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_delete_node_badmember():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -431,7 +431,7 @@ def test_delete_node_badmember():
assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_delete_node_badnode():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -458,7 +458,7 @@ def test_delete_node_badnode():
assert "Node nd-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_update_node_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -476,7 +476,7 @@ def test_update_node_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_update_node_badmember():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -504,7 +504,7 @@ def test_update_node_badmember():
assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_update_node_badnode():
conn = boto3.client("managedblockchain", region_name="us-east-1")
diff --git a/tests/test_managedblockchain/test_managedblockchain_proposals.py b/tests/test_managedblockchain/test_managedblockchain_proposals.py
index 05f0d93eb..1d45ce08c 100644
--- a/tests/test_managedblockchain/test_managedblockchain_proposals.py
+++ b/tests/test_managedblockchain/test_managedblockchain_proposals.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_managedblockchain
+from moto import mock_aws
from . import helpers
-@mock_managedblockchain
+@mock_aws
def test_create_proposal():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -40,7 +40,7 @@ def test_create_proposal():
assert response["Proposal"]["NetworkId"] == network_id
-@mock_managedblockchain
+@mock_aws
def test_create_proposal_withopts():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -69,7 +69,7 @@ def test_create_proposal_withopts():
assert response["Proposal"]["Description"] == "Adding a new member"
-@mock_managedblockchain
+@mock_aws
def test_create_proposal_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -84,7 +84,7 @@ def test_create_proposal_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_proposal_badmember():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -109,7 +109,7 @@ def test_create_proposal_badmember():
assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_proposal_badinvitationacctid():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -135,7 +135,7 @@ def test_create_proposal_badinvitationacctid():
assert "Account ID format specified in proposal is not valid" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_create_proposal_badremovalmemid():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -161,7 +161,7 @@ def test_create_proposal_badremovalmemid():
assert "Member ID format specified in proposal is not valid" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_list_proposal_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -172,7 +172,7 @@ def test_list_proposal_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_get_proposal_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -186,7 +186,7 @@ def test_get_proposal_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_get_proposal_badproposal():
conn = boto3.client("managedblockchain", region_name="us-east-1")
diff --git a/tests/test_managedblockchain/test_managedblockchain_proposalvotes.py b/tests/test_managedblockchain/test_managedblockchain_proposalvotes.py
index 97f511f9c..8b42beae2 100644
--- a/tests/test_managedblockchain/test_managedblockchain_proposalvotes.py
+++ b/tests/test_managedblockchain/test_managedblockchain_proposalvotes.py
@@ -6,12 +6,12 @@ import pytest
from botocore.exceptions import ClientError
from freezegun import freeze_time
-from moto import mock_managedblockchain
+from moto import mock_aws
from . import helpers
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_one_member_total_yes():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -57,7 +57,7 @@ def test_vote_on_proposal_one_member_total_yes():
assert response["Proposal"]["OutstandingVoteCount"] == 0
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_one_member_total_no():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -100,7 +100,7 @@ def test_vote_on_proposal_one_member_total_no():
assert response["Proposal"]["OutstandingVoteCount"] == 0
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_yes_greater_than():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -180,7 +180,7 @@ def test_vote_on_proposal_yes_greater_than():
assert response["Proposal"]["Status"] == "REJECTED"
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_no_greater_than():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -253,7 +253,7 @@ def test_vote_on_proposal_no_greater_than():
assert response["Proposal"]["Status"] == "REJECTED"
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_expiredproposal():
if os.environ.get("TEST_SERVER_MODE", "false").lower() == "true":
raise SkipTest("Cant manipulate time in server mode")
@@ -308,7 +308,7 @@ def test_vote_on_proposal_expiredproposal():
assert response["Proposal"]["Status"] == "EXPIRED"
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_status_check():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -423,7 +423,7 @@ def test_vote_on_proposal_status_check():
assert len(pendinginvs) == 1
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -439,7 +439,7 @@ def test_vote_on_proposal_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_badproposal():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -465,7 +465,7 @@ def test_vote_on_proposal_badproposal():
assert "Proposal p-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_badmember():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -497,7 +497,7 @@ def test_vote_on_proposal_badmember():
assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_badvote():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -531,7 +531,7 @@ def test_vote_on_proposal_badvote():
assert "Invalid request body" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_vote_on_proposal_alreadyvoted():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -616,7 +616,7 @@ def test_vote_on_proposal_alreadyvoted():
)
-@mock_managedblockchain
+@mock_aws
def test_list_proposal_votes_badnetwork():
conn = boto3.client("managedblockchain", region_name="us-east-1")
@@ -630,7 +630,7 @@ def test_list_proposal_votes_badnetwork():
assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"]
-@mock_managedblockchain
+@mock_aws
def test_list_proposal_votes_badproposal():
conn = boto3.client("managedblockchain", region_name="us-east-1")
diff --git a/tests/test_mediaconnect/test_mediaconnect.py b/tests/test_mediaconnect/test_mediaconnect.py
index 7946aa6fe..93255406f 100644
--- a/tests/test_mediaconnect/test_mediaconnect.py
+++ b/tests/test_mediaconnect/test_mediaconnect.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_mediaconnect
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
region = "eu-west-1"
@@ -71,7 +71,7 @@ def _check_mediaconnect_arn(type_, arn, name):
assert _arn_list[-1] == name
-@mock_mediaconnect
+@mock_aws
def test_create_flow_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -93,7 +93,7 @@ def test_create_flow_succeeds():
)
-@mock_mediaconnect
+@mock_aws
def test_create_flow_alternative_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config(
@@ -123,7 +123,7 @@ def test_create_flow_alternative_succeeds():
)
-@mock_mediaconnect
+@mock_aws
def test_list_flows_succeeds():
client = boto3.client("mediaconnect", region_name=region)
flow_1_config = _create_flow_config("test-Flow-1")
@@ -146,7 +146,7 @@ def test_list_flows_succeeds():
assert response["Flows"][1]["Status"] == "STANDBY"
-@mock_mediaconnect
+@mock_aws
def test_describe_flow_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -159,7 +159,7 @@ def test_describe_flow_succeeds():
assert describe_response["Flow"]["Name"] == "test-Flow-1"
-@mock_mediaconnect
+@mock_aws
def test_delete_flow_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -173,7 +173,7 @@ def test_delete_flow_succeeds():
assert delete_response["Status"] == "STANDBY"
-@mock_mediaconnect
+@mock_aws
def test_start_stop_flow_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -202,7 +202,7 @@ def test_start_stop_flow_succeeds():
assert describe_response["Flow"]["Status"] == "STANDBY"
-@mock_mediaconnect
+@mock_aws
def test_unknown_flow():
client = boto3.client("mediaconnect", region_name=region)
@@ -227,7 +227,7 @@ def test_unknown_flow():
assert exc.value.response["Error"]["Code"] == "NotFoundException"
-@mock_mediaconnect
+@mock_aws
def test_tag_resource_succeeds():
client = boto3.client("mediaconnect", region_name=region)
@@ -239,7 +239,7 @@ def test_tag_resource_succeeds():
assert list_response["Tags"] == {"Tag1": "Value1"}
-@mock_mediaconnect
+@mock_aws
def test_add_flow_vpc_interfaces_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -273,7 +273,7 @@ def test_add_flow_vpc_interfaces_succeeds():
]
-@mock_mediaconnect
+@mock_aws
def test_add_flow_vpc_interfaces_fails():
client = boto3.client("mediaconnect", region_name=region)
flow_arn = "unknown-flow"
@@ -284,7 +284,7 @@ def test_add_flow_vpc_interfaces_fails():
assert err["Message"] == "flow with arn=unknown-flow not found"
-@mock_mediaconnect
+@mock_aws
def test_remove_flow_vpc_interface_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -316,7 +316,7 @@ def test_remove_flow_vpc_interface_succeeds():
assert len(describe_response["Flow"]["VpcInterfaces"]) == 0
-@mock_mediaconnect
+@mock_aws
def test_remove_flow_vpc_interface_fails():
client = boto3.client("mediaconnect", region_name=region)
flow_arn = "unknown-flow"
@@ -329,7 +329,7 @@ def test_remove_flow_vpc_interface_fails():
assert err["Message"] == "flow with arn=unknown-flow not found"
-@mock_mediaconnect
+@mock_aws
def test_add_flow_outputs_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -352,7 +352,7 @@ def test_add_flow_outputs_succeeds():
assert outputs == [{"Description": "string", "Name": "string", "Port": 123}]
-@mock_mediaconnect
+@mock_aws
def test_add_flow_outputs_fails():
client = boto3.client("mediaconnect", region_name=region)
flow_arn = "unknown-flow"
@@ -363,7 +363,7 @@ def test_add_flow_outputs_fails():
assert err["Message"] == "flow with arn=unknown-flow not found"
-@mock_mediaconnect
+@mock_aws
def test_update_flow_output_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -380,7 +380,7 @@ def test_update_flow_output_succeeds():
assert update_response["Output"]["Description"] == "new description"
-@mock_mediaconnect
+@mock_aws
def test_update_flow_output_fails():
client = boto3.client("mediaconnect", region_name=region)
flow_arn = "unknown-flow"
@@ -395,7 +395,7 @@ def test_update_flow_output_fails():
assert err["Message"] == "flow with arn=unknown-flow not found"
-@mock_mediaconnect
+@mock_aws
def test_remove_flow_output_fails():
client = boto3.client("mediaconnect", region_name=region)
flow_arn = "unknown-flow"
@@ -407,7 +407,7 @@ def test_remove_flow_output_fails():
assert err["Message"] == "flow with arn=unknown-flow not found"
-@mock_mediaconnect
+@mock_aws
def test_remove_flow_output_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -434,7 +434,7 @@ def test_remove_flow_output_succeeds():
assert len(describe_response["Flow"]["Outputs"]) == 0
-@mock_mediaconnect
+@mock_aws
def test_add_flow_sources_fails():
client = boto3.client("mediaconnect", region_name=region)
flow_arn = "unknown-flow"
@@ -445,7 +445,7 @@ def test_add_flow_sources_fails():
assert err["Message"] == "flow with arn=unknown-flow not found"
-@mock_mediaconnect
+@mock_aws
def test_add_flow_sources_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -472,7 +472,7 @@ def test_add_flow_sources_succeeds():
assert len(describe_response["Flow"]["Sources"]) == 1
-@mock_mediaconnect
+@mock_aws
def test_update_flow_source_fails():
client = boto3.client("mediaconnect", region_name=region)
flow_arn = "unknown-flow"
@@ -490,7 +490,7 @@ def test_update_flow_source_fails():
assert err["Message"] == "flow with arn=unknown-flow not found"
-@mock_mediaconnect
+@mock_aws
def test_update_flow_source_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -524,7 +524,7 @@ def test_update_flow_source_succeeds():
assert update_response["Source"]["Description"] == "new description"
-@mock_mediaconnect
+@mock_aws
def test_grant_flow_entitlements_fails():
client = boto3.client("mediaconnect", region_name=region)
flow_arn = "unknown-flow"
@@ -551,7 +551,7 @@ def test_grant_flow_entitlements_fails():
assert err["Message"] == "flow with arn=unknown-flow not found"
-@mock_mediaconnect
+@mock_aws
def test_grant_flow_entitlements_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -594,7 +594,7 @@ def test_grant_flow_entitlements_succeeds():
assert "Entitlement-C" in entitlement_names
-@mock_mediaconnect
+@mock_aws
def test_revoke_flow_entitlement_fails():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -617,7 +617,7 @@ def test_revoke_flow_entitlement_fails():
assert err["Message"] == "entitlement with arn=some-other-arn not found"
-@mock_mediaconnect
+@mock_aws
def test_revoke_flow_entitlement_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -642,7 +642,7 @@ def test_revoke_flow_entitlement_succeeds():
assert len(describe_response["Flow"]["Entitlements"]) == 0
-@mock_mediaconnect
+@mock_aws
def test_update_flow_entitlement_fails():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
@@ -667,7 +667,7 @@ def test_update_flow_entitlement_fails():
assert err["Message"] == "entitlement with arn=some-other-arn not found"
-@mock_mediaconnect
+@mock_aws
def test_update_flow_entitlement_succeeds():
client = boto3.client("mediaconnect", region_name=region)
channel_config = _create_flow_config("test-Flow-1")
diff --git a/tests/test_mediaconnect/test_server.py b/tests/test_mediaconnect/test_server.py
index 36b973cad..94ca98340 100644
--- a/tests/test_mediaconnect/test_server.py
+++ b/tests/test_mediaconnect/test_server.py
@@ -1,14 +1,14 @@
import json
import moto.server as server
-from moto import mock_mediaconnect
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_mediaconnect
+@mock_aws
def test_mediaconnect_list_flows():
backend = server.create_backend_app("mediaconnect")
test_client = backend.test_client()
diff --git a/tests/test_medialive/test_medialive.py b/tests/test_medialive/test_medialive.py
index 973581c48..e3c0568fa 100644
--- a/tests/test_medialive/test_medialive.py
+++ b/tests/test_medialive/test_medialive.py
@@ -2,7 +2,7 @@ from uuid import uuid4
import boto3
-from moto import mock_medialive
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
region = "eu-west-1"
@@ -105,7 +105,7 @@ def _create_channel_config(name, **kwargs):
return channel_config
-@mock_medialive
+@mock_aws
def test_create_channel_succeeds():
client = boto3.client("medialive", region_name=region)
channel_config = _create_channel_config("test channel 1")
@@ -123,7 +123,7 @@ def test_create_channel_succeeds():
assert channel["Tags"]["Customer"] == "moto"
-@mock_medialive
+@mock_aws
def test_list_channels_succeeds():
client = boto3.client("medialive", region_name=region)
channel1_config = _create_channel_config("test channel 1", request_id="request-1")
@@ -145,7 +145,7 @@ def test_list_channels_succeeds():
assert response["Channels"][1]["PipelinesRunningCount"] == 1
-@mock_medialive
+@mock_aws
def test_delete_channel_moves_channel_in_deleted_state():
client = boto3.client("medialive", region_name=region)
channel_name = "test channel X"
@@ -158,7 +158,7 @@ def test_delete_channel_moves_channel_in_deleted_state():
assert delete_response["State"] == "DELETING"
-@mock_medialive
+@mock_aws
def test_describe_channel_succeeds():
client = boto3.client("medialive", region_name=region)
channel_name = "test channel X"
@@ -176,7 +176,7 @@ def test_describe_channel_succeeds():
assert channel["Tags"]["Customer"] == "moto"
-@mock_medialive
+@mock_aws
def test_start_channel_succeeds():
client = boto3.client("medialive", region_name=region)
channel_name = "testchan1"
@@ -190,7 +190,7 @@ def test_start_channel_succeeds():
assert client.describe_channel(ChannelId=channel_id)["State"] == "RUNNING"
-@mock_medialive
+@mock_aws
def test_stop_channel_succeeds():
client = boto3.client("medialive", region_name=region)
channel_name = "testchan2"
@@ -206,7 +206,7 @@ def test_stop_channel_succeeds():
assert client.describe_channel(ChannelId=channel_id)["State"] == "IDLE"
-@mock_medialive
+@mock_aws
def test_update_channel_succeeds():
client = boto3.client("medialive", region_name=region)
channel_name = "Original Channel"
@@ -225,7 +225,7 @@ def test_update_channel_succeeds():
assert channel["Name"] == "Updated Channel"
-@mock_medialive
+@mock_aws
def test_create_input_succeeds():
client = boto3.client("medialive", region_name=region)
input_name = "Input One"
@@ -252,7 +252,7 @@ def test_create_input_succeeds():
assert r_input["Type"] == input_config["Type"]
-@mock_medialive
+@mock_aws
def test_describe_input_succeeds():
client = boto3.client("medialive", region_name=region)
input_name = "Input Two"
@@ -269,7 +269,7 @@ def test_describe_input_succeeds():
assert describe_response["MediaConnectFlows"] == input_config["MediaConnectFlows"]
-@mock_medialive
+@mock_aws
def test_list_inputs_succeeds():
client = boto3.client("medialive", region_name=region)
input_config1 = _create_input_config("Input One")
@@ -284,7 +284,7 @@ def test_list_inputs_succeeds():
assert inputs[1]["Name"] == "Input Two"
-@mock_medialive
+@mock_aws
def test_delete_input_moves_input_in_deleted_state():
client = boto3.client("medialive", region_name=region)
input_name = "test input X"
@@ -299,7 +299,7 @@ def test_delete_input_moves_input_in_deleted_state():
assert input_["State"] == "DELETED"
-@mock_medialive
+@mock_aws
def test_update_input_succeeds():
client = boto3.client("medialive", region_name=region)
input_name = "test input X"
diff --git a/tests/test_medialive/test_server.py b/tests/test_medialive/test_server.py
index adb658a5c..66551c5bd 100644
--- a/tests/test_medialive/test_server.py
+++ b/tests/test_medialive/test_server.py
@@ -1,14 +1,14 @@
import json
import moto.server as server
-from moto import mock_medialive
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_medialive
+@mock_aws
def test_medialive_list_channels():
backend = server.create_backend_app("medialive")
test_client = backend.test_client()
@@ -18,7 +18,7 @@ def test_medialive_list_channels():
assert json.loads(result) == {"channels": [], "nextToken": None}
-@mock_medialive
+@mock_aws
def test_medialive_list_inputs():
backend = server.create_backend_app("medialive")
test_client = backend.test_client()
diff --git a/tests/test_mediapackage/test_mediapackage.py b/tests/test_mediapackage/test_mediapackage.py
index b5d75e0bb..3f5a8360a 100644
--- a/tests/test_mediapackage/test_mediapackage.py
+++ b/tests/test_mediapackage/test_mediapackage.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError # Boto3 will always throw this exception
-from moto import mock_mediapackage
+from moto import mock_aws
region = "eu-west-1"
@@ -52,7 +52,7 @@ def _create_origin_endpoint_config(**kwargs):
return origin_endpoint_config
-@mock_mediapackage
+@mock_aws
def test_create_channel_succeeds():
client = boto3.client("mediapackage", region_name=region)
channel_config = _create_channel_config()
@@ -65,7 +65,7 @@ def test_create_channel_succeeds():
assert channel["Tags"]["Customer"] == "moto"
-@mock_mediapackage
+@mock_aws
def test_describe_channel_succeeds():
client = boto3.client("mediapackage", region_name=region)
channel_config = _create_channel_config()
@@ -77,7 +77,7 @@ def test_describe_channel_succeeds():
assert channel["Tags"]["Customer"] == "moto"
-@mock_mediapackage
+@mock_aws
def test_describe_unknown_channel_throws_error():
client = boto3.client("mediapackage", region_name=region)
channel_id = "unknown-channel"
@@ -88,7 +88,7 @@ def test_describe_unknown_channel_throws_error():
assert err["Message"] == f"channel with id={channel_id} not found"
-@mock_mediapackage
+@mock_aws
def test_delete_unknown_channel_throws_error():
client = boto3.client("mediapackage", region_name=region)
channel_id = "unknown-channel"
@@ -99,7 +99,7 @@ def test_delete_unknown_channel_throws_error():
assert err["Message"] == f"channel with id={channel_id} not found"
-@mock_mediapackage
+@mock_aws
def test_delete_channel_successfully_deletes():
client = boto3.client("mediapackage", region_name=region)
channel_config = _create_channel_config()
@@ -114,7 +114,7 @@ def test_delete_channel_successfully_deletes():
assert len(post_deletion_channels_list) == len(channels_list) - 1
-@mock_mediapackage
+@mock_aws
def test_list_channels_succeds():
client = boto3.client("mediapackage", region_name=region)
channel_config = _create_channel_config()
@@ -129,7 +129,7 @@ def test_list_channels_succeds():
assert channel["Tags"]["Customer"] == "moto"
-@mock_mediapackage
+@mock_aws
def test_create_origin_endpoint_succeeds():
client = boto3.client("mediapackage", region_name=region)
origin_endpoint_config = _create_origin_endpoint_config()
@@ -143,7 +143,7 @@ def test_create_origin_endpoint_succeeds():
assert endpoint["Origination"] == "ALLOW"
-@mock_mediapackage
+@mock_aws
def test_describe_origin_endpoint_succeeds():
client = boto3.client("mediapackage", region_name=region)
origin_endpoint_config = _create_origin_endpoint_config()
@@ -162,7 +162,7 @@ def test_describe_origin_endpoint_succeeds():
)
-@mock_mediapackage
+@mock_aws
def test_describe_unknown_origin_endpoint_throws_error():
client = boto3.client("mediapackage", region_name=region)
channel_id = "unknown-channel"
@@ -173,7 +173,7 @@ def test_describe_unknown_origin_endpoint_throws_error():
assert err["Message"] == f"origin endpoint with id={channel_id} not found"
-@mock_mediapackage
+@mock_aws
def test_delete_origin_endpoint_succeeds():
client = boto3.client("mediapackage", region_name=region)
origin_endpoint_config = _create_origin_endpoint_config()
@@ -188,7 +188,7 @@ def test_delete_origin_endpoint_succeeds():
assert len(post_deletion_origin_endpoints_list) == len(origin_endpoints_list) - 1
-@mock_mediapackage
+@mock_aws
def test_delete_unknown_origin_endpoint_throws_error():
client = boto3.client("mediapackage", region_name=region)
channel_id = "unknown-channel"
@@ -199,7 +199,7 @@ def test_delete_unknown_origin_endpoint_throws_error():
assert err["Message"] == f"origin endpoint with id={channel_id} not found"
-@mock_mediapackage
+@mock_aws
def test_update_origin_endpoint_succeeds():
client = boto3.client("mediapackage", region_name=region)
origin_endpoint_config = _create_origin_endpoint_config()
@@ -214,7 +214,7 @@ def test_update_origin_endpoint_succeeds():
assert endpoint["ManifestName"] == "updated-manifest-name"
-@mock_mediapackage
+@mock_aws
def test_update_unknown_origin_endpoint_throws_error():
client = boto3.client("mediapackage", region_name=region)
channel_id = "unknown-channel"
@@ -229,7 +229,7 @@ def test_update_unknown_origin_endpoint_throws_error():
assert err["Message"] == f"origin endpoint with id={channel_id} not found"
-@mock_mediapackage
+@mock_aws
def test_list_origin_endpoint_succeeds():
client = boto3.client("mediapackage", region_name=region)
origin_endpoint_config = _create_origin_endpoint_config()
diff --git a/tests/test_mediapackage/test_server.py b/tests/test_mediapackage/test_server.py
index dd26a283f..69215bc24 100644
--- a/tests/test_mediapackage/test_server.py
+++ b/tests/test_mediapackage/test_server.py
@@ -1,14 +1,14 @@
import json
import moto.server as server
-from moto import mock_mediapackage
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_mediapackage
+@mock_aws
def test_mediapackage_list_channels():
backend = server.create_backend_app("mediapackage")
test_client = backend.test_client()
@@ -18,7 +18,7 @@ def test_mediapackage_list_channels():
assert json.loads(result) == {"channels": []}
-@mock_mediapackage
+@mock_aws
def test_mediapackage_list_origin_endpoints():
backend = server.create_backend_app("mediapackage")
test_client = backend.test_client()
diff --git a/tests/test_mediastore/test_mediastore.py b/tests/test_mediastore/test_mediastore.py
index ccb9e91f9..6a38bd927 100644
--- a/tests/test_mediastore/test_mediastore.py
+++ b/tests/test_mediastore/test_mediastore.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_mediastore
+from moto import mock_aws
region = "eu-west-1"
-@mock_mediastore
+@mock_aws
def test_create_container_succeeds():
client = boto3.client("mediastore", region_name=region)
response = client.create_container(
@@ -21,7 +21,7 @@ def test_create_container_succeeds():
assert container["Status"] == "CREATING"
-@mock_mediastore
+@mock_aws
def test_describe_container_succeeds():
client = boto3.client("mediastore", region_name=region)
name = "Awesome container!"
@@ -36,7 +36,7 @@ def test_describe_container_succeeds():
assert container["Status"] == "ACTIVE"
-@mock_mediastore
+@mock_aws
def test_list_containers_succeeds():
client = boto3.client("mediastore", region_name=region)
name = "Awesome container!"
@@ -49,7 +49,7 @@ def test_list_containers_succeeds():
assert len(containers) == 2
-@mock_mediastore
+@mock_aws
def test_describe_container_raises_error_if_container_does_not_exist():
client = boto3.client("mediastore", region_name=region)
with pytest.raises(ClientError) as ex:
@@ -57,7 +57,7 @@ def test_describe_container_raises_error_if_container_does_not_exist():
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_mediastore
+@mock_aws
def test_put_lifecycle_policy_succeeds():
client = boto3.client("mediastore", region_name=region)
name = "container-name"
@@ -69,7 +69,7 @@ def test_put_lifecycle_policy_succeeds():
assert response["LifecyclePolicy"] == "lifecycle-policy"
-@mock_mediastore
+@mock_aws
def test_put_lifecycle_policy_raises_error_if_container_does_not_exist():
client = boto3.client("mediastore", region_name=region)
with pytest.raises(ClientError) as ex:
@@ -77,7 +77,7 @@ def test_put_lifecycle_policy_raises_error_if_container_does_not_exist():
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_mediastore
+@mock_aws
def test_get_lifecycle_policy_raises_error_if_container_does_not_exist():
client = boto3.client("mediastore", region_name=region)
with pytest.raises(ClientError) as ex:
@@ -85,7 +85,7 @@ def test_get_lifecycle_policy_raises_error_if_container_does_not_exist():
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_mediastore
+@mock_aws
def test_get_lifecycle_policy_raises_error_if_container_does_not_have_lifecycle_policy():
client = boto3.client("mediastore", region_name=region)
client.create_container(ContainerName="container-name", Tags=[{"Key": "customer"}])
@@ -94,7 +94,7 @@ def test_get_lifecycle_policy_raises_error_if_container_does_not_have_lifecycle_
assert ex.value.response["Error"]["Code"] == "PolicyNotFoundException"
-@mock_mediastore
+@mock_aws
def test_put_container_policy_succeeds():
client = boto3.client("mediastore", region_name=region)
name = "container-name"
@@ -106,7 +106,7 @@ def test_put_container_policy_succeeds():
assert response["Policy"] == "container-policy"
-@mock_mediastore
+@mock_aws
def test_put_container_policy_raises_error_if_container_does_not_exist():
client = boto3.client("mediastore", region_name=region)
with pytest.raises(ClientError) as ex:
@@ -114,7 +114,7 @@ def test_put_container_policy_raises_error_if_container_does_not_exist():
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_mediastore
+@mock_aws
def test_get_container_policy_raises_error_if_container_does_not_exist():
client = boto3.client("mediastore", region_name=region)
with pytest.raises(ClientError) as ex:
@@ -122,7 +122,7 @@ def test_get_container_policy_raises_error_if_container_does_not_exist():
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_mediastore
+@mock_aws
def test_get_container_policy_raises_error_if_container_does_not_have_container_policy():
client = boto3.client("mediastore", region_name=region)
client.create_container(ContainerName="container-name", Tags=[{"Key": "customer"}])
@@ -131,7 +131,7 @@ def test_get_container_policy_raises_error_if_container_does_not_have_container_
assert ex.value.response["Error"]["Code"] == "PolicyNotFoundException"
-@mock_mediastore
+@mock_aws
def test_put_metric_policy_succeeds():
client = boto3.client("mediastore", region_name=region)
name = "container-name"
@@ -145,7 +145,7 @@ def test_put_metric_policy_succeeds():
assert response["MetricPolicy"] == {"ContainerLevelMetrics": "ENABLED"}
-@mock_mediastore
+@mock_aws
def test_put_metric_policy_raises_error_if_container_does_not_exist():
client = boto3.client("mediastore", region_name=region)
with pytest.raises(ClientError) as ex:
@@ -156,7 +156,7 @@ def test_put_metric_policy_raises_error_if_container_does_not_exist():
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_mediastore
+@mock_aws
def test_get_metric_policy_raises_error_if_container_does_not_exist():
client = boto3.client("mediastore", region_name=region)
with pytest.raises(ClientError) as ex:
@@ -164,7 +164,7 @@ def test_get_metric_policy_raises_error_if_container_does_not_exist():
assert ex.value.response["Error"]["Code"] == "ResourceNotFoundException"
-@mock_mediastore
+@mock_aws
def test_get_metric_policy_raises_error_if_container_does_not_have_metric_policy():
client = boto3.client("mediastore", region_name=region)
client.create_container(ContainerName="container-name", Tags=[{"Key": "customer"}])
@@ -173,7 +173,7 @@ def test_get_metric_policy_raises_error_if_container_does_not_have_metric_policy
assert ex.value.response["Error"]["Code"] == "PolicyNotFoundException"
-@mock_mediastore
+@mock_aws
def test_list_tags_for_resource():
client = boto3.client("mediastore", region_name=region)
tags = [{"Key": "customer"}]
@@ -186,7 +186,7 @@ def test_list_tags_for_resource():
assert response["Tags"] == tags
-@mock_mediastore
+@mock_aws
def test_list_tags_for_resource_return_none_if_no_tags():
client = boto3.client("mediastore", region_name=region)
@@ -198,7 +198,7 @@ def test_list_tags_for_resource_return_none_if_no_tags():
assert response.get("Tags") is None
-@mock_mediastore
+@mock_aws
def test_list_tags_for_resource_return_error_for_unknown_resource():
client = boto3.client("mediastore", region_name=region)
with pytest.raises(ClientError) as ex:
@@ -206,7 +206,7 @@ def test_list_tags_for_resource_return_error_for_unknown_resource():
assert ex.value.response["Error"]["Code"] == "ContainerNotFoundException"
-@mock_mediastore
+@mock_aws
def test_delete_container():
client = boto3.client("mediastore", region_name=region)
container_name = "Awesome container!"
@@ -219,7 +219,7 @@ def test_delete_container():
assert not any(d["Name"] == container_name for d in containers)
-@mock_mediastore
+@mock_aws
def test_delete_container_raise_error_if_container_not_found():
client = boto3.client("mediastore", region_name=region)
client.create_container(ContainerName="Awesome container!")
diff --git a/tests/test_mediastore/test_server.py b/tests/test_mediastore/test_server.py
index d88e96f4d..e2e697831 100644
--- a/tests/test_mediastore/test_server.py
+++ b/tests/test_mediastore/test_server.py
@@ -1,14 +1,14 @@
import json
import moto.server as server
-from moto import mock_mediastore
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_mediastore
+@mock_aws
def test_mediastore_lists_containers():
backend = server.create_backend_app("mediastore")
test_client = backend.test_client()
diff --git a/tests/test_mediastoredata/test_mediastoredata.py b/tests/test_mediastoredata/test_mediastoredata.py
index b210248ef..a3d84f7aa 100644
--- a/tests/test_mediastoredata/test_mediastoredata.py
+++ b/tests/test_mediastoredata/test_mediastoredata.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_mediastoredata
+from moto import mock_aws
region = "eu-west-1"
-@mock_mediastoredata
+@mock_aws
def test_put_object():
client = boto3.client("mediastore-data", region_name=region)
response = client.put_object(Body="011001", Path="foo")
@@ -18,7 +18,7 @@ def test_put_object():
assert any(d["Name"] == "foo" for d in items)
-@mock_mediastoredata
+@mock_aws
def test_get_object_throws_not_found_error():
client = boto3.client("mediastore-data", region_name=region)
with pytest.raises(ClientError) as ex:
@@ -26,7 +26,7 @@ def test_get_object_throws_not_found_error():
assert ex.value.response["Error"]["Code"] == "ObjectNotFoundException"
-@mock_mediastoredata
+@mock_aws
def test_get_object():
client = boto3.client("mediastore-data", region_name=region)
client.put_object(Body="011001", Path="foo")
@@ -36,7 +36,7 @@ def test_get_object():
assert response["Body"].read() == b"011001"
-@mock_mediastoredata
+@mock_aws
def test_delete_object_error():
client = boto3.client("mediastore-data", region_name=region)
with pytest.raises(ClientError) as ex:
@@ -44,7 +44,7 @@ def test_delete_object_error():
assert ex.value.response["Error"]["Code"] == "ObjectNotFoundException"
-@mock_mediastoredata
+@mock_aws
def test_delete_object_succeeds():
client = boto3.client("mediastore-data", region_name=region)
object_path = "foo"
@@ -55,7 +55,7 @@ def test_delete_object_succeeds():
assert len(client.list_items()["Items"]) == 0
-@mock_mediastoredata
+@mock_aws
def test_list_items():
client = boto3.client("mediastore-data", region_name=region)
assert len(client.list_items()["Items"]) == 0
diff --git a/tests/test_mediastoredata/test_server.py b/tests/test_mediastoredata/test_server.py
index 7e6bd3fb6..8d7556bf9 100644
--- a/tests/test_mediastoredata/test_server.py
+++ b/tests/test_mediastoredata/test_server.py
@@ -1,14 +1,14 @@
import json
import moto.server as server
-from moto import mock_mediastoredata
+from moto import mock_aws
"""
Test the different server responses
"""
-@mock_mediastoredata
+@mock_aws
def test_mediastore_lists_containers():
backend = server.create_backend_app("mediastore-data")
test_client = backend.test_client()
diff --git a/tests/test_meteringmarketplace/test_meteringmarketplace.py b/tests/test_meteringmarketplace/test_meteringmarketplace.py
index b6811154b..1b7dafd6b 100644
--- a/tests/test_meteringmarketplace/test_meteringmarketplace.py
+++ b/tests/test_meteringmarketplace/test_meteringmarketplace.py
@@ -3,7 +3,7 @@ from datetime import datetime
import boto3
-from moto import mock_meteringmarketplace
+from moto import mock_aws
from moto.meteringmarketplace.models import Result
USAGE_RECORDS = [
@@ -70,7 +70,7 @@ USAGE_RECORDS = [
]
-@mock_meteringmarketplace()
+@mock_aws()
def test_batch_meter_usage():
client = boto3.client("meteringmarketplace", region_name="us-east-1")
diff --git a/tests/test_moto_api/recorder/test_recorder.py b/tests/test_moto_api/recorder/test_recorder.py
index 96314c221..abcb125ae 100644
--- a/tests/test_moto_api/recorder/test_recorder.py
+++ b/tests/test_moto_api/recorder/test_recorder.py
@@ -6,24 +6,13 @@ from unittest import SkipTest, TestCase
import boto3
import requests
-from moto import (
- mock_apigateway,
- mock_dynamodb,
- mock_ec2,
- mock_s3,
- mock_timestreamwrite,
- settings,
-)
+from moto import mock_aws, settings
from moto.moto_api import recorder
from moto.server import ThreadedMotoServer
from tests import EXAMPLE_AMI_ID
-@mock_apigateway
-@mock_dynamodb
-@mock_ec2
-@mock_s3
-@mock_timestreamwrite
+@mock_aws
class TestRecorder(TestCase):
def _reset_recording(self):
if settings.TEST_SERVER_MODE:
diff --git a/tests/test_moto_api/seeder/__init__.py b/tests/test_moto_api/seeder/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/test_moto_api/seeder/test_seeder.py b/tests/test_moto_api/seeder/test_seeder.py
new file mode 100644
index 000000000..e11c4b5c2
--- /dev/null
+++ b/tests/test_moto_api/seeder/test_seeder.py
@@ -0,0 +1,56 @@
+import unittest
+
+import boto3
+import requests
+
+import moto
+
+
+# https://github.com/getmoto/moto/issues/6592
+class TestDifferentAccountsDoesNotBreakSeeding:
+ def setup_method(self) -> None:
+ if not moto.settings.TEST_DECORATOR_MODE:
+ raise unittest.SkipTest(
+ "Seed behaviour only needs to be tested in DecoratorMode"
+ )
+ self.mock = moto.mock_aws()
+ self.mock.start()
+
+ requests.post("http://motoapi.amazonaws.com/moto-api/seed?a=42")
+
+ self.sts_client = boto3.client("sts", "us-east-1")
+ self.ec2_client = boto3.client("ec2", "us-east-1")
+
+ self.session_client = self.sts_client.assume_role(
+ RoleArn="arn:aws:iam::111111111111:role/my-role",
+ RoleSessionName="role-session-name",
+ )
+
+ self.session = boto3.session.Session(
+ aws_access_key_id=self.session_client["Credentials"]["AccessKeyId"],
+ aws_secret_access_key=self.session_client["Credentials"]["SecretAccessKey"],
+ aws_session_token=self.session_client["Credentials"]["SessionToken"],
+ )
+
+ def teardown_method(self) -> None:
+ self.mock.stop()
+
+ def test_0(self) -> None:
+ # We seeded Moto in the setup-method
+ # So our instances should have a fixed InstanceId
+ instances = self.ec2_client.run_instances(MaxCount=1, MinCount=1)["Instances"]
+
+ instance_ids = [instance["InstanceId"] for instance in instances]
+ assert instance_ids == ["i-dc50244d2b9e8e0b7"]
+
+ def test_1(self) -> None:
+ # Create some data in a different account (111111111111)
+ self.sts_client.assume_role(
+ RoleArn="arn:aws:iam::111111111111:role/my-role",
+ RoleSessionName="role-session-name",
+ )
+
+ def test_2(self) -> None:
+ # The fact that some data now exists in a different account (111111111111)
+ # should not change the fixed InstanceId-value
+ self.test_0()
diff --git a/tests/test_moto_api/state_manager/test_batch_integration.py b/tests/test_moto_api/state_manager/test_batch_integration.py
index 6e67ebe5f..79cf04244 100644
--- a/tests/test_moto_api/state_manager/test_batch_integration.py
+++ b/tests/test_moto_api/state_manager/test_batch_integration.py
@@ -1,17 +1,13 @@
from unittest import SkipTest
-from moto import mock_batch, mock_ec2, mock_ecs, mock_iam, mock_logs, settings
+from moto import mock_aws, settings
from moto.moto_api import state_manager
from tests.markers import requires_docker
from tests.test_batch import _get_clients, _setup
from tests.test_batch.test_batch_jobs import _wait_for_job_status, prepare_job
-@mock_logs
-@mock_ec2
-@mock_ecs
-@mock_iam
-@mock_batch
+@mock_aws
@requires_docker
def test_cancel_pending_job():
if settings.TEST_SERVER_MODE:
@@ -46,6 +42,6 @@ def test_cancel_pending_job():
assert resp["jobs"][0]["statusReason"] == "test_cancel"
-@mock_batch
+@mock_aws
def test_state_manager_should_return_registered_model():
assert "batch::job" in state_manager.get_registered_models()
diff --git a/tests/test_mq/test_mq.py b/tests/test_mq/test_mq.py
index 6b1b380b1..1fa9095a2 100644
--- a/tests/test_mq/test_mq.py
+++ b/tests/test_mq/test_mq.py
@@ -2,13 +2,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_mq
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_mq
+@mock_aws
def test_create_broker_minimal():
client = boto3.client("mq", region_name="ap-southeast-1")
resp = client.create_broker(
@@ -31,7 +31,7 @@ def test_create_broker_minimal():
assert "Id" in broker["Configurations"]["Current"]
-@mock_mq
+@mock_aws
def test_create_with_tags():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -51,7 +51,7 @@ def test_create_with_tags():
assert resp["Tags"] == {"key1": "val2", "key2": "val2"}
-@mock_mq
+@mock_aws
def test_create_with_multiple_users():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -89,7 +89,7 @@ def test_create_with_multiple_users():
assert user2["ConsoleAccess"] is False
-@mock_mq
+@mock_aws
def test_create_with_configuration():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -111,7 +111,7 @@ def test_create_with_configuration():
assert resp["Configurations"]["Current"] == {"Id": "config_id_x", "Revision": 3}
-@mock_mq
+@mock_aws
def test_update_with_configuration():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -137,7 +137,7 @@ def test_update_with_configuration():
assert resp["Configurations"]["Current"] == {"Id": "config_id_x", "Revision": 2}
-@mock_mq
+@mock_aws
def test_delete_broker():
client = boto3.client("mq", region_name="ap-southeast-1")
broker_id = client.create_broker(
@@ -157,7 +157,7 @@ def test_delete_broker():
assert len(client.list_brokers()["BrokerSummaries"]) == 0
-@mock_mq
+@mock_aws
def test_describe_broker():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -216,7 +216,7 @@ def test_describe_broker():
assert resp["Users"] == [{"Username": "admin"}]
-@mock_mq
+@mock_aws
def test_describe_broker_with_defaults():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -252,7 +252,7 @@ def test_describe_broker_with_defaults():
assert len(resp["SubnetIds"]) == 1
-@mock_mq
+@mock_aws
def test_describe_multiple_rabbits():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -278,7 +278,7 @@ def test_describe_multiple_rabbits():
assert len(resp["SubnetIds"]) == 4
-@mock_mq
+@mock_aws
def test_describe_active_mq_with_standby():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -299,7 +299,7 @@ def test_describe_active_mq_with_standby():
assert len(resp["SubnetIds"]) == 2
-@mock_mq
+@mock_aws
def test_describe_broker_unknown():
client = boto3.client("mq", region_name="us-east-2")
@@ -313,7 +313,7 @@ def test_describe_broker_unknown():
)
-@mock_mq
+@mock_aws
def test_list_brokers_empty():
client = boto3.client("mq", region_name="eu-west-1")
resp = client.list_brokers()
@@ -321,7 +321,7 @@ def test_list_brokers_empty():
assert resp["BrokerSummaries"] == []
-@mock_mq
+@mock_aws
def test_list_brokers():
client = boto3.client("mq", region_name="eu-west-1")
broker_id = client.create_broker(
@@ -352,7 +352,7 @@ def test_list_brokers():
assert "Users" not in summary
-@mock_mq
+@mock_aws
def test_update_broker_single_attribute():
client = boto3.client("mq", region_name="ap-southeast-1")
broker_id = client.create_broker(
@@ -375,7 +375,7 @@ def test_update_broker_single_attribute():
assert resp["EngineVersion"] == "version"
-@mock_mq
+@mock_aws
def test_update_broker_multiple_attributes():
client = boto3.client("mq", region_name="ap-southeast-1")
broker_id = client.create_broker(
@@ -407,7 +407,7 @@ def test_update_broker_multiple_attributes():
assert resp["BrokerId"] == broker_id
-@mock_mq
+@mock_aws
def test_reboot_broker():
client = boto3.client("mq", region_name="ap-southeast-1")
broker_id = client.create_broker(
diff --git a/tests/test_mq/test_mq_configuration.py b/tests/test_mq/test_mq_configuration.py
index 1450f54b6..d97599281 100644
--- a/tests/test_mq/test_mq_configuration.py
+++ b/tests/test_mq/test_mq_configuration.py
@@ -1,18 +1,17 @@
-"""Unit tests for mq-supported APIs."""
import base64
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_mq
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_mq
+@mock_aws
def test_create_configuration_minimal():
client = boto3.client("mq", region_name="ap-southeast-1")
resp = client.create_configuration(
@@ -35,7 +34,7 @@ def test_create_configuration_minimal():
assert revision["Revision"] == 1
-@mock_mq
+@mock_aws
def test_create_configuration_for_unknown_engine():
client = boto3.client("mq", region_name="us-east-1")
@@ -51,7 +50,7 @@ def test_create_configuration_for_unknown_engine():
)
-@mock_mq
+@mock_aws
def test_describe_configuration():
client = boto3.client("mq", region_name="eu-north-1")
config_id = client.create_configuration(
@@ -75,7 +74,7 @@ def test_describe_configuration():
assert revision["Revision"] == 1
-@mock_mq
+@mock_aws
def test_describe_configuration_revision():
client = boto3.client("mq", region_name="eu-north-1")
config_id = client.create_configuration(
@@ -95,7 +94,7 @@ def test_describe_configuration_revision():
assert "Data" in resp
-@mock_mq
+@mock_aws
def test_describe_configuration_unknown():
client = boto3.client("mq", region_name="us-east-2")
@@ -110,7 +109,7 @@ def test_describe_configuration_unknown():
)
-@mock_mq
+@mock_aws
def test_list_configurations_empty():
client = boto3.client("mq", region_name="us-east-2")
@@ -119,7 +118,7 @@ def test_list_configurations_empty():
assert resp["Configurations"] == []
-@mock_mq
+@mock_aws
def test_list_configurations():
client = boto3.client("mq", region_name="ap-southeast-1")
config_id = client.create_configuration(
@@ -139,7 +138,7 @@ def test_list_configurations():
assert config["EngineVersion"] == "active1"
-@mock_mq
+@mock_aws
def test_update_configuration():
client = boto3.client("mq", region_name="ap-southeast-1")
config_id = client.create_configuration(
@@ -164,7 +163,7 @@ def test_update_configuration():
assert revision["Revision"] == 2
-@mock_mq
+@mock_aws
def test_update_configuration_to_ldap():
client = boto3.client("mq", region_name="ap-southeast-1")
config_id = client.create_configuration(
diff --git a/tests/test_mq/test_mq_tags.py b/tests/test_mq/test_mq_tags.py
index 3bb64538f..e79426671 100644
--- a/tests/test_mq/test_mq_tags.py
+++ b/tests/test_mq/test_mq_tags.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_mq
+from moto import mock_aws
-@mock_mq
+@mock_aws
def test_create_broker_with_tags():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -23,7 +23,7 @@ def test_create_broker_with_tags():
assert resp["Tags"] == {"key1": "val2", "key2": "val2"}
-@mock_mq
+@mock_aws
def test_create_tags():
client = boto3.client("mq", region_name="us-east-2")
resp = client.create_broker(
@@ -50,7 +50,7 @@ def test_create_tags():
assert tags == {"key1": "val2", "key2": "val2"}
-@mock_mq
+@mock_aws
def test_delete_tags():
client = boto3.client("mq", region_name="us-east-2")
resp = client.create_broker(
@@ -76,7 +76,7 @@ def test_delete_tags():
assert resp["Tags"] == {"key2": "val2"}
-@mock_mq
+@mock_aws
def test_create_configuration_with_tags():
client = boto3.client("mq", region_name="ap-southeast-1")
resp = client.create_configuration(
@@ -94,7 +94,7 @@ def test_create_configuration_with_tags():
assert resp["Tags"] == {"key1": "val1", "key2": "val2"}
-@mock_mq
+@mock_aws
def test_add_tags_to_configuration():
client = boto3.client("mq", region_name="ap-southeast-1")
resp = client.create_configuration(
diff --git a/tests/test_mq/test_mq_users.py b/tests/test_mq/test_mq_users.py
index 1734ba068..b10fec34b 100644
--- a/tests/test_mq/test_mq_users.py
+++ b/tests/test_mq/test_mq_users.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_mq
+from moto import mock_aws
-@mock_mq
+@mock_aws
def test_create_user():
client = boto3.client("mq", region_name="us-east-1")
broker_id = client.create_broker(
@@ -26,7 +26,7 @@ def test_create_user():
assert resp["Users"] == [{"Username": "admin"}]
-@mock_mq
+@mock_aws
def test_describe_user():
client = boto3.client("mq", region_name="us-east-1")
broker_id = client.create_broker(
@@ -56,7 +56,7 @@ def test_describe_user():
assert resp["Username"] == "admin"
-@mock_mq
+@mock_aws
def test_describe_user_unknown():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -80,7 +80,7 @@ def test_describe_user_unknown():
)
-@mock_mq
+@mock_aws
def test_list_users_empty():
client = boto3.client("mq", region_name="us-east-1")
broker_id = client.create_broker(
@@ -100,7 +100,7 @@ def test_list_users_empty():
assert resp["Users"] == []
-@mock_mq
+@mock_aws
def test_list_users():
client = boto3.client("mq", region_name="us-east-1")
broker_id = client.create_broker(
@@ -124,7 +124,7 @@ def test_list_users():
assert {"Username": "user1"} in resp["Users"]
-@mock_mq
+@mock_aws
def test_update_user():
client = boto3.client("mq", region_name="us-east-2")
broker_id = client.create_broker(
@@ -147,7 +147,7 @@ def test_update_user():
assert resp["Username"] == "admin"
-@mock_mq
+@mock_aws
def test_delete_user():
client = boto3.client("mq", region_name="us-east-1")
broker_id = client.create_broker(
diff --git a/tests/test_mq/test_server.py b/tests/test_mq/test_server.py
index d2a3c469f..484802d00 100644
--- a/tests/test_mq/test_server.py
+++ b/tests/test_mq/test_server.py
@@ -1,10 +1,10 @@
import json
import moto.server as server
-from moto import mock_mq
+from moto import mock_aws
-@mock_mq
+@mock_aws
def test_mq_list():
backend = server.create_backend_app("mq")
test_client = backend.test_client()
diff --git a/tests/test_neptune/test_cluster_options.py b/tests/test_neptune/test_cluster_options.py
index d67db38b2..483f7343f 100644
--- a/tests/test_neptune/test_cluster_options.py
+++ b/tests/test_neptune/test_cluster_options.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_neptune
+from moto import mock_aws
-@mock_neptune
+@mock_aws
def test_db_cluster_options():
# Verified against AWS on 23-02-2023
# We're not checking the exact data here, that is already done in TF
diff --git a/tests/test_neptune/test_cluster_tags.py b/tests/test_neptune/test_cluster_tags.py
index 82a87708d..645e3bcd1 100644
--- a/tests/test_neptune/test_cluster_tags.py
+++ b/tests/test_neptune/test_cluster_tags.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_neptune
+from moto import mock_aws
-@mock_neptune
+@mock_aws
def test_add_tags_to_cluster():
conn = boto3.client("neptune", region_name="us-west-2")
resp = conn.create_db_cluster(
diff --git a/tests/test_neptune/test_clusters.py b/tests/test_neptune/test_clusters.py
index 5610edf40..c1dfdd343 100644
--- a/tests/test_neptune/test_clusters.py
+++ b/tests/test_neptune/test_clusters.py
@@ -1,15 +1,14 @@
-"""Unit tests for neptune-supported APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_neptune
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_neptune
+@mock_aws
def test_create_db_cluster():
client = boto3.client("neptune", region_name="us-east-2")
resp = client.create_db_cluster(DBClusterIdentifier="cluster-id", Engine="neptune")[
@@ -32,7 +31,7 @@ def test_create_db_cluster():
assert len(europe_client.describe_db_clusters()["DBClusters"]) == 0
-@mock_neptune
+@mock_aws
def test_create_db_cluster__with_additional_params():
client = boto3.client("neptune", region_name="us-east-1")
resp = client.create_db_cluster(
@@ -56,7 +55,7 @@ def test_create_db_cluster__with_additional_params():
assert resp["DatabaseName"] == "sth"
-@mock_neptune
+@mock_aws
def test_describe_db_clusters():
client = boto3.client("neptune", region_name="ap-southeast-1")
assert client.describe_db_clusters()["DBClusters"] == []
@@ -71,7 +70,7 @@ def test_describe_db_clusters():
assert clusters[0]["Engine"] == "neptune"
-@mock_neptune
+@mock_aws
def test_delete_db_cluster():
client = boto3.client("neptune", region_name="ap-southeast-1")
@@ -81,7 +80,7 @@ def test_delete_db_cluster():
assert client.describe_db_clusters()["DBClusters"] == []
-@mock_neptune
+@mock_aws
def test_delete_unknown_db_cluster():
client = boto3.client("neptune", region_name="ap-southeast-1")
@@ -91,7 +90,7 @@ def test_delete_unknown_db_cluster():
assert err["Code"] == "DBClusterNotFoundFault"
-@mock_neptune
+@mock_aws
def test_modify_db_cluster():
client = boto3.client("neptune", region_name="us-east-1")
client.create_db_cluster(DBClusterIdentifier="cluster-id", Engine="neptune")
@@ -106,7 +105,7 @@ def test_modify_db_cluster():
assert resp["PreferredBackupWindow"] == "window"
-@mock_neptune
+@mock_aws
def test_start_db_cluster():
client = boto3.client("neptune", region_name="us-east-2")
client.create_db_cluster(DBClusterIdentifier="cluster-id", Engine="neptune")[
diff --git a/tests/test_neptune/test_global_clusters.py b/tests/test_neptune/test_global_clusters.py
index 2f0204ea2..edf207ad1 100644
--- a/tests/test_neptune/test_global_clusters.py
+++ b/tests/test_neptune/test_global_clusters.py
@@ -1,15 +1,15 @@
import boto3
-from moto import mock_neptune
+from moto import mock_aws
-@mock_neptune
+@mock_aws
def test_describe():
client = boto3.client("neptune", "us-east-2")
assert client.describe_global_clusters()["GlobalClusters"] == []
-@mock_neptune
+@mock_aws
def test_create_global_cluster():
client = boto3.client("neptune", "us-east-1")
resp = client.create_global_cluster(
@@ -30,7 +30,7 @@ def test_create_global_cluster():
assert len(europe_client.describe_global_clusters()["GlobalClusters"]) == 1
-@mock_neptune
+@mock_aws
def test_create_global_cluster_with_additional_params():
client = boto3.client("neptune", "us-east-1")
resp = client.create_global_cluster(
@@ -46,7 +46,7 @@ def test_create_global_cluster_with_additional_params():
assert resp["DeletionProtection"] is True
-@mock_neptune
+@mock_aws
def test_delete_global_cluster():
client = boto3.client("neptune", "us-east-2")
client.create_global_cluster(GlobalClusterIdentifier="g-id2", Engine="neptune")
diff --git a/tests/test_opensearch/test_domain_tags.py b/tests/test_opensearch/test_domain_tags.py
index ef82949f1..75b27049f 100644
--- a/tests/test_opensearch/test_domain_tags.py
+++ b/tests/test_opensearch/test_domain_tags.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_opensearch
+from moto import mock_aws
-@mock_opensearch
+@mock_aws
def test_create_without_tags():
client = boto3.client("opensearch", region_name="eu-north-1")
arn = client.create_domain(DomainName="testdn")["DomainStatus"]["ARN"]
@@ -11,7 +11,7 @@ def test_create_without_tags():
assert client.list_tags(ARN=arn)["TagList"] == []
-@mock_opensearch
+@mock_aws
def test_create_with_tags():
client = boto3.client("opensearch", region_name="eu-north-1")
domain = client.create_domain(
diff --git a/tests/test_opensearch/test_opensearch.py b/tests/test_opensearch/test_opensearch.py
index 1b5afa250..7c92475fb 100644
--- a/tests/test_opensearch/test_opensearch.py
+++ b/tests/test_opensearch/test_opensearch.py
@@ -2,13 +2,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_opensearch
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_opensearch
+@mock_aws
def test_create_domain__minimal_options():
client = boto3.client("opensearch", region_name="eu-west-1")
status = client.create_domain(DomainName="testdn")["DomainStatus"]
@@ -19,7 +19,7 @@ def test_create_domain__minimal_options():
assert "Endpoints" not in status
-@mock_opensearch
+@mock_aws
def test_create_domain_in_vpc():
client = boto3.client("opensearch", region_name="eu-west-1")
status = client.create_domain(
@@ -32,7 +32,7 @@ def test_create_domain_in_vpc():
assert status["Endpoints"] is not None
-@mock_opensearch
+@mock_aws
def test_create_domain_with_some_options():
client = boto3.client("opensearch", region_name="eu-north-1")
status = client.create_domain(
@@ -57,7 +57,7 @@ def test_create_domain_with_some_options():
assert status["SnapshotOptions"] == {"AutomatedSnapshotStartHour": 20}
-@mock_opensearch
+@mock_aws
def test_get_compatible_versions():
client = boto3.client("opensearch", region_name="us-east-2")
client.create_domain(DomainName="testdn")
@@ -66,7 +66,7 @@ def test_get_compatible_versions():
assert len(versions) == 22
-@mock_opensearch
+@mock_aws
def test_get_compatible_versions_unknown_domain():
client = boto3.client("opensearch", region_name="us-east-2")
@@ -77,7 +77,7 @@ def test_get_compatible_versions_unknown_domain():
assert err["Message"] == "Domain not found: testdn"
-@mock_opensearch
+@mock_aws
def test_describe_unknown_domain():
client = boto3.client("opensearch", region_name="eu-west-1")
@@ -88,7 +88,7 @@ def test_describe_unknown_domain():
assert err["Message"] == "Domain not found: testdn"
-@mock_opensearch
+@mock_aws
def test_describe_domain():
client = boto3.client("opensearch", region_name="eu-west-1")
client.create_domain(DomainName="testdn")
@@ -99,7 +99,7 @@ def test_describe_domain():
assert status["DomainName"] == "testdn"
-@mock_opensearch
+@mock_aws
def test_delete_domain():
client = boto3.client("opensearch", region_name="eu-west-1")
client.create_domain(DomainName="testdn")
@@ -112,7 +112,7 @@ def test_delete_domain():
assert err["Message"] == "Domain not found: testdn"
-@mock_opensearch
+@mock_aws
def test_update_domain_config():
client = boto3.client("opensearch", region_name="eu-north-1")
client.create_domain(
@@ -141,7 +141,7 @@ def test_update_domain_config():
}
-@mock_opensearch
+@mock_aws
def test_list_domain_names():
client = boto3.client("opensearch", region_name="ap-southeast-1")
@@ -164,7 +164,7 @@ def test_list_domain_names():
assert test_domain_names_list_exist
-@mock_opensearch
+@mock_aws
def test_list_filtered_domain_names():
client = boto3.client("opensearch", region_name="ap-southeast-1")
@@ -188,7 +188,7 @@ def test_list_filtered_domain_names():
assert test_domain_names_list_exist
-@mock_opensearch
+@mock_aws
def test_list_unknown_domain_names_engine_type():
client = boto3.client("opensearch", region_name="ap-southeast-1")
diff --git a/tests/test_opsworks/test_apps.py b/tests/test_opsworks/test_apps.py
index d2d30ec6a..d6872f6ce 100644
--- a/tests/test_opsworks/test_apps.py
+++ b/tests/test_opsworks/test_apps.py
@@ -3,11 +3,11 @@ import pytest
from botocore.exceptions import ClientError
from freezegun import freeze_time
-from moto import mock_opsworks
+from moto import mock_aws
@freeze_time("2015-01-01")
-@mock_opsworks
+@mock_aws
def test_create_app_response():
client = boto3.client("opsworks", region_name="us-east-1")
stack_id = client.create_stack(
@@ -44,7 +44,7 @@ def test_create_app_response():
@freeze_time("2015-01-01")
-@mock_opsworks
+@mock_aws
def test_describe_apps():
client = boto3.client("opsworks", region_name="us-east-1")
stack_id = client.create_stack(
diff --git a/tests/test_opsworks/test_instances.py b/tests/test_opsworks/test_instances.py
index b85dc945f..23f2a5fd2 100644
--- a/tests/test_opsworks/test_instances.py
+++ b/tests/test_opsworks/test_instances.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_opsworks
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
-@mock_opsworks
+@mock_aws
def test_create_instance():
client = boto3.client("opsworks", region_name="us-east-1")
stack_id = client.create_stack(
@@ -74,7 +74,7 @@ def test_create_instance():
)
-@mock_opsworks
+@mock_aws
def test_describe_instances():
"""
create two stacks, with 1 layer and 2 layers (S1L1, S2L1, S2L2)
@@ -180,8 +180,7 @@ def test_describe_instances():
assert exc.value.response["Error"]["Message"] == "nothere"
-@mock_opsworks
-@mock_ec2
+@mock_aws
def test_ec2_integration():
"""Verify instances created via OpsWorks are discoverable via ec2."""
opsworks = boto3.client("opsworks", region_name="us-east-1")
diff --git a/tests/test_opsworks/test_layers.py b/tests/test_opsworks/test_layers.py
index 26d04a26b..29f9ccad7 100644
--- a/tests/test_opsworks/test_layers.py
+++ b/tests/test_opsworks/test_layers.py
@@ -3,11 +3,11 @@ import pytest
from botocore.exceptions import ClientError
from freezegun import freeze_time
-from moto import mock_opsworks
+from moto import mock_aws
@freeze_time("2015-01-01")
-@mock_opsworks
+@mock_aws
def test_create_layer_response():
client = boto3.client("opsworks", region_name="us-east-1")
stack_id = client.create_stack(
@@ -69,7 +69,7 @@ def test_create_layer_response():
@freeze_time("2015-01-01")
-@mock_opsworks
+@mock_aws
def test_describe_layers():
client = boto3.client("opsworks", region_name="us-east-1")
stack_id = client.create_stack(
diff --git a/tests/test_opsworks/test_stack.py b/tests/test_opsworks/test_stack.py
index fff1953ad..964aed8cd 100644
--- a/tests/test_opsworks/test_stack.py
+++ b/tests/test_opsworks/test_stack.py
@@ -1,10 +1,10 @@
import boto3
import pytest
-from moto import mock_opsworks
+from moto import mock_aws
-@mock_opsworks
+@mock_aws
def test_create_stack_response():
client = boto3.client("opsworks", region_name="us-east-1")
response = client.create_stack(
@@ -16,7 +16,7 @@ def test_create_stack_response():
assert "StackId" in response
-@mock_opsworks
+@mock_aws
def test_describe_stacks():
client = boto3.client("opsworks", region_name="us-east-1")
for i in range(1, 4):
diff --git a/tests/test_organizations/test_organizations_boto3.py b/tests/test_organizations/test_organizations_boto3.py
index a2101cccd..942b7c341 100644
--- a/tests/test_organizations/test_organizations_boto3.py
+++ b/tests/test_organizations/test_organizations_boto3.py
@@ -6,7 +6,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_organizations
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.organizations import utils
from moto.organizations.exceptions import InvalidInputException, TargetNotFoundException
@@ -30,7 +30,7 @@ from .organizations_test_utils import (
)
-@mock_organizations
+@mock_aws
def test_create_organization():
client = boto3.client("organizations", region_name="us-east-1")
response = client.create_organization(FeatureSet="ALL")
@@ -57,7 +57,7 @@ def test_create_organization():
assert master_account["Name"] == "master"
-@mock_organizations
+@mock_aws
def test_create_organization_without_feature_set():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization()
@@ -66,7 +66,7 @@ def test_create_organization_without_feature_set():
assert response["Organization"]["FeatureSet"] == "ALL"
-@mock_organizations
+@mock_aws
def test_describe_organization():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -74,7 +74,7 @@ def test_describe_organization():
validate_organization(response)
-@mock_organizations
+@mock_aws
def test_describe_organization_exception():
client = boto3.client("organizations", region_name="us-east-1")
with pytest.raises(ClientError) as e:
@@ -91,7 +91,7 @@ def test_describe_organization_exception():
# Organizational Units
-@mock_organizations
+@mock_aws
def test_list_roots():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -99,7 +99,7 @@ def test_list_roots():
validate_roots(org, response)
-@mock_organizations
+@mock_aws
def test_create_organizational_unit():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -110,7 +110,7 @@ def test_create_organizational_unit():
assert response["OrganizationalUnit"]["Name"] == ou_name
-@mock_organizations
+@mock_aws
def test_delete_organizational_unit():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -133,7 +133,7 @@ def test_delete_organizational_unit():
assert "OrganizationalUnitNotFoundException" in ex.response["Error"]["Message"]
-@mock_organizations
+@mock_aws
def test_describe_organizational_unit():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -145,7 +145,7 @@ def test_describe_organizational_unit():
validate_organizational_unit(org, response)
-@mock_organizations
+@mock_aws
def test_describe_organizational_unit_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -159,7 +159,7 @@ def test_describe_organizational_unit_exception():
assert "OrganizationalUnitNotFoundException" in ex.response["Error"]["Message"]
-@mock_organizations
+@mock_aws
def test_list_organizational_units_for_parent():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -173,7 +173,7 @@ def test_list_organizational_units_for_parent():
validate_organizational_unit(org, {"OrganizationalUnit": ou})
-@mock_organizations
+@mock_aws
def test_list_organizational_units_pagination():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -193,7 +193,7 @@ def test_list_organizational_units_pagination():
assert "19" in page_list[-1]["OrganizationalUnits"][-1]["Name"]
-@mock_organizations
+@mock_aws
def test_list_organizational_units_for_parent_exception():
client = boto3.client("organizations", region_name="us-east-1")
with pytest.raises(ClientError) as e:
@@ -212,7 +212,7 @@ mockdomain = "moto-example.org"
mockemail = "@".join([mockname, mockdomain])
-@mock_organizations
+@mock_aws
def test_create_account():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -223,7 +223,7 @@ def test_create_account():
assert create_status["AccountName"] == mockname
-@mock_organizations
+@mock_aws
def test_close_account_returns_nothing():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -239,7 +239,7 @@ def test_close_account_returns_nothing():
assert resp == {}
-@mock_organizations
+@mock_aws
def test_close_account_puts_account_in_suspended_status():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -254,7 +254,7 @@ def test_close_account_puts_account_in_suspended_status():
assert account["Status"] == "SUSPENDED"
-@mock_organizations
+@mock_aws
def test_close_account_id_not_in_org_raises_exception():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -271,7 +271,7 @@ def test_close_account_id_not_in_org_raises_exception():
)
-@mock_organizations
+@mock_aws
def test_describe_create_account_status():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -282,7 +282,7 @@ def test_describe_create_account_status():
validate_create_account_status(response["CreateAccountStatus"])
-@mock_organizations
+@mock_aws
def test_describe_account():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -295,7 +295,7 @@ def test_describe_account():
assert response["Account"]["Email"] == mockemail
-@mock_organizations
+@mock_aws
def test_describe_account_exception():
client = boto3.client("organizations", region_name="us-east-1")
with pytest.raises(ClientError) as e:
@@ -309,7 +309,7 @@ def test_describe_account_exception():
)
-@mock_organizations
+@mock_aws
def test_list_accounts():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -327,7 +327,7 @@ def test_list_accounts():
assert accounts[3]["Email"] == mockname + "2" + "@" + mockdomain
-@mock_organizations
+@mock_aws
def test_list_accounts_pagination():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -347,7 +347,7 @@ def test_list_accounts_pagination():
assert "24" in page_list[-1]["Accounts"][-1]["Name"]
-@mock_organizations
+@mock_aws
def test_list_accounts_for_parent():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -359,7 +359,7 @@ def test_list_accounts_for_parent():
assert account_id in [account["Id"] for account in response["Accounts"]]
-@mock_organizations
+@mock_aws
def test_list_accounts_for_parent_pagination():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -382,7 +382,7 @@ def test_list_accounts_for_parent_pagination():
assert "20" in page_list[-1]["Accounts"][-1]["Name"]
-@mock_organizations
+@mock_aws
def test_move_account():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -399,7 +399,7 @@ def test_move_account():
assert account_id in [account["Id"] for account in response["Accounts"]]
-@mock_organizations
+@mock_aws
def test_list_parents_for_ou():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -418,7 +418,7 @@ def test_list_parents_for_ou():
assert response02["Parents"][0]["Type"] == "ORGANIZATIONAL_UNIT"
-@mock_organizations
+@mock_aws
def test_list_parents_for_accounts():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -444,7 +444,7 @@ def test_list_parents_for_accounts():
assert response02["Parents"][0]["Type"] == "ORGANIZATIONAL_UNIT"
-@mock_organizations
+@mock_aws
def test_list_children():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -478,7 +478,7 @@ def test_list_children():
assert response04["Children"][0]["Type"] == "ORGANIZATIONAL_UNIT"
-@mock_organizations
+@mock_aws
def test_list_children_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -498,7 +498,7 @@ def test_list_children_exception():
assert ex.response["Error"]["Message"] == "You specified an invalid value."
-@mock_organizations
+@mock_aws
def test_list_create_account_status():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -517,7 +517,7 @@ def test_list_create_account_status():
validate_create_account_status(createAccountStatus)
-@mock_organizations
+@mock_aws
def test_list_create_account_status_succeeded():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -528,7 +528,7 @@ def test_list_create_account_status_succeeded():
validate_create_account_status(createAccountStatuses[0])
-@mock_organizations
+@mock_aws
def test_list_create_account_status_in_progress():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -538,7 +538,7 @@ def test_list_create_account_status_in_progress():
assert len(createAccountStatuses) == 0
-@mock_organizations
+@mock_aws
def test_get_paginated_list_create_account_status():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -561,7 +561,7 @@ def test_get_paginated_list_create_account_status():
validate_create_account_status(createAccountStatus)
-@mock_organizations
+@mock_aws
def test_remove_account_from_organization():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -586,7 +586,7 @@ def test_remove_account_from_organization():
assert not created_account_exists(accounts)
-@mock_organizations
+@mock_aws
def test_delete_organization_with_existing_account():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -618,7 +618,7 @@ policy_doc01 = {
}
-@mock_organizations
+@mock_aws
def test_create_policy():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -634,7 +634,7 @@ def test_create_policy():
assert policy["Content"] == json.dumps(policy_doc01)
-@mock_organizations
+@mock_aws
def test_create_policy_errors():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -658,7 +658,7 @@ def test_create_policy_errors():
assert ex.response["Error"]["Message"] == "You specified an invalid value."
-@mock_organizations
+@mock_aws
def test_describe_policy():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -675,7 +675,7 @@ def test_describe_policy():
assert policy["Content"] == json.dumps(policy_doc01)
-@mock_organizations
+@mock_aws
def test_describe_policy_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -697,7 +697,7 @@ def test_describe_policy_exception():
assert ex.response["Error"]["Message"] == "You specified an invalid value."
-@mock_organizations
+@mock_aws
def test_attach_policy():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -722,7 +722,7 @@ def test_attach_policy():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_organizations
+@mock_aws
def test_detach_policy():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -770,7 +770,7 @@ def get_nonaws_policies(account_id, client):
]
-@mock_organizations
+@mock_aws
def test_detach_policy_root_ou_not_found_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -797,7 +797,7 @@ def test_detach_policy_root_ou_not_found_exception():
assert "OrganizationalUnitNotFoundException" in ex.response["Error"]["Message"]
-@mock_organizations
+@mock_aws
def test_detach_policy_ou_not_found_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -820,7 +820,7 @@ def test_detach_policy_ou_not_found_exception():
assert "OrganizationalUnitNotFoundException" in ex.response["Error"]["Message"]
-@mock_organizations
+@mock_aws
def test_detach_policy_account_id_not_found_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -845,7 +845,7 @@ def test_detach_policy_account_id_not_found_exception():
)
-@mock_organizations
+@mock_aws
def test_detach_policy_invalid_target_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -869,7 +869,7 @@ def test_detach_policy_invalid_target_exception():
assert ex.response["Error"]["Message"] == "You specified an invalid value."
-@mock_organizations
+@mock_aws
def test_delete_policy():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -890,7 +890,7 @@ def test_delete_policy():
assert len(new_policies) == 1
-@mock_organizations
+@mock_aws
def test_delete_policy_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -922,7 +922,7 @@ def test_delete_policy_exception():
assert "PolicyInUseException" in ex.response["Error"]["Message"]
-@mock_organizations
+@mock_aws
def test_attach_policy_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -965,7 +965,7 @@ def test_attach_policy_exception():
assert ex.response["Error"]["Message"] == "You specified an invalid value."
-@mock_organizations
+@mock_aws
def test_update_policy():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -990,7 +990,7 @@ def test_update_policy():
validate_service_control_policy(org, response["Policy"])
-@mock_organizations
+@mock_aws
def test_update_policy_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -1006,7 +1006,7 @@ def test_update_policy_exception():
)
-@mock_organizations
+@mock_aws
def test_list_polices():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -1022,7 +1022,7 @@ def test_list_polices():
validate_policy_summary(org, policy)
-@mock_organizations
+@mock_aws
def test_list_policies_for_target():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -1053,7 +1053,7 @@ def test_list_policies_for_target():
validate_policy_summary(org, policy)
-@mock_organizations
+@mock_aws
def test_list_policies_for_target_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -1116,7 +1116,7 @@ def test_list_policies_for_target_exception():
assert ex.response["Error"]["Message"] == "You specified an invalid value."
-@mock_organizations
+@mock_aws
def test_list_targets_for_policy():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -1145,7 +1145,7 @@ def test_list_targets_for_policy():
assert target["Type"] in ["ROOT", "ORGANIZATIONAL_UNIT", "ACCOUNT"]
-@mock_organizations
+@mock_aws
def test_list_targets_for_policy_exception():
client = boto3.client("organizations", region_name="us-east-1")
_ = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -1167,7 +1167,7 @@ def test_list_targets_for_policy_exception():
assert ex.response["Error"]["Message"] == "You specified an invalid value."
-@mock_organizations
+@mock_aws
def test_tag_resource_account():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1194,7 +1194,7 @@ def test_tag_resource_account():
assert response["Tags"] == []
-@mock_organizations
+@mock_aws
def test_tag_resource_organization_organization_root():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1219,7 +1219,7 @@ def test_tag_resource_organization_organization_root():
assert response["Tags"] == []
-@mock_organizations
+@mock_aws
def test_tag_resource_organization_organizational_unit():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1247,7 +1247,7 @@ def test_tag_resource_organization_organizational_unit():
assert response["Tags"] == []
-@mock_organizations
+@mock_aws
def test_tag_resource_policy():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1279,7 +1279,7 @@ def test_tag_resource_policy():
assert response["Tags"] == []
-@mock_organizations
+@mock_aws
def test_tag_resource_errors():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1400,7 +1400,7 @@ def test__get_resource_to_tag_incorrect_resource():
)
-@mock_organizations
+@mock_aws
def test_list_tags_for_resource():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1414,7 +1414,7 @@ def test_list_tags_for_resource():
assert response["Tags"] == [{"Key": "key", "Value": "value"}]
-@mock_organizations
+@mock_aws
def test_list_tags_for_resource_errors():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1439,7 +1439,7 @@ def test_list_tags_for_resource_errors():
)
-@mock_organizations
+@mock_aws
def test_untag_resource():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1460,7 +1460,7 @@ def test_untag_resource():
assert len(response["Tags"]) == 0
-@mock_organizations
+@mock_aws
def test_untag_resource_errors():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1485,7 +1485,7 @@ def test_untag_resource_errors():
)
-@mock_organizations
+@mock_aws
def test_update_organizational_unit():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -1502,7 +1502,7 @@ def test_update_organizational_unit():
assert response["OrganizationalUnit"]["Name"] == new_ou_name
-@mock_organizations
+@mock_aws
def test_update_organizational_unit_duplicate_error():
client = boto3.client("organizations", region_name="us-east-1")
org = client.create_organization(FeatureSet="ALL")["Organization"]
@@ -1523,7 +1523,7 @@ def test_update_organizational_unit_duplicate_error():
)
-@mock_organizations
+@mock_aws
def test_enable_aws_service_access():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1552,7 +1552,7 @@ def test_enable_aws_service_access():
assert service["DateEnabled"] == date_enabled
-@mock_organizations
+@mock_aws
def test_enable_aws_service_access_error():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1568,7 +1568,7 @@ def test_enable_aws_service_access_error():
)
-@mock_organizations
+@mock_aws
def test_enable_multiple_aws_service_access():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1590,7 +1590,7 @@ def test_enable_multiple_aws_service_access():
assert isinstance(services[1]["DateEnabled"], datetime)
-@mock_organizations
+@mock_aws
def test_disable_aws_service_access():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1613,7 +1613,7 @@ def test_disable_aws_service_access():
assert len(response["EnabledServicePrincipals"]) == 0
-@mock_organizations
+@mock_aws
def test_disable_aws_service_access_errors():
client = boto3.client("organizations", region_name="us-east-1")
client.create_organization(FeatureSet="ALL")
@@ -1629,7 +1629,7 @@ def test_disable_aws_service_access_errors():
)
-@mock_organizations
+@mock_aws
def test_register_delegated_administrator():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1659,7 +1659,7 @@ def test_register_delegated_administrator():
assert isinstance(admin["DelegationEnabledDate"], datetime)
-@mock_organizations
+@mock_aws
def test_register_delegated_administrator_errors():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1738,7 +1738,7 @@ def test_register_delegated_administrator_errors():
)
-@mock_organizations
+@mock_aws
def test_list_delegated_administrators():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1785,7 +1785,7 @@ def test_list_delegated_administrators():
assert isinstance(admin["DelegationEnabledDate"], datetime)
-@mock_organizations
+@mock_aws
def test_list_delegated_administrators_erros():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1806,7 +1806,7 @@ def test_list_delegated_administrators_erros():
)
-@mock_organizations
+@mock_aws
def test_list_delegated_services_for_account():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1831,7 +1831,7 @@ def test_list_delegated_services_for_account():
) == ["guardduty.amazonaws.com", "ssm.amazonaws.com"]
-@mock_organizations
+@mock_aws
def test_list_delegated_services_for_account_erros():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1866,7 +1866,7 @@ def test_list_delegated_services_for_account_erros():
)
-@mock_organizations
+@mock_aws
def test_deregister_delegated_administrator():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1888,7 +1888,7 @@ def test_deregister_delegated_administrator():
assert len(response["DelegatedAdministrators"]) == 0
-@mock_organizations
+@mock_aws
def test_deregister_delegated_administrator_erros():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1968,7 +1968,7 @@ def test_deregister_delegated_administrator_erros():
)
-@mock_organizations
+@mock_aws
def test_enable_policy_type():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -1992,7 +1992,7 @@ def test_enable_policy_type():
)
-@mock_organizations
+@mock_aws
def test_enable_policy_type_errors():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -2045,7 +2045,7 @@ def test_enable_policy_type_errors():
assert ex.response["Error"]["Message"] == "You specified an invalid value."
-@mock_organizations
+@mock_aws
def test_disable_policy_type():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -2068,7 +2068,7 @@ def test_disable_policy_type():
assert root["PolicyTypes"] == []
-@mock_organizations
+@mock_aws
def test_disable_policy_type_errors():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -2120,7 +2120,7 @@ def test_disable_policy_type_errors():
assert ex.response["Error"]["Message"] == "You specified an invalid value."
-@mock_organizations
+@mock_aws
def test_aiservices_opt_out_policy():
# given
client = boto3.client("organizations", region_name="us-east-1")
diff --git a/tests/test_panorama/test_panorama_device.py b/tests/test_panorama/test_panorama_device.py
index d452055bd..72b966fa1 100644
--- a/tests/test_panorama/test_panorama_device.py
+++ b/tests/test_panorama/test_panorama_device.py
@@ -8,11 +8,11 @@ from botocore.exceptions import ClientError
from dateutil.tz import tzutc
from freezegun import freeze_time
-from moto import mock_panorama, settings
+from moto import mock_aws, settings
from moto.moto_api import state_manager
-@mock_panorama
+@mock_aws
def test_provision_device() -> None:
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't use ManagedState in ServerMode")
@@ -59,7 +59,7 @@ def test_provision_device() -> None:
assert resp["Status"] == "AWAITING_PROVISIONING"
-@mock_panorama
+@mock_aws
def test_describe_device() -> None:
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't freeze time in ServerMode")
@@ -140,7 +140,7 @@ def test_describe_device() -> None:
assert resp["Type"] == "PANORAMA_APPLIANCE"
-@mock_panorama
+@mock_aws
def test_provision_device_aggregated_status_lifecycle() -> None:
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't use ManagedState in ServerMode")
@@ -208,7 +208,7 @@ def test_provision_device_aggregated_status_lifecycle() -> None:
assert resp_3["ProvisioningStatus"] == "PENDING"
-@mock_panorama
+@mock_aws
def test_list_device() -> None:
client = boto3.client("panorama", region_name="eu-west-1")
resp_1 = client.provision_device(
@@ -256,7 +256,7 @@ def test_list_device() -> None:
assert resp["Devices"][1]["DeviceId"] == resp_2["DeviceId"]
-@mock_panorama
+@mock_aws
def test_list_device_name_filter() -> None:
client = boto3.client("panorama", region_name="eu-west-1")
resp_1 = client.provision_device(
@@ -282,7 +282,7 @@ def test_list_device_name_filter() -> None:
assert resp["Devices"][1]["DeviceId"] == resp_2["DeviceId"]
-@mock_panorama
+@mock_aws
def test_list_device_max_result_and_next_token() -> None:
client = boto3.client("panorama", region_name="eu-west-1")
_ = client.provision_device(
@@ -314,7 +314,7 @@ def test_list_device_max_result_and_next_token() -> None:
("DESCENDING", [1, 0]),
],
)
-@mock_panorama
+@mock_aws
def test_list_devices_sort_order(sort_order: str, indexes: List[int]) -> None:
client = boto3.client("panorama", region_name="eu-west-1")
resp_1 = client.provision_device(
@@ -344,7 +344,7 @@ def test_list_devices_sort_order(sort_order: str, indexes: List[int]) -> None:
("DEVICE_AGGREGATED_STATUS", [1, 0]),
],
)
-@mock_panorama
+@mock_aws
def test_list_devices_sort_by(sort_by: str, indexes: List[int]) -> None:
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't freeze time in ServerMode")
@@ -373,7 +373,7 @@ def test_list_devices_sort_by(sort_by: str, indexes: List[int]) -> None:
assert resp["Devices"][indexes[1]]["DeviceId"] == resp_2["DeviceId"]
-@mock_panorama
+@mock_aws
def test_list_devices_device_aggregated_status_filter() -> None:
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't use ManagedState in ServerMode")
@@ -401,7 +401,7 @@ def test_list_devices_device_aggregated_status_filter() -> None:
assert resp["Devices"][0]["DeviceId"] == resp_2["DeviceId"]
-@mock_panorama
+@mock_aws
def test_update_device_metadata() -> None:
client = boto3.client("panorama", region_name="eu-west-1")
resp = client.provision_device(
@@ -418,7 +418,7 @@ def test_update_device_metadata() -> None:
assert resp_updated["Description"] == "updated device description"
-@mock_panorama
+@mock_aws
def test_delete_device() -> None:
client = boto3.client("panorama", region_name="eu-west-1")
resp = client.provision_device(
diff --git a/tests/test_personalize/test_personalize_schema.py b/tests/test_personalize/test_personalize_schema.py
index fa31aea64..9888ddf92 100644
--- a/tests/test_personalize/test_personalize_schema.py
+++ b/tests/test_personalize/test_personalize_schema.py
@@ -6,14 +6,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_personalize
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_personalize
+@mock_aws
def test_create_schema():
client = boto3.client("personalize", region_name="ap-southeast-1")
schema = {
@@ -37,7 +37,7 @@ def test_create_schema():
)
-@mock_personalize
+@mock_aws
def test_delete_schema():
client = boto3.client("personalize", region_name="us-east-1")
schema_arn = client.create_schema(name="myname", schema=json.dumps("sth"))[
@@ -48,7 +48,7 @@ def test_delete_schema():
assert client.list_schemas()["schemas"] == []
-@mock_personalize
+@mock_aws
def test_delete_schema__unknown():
arn = f"arn:aws:personalize:ap-southeast-1:{DEFAULT_ACCOUNT_ID}:schema/personalize-demo-schema"
client = boto3.client("personalize", region_name="us-east-2")
@@ -59,7 +59,7 @@ def test_delete_schema__unknown():
assert err["Message"] == f"Resource Arn {arn} does not exist."
-@mock_personalize
+@mock_aws
def test_describe_schema():
client = boto3.client("personalize", region_name="us-east-2")
schema_arn = client.create_schema(name="myname", schema="sth")["schemaArn"]
@@ -74,7 +74,7 @@ def test_describe_schema():
assert "lastUpdatedDateTime" in schema
-@mock_personalize
+@mock_aws
def test_describe_schema__with_domain():
client = boto3.client("personalize", region_name="us-east-2")
schema_arn = client.create_schema(name="myname", schema="sth", domain="ECOMMERCE")[
@@ -87,7 +87,7 @@ def test_describe_schema__with_domain():
assert schema["domain"] == "ECOMMERCE"
-@mock_personalize
+@mock_aws
def test_describe_schema__unknown():
arn = (
"arn:aws:personalize:ap-southeast-1:486285699788:schema/personalize-demo-schema"
@@ -100,7 +100,7 @@ def test_describe_schema__unknown():
assert err["Message"] == f"Resource Arn {arn} does not exist."
-@mock_personalize
+@mock_aws
def test_list_schemas__initial():
client = boto3.client("personalize", region_name="us-east-2")
resp = client.list_schemas()
@@ -108,7 +108,7 @@ def test_list_schemas__initial():
assert resp["schemas"] == []
-@mock_personalize
+@mock_aws
def test_list_schema():
client = boto3.client("personalize", region_name="us-east-2")
schema_arn = client.create_schema(name="myname", schema="sth")["schemaArn"]
diff --git a/tests/test_pinpoint/test_pinpoint.py b/tests/test_pinpoint/test_pinpoint.py
index 4230fee58..a532fccb2 100644
--- a/tests/test_pinpoint/test_pinpoint.py
+++ b/tests/test_pinpoint/test_pinpoint.py
@@ -3,13 +3,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_pinpoint
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_pinpoint
+@mock_aws
def test_create_app():
client = boto3.client("pinpoint", region_name="us-east-1")
resp = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})
@@ -21,7 +21,7 @@ def test_create_app():
assert "CreationDate" in resp["ApplicationResponse"]
-@mock_pinpoint
+@mock_aws
def test_delete_app():
client = boto3.client("pinpoint", region_name="ap-southeast-1")
creation = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})[
@@ -39,7 +39,7 @@ def test_delete_app():
assert err["Message"] == "Application not found"
-@mock_pinpoint
+@mock_aws
def test_get_app():
client = boto3.client("pinpoint", region_name="eu-west-1")
resp = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})
@@ -54,7 +54,7 @@ def test_get_app():
assert "CreationDate" in resp["ApplicationResponse"]
-@mock_pinpoint
+@mock_aws
def test_get_apps_initial():
client = boto3.client("pinpoint", region_name="us-east-1")
resp = client.get_apps()
@@ -63,7 +63,7 @@ def test_get_apps_initial():
assert resp["ApplicationsResponse"] == {"Item": []}
-@mock_pinpoint
+@mock_aws
def test_get_apps():
client = boto3.client("pinpoint", region_name="us-east-1")
resp = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})
@@ -78,7 +78,7 @@ def test_get_apps():
assert "CreationDate" in resp["ApplicationsResponse"]["Item"][0]
-@mock_pinpoint
+@mock_aws
def test_update_application_settings():
client = boto3.client("pinpoint", region_name="eu-west-1")
resp = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})
@@ -102,7 +102,7 @@ def test_update_application_settings():
assert "LastModifiedDate" in app_settings
-@mock_pinpoint
+@mock_aws
def test_get_application_settings():
client = boto3.client("pinpoint", region_name="ap-southeast-1")
resp = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})
diff --git a/tests/test_pinpoint/test_pinpoint_application_tags.py b/tests/test_pinpoint/test_pinpoint_application_tags.py
index b011aee33..fa11b30d2 100644
--- a/tests/test_pinpoint/test_pinpoint_application_tags.py
+++ b/tests/test_pinpoint/test_pinpoint_application_tags.py
@@ -1,10 +1,10 @@
"""Unit tests for pinpoint-supported APIs."""
import boto3
-from moto import mock_pinpoint
+from moto import mock_aws
-@mock_pinpoint
+@mock_aws
def test_list_tags_for_resource_empty():
client = boto3.client("pinpoint", region_name="ap-southeast-1")
resp = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})
@@ -14,7 +14,7 @@ def test_list_tags_for_resource_empty():
assert resp["TagsModel"] == {"tags": {}}
-@mock_pinpoint
+@mock_aws
def test_list_tags_for_resource():
client = boto3.client("pinpoint", region_name="ap-southeast-1")
resp = client.create_app(
@@ -30,7 +30,7 @@ def test_list_tags_for_resource():
assert resp["TagsModel"]["tags"] == {"key1": "value1", "key2": "value2"}
-@mock_pinpoint
+@mock_aws
def test_tag_resource():
client = boto3.client("pinpoint", region_name="us-east-1")
resp = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})
@@ -45,7 +45,7 @@ def test_tag_resource():
assert resp["TagsModel"]["tags"] == {"key1": "value1", "key2": "value2"}
-@mock_pinpoint
+@mock_aws
def test_untag_resource():
client = boto3.client("pinpoint", region_name="eu-west-1")
resp = client.create_app(
diff --git a/tests/test_pinpoint/test_pinpoint_event_stream.py b/tests/test_pinpoint/test_pinpoint_event_stream.py
index 7f0ed5b53..57f85f580 100644
--- a/tests/test_pinpoint/test_pinpoint_event_stream.py
+++ b/tests/test_pinpoint/test_pinpoint_event_stream.py
@@ -3,13 +3,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_pinpoint
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_pinpoint
+@mock_aws
def test_put_event_stream():
client = boto3.client("pinpoint", region_name="eu-west-1")
resp = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})
@@ -27,7 +27,7 @@ def test_put_event_stream():
assert resp["EventStream"]["RoleArn"] == "iam:arn"
-@mock_pinpoint
+@mock_aws
def test_get_event_stream():
client = boto3.client("pinpoint", region_name="us-east-1")
resp = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})
@@ -47,7 +47,7 @@ def test_get_event_stream():
assert resp["EventStream"]["RoleArn"] == "iam:arn"
-@mock_pinpoint
+@mock_aws
def test_delete_event_stream():
client = boto3.client("pinpoint", region_name="us-east-1")
resp = client.create_app(CreateApplicationRequest={"Name": "myfirstapp"})
diff --git a/tests/test_polly/test_polly.py b/tests/test_polly/test_polly.py
index c02788905..264cc82cb 100644
--- a/tests/test_polly/test_polly.py
+++ b/tests/test_polly/test_polly.py
@@ -1,7 +1,7 @@
import boto3
from botocore.exceptions import ClientError
-from moto import mock_polly
+from moto import mock_aws
# Polly only available in a few regions
DEFAULT_REGION = "eu-west-1"
@@ -21,7 +21,7 @@ LEXICON_XML = """
"""
-@mock_polly
+@mock_aws
def test_describe_voices():
client = boto3.client("polly", region_name=DEFAULT_REGION)
@@ -39,7 +39,7 @@ def test_describe_voices():
raise RuntimeError("Should have raised an exception")
-@mock_polly
+@mock_aws
def test_put_list_lexicon():
client = boto3.client("polly", region_name=DEFAULT_REGION)
@@ -50,7 +50,7 @@ def test_put_list_lexicon():
assert len(resp["Lexicons"]) == 1
-@mock_polly
+@mock_aws
def test_put_get_lexicon():
client = boto3.client("polly", region_name=DEFAULT_REGION)
@@ -62,7 +62,7 @@ def test_put_get_lexicon():
assert "LexiconAttributes" in resp
-@mock_polly
+@mock_aws
def test_put_lexicon_bad_name():
client = boto3.client("polly", region_name=DEFAULT_REGION)
@@ -74,7 +74,7 @@ def test_put_lexicon_bad_name():
raise RuntimeError("Should have raised an exception")
-@mock_polly
+@mock_aws
def test_synthesize_speech():
client = boto3.client("polly", region_name=DEFAULT_REGION)
@@ -94,7 +94,7 @@ def test_synthesize_speech():
assert resp["ContentType"] == content_type
-@mock_polly
+@mock_aws
def test_synthesize_speech_bad_lexicon():
client = boto3.client("polly", region_name=DEFAULT_REGION)
client.put_lexicon(Name="test", Content=LEXICON_XML)
@@ -114,7 +114,7 @@ def test_synthesize_speech_bad_lexicon():
raise RuntimeError("Should have raised LexiconNotFoundException")
-@mock_polly
+@mock_aws
def test_synthesize_speech_bad_output_format():
client = boto3.client("polly", region_name=DEFAULT_REGION)
client.put_lexicon(Name="test", Content=LEXICON_XML)
@@ -134,7 +134,7 @@ def test_synthesize_speech_bad_output_format():
raise RuntimeError("Should have raised ")
-@mock_polly
+@mock_aws
def test_synthesize_speech_bad_sample_rate():
client = boto3.client("polly", region_name=DEFAULT_REGION)
client.put_lexicon(Name="test", Content=LEXICON_XML)
@@ -154,7 +154,7 @@ def test_synthesize_speech_bad_sample_rate():
raise RuntimeError("Should have raised ")
-@mock_polly
+@mock_aws
def test_synthesize_speech_bad_text_type():
client = boto3.client("polly", region_name=DEFAULT_REGION)
client.put_lexicon(Name="test", Content=LEXICON_XML)
@@ -174,7 +174,7 @@ def test_synthesize_speech_bad_text_type():
raise RuntimeError("Should have raised ")
-@mock_polly
+@mock_aws
def test_synthesize_speech_bad_voice_id():
client = boto3.client("polly", region_name=DEFAULT_REGION)
client.put_lexicon(Name="test", Content=LEXICON_XML)
@@ -194,7 +194,7 @@ def test_synthesize_speech_bad_voice_id():
raise RuntimeError("Should have raised ")
-@mock_polly
+@mock_aws
def test_synthesize_speech_text_too_long():
client = boto3.client("polly", region_name=DEFAULT_REGION)
client.put_lexicon(Name="test", Content=LEXICON_XML)
@@ -214,7 +214,7 @@ def test_synthesize_speech_text_too_long():
raise RuntimeError("Should have raised ")
-@mock_polly
+@mock_aws
def test_synthesize_speech_bad_speech_marks1():
client = boto3.client("polly", region_name=DEFAULT_REGION)
client.put_lexicon(Name="test", Content=LEXICON_XML)
@@ -235,7 +235,7 @@ def test_synthesize_speech_bad_speech_marks1():
raise RuntimeError("Should have raised ")
-@mock_polly
+@mock_aws
def test_synthesize_speech_bad_speech_marks2():
client = boto3.client("polly", region_name=DEFAULT_REGION)
client.put_lexicon(Name="test", Content=LEXICON_XML)
@@ -256,7 +256,7 @@ def test_synthesize_speech_bad_speech_marks2():
raise RuntimeError("Should have raised ")
-@mock_polly
+@mock_aws
def test_update_lexicon():
client = boto3.client("polly", region_name=DEFAULT_REGION)
client.put_lexicon(Name="test", Content=LEXICON_XML)
diff --git a/tests/test_polly/test_server.py b/tests/test_polly/test_server.py
index 8db2b148f..cb5f6cba8 100644
--- a/tests/test_polly/test_server.py
+++ b/tests/test_polly/test_server.py
@@ -1,9 +1,9 @@
"""Test the different server responses."""
import moto.server as server
-from moto import mock_polly
+from moto import mock_aws
-@mock_polly
+@mock_aws
def test_polly_list():
backend = server.create_backend_app("polly")
test_client = backend.test_client()
diff --git a/tests/test_quicksight/test_quicksight_datasets.py b/tests/test_quicksight/test_quicksight_datasets.py
index 1bce45a4b..d6b92ad88 100644
--- a/tests/test_quicksight/test_quicksight_datasets.py
+++ b/tests/test_quicksight/test_quicksight_datasets.py
@@ -1,13 +1,13 @@
import boto3
-from moto import mock_quicksight
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_quicksight
+@mock_aws
def test_create_data_set():
client = boto3.client("quicksight", region_name="eu-west-1")
@@ -35,7 +35,7 @@ def test_create_data_set():
)
-@mock_quicksight
+@mock_aws
def test_create_ingestion():
client = boto3.client("quicksight", region_name="eu-west-1")
diff --git a/tests/test_quicksight/test_quicksight_groups.py b/tests/test_quicksight/test_quicksight_groups.py
index 5624b0fc6..718f63465 100644
--- a/tests/test_quicksight/test_quicksight_groups.py
+++ b/tests/test_quicksight/test_quicksight_groups.py
@@ -3,14 +3,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_quicksight
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_quicksight
+@mock_aws
def test_create_group():
client = boto3.client("quicksight", region_name="us-west-2")
resp = client.create_group(
@@ -30,7 +30,7 @@ def test_create_group():
assert resp["Group"]["PrincipalId"] == f"{ACCOUNT_ID}"
-@mock_quicksight
+@mock_aws
def test_describe_group():
client = boto3.client("quicksight", region_name="us-west-2")
client.create_group(
@@ -54,7 +54,7 @@ def test_describe_group():
assert resp["Group"]["PrincipalId"] == f"{ACCOUNT_ID}"
-@mock_quicksight
+@mock_aws
def test_update_group():
client = boto3.client("quicksight", region_name="us-west-2")
client.create_group(
@@ -85,7 +85,7 @@ def test_update_group():
assert resp["Group"]["PrincipalId"] == f"{ACCOUNT_ID}"
-@mock_quicksight
+@mock_aws
def test_delete_group():
client = boto3.client("quicksight", region_name="us-east-2")
client.create_group(
@@ -107,7 +107,7 @@ def test_delete_group():
assert err["Code"] == "ResourceNotFoundException"
-@mock_quicksight
+@mock_aws
def test_list_groups__initial():
client = boto3.client("quicksight", region_name="us-east-2")
resp = client.list_groups(AwsAccountId=ACCOUNT_ID, Namespace="default")
@@ -116,7 +116,7 @@ def test_list_groups__initial():
assert resp["Status"] == 200
-@mock_quicksight
+@mock_aws
def test_list_groups():
client = boto3.client("quicksight", region_name="us-east-1")
for i in range(4):
diff --git a/tests/test_quicksight/test_quicksight_users.py b/tests/test_quicksight/test_quicksight_users.py
index 255e5f05a..b1a80e038 100644
--- a/tests/test_quicksight/test_quicksight_users.py
+++ b/tests/test_quicksight/test_quicksight_users.py
@@ -3,14 +3,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_quicksight
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_quicksight
+@mock_aws
def test_register_user__quicksight():
client = boto3.client("quicksight", region_name="us-east-2")
resp = client.register_user(
@@ -35,7 +35,7 @@ def test_register_user__quicksight():
assert resp["User"]["Active"] is False
-@mock_quicksight
+@mock_aws
def test_describe_user__quicksight():
client = boto3.client("quicksight", region_name="us-east-1")
client.register_user(
@@ -63,7 +63,7 @@ def test_describe_user__quicksight():
assert resp["User"]["Active"] is False
-@mock_quicksight
+@mock_aws
def test_delete_user__quicksight():
client = boto3.client("quicksight", region_name="us-east-2")
client.register_user(
@@ -87,7 +87,7 @@ def test_delete_user__quicksight():
assert err["Code"] == "ResourceNotFoundException"
-@mock_quicksight
+@mock_aws
def test_list_users__initial():
client = boto3.client("quicksight", region_name="us-east-2")
resp = client.list_users(AwsAccountId=ACCOUNT_ID, Namespace="default")
@@ -96,7 +96,7 @@ def test_list_users__initial():
assert resp["Status"] == 200
-@mock_quicksight
+@mock_aws
def test_list_users():
client = boto3.client("quicksight", region_name="us-east-2")
for i in range(4):
@@ -135,7 +135,7 @@ def test_list_users():
} in resp["UserList"]
-@mock_quicksight
+@mock_aws
def test_create_group_membership():
client = boto3.client("quicksight", region_name="us-east-2")
client.register_user(
@@ -164,7 +164,7 @@ def test_create_group_membership():
assert resp["Status"] == 200
-@mock_quicksight
+@mock_aws
def test_describe_group_membership():
client = boto3.client("quicksight", region_name="us-east-2")
client.register_user(
@@ -200,7 +200,7 @@ def test_describe_group_membership():
assert resp["Status"] == 200
-@mock_quicksight
+@mock_aws
def test_list_group_memberships():
client = boto3.client("quicksight", region_name="us-east-2")
for i in range(3):
@@ -255,7 +255,7 @@ def test_list_group_memberships():
} in resp["GroupMemberList"]
-@mock_quicksight
+@mock_aws
def test_list_group_memberships__after_deleting_user():
client = boto3.client("quicksight", region_name="us-east-2")
client.create_group(
diff --git a/tests/test_ram/test_ram.py b/tests/test_ram/test_ram.py
index 79ec87947..6b4ed32f8 100644
--- a/tests/test_ram/test_ram.py
+++ b/tests/test_ram/test_ram.py
@@ -6,11 +6,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_organizations, mock_ram
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_ram
+@mock_aws
def test_create_resource_share():
# given
client = boto3.client("ram", region_name="us-east-1")
@@ -66,7 +66,7 @@ def test_create_resource_share():
assert len(response["resourceShares"]) == 2
-@mock_ram
+@mock_aws
def test_create_resource_share_errors():
# given
client = boto3.client("ram", region_name="us-east-1")
@@ -118,8 +118,7 @@ def test_create_resource_share_errors():
)
-@mock_ram
-@mock_organizations
+@mock_aws
def test_create_resource_share_with_organization():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -157,8 +156,7 @@ def test_create_resource_share_with_organization():
assert response["resourceShare"]["name"] == "test"
-@mock_ram
-@mock_organizations
+@mock_aws
def test_create_resource_share_with_organization_errors():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -204,7 +202,7 @@ def test_create_resource_share_with_organization_errors():
)
-@mock_ram
+@mock_aws
def test_get_resource_shares():
# given
client = boto3.client("ram", region_name="us-east-1")
@@ -232,7 +230,7 @@ def test_get_resource_shares():
assert resource["status"] == "ACTIVE"
-@mock_ram
+@mock_aws
def test_get_resource_shares_errors():
# given
client = boto3.client("ram", region_name="us-east-1")
@@ -251,7 +249,7 @@ def test_get_resource_shares_errors():
)
-@mock_ram
+@mock_aws
def test_update_resource_share():
# given
client = boto3.client("ram", region_name="us-east-1")
@@ -282,7 +280,7 @@ def test_update_resource_share():
assert len(response["resourceShares"]) == 1
-@mock_ram
+@mock_aws
def test_update_resource_share_errors():
# given
client = boto3.client("ram", region_name="us-east-1")
@@ -304,7 +302,7 @@ def test_update_resource_share_errors():
)
-@mock_ram
+@mock_aws
def test_delete_resource_share():
# given
client = boto3.client("ram", region_name="us-east-1")
@@ -325,7 +323,7 @@ def test_delete_resource_share():
assert resource["lastUpdatedTime"] > creation_time
-@mock_ram
+@mock_aws
def test_delete_resource_share_errors():
# given
client = boto3.client("ram", region_name="us-east-1")
@@ -346,8 +344,7 @@ def test_delete_resource_share_errors():
)
-@mock_ram
-@mock_organizations
+@mock_aws
def test_enable_sharing_with_aws_organization():
# given
client = boto3.client("organizations", region_name="us-east-1")
@@ -361,8 +358,7 @@ def test_enable_sharing_with_aws_organization():
assert response["returnValue"] is True
-@mock_ram
-@mock_organizations
+@mock_aws
def test_enable_sharing_with_aws_organization_errors():
# given
client = boto3.client("ram", region_name="us-east-1")
diff --git a/tests/test_rds/test_db_cluster_param_group.py b/tests/test_rds/test_db_cluster_param_group.py
index 3257bd624..e1ceaf7e2 100644
--- a/tests/test_rds/test_db_cluster_param_group.py
+++ b/tests/test_rds/test_db_cluster_param_group.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_rds
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID
-@mock_rds
+@mock_aws
def test_create_describe_delete():
client = boto3.client("rds", "us-east-2")
diff --git a/tests/test_rds/test_db_cluster_params.py b/tests/test_rds/test_db_cluster_params.py
index d26ddf009..781ebe27e 100644
--- a/tests/test_rds/test_db_cluster_params.py
+++ b/tests/test_rds/test_db_cluster_params.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_rds
+from moto import mock_aws
-@mock_rds
+@mock_aws
def test_describe_db_cluster_parameters():
client = boto3.client("rds", "us-east-2")
diff --git a/tests/test_rds/test_filters.py b/tests/test_rds/test_filters.py
index cb4045241..a6713cd60 100644
--- a/tests/test_rds/test_filters.py
+++ b/tests/test_rds/test_filters.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_rds
+from moto import mock_aws
class TestDBInstanceFilters:
- mock = mock_rds()
+ mock = mock_aws()
@classmethod
def setup_class(cls):
@@ -188,7 +188,7 @@ class TestDBInstanceFilters:
class TestDBSnapshotFilters:
- mock = mock_rds()
+ mock = mock_aws()
@classmethod
def setup_class(cls):
@@ -385,7 +385,7 @@ class TestDBSnapshotFilters:
class TestDBClusterSnapshotFilters:
- mock = mock_rds()
+ mock = mock_aws()
@classmethod
def setup_class(cls):
diff --git a/tests/test_rds/test_global_clusters.py b/tests/test_rds/test_global_clusters.py
index 0eb02a4b1..be84baa71 100644
--- a/tests/test_rds/test_global_clusters.py
+++ b/tests/test_rds/test_global_clusters.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_rds
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID
-@mock_rds
+@mock_aws
def test_create_global_cluster__not_enough_parameters():
client = boto3.client("rds", "us-east-1")
@@ -20,7 +20,7 @@ def test_create_global_cluster__not_enough_parameters():
)
-@mock_rds
+@mock_aws
def test_global_cluster_members():
# WHEN create_global_cluster is called
# AND create_db_cluster is called with GlobalClusterIdentifier set to the global cluster ARN
@@ -62,7 +62,7 @@ def test_global_cluster_members():
assert global_cluster["GlobalClusterMembers"][0]["DBClusterArn"] == cluster_arn
-@mock_rds
+@mock_aws
def test_create_global_cluster_from_regular_cluster():
# WHEN create_db_cluster is called
# AND create_global_cluster is called with SourceDBClusterIdentifier
@@ -92,7 +92,7 @@ def test_create_global_cluster_from_regular_cluster():
assert global_cluster["GlobalClusterMembers"][0]["DBClusterArn"] == cluster_arn
-@mock_rds
+@mock_aws
def test_create_global_cluster_from_regular_cluster_with_reader():
east_client = boto3.client("rds", "eu-west-1")
west_client = boto3.client("rds", "eu-west-2")
@@ -152,7 +152,7 @@ def test_create_global_cluster_from_regular_cluster_with_reader():
assert not members[1]["IsWriter"]
-@mock_rds
+@mock_aws
def test_create_global_cluster_from_regular_cluster__using_name():
client = boto3.client("rds", "us-east-1")
@@ -165,7 +165,7 @@ def test_create_global_cluster_from_regular_cluster__using_name():
assert err["Message"] == "Malformed db cluster arn dbci"
-@mock_rds
+@mock_aws
def test_create_global_cluster_from_regular_cluster__and_specify_engine():
client = boto3.client("rds", "us-east-1")
@@ -192,7 +192,7 @@ def test_create_global_cluster_from_regular_cluster__and_specify_engine():
)
-@mock_rds
+@mock_aws
def test_delete_non_global_cluster():
# WHEN a global cluster contains a regular cluster
# AND we attempt to delete the global cluster
@@ -229,7 +229,7 @@ def test_delete_non_global_cluster():
assert client.describe_global_clusters()["GlobalClusters"] == []
-@mock_rds
+@mock_aws
def test_remove_from_global_cluster():
client = boto3.client("rds", "us-east-1")
diff --git a/tests/test_rds/test_rds.py b/tests/test_rds/test_rds.py
index fd2551550..4f0aa02ae 100644
--- a/tests/test_rds/test_rds.py
+++ b/tests/test_rds/test_rds.py
@@ -4,13 +4,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_kms, mock_rds
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
DEFAULT_REGION = "us-west-2"
-@mock_rds
+@mock_aws
def test_create_database():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -50,7 +50,7 @@ def test_create_database():
assert db_instance["DbInstancePort"] == 1234
-@mock_rds
+@mock_aws
def test_database_with_deletion_protection_cannot_be_deleted():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -66,7 +66,7 @@ def test_database_with_deletion_protection_cannot_be_deleted():
assert db_instance["DeletionProtection"] is True
-@mock_rds
+@mock_aws
def test_create_database_no_allocated_storage():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -82,7 +82,7 @@ def test_create_database_no_allocated_storage():
assert db_instance["PreferredMaintenanceWindow"] == "wed:06:38-wed:07:08"
-@mock_rds
+@mock_aws
def test_create_database_invalid_preferred_maintenance_window_more_24_hours():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as ex:
@@ -98,7 +98,7 @@ def test_create_database_invalid_preferred_maintenance_window_more_24_hours():
assert err["Message"] == "Maintenance window must be less than 24 hours."
-@mock_rds
+@mock_aws
def test_create_database_invalid_preferred_maintenance_window_less_30_mins():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as ex:
@@ -114,7 +114,7 @@ def test_create_database_invalid_preferred_maintenance_window_less_30_mins():
assert err["Message"] == "The maintenance window must be at least 30 minutes."
-@mock_rds
+@mock_aws
def test_create_database_invalid_preferred_maintenance_window_value():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as ex:
@@ -130,7 +130,7 @@ def test_create_database_invalid_preferred_maintenance_window_value():
assert "Invalid day:hour:minute" in err["Message"]
-@mock_rds
+@mock_aws
def test_create_database_invalid_preferred_maintenance_window_format():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as ex:
@@ -149,7 +149,7 @@ def test_create_database_invalid_preferred_maintenance_window_format():
) in err["Message"]
-@mock_rds
+@mock_aws
def test_create_database_preferred_backup_window_overlap_no_spill():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as ex:
@@ -168,7 +168,7 @@ def test_create_database_preferred_backup_window_overlap_no_spill():
)
-@mock_rds
+@mock_aws
def test_create_database_preferred_backup_window_overlap_maintenance_window_spill():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as ex:
@@ -187,7 +187,7 @@ def test_create_database_preferred_backup_window_overlap_maintenance_window_spil
)
-@mock_rds
+@mock_aws
def test_create_database_preferred_backup_window_overlap_backup_window_spill():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as ex:
@@ -206,7 +206,7 @@ def test_create_database_preferred_backup_window_overlap_backup_window_spill():
)
-@mock_rds
+@mock_aws
def test_create_database_preferred_backup_window_overlap_both_spill():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as ex:
@@ -225,7 +225,7 @@ def test_create_database_preferred_backup_window_overlap_both_spill():
)
-@mock_rds
+@mock_aws
def test_create_database_valid_preferred_maintenance_window_format():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -240,7 +240,7 @@ def test_create_database_valid_preferred_maintenance_window_format():
assert db_instance["PreferredMaintenanceWindow"] == "sun:16:00-sun:16:30"
-@mock_rds
+@mock_aws
def test_create_database_valid_preferred_maintenance_window_uppercase_format():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -255,7 +255,7 @@ def test_create_database_valid_preferred_maintenance_window_uppercase_format():
assert db_instance["PreferredMaintenanceWindow"] == "mon:16:00-tue:01:30"
-@mock_rds
+@mock_aws
def test_create_database_non_existing_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
@@ -269,7 +269,7 @@ def test_create_database_non_existing_option_group():
)
-@mock_rds
+@mock_aws
def test_create_database_with_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_option_group(
@@ -293,7 +293,7 @@ def test_create_database_with_option_group():
assert db_instance["OptionGroupMemberships"][0]["OptionGroupName"] == "my-og"
-@mock_rds
+@mock_aws
def test_stop_database():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -330,7 +330,7 @@ def test_stop_database():
assert response["DBSnapshots"] == []
-@mock_rds
+@mock_aws
def test_start_database():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -381,7 +381,7 @@ def test_start_database():
assert response["DBInstance"]["DBInstanceStatus"] == "stopped"
-@mock_rds
+@mock_aws
def test_fail_to_stop_multi_az_and_sqlserver():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -410,7 +410,7 @@ def test_fail_to_stop_multi_az_and_sqlserver():
conn.start_db_instance(DBInstanceIdentifier=mydb["DBInstanceIdentifier"])
-@mock_rds
+@mock_aws
def test_stop_multi_az_postgres():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -437,7 +437,7 @@ def test_stop_multi_az_postgres():
assert response["DBInstance"]["DBInstanceStatus"] == "stopped"
-@mock_rds
+@mock_aws
def test_fail_to_stop_readreplica():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -471,7 +471,7 @@ def test_fail_to_stop_readreplica():
conn.start_db_instance(DBInstanceIdentifier=mydb["DBInstanceIdentifier"])
-@mock_rds
+@mock_aws
def test_get_databases():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
@@ -516,7 +516,7 @@ def test_get_databases():
assert instances["DBInstances"][0]["DbInstancePort"] == 1234
-@mock_rds
+@mock_aws
def test_get_databases_paginated():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
@@ -540,14 +540,14 @@ def test_get_databases_paginated():
assert len(resp3["DBInstances"]) == 51
-@mock_rds
+@mock_aws
def test_describe_non_existent_database():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
conn.describe_db_instances(DBInstanceIdentifier="not-a-db")
-@mock_rds
+@mock_aws
def test_modify_db_instance():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -579,7 +579,7 @@ def test_modify_db_instance():
)
-@mock_rds
+@mock_aws
def test_modify_db_instance_not_existent_db_parameter_group_name():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -601,7 +601,7 @@ def test_modify_db_instance_not_existent_db_parameter_group_name():
)
-@mock_rds
+@mock_aws
def test_modify_db_instance_valid_preferred_maintenance_window():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -625,7 +625,7 @@ def test_modify_db_instance_valid_preferred_maintenance_window():
)
-@mock_rds
+@mock_aws
def test_modify_db_instance_valid_preferred_maintenance_window_uppercase():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -649,7 +649,7 @@ def test_modify_db_instance_valid_preferred_maintenance_window_uppercase():
)
-@mock_rds
+@mock_aws
def test_modify_db_instance_invalid_preferred_maintenance_window_more_than_24_hours():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -672,7 +672,7 @@ def test_modify_db_instance_invalid_preferred_maintenance_window_more_than_24_ho
assert err["Message"] == "Maintenance window must be less than 24 hours."
-@mock_rds
+@mock_aws
def test_modify_db_instance_invalid_preferred_maintenance_window_less_than_30_mins():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -695,7 +695,7 @@ def test_modify_db_instance_invalid_preferred_maintenance_window_less_than_30_mi
assert err["Message"] == "The maintenance window must be at least 30 minutes."
-@mock_rds
+@mock_aws
def test_modify_db_instance_invalid_preferred_maintenance_window_value():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -718,7 +718,7 @@ def test_modify_db_instance_invalid_preferred_maintenance_window_value():
assert "Invalid day:hour:minute value" in err["Message"]
-@mock_rds
+@mock_aws
def test_modify_db_instance_invalid_preferred_maintenance_window_format():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -744,7 +744,7 @@ def test_modify_db_instance_invalid_preferred_maintenance_window_format():
) in err["Message"]
-@mock_rds
+@mock_aws
def test_modify_db_instance_maintenance_backup_window_no_spill():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -770,7 +770,7 @@ def test_modify_db_instance_maintenance_backup_window_no_spill():
)
-@mock_rds
+@mock_aws
def test_modify_db_instance_maintenance_backup_window_maintenance_spill():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -796,7 +796,7 @@ def test_modify_db_instance_maintenance_backup_window_maintenance_spill():
)
-@mock_rds
+@mock_aws
def test_modify_db_instance_maintenance_backup_window_backup_spill():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -822,7 +822,7 @@ def test_modify_db_instance_maintenance_backup_window_backup_spill():
)
-@mock_rds
+@mock_aws
def test_modify_db_instance_maintenance_backup_window_both_spill():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -848,7 +848,7 @@ def test_modify_db_instance_maintenance_backup_window_both_spill():
)
-@mock_rds
+@mock_aws
def test_rename_db_instance():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -876,7 +876,7 @@ def test_rename_db_instance():
assert len(list(instances["DBInstances"])) == 1
-@mock_rds
+@mock_aws
def test_modify_non_existent_database():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
@@ -885,7 +885,7 @@ def test_modify_non_existent_database():
)
-@mock_rds
+@mock_aws
def test_reboot_db_instance():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -902,14 +902,14 @@ def test_reboot_db_instance():
assert database["DBInstance"]["DBInstanceIdentifier"] == "db-master-1"
-@mock_rds
+@mock_aws
def test_reboot_non_existent_database():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
conn.reboot_db_instance(DBInstanceIdentifier="not-a-db")
-@mock_rds
+@mock_aws
def test_delete_database():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
instances = conn.describe_db_instances()
@@ -941,7 +941,7 @@ def test_delete_database():
assert snapshot["SnapshotType"] == "automated"
-@mock_rds
+@mock_aws
def test_create_db_snapshots():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
@@ -972,7 +972,7 @@ def test_create_db_snapshots():
assert result["TagList"] == []
-@mock_rds
+@mock_aws
def test_create_db_snapshots_copy_tags():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
@@ -1008,7 +1008,7 @@ def test_create_db_snapshots_copy_tags():
]
-@mock_rds
+@mock_aws
def test_create_db_snapshots_with_tags():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1039,7 +1039,7 @@ def test_create_db_snapshots_with_tags():
]
-@mock_rds
+@mock_aws
def test_copy_db_snapshots():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
@@ -1070,7 +1070,7 @@ def test_copy_db_snapshots():
assert result["TagList"] == []
-@mock_rds
+@mock_aws
def test_describe_db_snapshots():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1112,7 +1112,7 @@ def test_describe_db_snapshots():
assert len(snapshots) == 2
-@mock_rds
+@mock_aws
def test_promote_read_replica():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1140,7 +1140,7 @@ def test_promote_read_replica():
assert replicas is None
-@mock_rds
+@mock_aws
def test_delete_db_snapshot():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1166,7 +1166,7 @@ def test_delete_db_snapshot():
conn.describe_db_snapshots(DBSnapshotIdentifier="snapshot-1")
-@mock_rds
+@mock_aws
def test_restore_db_instance_from_db_snapshot():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1214,7 +1214,7 @@ def test_restore_db_instance_from_db_snapshot():
)
-@mock_rds
+@mock_aws
def test_restore_db_instance_to_point_in_time():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1259,7 +1259,7 @@ def test_restore_db_instance_to_point_in_time():
)
-@mock_rds
+@mock_aws
def test_restore_db_instance_from_db_snapshot_and_override_params():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1298,7 +1298,7 @@ def test_restore_db_instance_from_db_snapshot_and_override_params():
assert new_instance["Endpoint"]["Port"] == 10000
-@mock_rds
+@mock_aws
def test_create_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
option_group = conn.create_option_group(
@@ -1318,7 +1318,7 @@ def test_create_option_group():
)
-@mock_rds
+@mock_aws
def test_create_option_group_bad_engine_name():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
@@ -1330,7 +1330,7 @@ def test_create_option_group_bad_engine_name():
)
-@mock_rds
+@mock_aws
def test_create_option_group_bad_engine_major_version():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
@@ -1342,7 +1342,7 @@ def test_create_option_group_bad_engine_major_version():
)
-@mock_rds
+@mock_aws
def test_create_option_group_empty_description():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
@@ -1354,7 +1354,7 @@ def test_create_option_group_empty_description():
)
-@mock_rds
+@mock_aws
def test_create_option_group_duplicate():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_option_group(
@@ -1372,7 +1372,7 @@ def test_create_option_group_duplicate():
)
-@mock_rds
+@mock_aws
def test_describe_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_option_group(
@@ -1385,14 +1385,14 @@ def test_describe_option_group():
assert option_groups["OptionGroupsList"][0]["OptionGroupName"] == "test"
-@mock_rds
+@mock_aws
def test_describe_non_existent_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
conn.describe_option_groups(OptionGroupName="not-a-option-group")
-@mock_rds
+@mock_aws
def test_delete_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_option_group(
@@ -1408,14 +1408,14 @@ def test_delete_option_group():
conn.describe_option_groups(OptionGroupName="test")
-@mock_rds
+@mock_aws
def test_delete_non_existent_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
conn.delete_option_group(OptionGroupName="non-existent")
-@mock_rds
+@mock_aws
def test_describe_option_group_options():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
option_group_options = conn.describe_option_group_options(EngineName="sqlserver-ee")
@@ -1436,7 +1436,7 @@ def test_describe_option_group_options():
)
-@mock_rds
+@mock_aws
def test_modify_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_option_group(
@@ -1459,7 +1459,7 @@ def test_modify_option_group():
assert result["OptionGroup"]["OptionGroupName"] == "test"
-@mock_rds
+@mock_aws
def test_modify_option_group_no_options():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_option_group(
@@ -1472,7 +1472,7 @@ def test_modify_option_group_no_options():
conn.modify_option_group(OptionGroupName="test")
-@mock_rds
+@mock_aws
def test_modify_non_existent_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as client_err:
@@ -1485,7 +1485,7 @@ def test_modify_non_existent_option_group():
)
-@mock_rds
+@mock_aws
def test_delete_database_with_protection():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1502,7 +1502,7 @@ def test_delete_database_with_protection():
assert err["Message"] == "Can't delete Instance with protection enabled"
-@mock_rds
+@mock_aws
def test_delete_non_existent_database():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as ex:
@@ -1511,14 +1511,14 @@ def test_delete_non_existent_database():
assert ex.value.response["Error"]["Message"] == "DBInstance non-existent not found."
-@mock_rds
+@mock_aws
def test_list_tags_invalid_arn():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
conn.list_tags_for_resource(ResourceName="arn:aws:rds:bad-arn")
-@mock_rds
+@mock_aws
def test_list_tags_db():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
result = conn.list_tags_for_resource(
@@ -1545,7 +1545,7 @@ def test_list_tags_db():
]
-@mock_rds
+@mock_aws
def test_add_tags_db():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1573,7 +1573,7 @@ def test_add_tags_db():
assert len(list(result["TagList"])) == 3
-@mock_rds
+@mock_aws
def test_remove_tags_db():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1600,7 +1600,7 @@ def test_remove_tags_db():
assert len(result["TagList"]) == 1
-@mock_rds
+@mock_aws
def test_list_tags_snapshot():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
result = conn.list_tags_for_resource(
@@ -1632,7 +1632,7 @@ def test_list_tags_snapshot():
]
-@mock_rds
+@mock_aws
def test_add_tags_snapshot():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1665,7 +1665,7 @@ def test_add_tags_snapshot():
assert len(list(result["TagList"])) == 3
-@mock_rds
+@mock_aws
def test_remove_tags_snapshot():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
@@ -1698,7 +1698,7 @@ def test_remove_tags_snapshot():
assert len(result["TagList"]) == 1
-@mock_rds
+@mock_aws
def test_add_tags_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_option_group(
@@ -1721,7 +1721,7 @@ def test_add_tags_option_group():
assert len(list(result["TagList"])) == 2
-@mock_rds
+@mock_aws
def test_remove_tags_option_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_option_group(
@@ -1750,7 +1750,7 @@ def test_remove_tags_option_group():
assert len(list(result["TagList"])) == 1
-@mock_rds
+@mock_aws
def test_create_database_security_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
@@ -1764,7 +1764,7 @@ def test_create_database_security_group():
assert result["DBSecurityGroup"]["IPRanges"] == []
-@mock_rds
+@mock_aws
def test_get_security_groups():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
@@ -1786,14 +1786,14 @@ def test_get_security_groups():
assert result["DBSecurityGroups"][0]["DBSecurityGroupName"] == "db_sg1"
-@mock_rds
+@mock_aws
def test_get_non_existent_security_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
conn.describe_db_security_groups(DBSecurityGroupName="not-a-sg")
-@mock_rds
+@mock_aws
def test_delete_database_security_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_security_group(
@@ -1808,14 +1808,14 @@ def test_delete_database_security_group():
assert len(result["DBSecurityGroups"]) == 0
-@mock_rds
+@mock_aws
def test_delete_non_existent_security_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
conn.delete_db_security_group(DBSecurityGroupName="not-a-db")
-@mock_rds
+@mock_aws
def test_security_group_authorize():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
security_group = conn.create_db_security_group(
@@ -1844,7 +1844,7 @@ def test_security_group_authorize():
]
-@mock_rds
+@mock_aws
def test_add_security_group_to_database():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
@@ -1873,7 +1873,7 @@ def test_add_security_group_to_database():
)
-@mock_rds
+@mock_aws
def test_list_tags_security_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
result = conn.describe_db_subnet_groups()
@@ -1892,7 +1892,7 @@ def test_list_tags_security_group():
]
-@mock_rds
+@mock_aws
def test_add_tags_security_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
result = conn.describe_db_subnet_groups()
@@ -1915,7 +1915,7 @@ def test_add_tags_security_group():
]
-@mock_rds
+@mock_aws
def test_remove_tags_security_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
result = conn.describe_db_subnet_groups()
@@ -1934,8 +1934,7 @@ def test_remove_tags_security_group():
assert result["TagList"] == [{"Value": "bar1", "Key": "foo1"}]
-@mock_ec2
-@mock_rds
+@mock_aws
def test_create_database_subnet_group():
vpc_conn = boto3.client("ec2", DEFAULT_REGION)
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -1960,8 +1959,7 @@ def test_create_database_subnet_group():
assert list(subnet_group_ids) == subnet_ids
-@mock_ec2
-@mock_rds
+@mock_aws
def test_modify_database_subnet_group():
vpc_conn = boto3.client("ec2", DEFAULT_REGION)
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -1990,8 +1988,7 @@ def test_modify_database_subnet_group():
# TODO: we should check whether all attrs are persisted
-@mock_ec2
-@mock_rds
+@mock_aws
def test_create_database_in_subnet_group():
vpc_conn = boto3.client("ec2", DEFAULT_REGION)
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -2021,8 +2018,7 @@ def test_create_database_in_subnet_group():
)
-@mock_ec2
-@mock_rds
+@mock_aws
def test_describe_database_subnet_group():
vpc_conn = boto3.client("ec2", DEFAULT_REGION)
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -2063,8 +2059,7 @@ def test_describe_database_subnet_group():
conn.describe_db_subnet_groups(DBSubnetGroupName="not-a-subnet")
-@mock_ec2
-@mock_rds
+@mock_aws
def test_delete_database_subnet_group():
vpc_conn = boto3.client("ec2", DEFAULT_REGION)
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -2092,8 +2087,7 @@ def test_delete_database_subnet_group():
conn.delete_db_subnet_group(DBSubnetGroupName="db_subnet1")
-@mock_ec2
-@mock_rds
+@mock_aws
def test_list_tags_database_subnet_group():
vpc_conn = boto3.client("ec2", DEFAULT_REGION)
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -2120,7 +2114,7 @@ def test_list_tags_database_subnet_group():
]
-@mock_rds
+@mock_aws
def test_modify_tags_parameter_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
client_tags = [{"Key": "character_set_client", "Value": "utf-8"}]
@@ -2146,7 +2140,7 @@ def test_modify_tags_parameter_group():
assert result["TagList"] == server_tags
-@mock_rds
+@mock_aws
def test_modify_tags_event_subscription():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
tags = [{"Key": "hello", "Value": "world"}]
@@ -2171,8 +2165,7 @@ def test_modify_tags_event_subscription():
assert result["TagList"] == tags
-@mock_ec2
-@mock_rds
+@mock_aws
def test_add_tags_database_subnet_group():
vpc_conn = boto3.client("ec2", DEFAULT_REGION)
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -2204,8 +2197,7 @@ def test_add_tags_database_subnet_group():
]
-@mock_ec2
-@mock_rds
+@mock_aws
def test_remove_tags_database_subnet_group():
vpc_conn = boto3.client("ec2", DEFAULT_REGION)
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -2231,7 +2223,7 @@ def test_remove_tags_database_subnet_group():
assert result["TagList"] == [{"Value": "bar1", "Key": "foo1"}]
-@mock_rds
+@mock_aws
def test_create_database_replica():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
@@ -2272,7 +2264,7 @@ def test_create_database_replica():
assert master["DBInstances"][0]["ReadReplicaDBInstanceIdentifiers"] == []
-@mock_rds
+@mock_aws
def test_create_database_replica_cross_region():
us1 = boto3.client("rds", region_name="us-east-1")
us2 = boto3.client("rds", region_name=DEFAULT_REGION)
@@ -2303,8 +2295,7 @@ def test_create_database_replica_cross_region():
assert target_db["ReadReplicaSourceDBInstanceIdentifier"] == source_arn
-@mock_rds
-@mock_kms
+@mock_aws
def test_create_database_with_encrypted_storage():
kms_conn = boto3.client("kms", region_name=DEFAULT_REGION)
key = kms_conn.create_key(
@@ -2331,7 +2322,7 @@ def test_create_database_with_encrypted_storage():
assert database["DBInstance"]["KmsKeyId"] == key["KeyMetadata"]["KeyId"]
-@mock_rds
+@mock_aws
def test_create_db_parameter_group():
region = DEFAULT_REGION
pg_name = "test"
@@ -2354,7 +2345,7 @@ def test_create_db_parameter_group():
)
-@mock_rds
+@mock_aws
def test_create_db_instance_with_parameter_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_parameter_group(
@@ -2383,7 +2374,7 @@ def test_create_db_instance_with_parameter_group():
)
-@mock_rds
+@mock_aws
def test_create_database_with_default_port():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -2398,7 +2389,7 @@ def test_create_database_with_default_port():
assert database["DBInstance"]["Endpoint"]["Port"] == 5432
-@mock_rds
+@mock_aws
def test_modify_db_instance_with_parameter_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
database = conn.create_db_instance(
@@ -2438,7 +2429,7 @@ def test_modify_db_instance_with_parameter_group():
assert database["DBParameterGroups"][0]["ParameterApplyStatus"] == "in-sync"
-@mock_rds
+@mock_aws
def test_create_db_parameter_group_empty_description():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
@@ -2449,7 +2440,7 @@ def test_create_db_parameter_group_empty_description():
)
-@mock_rds
+@mock_aws
def test_create_db_parameter_group_duplicate():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_parameter_group(
@@ -2465,7 +2456,7 @@ def test_create_db_parameter_group_duplicate():
)
-@mock_rds
+@mock_aws
def test_describe_db_parameter_group():
region = DEFAULT_REGION
pg_name = "test"
@@ -2484,14 +2475,14 @@ def test_describe_db_parameter_group():
)
-@mock_rds
+@mock_aws
def test_describe_non_existent_db_parameter_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
db_parameter_groups = conn.describe_db_parameter_groups(DBParameterGroupName="test")
assert len(db_parameter_groups["DBParameterGroups"]) == 0
-@mock_rds
+@mock_aws
def test_delete_db_parameter_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_parameter_group(
@@ -2508,7 +2499,7 @@ def test_delete_db_parameter_group():
assert len(db_parameter_groups["DBParameterGroups"]) == 0
-@mock_rds
+@mock_aws
def test_modify_db_parameter_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_parameter_group(
@@ -2538,14 +2529,14 @@ def test_modify_db_parameter_group():
assert db_parameters["Parameters"][0]["ApplyMethod"] == "immediate"
-@mock_rds
+@mock_aws
def test_delete_non_existent_db_parameter_group():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError):
conn.delete_db_parameter_group(DBParameterGroupName="non-existent")
-@mock_rds
+@mock_aws
def test_create_parameter_group_with_tags():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_parameter_group(
@@ -2560,7 +2551,7 @@ def test_create_parameter_group_with_tags():
assert result["TagList"] == [{"Value": "bar", "Key": "foo"}]
-@mock_rds
+@mock_aws
def test_create_db_with_iam_authentication():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
@@ -2581,7 +2572,7 @@ def test_create_db_with_iam_authentication():
assert snapshot.get("IAMDatabaseAuthenticationEnabled") is True
-@mock_rds
+@mock_aws
def test_create_db_instance_with_tags():
client = boto3.client("rds", region_name=DEFAULT_REGION)
tags = [{"Key": "foo", "Value": "bar"}, {"Key": "foo1", "Value": "bar1"}]
@@ -2599,7 +2590,7 @@ def test_create_db_instance_with_tags():
assert resp["DBInstances"][0]["TagList"] == tags
-@mock_rds
+@mock_aws
def test_create_db_instance_without_availability_zone():
region = "us-east-1"
client = boto3.client("rds", region_name=region)
@@ -2616,7 +2607,7 @@ def test_create_db_instance_without_availability_zone():
assert region in resp["DBInstances"][0]["AvailabilityZone"]
-@mock_rds
+@mock_aws
def test_create_db_instance_with_availability_zone():
region = "us-east-1"
availability_zone = f"{region}c"
@@ -2635,7 +2626,7 @@ def test_create_db_instance_with_availability_zone():
assert resp["DBInstances"][0]["AvailabilityZone"] == availability_zone
-@mock_rds
+@mock_aws
def test_validate_db_identifier():
client = boto3.client("rds", region_name=DEFAULT_REGION)
invalid_db_instance_identifier = "arn:aws:rds:eu-west-1:123456789012:db:mydb"
@@ -2674,7 +2665,7 @@ def test_validate_db_identifier():
validation_helper(exc)
-@mock_rds
+@mock_aws
def test_createdb_instance_engine_with_invalid_value():
client = boto3.client("rds", region_name=DEFAULT_REGION)
with pytest.raises(ClientError) as exc:
@@ -2694,7 +2685,7 @@ def test_createdb_instance_engine_with_invalid_value():
)
-@mock_rds
+@mock_aws
def test_describe_db_snapshot_attributes_default():
client = boto3.client("rds", region_name="us-east-2")
client.create_db_instance(
@@ -2719,7 +2710,7 @@ def test_describe_db_snapshot_attributes_default():
assert resp["DBSnapshotAttributesResult"]["DBSnapshotAttributes"] == []
-@mock_rds
+@mock_aws
def test_describe_db_snapshot_attributes():
client = boto3.client("rds", region_name="us-east-2")
client.create_db_instance(
@@ -2755,7 +2746,7 @@ def test_describe_db_snapshot_attributes():
] == ["Test", "Test2"]
-@mock_rds
+@mock_aws
def test_modify_db_snapshot_attribute():
client = boto3.client("rds", region_name="us-east-2")
client.create_db_instance(
diff --git a/tests/test_rds/test_rds_cloudformation.py b/tests/test_rds/test_rds_cloudformation.py
index 6238044be..71ff25be2 100644
--- a/tests/test_rds/test_rds_cloudformation.py
+++ b/tests/test_rds/test_rds_cloudformation.py
@@ -2,16 +2,14 @@ import json
import boto3
-from moto import mock_cloudformation, mock_ec2, mock_rds
+from moto import mock_aws
from tests.test_cloudformation.fixtures import (
rds_mysql_with_db_parameter_group,
rds_mysql_with_read_replica,
)
-@mock_ec2
-@mock_rds
-@mock_cloudformation
+@mock_aws
def test_create_subnetgroup_via_cf():
vpc_conn = boto3.client("ec2", "us-west-2")
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -47,9 +45,7 @@ def test_create_subnetgroup_via_cf():
assert created_subnet["VpcId"] == vpc["VpcId"]
-@mock_ec2
-@mock_rds
-@mock_cloudformation
+@mock_aws
def test_create_dbinstance_via_cf():
vpc_conn = boto3.client("ec2", "us-west-2")
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -100,9 +96,7 @@ def test_create_dbinstance_via_cf():
assert o["db_port"] == "3307"
-@mock_ec2
-@mock_rds
-@mock_cloudformation
+@mock_aws
def test_create_dbsecuritygroup_via_cf():
vpc_conn = boto3.client("ec2", "us-west-2")
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
@@ -130,9 +124,7 @@ def test_create_dbsecuritygroup_via_cf():
assert created["DBSecurityGroupDescription"] == "my sec group"
-@mock_cloudformation
-@mock_ec2
-@mock_rds
+@mock_aws
def test_rds_db_parameter_groups():
ec2_conn = boto3.client("ec2", region_name="us-west-1")
ec2_conn.create_security_group(
@@ -180,9 +172,7 @@ def test_rds_db_parameter_groups():
assert found_cloudformation_set_parameter is True
-@mock_cloudformation
-@mock_ec2
-@mock_rds
+@mock_aws
def test_rds_mysql_with_read_replica():
ec2_conn = boto3.client("ec2", region_name="us-west-1")
ec2_conn.create_security_group(
@@ -233,9 +223,7 @@ def test_rds_mysql_with_read_replica():
)
-@mock_cloudformation
-@mock_ec2
-@mock_rds
+@mock_aws
def test_rds_mysql_with_read_replica_in_vpc():
template_json = json.dumps(rds_mysql_with_read_replica.template)
cf = boto3.client("cloudformation", "eu-central-1")
@@ -266,9 +254,7 @@ def test_rds_mysql_with_read_replica_in_vpc():
assert subnet_group["DBSubnetGroupDescription"] == "my db subnet group"
-@mock_ec2
-@mock_rds
-@mock_cloudformation
+@mock_aws
def test_delete_dbinstance_via_cf():
vpc_conn = boto3.client("ec2", "us-west-2")
vpc = vpc_conn.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
diff --git a/tests/test_rds/test_rds_clusters.py b/tests/test_rds/test_rds_clusters.py
index 14dde421d..00554c2b0 100644
--- a/tests/test_rds/test_rds_clusters.py
+++ b/tests/test_rds/test_rds_clusters.py
@@ -4,13 +4,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_rds
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
RDS_REGION = "eu-north-1"
-@mock_rds
+@mock_aws
def test_describe_db_cluster_initial():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -18,7 +18,7 @@ def test_describe_db_cluster_initial():
assert len(resp["DBClusters"]) == 0
-@mock_rds
+@mock_aws
def test_describe_db_cluster_fails_for_non_existent_cluster():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -31,7 +31,7 @@ def test_describe_db_cluster_fails_for_non_existent_cluster():
assert err["Message"] == "DBCluster cluster-id not found."
-@mock_rds
+@mock_aws
def test_create_db_cluster_invalid_engine():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -46,7 +46,7 @@ def test_create_db_cluster_invalid_engine():
)
-@mock_rds
+@mock_aws
def test_create_db_cluster_needs_master_username():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -61,7 +61,7 @@ def test_create_db_cluster_needs_master_username():
)
-@mock_rds
+@mock_aws
def test_create_db_cluster_needs_master_user_password():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -78,7 +78,7 @@ def test_create_db_cluster_needs_master_user_password():
)
-@mock_rds
+@mock_aws
def test_create_db_cluster_needs_long_master_user_password():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -97,7 +97,7 @@ def test_create_db_cluster_needs_long_master_user_password():
)
-@mock_rds
+@mock_aws
def test_modify_db_cluster_needs_long_master_user_password():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -121,7 +121,7 @@ def test_modify_db_cluster_needs_long_master_user_password():
)
-@mock_rds
+@mock_aws
def test_modify_db_cluster_new_cluster_identifier():
client = boto3.client("rds", region_name=RDS_REGION)
old_id = "cluster-id"
@@ -150,7 +150,7 @@ def test_modify_db_cluster_new_cluster_identifier():
assert old_id not in clusters
-@mock_rds
+@mock_aws
def test_create_db_cluster__verify_default_properties():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -219,7 +219,7 @@ def test_create_db_cluster__verify_default_properties():
assert cluster["GlobalWriteForwardingRequested"] is False
-@mock_rds
+@mock_aws
def test_create_db_cluster_additional_parameters():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -278,7 +278,7 @@ def test_create_db_cluster_additional_parameters():
assert {"VpcSecurityGroupId": "sg2", "Status": "active"} in security_groups
-@mock_rds
+@mock_aws
def test_describe_db_cluster_after_creation():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -311,7 +311,7 @@ def test_describe_db_cluster_after_creation():
)
-@mock_rds
+@mock_aws
def test_delete_db_cluster():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -327,7 +327,7 @@ def test_delete_db_cluster():
assert len(client.describe_db_clusters()["DBClusters"]) == 0
-@mock_rds
+@mock_aws
def test_delete_db_cluster_do_snapshot():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -348,7 +348,7 @@ def test_delete_db_cluster_do_snapshot():
assert snapshot["SnapshotType"] == "automated"
-@mock_rds
+@mock_aws
def test_delete_db_cluster_that_is_protected():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -366,7 +366,7 @@ def test_delete_db_cluster_that_is_protected():
assert err["Message"] == "Can't delete Cluster with protection enabled"
-@mock_rds
+@mock_aws
def test_delete_db_cluster_unknown_cluster():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -377,7 +377,7 @@ def test_delete_db_cluster_unknown_cluster():
assert err["Message"] == "DBCluster cluster-unknown not found."
-@mock_rds
+@mock_aws
def test_start_db_cluster_unknown_cluster():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -388,7 +388,7 @@ def test_start_db_cluster_unknown_cluster():
assert err["Message"] == "DBCluster cluster-unknown not found."
-@mock_rds
+@mock_aws
def test_start_db_cluster_after_stopping():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -405,7 +405,7 @@ def test_start_db_cluster_after_stopping():
assert cluster["Status"] == "available"
-@mock_rds
+@mock_aws
def test_start_db_cluster_without_stopping():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -423,7 +423,7 @@ def test_start_db_cluster_without_stopping():
assert err["Message"] == "DbCluster cluster-id is not in stopped state."
-@mock_rds
+@mock_aws
def test_stop_db_cluster():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -444,7 +444,7 @@ def test_stop_db_cluster():
assert cluster["Status"] == "stopped"
-@mock_rds
+@mock_aws
def test_stop_db_cluster_already_stopped():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -464,7 +464,7 @@ def test_stop_db_cluster_already_stopped():
assert err["Message"] == "DbCluster cluster-id is not in available state."
-@mock_rds
+@mock_aws
def test_stop_db_cluster_unknown_cluster():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -475,7 +475,7 @@ def test_stop_db_cluster_unknown_cluster():
assert err["Message"] == "DBCluster cluster-unknown not found."
-@mock_rds
+@mock_aws
def test_create_db_cluster_snapshot_fails_for_unknown_cluster():
conn = boto3.client("rds", region_name="us-west-2")
with pytest.raises(ClientError) as exc:
@@ -486,7 +486,7 @@ def test_create_db_cluster_snapshot_fails_for_unknown_cluster():
assert err["Message"] == "DBCluster db-primary-1 not found."
-@mock_rds
+@mock_aws
def test_create_db_cluster_snapshot():
conn = boto3.client("rds", region_name="us-west-2")
conn.create_db_cluster(
@@ -512,7 +512,7 @@ def test_create_db_cluster_snapshot():
assert result["TagList"] == []
-@mock_rds
+@mock_aws
def test_create_db_cluster_snapshot_copy_tags():
conn = boto3.client("rds", region_name="us-west-2")
@@ -553,7 +553,7 @@ def test_create_db_cluster_snapshot_copy_tags():
]
-@mock_rds
+@mock_aws
def test_copy_db_cluster_snapshot_fails_for_unknown_snapshot():
conn = boto3.client("rds", region_name="us-west-2")
@@ -567,7 +567,7 @@ def test_copy_db_cluster_snapshot_fails_for_unknown_snapshot():
assert err["Message"] == "DBClusterSnapshot snapshot-1 not found."
-@mock_rds
+@mock_aws
def test_copy_db_cluster_snapshot():
conn = boto3.client("rds", region_name="us-west-2")
@@ -600,7 +600,7 @@ def test_copy_db_cluster_snapshot():
assert result["TagList"] == []
-@mock_rds
+@mock_aws
def test_copy_db_cluster_snapshot_fails_for_existed_target_snapshot():
conn = boto3.client("rds", region_name="us-west-2")
@@ -636,7 +636,7 @@ def test_copy_db_cluster_snapshot_fails_for_existed_target_snapshot():
)
-@mock_rds
+@mock_aws
def test_describe_db_cluster_snapshots():
conn = boto3.client("rds", region_name="us-west-2")
conn.create_db_cluster(
@@ -677,7 +677,7 @@ def test_describe_db_cluster_snapshots():
assert len(snapshots) == 2
-@mock_rds
+@mock_aws
def test_delete_db_cluster_snapshot():
conn = boto3.client("rds", region_name="us-west-2")
conn.create_db_cluster(
@@ -700,7 +700,7 @@ def test_delete_db_cluster_snapshot():
conn.describe_db_cluster_snapshots(DBClusterSnapshotIdentifier="snapshot-1")
-@mock_rds
+@mock_aws
def test_restore_db_cluster_from_snapshot():
conn = boto3.client("rds", region_name="us-west-2")
conn.create_db_cluster(
@@ -739,7 +739,7 @@ def test_restore_db_cluster_from_snapshot():
)
-@mock_rds
+@mock_aws
def test_restore_db_cluster_from_snapshot_and_override_params():
conn = boto3.client("rds", region_name="us-west-2")
conn.create_db_cluster(
@@ -771,7 +771,7 @@ def test_restore_db_cluster_from_snapshot_and_override_params():
assert new_cluster["Port"] == 10000
-@mock_rds
+@mock_aws
def test_add_tags_to_cluster():
conn = boto3.client("rds", region_name="us-west-2")
resp = conn.create_db_cluster(
@@ -800,7 +800,7 @@ def test_add_tags_to_cluster():
assert tags == [{"Key": "k2", "Value": "v2"}]
-@mock_rds
+@mock_aws
def test_add_tags_to_cluster_snapshot():
conn = boto3.client("rds", region_name="us-west-2")
conn.create_db_cluster(
@@ -832,7 +832,7 @@ def test_add_tags_to_cluster_snapshot():
assert tags == [{"Key": "k2", "Value": "v2"}]
-@mock_rds
+@mock_aws
def test_create_serverless_db_cluster():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -856,7 +856,7 @@ def test_create_serverless_db_cluster():
assert cluster["ScalingConfigurationInfo"]["MaxCapacity"] == 16
-@mock_rds
+@mock_aws
def test_create_db_cluster_with_enable_http_endpoint_invalid():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -875,7 +875,7 @@ def test_create_db_cluster_with_enable_http_endpoint_invalid():
assert cluster["HttpEndpointEnabled"] is False
-@mock_rds
+@mock_aws
def test_describe_db_clusters_filter_by_engine():
client = boto3.client("rds", region_name=RDS_REGION)
@@ -909,7 +909,7 @@ def test_describe_db_clusters_filter_by_engine():
assert cluster["Engine"] == "aurora-postgresql"
-@mock_rds
+@mock_aws
def test_replicate_cluster():
# WHEN create_db_cluster is called
# AND create_db_cluster is called again with ReplicationSourceIdentifier
@@ -951,7 +951,7 @@ def test_replicate_cluster():
assert replica["MultiAZ"] is False
-@mock_rds
+@mock_aws
def test_createdb_instance_engine_mismatch_fail():
# Setup
client = boto3.client("rds", "us-east-1")
@@ -985,7 +985,7 @@ def test_createdb_instance_engine_mismatch_fail():
)
-@mock_rds
+@mock_aws
def test_describe_db_cluster_snapshot_attributes_default():
conn = boto3.client("rds", region_name="us-west-2")
conn.create_db_cluster(
@@ -1016,7 +1016,7 @@ def test_describe_db_cluster_snapshot_attributes_default():
)
-@mock_rds
+@mock_aws
def test_describe_db_cluster_snapshot_attributes():
conn = boto3.client("rds", region_name="us-west-2")
conn.create_db_cluster(
@@ -1059,7 +1059,7 @@ def test_describe_db_cluster_snapshot_attributes():
] == ["test", "test2"]
-@mock_rds
+@mock_aws
def test_modify_db_cluster_snapshot_attribute():
conn = boto3.client("rds", region_name="us-west-2")
conn.create_db_cluster(
diff --git a/tests/test_rds/test_rds_clusters_with_instances.py b/tests/test_rds/test_rds_clusters_with_instances.py
index 17c65f315..27933cb9d 100644
--- a/tests/test_rds/test_rds_clusters_with_instances.py
+++ b/tests/test_rds/test_rds_clusters_with_instances.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_rds
+from moto import mock_aws
-@mock_rds
+@mock_aws
def test_add_instance_as_cluster_member():
# When creating a rds instance with DBClusterIdentifier provided,
# the instance is included as a ClusterMember in the describe_db_clusters call
@@ -37,7 +37,7 @@ def test_add_instance_as_cluster_member():
}
-@mock_rds
+@mock_aws
def test_remove_instance_from_cluster():
# When creating a rds instance with DBClusterIdentifier provided,
# the instance is included as a ClusterMember in the describe_db_clusters call
@@ -68,7 +68,7 @@ def test_remove_instance_from_cluster():
assert len(members) == 0
-@mock_rds
+@mock_aws
def test_add_instance_to_serverless_cluster():
client = boto3.client("rds", "us-east-1")
@@ -91,7 +91,7 @@ def test_add_instance_to_serverless_cluster():
assert err["Message"] == "Instances cannot be added to Aurora Serverless clusters."
-@mock_rds
+@mock_aws
def test_delete_db_cluster_fails_if_cluster_contains_db_instances():
cluster_identifier = "test-cluster"
instance_identifier = "test-instance"
diff --git a/tests/test_rds/test_rds_event_subscriptions.py b/tests/test_rds/test_rds_event_subscriptions.py
index 9a636f901..1dd3a6839 100644
--- a/tests/test_rds/test_rds_event_subscriptions.py
+++ b/tests/test_rds/test_rds_event_subscriptions.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_rds
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
DB_INSTANCE_IDENTIFIER = "db-primary-1"
@@ -23,7 +23,7 @@ def _prepare_db_instance(client):
return resp["DBInstance"]["DBInstanceIdentifier"]
-@mock_rds
+@mock_aws
def test_create_event_subscription():
client = boto3.client("rds", region_name="us-west-2")
db_identifier = _prepare_db_instance(client)
@@ -55,7 +55,7 @@ def test_create_event_subscription():
assert es["Enabled"] is False
-@mock_rds
+@mock_aws
def test_create_event_fail_already_exists():
client = boto3.client("rds", region_name="us-west-2")
db_identifier = _prepare_db_instance(client)
@@ -78,7 +78,7 @@ def test_create_event_fail_already_exists():
assert err["Message"] == "Subscription db-primary-1-events already exists."
-@mock_rds
+@mock_aws
def test_delete_event_subscription_fails_unknown_subscription():
client = boto3.client("rds", region_name="us-west-2")
with pytest.raises(ClientError) as ex:
@@ -89,7 +89,7 @@ def test_delete_event_subscription_fails_unknown_subscription():
assert err["Message"] == "Subscription my-db-events not found."
-@mock_rds
+@mock_aws
def test_delete_event_subscription():
client = boto3.client("rds", region_name="us-west-2")
db_identifier = _prepare_db_instance(client)
@@ -109,7 +109,7 @@ def test_delete_event_subscription():
)
-@mock_rds
+@mock_aws
def test_describe_event_subscriptions():
client = boto3.client("rds", region_name="us-west-2")
db_identifier = _prepare_db_instance(client)
@@ -125,7 +125,7 @@ def test_describe_event_subscriptions():
assert subscriptions[0]["CustSubscriptionId"] == f"{db_identifier}-events"
-@mock_rds
+@mock_aws
def test_describe_event_subscriptions_fails_unknown_subscription():
client = boto3.client("rds", region_name="us-west-2")
with pytest.raises(ClientError) as ex:
diff --git a/tests/test_rds/test_rds_export_tasks.py b/tests/test_rds/test_rds_export_tasks.py
index 872287349..82c87c65b 100644
--- a/tests/test_rds/test_rds_export_tasks.py
+++ b/tests/test_rds/test_rds_export_tasks.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_rds
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
@@ -48,7 +48,7 @@ def _prepare_db_cluster_snapshot(client, snapshot_name="cluster-snapshot-1"):
return resp["DBClusterSnapshot"]["DBClusterSnapshotArn"]
-@mock_rds
+@mock_aws
def test_start_export_task_fails_unknown_snapshot():
client = boto3.client("rds", region_name="us-west-2")
@@ -66,7 +66,7 @@ def test_start_export_task_fails_unknown_snapshot():
assert err["Message"] == "DBSnapshot snapshot-1 not found."
-@mock_rds
+@mock_aws
def test_start_export_task_db():
client = boto3.client("rds", region_name="us-west-2")
source_arn = _prepare_db_snapshot(client)
@@ -93,7 +93,7 @@ def test_start_export_task_db():
assert export["SourceType"] == "SNAPSHOT"
-@mock_rds
+@mock_aws
def test_start_export_task_db_cluster():
client = boto3.client("rds", region_name="us-west-2")
source_arn = _prepare_db_cluster_snapshot(client)
@@ -120,7 +120,7 @@ def test_start_export_task_db_cluster():
assert export["SourceType"] == "CLUSTER"
-@mock_rds
+@mock_aws
def test_start_export_task_fail_already_exists():
client = boto3.client("rds", region_name="us-west-2")
source_arn = _prepare_db_snapshot(client)
@@ -149,7 +149,7 @@ def test_start_export_task_fail_already_exists():
)
-@mock_rds
+@mock_aws
def test_cancel_export_task_fails_unknown_task():
client = boto3.client("rds", region_name="us-west-2")
with pytest.raises(ClientError) as ex:
@@ -163,7 +163,7 @@ def test_cancel_export_task_fails_unknown_task():
)
-@mock_rds
+@mock_aws
def test_cancel_export_task():
client = boto3.client("rds", region_name="us-west-2")
source_arn = _prepare_db_snapshot(client)
@@ -182,7 +182,7 @@ def test_cancel_export_task():
assert export["Status"] == "canceled"
-@mock_rds
+@mock_aws
def test_describe_export_tasks():
client = boto3.client("rds", region_name="us-west-2")
source_arn = _prepare_db_snapshot(client)
@@ -200,7 +200,7 @@ def test_describe_export_tasks():
assert exports[0]["ExportTaskIdentifier"] == "export-snapshot-1"
-@mock_rds
+@mock_aws
def test_describe_export_tasks_fails_unknown_task():
client = boto3.client("rds", region_name="us-west-2")
with pytest.raises(ClientError) as ex:
diff --git a/tests/test_rdsdata/test_rdsdata.py b/tests/test_rdsdata/test_rdsdata.py
index 5d2d73b7d..cf5073cf4 100644
--- a/tests/test_rdsdata/test_rdsdata.py
+++ b/tests/test_rdsdata/test_rdsdata.py
@@ -1,13 +1,13 @@
import boto3
import requests
-from moto import mock_rdsdata, settings
+from moto import mock_aws, settings
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_rdsdata
+@mock_aws
def test_execute_statement():
rdsdata = boto3.client("rds-data", region_name="eu-west-1")
@@ -20,7 +20,7 @@ def test_execute_statement():
assert resp["records"] == []
-@mock_rdsdata
+@mock_aws
def test_set_query_results():
base_url = (
settings.test_server_mode_endpoint()
diff --git a/tests/test_redshift/test_redshift.py b/tests/test_redshift/test_redshift.py
index e7f51b111..9c101ca2b 100644
--- a/tests/test_redshift/test_redshift.py
+++ b/tests/test_redshift/test_redshift.py
@@ -7,11 +7,11 @@ import pytest
from botocore.exceptions import ClientError
from dateutil.tz import tzutc
-from moto import mock_ec2, mock_redshift
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_redshift
+@mock_aws
def test_create_cluster_boto3():
client = boto3.client("redshift", region_name="us-east-1")
response = client.create_cluster(
@@ -55,7 +55,7 @@ def test_create_cluster_boto3():
assert cluster["Endpoint"]["Port"] == 5439
-@mock_redshift
+@mock_aws
def test_create_cluster_with_enhanced_vpc_routing_enabled():
client = boto3.client("redshift", region_name="us-east-1")
response = client.create_cluster(
@@ -76,7 +76,7 @@ def test_create_cluster_with_enhanced_vpc_routing_enabled():
assert response["Cluster"]["EnhancedVpcRouting"] is True
-@mock_redshift
+@mock_aws
def test_create_and_describe_cluster_with_kms_key_id():
kms_key_id = (
"arn:aws:kms:us-east-1:123456789012:key/00000000-0000-0000-0000-000000000000"
@@ -101,7 +101,7 @@ def test_create_and_describe_cluster_with_kms_key_id():
assert cluster["KmsKeyId"] == kms_key_id
-@mock_redshift
+@mock_aws
def test_create_snapshot_copy_grant():
client = boto3.client("redshift", region_name="us-east-1")
grants = client.create_snapshot_copy_grant(
@@ -116,7 +116,7 @@ def test_create_snapshot_copy_grant():
client.describe_snapshot_copy_grants(SnapshotCopyGrantName="test-us-east-1")
-@mock_redshift
+@mock_aws
def test_create_many_snapshot_copy_grants():
client = boto3.client("redshift", region_name="us-east-1")
@@ -128,14 +128,14 @@ def test_create_many_snapshot_copy_grants():
assert len(response["SnapshotCopyGrants"]) == 10
-@mock_redshift
+@mock_aws
def test_no_snapshot_copy_grants():
client = boto3.client("redshift", region_name="us-east-1")
response = client.describe_snapshot_copy_grants()
assert len(response["SnapshotCopyGrants"]) == 0
-@mock_redshift
+@mock_aws
def test_create_cluster_all_attributes():
"""
Ran against AWS (on 30/05/2021)
@@ -221,7 +221,7 @@ def test_create_cluster_all_attributes():
assert cluster["TotalStorageCapacityInMegaBytes"] == 0
-@mock_redshift
+@mock_aws
def test_create_single_node_cluster_boto3():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -247,8 +247,7 @@ def test_create_single_node_cluster_boto3():
assert cluster["NumberOfNodes"] == 1
-@mock_redshift
-@mock_ec2
+@mock_aws
def test_create_cluster_in_subnet_group():
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -273,8 +272,7 @@ def test_create_cluster_in_subnet_group():
assert cluster["ClusterSubnetGroupName"] == "my_subnet_group"
-@mock_redshift
-@mock_ec2
+@mock_aws
def test_create_cluster_in_subnet_group_boto3():
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -299,7 +297,7 @@ def test_create_cluster_in_subnet_group_boto3():
assert cluster["ClusterSubnetGroupName"] == "my_subnet_group"
-@mock_redshift
+@mock_aws
def test_create_cluster_with_security_group_boto3():
client = boto3.client("redshift", region_name="us-east-1")
client.create_cluster_security_group(
@@ -327,8 +325,7 @@ def test_create_cluster_with_security_group_boto3():
assert set(group_names) == {"security_group1", "security_group2"}
-@mock_redshift
-@mock_ec2
+@mock_aws
def test_create_cluster_with_vpc_security_groups_boto3():
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -350,7 +347,7 @@ def test_create_cluster_with_vpc_security_groups_boto3():
assert list(group_ids) == [security_group.id]
-@mock_redshift
+@mock_aws
def test_create_cluster_with_iam_roles():
iam_roles_arn = ["arn:aws:iam:::role/my-iam-role"]
client = boto3.client("redshift", region_name="us-east-1")
@@ -368,7 +365,7 @@ def test_create_cluster_with_iam_roles():
assert iam_roles_arn == iam_roles
-@mock_redshift
+@mock_aws
def test_create_cluster_with_parameter_group_boto3():
client = boto3.client("redshift", region_name="us-east-1")
cluster_id = "my-cluster"
@@ -405,7 +402,7 @@ def test_create_cluster_with_parameter_group_boto3():
assert cluster["ClusterParameterGroups"][0]["ParameterApplyStatus"] == "in-sync"
-@mock_redshift
+@mock_aws
def test_describe_non_existent_cluster_boto3():
client = boto3.client("redshift", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -415,7 +412,7 @@ def test_describe_non_existent_cluster_boto3():
assert err["Message"] == "Cluster not-a-cluster not found."
-@mock_redshift
+@mock_aws
def test_modify_cluster_vpc_routing():
iam_roles_arn = ["arn:aws:iam:::role/my-iam-role"]
client = boto3.client("redshift", region_name="us-east-1")
@@ -470,7 +467,7 @@ def test_modify_cluster_vpc_routing():
assert cluster["EnhancedVpcRouting"] is True
-@mock_redshift
+@mock_aws
def test_modify_cluster_boto3():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -525,8 +522,7 @@ def test_modify_cluster_boto3():
assert cluster["NumberOfNodes"] == 4
-@mock_redshift
-@mock_ec2
+@mock_aws
def test_create_cluster_subnet_group():
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -551,7 +547,7 @@ def test_create_cluster_subnet_group():
assert set(subnet_ids) == set([subnet1.id, subnet2.id])
-@mock_redshift
+@mock_aws
def test_authorize_security_group_ingress():
iam_roles_arn = ["arn:aws:iam:::role/my-iam-role"]
client = boto3.client("redshift", region_name="us-east-1")
@@ -603,8 +599,7 @@ def test_authorize_security_group_ingress():
)
-@mock_redshift
-@mock_ec2
+@mock_aws
def test_create_invalid_cluster_subnet_group_boto3():
client = boto3.client("redshift", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -618,8 +613,7 @@ def test_create_invalid_cluster_subnet_group_boto3():
assert re.match(r"Subnet \[[a-z0-9-']+\] not found.", err["Message"])
-@mock_redshift
-@mock_ec2
+@mock_aws
def test_describe_non_existent_subnet_group_boto3():
client = boto3.client("redshift", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -629,8 +623,7 @@ def test_describe_non_existent_subnet_group_boto3():
assert err["Message"] == "Subnet group my_subnet not found."
-@mock_redshift
-@mock_ec2
+@mock_aws
def test_delete_cluster_subnet_group():
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -658,7 +651,7 @@ def test_delete_cluster_subnet_group():
client.delete_cluster_subnet_group(ClusterSubnetGroupName="not-a-subnet-group")
-@mock_redshift
+@mock_aws
def test_create_cluster_security_group_boto3():
client = boto3.client("redshift", region_name="us-east-1")
group = client.create_cluster_security_group(
@@ -684,7 +677,7 @@ def test_create_cluster_security_group_boto3():
assert my_group["Tags"] == [{"Key": "tag_key", "Value": "tag_value"}]
-@mock_redshift
+@mock_aws
def test_describe_non_existent_security_group_boto3():
client = boto3.client("redshift", region_name="us-east-1")
@@ -695,7 +688,7 @@ def test_describe_non_existent_security_group_boto3():
assert err["Message"] == "Security group non-existent not found."
-@mock_redshift
+@mock_aws
def test_delete_cluster_security_group_boto3():
client = boto3.client("redshift", region_name="us-east-1")
client.create_cluster_security_group(
@@ -721,7 +714,7 @@ def test_delete_cluster_security_group_boto3():
assert err["Message"] == "Security group not-a-security-group not found."
-@mock_redshift
+@mock_aws
def test_create_cluster_parameter_group_boto3():
client = boto3.client("redshift", region_name="us-east-1")
group = client.create_cluster_parameter_group(
@@ -744,7 +737,7 @@ def test_create_cluster_parameter_group_boto3():
assert my_group["Description"] == "This is my group"
-@mock_redshift
+@mock_aws
def test_describe_non_existent_parameter_group_boto3():
client = boto3.client("redshift", region_name="us-east-1")
with pytest.raises(ClientError) as ex:
@@ -756,7 +749,7 @@ def test_describe_non_existent_parameter_group_boto3():
assert err["Message"] == "Parameter group not-a-parameter-group not found."
-@mock_redshift
+@mock_aws
def test_delete_parameter_group_boto3():
client = boto3.client("redshift", region_name="us-east-1")
client.create_cluster_parameter_group(
@@ -781,7 +774,7 @@ def test_delete_parameter_group_boto3():
assert len(client.describe_cluster_parameter_groups()["ParameterGroups"]) == 1
-@mock_redshift
+@mock_aws
def test_create_cluster_snapshot_of_non_existent_cluster():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "non-existent-cluster-id"
@@ -794,7 +787,7 @@ def test_create_cluster_snapshot_of_non_existent_cluster():
)
-@mock_redshift
+@mock_aws
def test_automated_snapshot_on_cluster_creation():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -821,7 +814,7 @@ def test_automated_snapshot_on_cluster_creation():
assert resp_auto_snap["Snapshots"][0]["Tags"] == []
-@mock_redshift
+@mock_aws
def test_delete_automated_snapshot():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -849,7 +842,7 @@ def test_delete_automated_snapshot():
)
-@mock_redshift
+@mock_aws
def test_presence_automated_snapshot_on_cluster_delete():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -877,7 +870,7 @@ def test_presence_automated_snapshot_on_cluster_delete():
assert len(resp["Snapshots"]) == 0
-@mock_redshift
+@mock_aws
def test_describe_snapshot_with_filter():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -938,7 +931,7 @@ def test_describe_snapshot_with_filter():
)
-@mock_redshift
+@mock_aws
def test_create_cluster_from_automated_snapshot():
client = boto3.client("redshift", region_name="us-east-1")
original_cluster_identifier = "original-cluster"
@@ -985,7 +978,7 @@ def test_create_cluster_from_automated_snapshot():
assert len(resp_auto_snap["Snapshots"]) == 1
-@mock_redshift
+@mock_aws
def test_create_cluster_snapshot():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -1015,7 +1008,7 @@ def test_create_cluster_snapshot():
assert snapshot["MasterUsername"] == "username"
-@mock_redshift
+@mock_aws
def test_describe_cluster_snapshots():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -1065,7 +1058,7 @@ def test_describe_cluster_snapshots():
assert resp_clust["Snapshots"][1] == resp_snap_2["Snapshots"][0]
-@mock_redshift
+@mock_aws
def test_describe_cluster_snapshots_not_found_error():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "non-existent-cluster-id"
@@ -1081,7 +1074,7 @@ def test_describe_cluster_snapshots_not_found_error():
)
-@mock_redshift
+@mock_aws
def test_delete_cluster_snapshot():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -1119,7 +1112,7 @@ def test_delete_cluster_snapshot():
)
-@mock_redshift
+@mock_aws
def test_cluster_snapshot_already_exists():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -1148,7 +1141,7 @@ def test_cluster_snapshot_already_exists():
)
-@mock_redshift
+@mock_aws
def test_create_cluster_from_snapshot():
client = boto3.client("redshift", region_name="us-east-1")
original_cluster_identifier = "original-cluster"
@@ -1191,7 +1184,7 @@ def test_create_cluster_from_snapshot():
assert new_cluster["EnhancedVpcRouting"] is True
-@mock_redshift
+@mock_aws
def test_create_cluster_with_node_type_from_snapshot():
client = boto3.client("redshift", region_name="us-east-1")
original_cluster_identifier = "original-cluster"
@@ -1236,7 +1229,7 @@ def test_create_cluster_with_node_type_from_snapshot():
assert new_cluster["EnhancedVpcRouting"] is True
-@mock_redshift
+@mock_aws
def test_create_cluster_from_snapshot_with_waiter():
client = boto3.client("redshift", region_name="us-east-1")
original_cluster_identifier = "original-cluster"
@@ -1275,7 +1268,7 @@ def test_create_cluster_from_snapshot_with_waiter():
assert new_cluster["Endpoint"]["Port"] == 1234
-@mock_redshift
+@mock_aws
def test_create_cluster_from_non_existent_snapshot():
client = boto3.client("redshift", region_name="us-east-1")
with pytest.raises(ClientError) as client_err:
@@ -1287,7 +1280,7 @@ def test_create_cluster_from_non_existent_snapshot():
)
-@mock_redshift
+@mock_aws
def test_create_cluster_status_update():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "test-cluster"
@@ -1305,7 +1298,7 @@ def test_create_cluster_status_update():
assert response["Clusters"][0]["ClusterStatus"] == "available"
-@mock_redshift
+@mock_aws
def test_describe_tags_with_resource_type():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -1353,7 +1346,7 @@ def test_describe_tags_with_resource_type():
assert tag["Value"] == tag_value
-@mock_redshift
+@mock_aws
def test_describe_tags_cannot_specify_resource_type_and_resource_name():
client = boto3.client("redshift", region_name="us-east-1")
resource_name = f"arn:aws:redshift:us-east-1:{ACCOUNT_ID}:cluster:cluster-id"
@@ -1366,7 +1359,7 @@ def test_describe_tags_cannot_specify_resource_type_and_resource_name():
)
-@mock_redshift
+@mock_aws
def test_describe_tags_with_resource_name():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "cluster-id"
@@ -1414,7 +1407,7 @@ def test_describe_tags_with_resource_name():
assert tag["Value"] == tag_value
-@mock_redshift
+@mock_aws
def test_create_tags():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "cluster-id"
@@ -1445,7 +1438,7 @@ def test_create_tags():
assert len(list(response["TaggedResources"])) == num_tags
-@mock_redshift
+@mock_aws
def test_delete_tags():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "cluster-id"
@@ -1479,8 +1472,7 @@ def test_delete_tags():
assert len(list(response["TaggedResources"])) == 1
-@mock_ec2
-@mock_redshift
+@mock_aws
def test_describe_tags_all_resource_types():
ec2 = boto3.resource("ec2", region_name="us-east-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -1533,7 +1525,7 @@ def test_describe_tags_all_resource_types():
assert set(returned_types) == set(expected_types)
-@mock_redshift
+@mock_aws
def test_tagged_resource_not_found_error():
client = boto3.client("redshift", region_name="us-east-1")
@@ -1563,7 +1555,7 @@ def test_tagged_resource_not_found_error():
)
-@mock_redshift
+@mock_aws
def test_enable_snapshot_copy():
client = boto3.client("redshift", region_name="us-east-1")
client.create_cluster(
@@ -1607,7 +1599,7 @@ def test_enable_snapshot_copy():
)
-@mock_redshift
+@mock_aws
def test_enable_snapshot_copy_unencrypted():
client = boto3.client("redshift", region_name="us-east-1")
client.create_cluster(
@@ -1625,7 +1617,7 @@ def test_enable_snapshot_copy_unencrypted():
assert cluster_snapshot_copy_status["DestinationRegion"] == "us-west-2"
-@mock_redshift
+@mock_aws
def test_disable_snapshot_copy():
client = boto3.client("redshift", region_name="us-east-1")
client.create_cluster(
@@ -1647,7 +1639,7 @@ def test_disable_snapshot_copy():
assert "ClusterSnapshotCopyStatus" not in response["Clusters"][0]
-@mock_redshift
+@mock_aws
def test_modify_snapshot_copy_retention_period():
client = boto3.client("redshift", region_name="us-east-1")
client.create_cluster(
@@ -1672,7 +1664,7 @@ def test_modify_snapshot_copy_retention_period():
assert cluster_snapshot_copy_status["RetentionPeriod"] == 5
-@mock_redshift
+@mock_aws
def test_create_duplicate_cluster_fails():
kwargs = {
"ClusterIdentifier": "test",
@@ -1689,7 +1681,7 @@ def test_create_duplicate_cluster_fails():
assert client_err.value.response["Error"]["Code"] == "ClusterAlreadyExists"
-@mock_redshift
+@mock_aws
def test_delete_cluster_with_final_snapshot():
client = boto3.client("redshift", region_name="us-east-1")
@@ -1735,7 +1727,7 @@ def test_delete_cluster_with_final_snapshot():
assert re.match(r"Cluster .+ not found.", ex.value.response["Error"]["Message"])
-@mock_redshift
+@mock_aws
def test_delete_cluster_without_final_snapshot():
client = boto3.client("redshift", region_name="us-east-1")
cluster_identifier = "my_cluster"
@@ -1786,7 +1778,7 @@ def test_delete_cluster_without_final_snapshot():
assert re.match(r"Cluster .+ not found.", ex.value.response["Error"]["Message"])
-@mock_redshift
+@mock_aws
def test_resize_cluster():
client = boto3.client("redshift", region_name="us-east-1")
resp = client.create_cluster(
@@ -1828,7 +1820,7 @@ def test_resize_cluster():
assert "Invalid cluster type" in ex.value.response["Error"]["Message"]
-@mock_redshift
+@mock_aws
def test_get_cluster_credentials_non_existent_cluster_and_user():
client = boto3.client("redshift", region_name="us-east-1")
@@ -1840,7 +1832,7 @@ def test_get_cluster_credentials_non_existent_cluster_and_user():
assert re.match(r"Cluster .+ not found.", ex.value.response["Error"]["Message"])
-@mock_redshift
+@mock_aws
def test_get_cluster_credentials_invalid_duration():
client = boto3.client("redshift", region_name="us-east-1")
@@ -1876,7 +1868,7 @@ def test_get_cluster_credentials_invalid_duration():
)
-@mock_redshift
+@mock_aws
def test_get_cluster_credentials():
client = boto3.client("redshift", region_name="us-east-1")
@@ -1924,7 +1916,7 @@ def test_get_cluster_credentials():
)
-@mock_redshift
+@mock_aws
def test_pause_cluster():
client = boto3.client("redshift", region_name="us-east-1")
response = client.create_cluster(
@@ -1949,7 +1941,7 @@ def test_pause_cluster():
assert cluster["Endpoint"]["Port"] == 5439
-@mock_redshift
+@mock_aws
def test_pause_unknown_cluster():
client = boto3.client("redshift", region_name="us-east-1")
@@ -1960,7 +1952,7 @@ def test_pause_unknown_cluster():
assert err["Message"] == "Cluster test not found."
-@mock_redshift
+@mock_aws
def test_resume_cluster():
client = boto3.client("redshift", region_name="us-east-1")
client.create_cluster(
@@ -1984,7 +1976,7 @@ def test_resume_cluster():
assert cluster["Endpoint"]["Port"] == 5439
-@mock_redshift
+@mock_aws
def test_resume_unknown_cluster():
client = boto3.client("redshift", region_name="us-east-1")
diff --git a/tests/test_redshift/test_redshift_cloudformation.py b/tests/test_redshift/test_redshift_cloudformation.py
index 837ad9092..4acd3a49f 100644
--- a/tests/test_redshift/test_redshift_cloudformation.py
+++ b/tests/test_redshift/test_redshift_cloudformation.py
@@ -2,13 +2,11 @@ import json
import boto3
-from moto import mock_cloudformation, mock_ec2, mock_redshift
+from moto import mock_aws
from tests.test_cloudformation.fixtures import redshift
-@mock_ec2
-@mock_redshift
-@mock_cloudformation
+@mock_aws
def test_redshift_stack():
redshift_template_json = json.dumps(redshift.template)
diff --git a/tests/test_redshift/test_server.py b/tests/test_redshift/test_server.py
index 75d982c0d..95c9c4dab 100644
--- a/tests/test_redshift/test_server.py
+++ b/tests/test_redshift/test_server.py
@@ -7,7 +7,7 @@ import pytest
import xmltodict
import moto.server as server
-from moto import mock_redshift, settings
+from moto import mock_aws, settings
@pytest.fixture(scope="function", autouse=True)
@@ -16,7 +16,7 @@ def skip_in_server_mode():
raise unittest.SkipTest("No point in testing this in ServerMode")
-@mock_redshift
+@mock_aws
def test_describe_clusters():
backend = server.create_backend_app("redshift")
test_client = backend.test_client()
@@ -27,7 +27,7 @@ def test_describe_clusters():
assert "" in result
-@mock_redshift
+@mock_aws
def test_describe_clusters_with_json_content_type():
backend = server.create_backend_app("redshift")
test_client = backend.test_client()
@@ -42,7 +42,7 @@ def test_describe_clusters_with_json_content_type():
@pytest.mark.parametrize("is_json", [True, False], ids=["JSON", "XML"])
-@mock_redshift
+@mock_aws
def test_create_cluster(is_json):
backend = server.create_backend_app("redshift")
test_client = backend.test_client()
@@ -92,7 +92,7 @@ def test_create_cluster(is_json):
@pytest.mark.parametrize("is_json", [True, False], ids=["JSON", "XML"])
-@mock_redshift
+@mock_aws
def test_create_cluster_multiple_params(is_json):
backend = server.create_backend_app("redshift")
test_client = backend.test_client()
@@ -157,7 +157,7 @@ def test_create_cluster_multiple_params(is_json):
@pytest.mark.parametrize("is_json", [True, False], ids=["JSON", "XML"])
-@mock_redshift
+@mock_aws
def test_create_and_describe_clusters(is_json):
backend = server.create_backend_app("redshift")
test_client = backend.test_client()
@@ -199,7 +199,7 @@ def test_create_and_describe_clusters(is_json):
@pytest.mark.parametrize("is_json", [True, False], ids=["JSON", "XML"])
-@mock_redshift
+@mock_aws
def test_create_and_describe_cluster_security_group(is_json):
backend = server.create_backend_app("redshift")
test_client = backend.test_client()
@@ -261,7 +261,7 @@ def test_create_and_describe_cluster_security_group(is_json):
@pytest.mark.parametrize("is_json", [True, False], ids=["JSON", "XML"])
-@mock_redshift
+@mock_aws
def test_describe_unknown_cluster_security_group(is_json):
backend = server.create_backend_app("redshift")
test_client = backend.test_client()
@@ -288,7 +288,7 @@ def test_describe_unknown_cluster_security_group(is_json):
@pytest.mark.parametrize("is_json", [True, False], ids=["JSON", "XML"])
-@mock_redshift
+@mock_aws
def test_create_cluster_with_security_group(is_json):
backend = server.create_backend_app("redshift")
test_client = backend.test_client()
diff --git a/tests/test_redshiftdata/test_redshiftdata.py b/tests/test_redshiftdata/test_redshiftdata.py
index ae6181e25..a5d6c9f35 100644
--- a/tests/test_redshiftdata/test_redshiftdata.py
+++ b/tests/test_redshiftdata/test_redshiftdata.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_redshiftdata
+from moto import mock_aws
from tests.test_redshiftdata.test_redshiftdata_constants import ErrorAttributes
REGION = "us-east-1"
@@ -15,7 +15,7 @@ RESOURCE_NOT_FOUND_ERROR_MESSAGE = "Query does not exist."
@pytest.fixture(autouse=True, name="client")
def fixture_client():
- with mock_redshiftdata():
+ with mock_aws():
yield boto3.client("redshift-data", region_name=REGION)
diff --git a/tests/test_rekognition/test_rekognition.py b/tests/test_rekognition/test_rekognition.py
index 7b1070462..bf3d20a00 100644
--- a/tests/test_rekognition/test_rekognition.py
+++ b/tests/test_rekognition/test_rekognition.py
@@ -4,13 +4,13 @@ import string
import boto3
-from moto import mock_rekognition
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_rekognition
+@mock_aws
def test_start_face_search():
client = boto3.client("rekognition", region_name="ap-southeast-1")
collection_id = "collection_id"
@@ -27,7 +27,7 @@ def test_start_face_search():
assert "JobId" in resp
-@mock_rekognition
+@mock_aws
def test_start_text_detection():
client = boto3.client("rekognition", region_name="ap-southeast-1")
video = {
@@ -43,7 +43,7 @@ def test_start_text_detection():
assert "JobId" in resp
-@mock_rekognition
+@mock_aws
def test_compare_faces():
client = boto3.client("rekognition", region_name="ap-southeast-1")
sourceimage = {
@@ -61,7 +61,7 @@ def test_compare_faces():
assert "FaceMatches" in resp
-@mock_rekognition
+@mock_aws
def test_detect_labels():
client = boto3.client("rekognition", region_name="ap-southeast-1")
@@ -73,7 +73,7 @@ def test_detect_labels():
assert "Labels" in resp
-@mock_rekognition
+@mock_aws
def test_detect_text():
client = boto3.client("rekognition", region_name="ap-southeast-1")
@@ -85,7 +85,7 @@ def test_detect_text():
assert "TextDetections" in resp
-@mock_rekognition
+@mock_aws
def test_get_face_search():
client = boto3.client("rekognition", region_name="us-east-2")
job_id = "".join(
@@ -102,7 +102,7 @@ def test_get_face_search():
)
-@mock_rekognition
+@mock_aws
def test_get_text_detection():
client = boto3.client("rekognition", region_name="us-east-2")
job_id = "".join(
diff --git a/tests/test_resourcegroups/test_resourcegroups.py b/tests/test_resourcegroups/test_resourcegroups.py
index 590007e27..800de6ddc 100644
--- a/tests/test_resourcegroups/test_resourcegroups.py
+++ b/tests/test_resourcegroups/test_resourcegroups.py
@@ -2,7 +2,7 @@ import json
import boto3
-from moto import mock_resourcegroups
+from moto import mock_aws
def create_group(client):
@@ -24,7 +24,7 @@ def create_group(client):
)
-@mock_resourcegroups
+@mock_aws
def test_create_group():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -34,7 +34,7 @@ def test_create_group():
assert "resource_group_tag_value" in response["Tags"]["resource_group_tag_key"]
-@mock_resourcegroups
+@mock_aws
def test_delete_group():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -48,7 +48,7 @@ def test_delete_group():
assert len(response["Groups"]) == 0
-@mock_resourcegroups
+@mock_aws
def test_get_group():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -58,7 +58,7 @@ def test_get_group():
assert "description" in response["Group"]["Description"]
-@mock_resourcegroups
+@mock_aws
def test_get_group_query():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -71,7 +71,7 @@ def test_get_group_query():
assert "TAG_FILTERS_1_0" in response_get["GroupQuery"]["ResourceQuery"]["Type"]
-@mock_resourcegroups
+@mock_aws
def test_get_tags():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -82,7 +82,7 @@ def test_get_tags():
assert "resource_group_tag_value" in response["Tags"]["resource_group_tag_key"]
-@mock_resourcegroups
+@mock_aws
def test_list_groups():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -93,7 +93,7 @@ def test_list_groups():
assert len(response["Groups"]) == 1
-@mock_resourcegroups
+@mock_aws
def test_tag():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -110,7 +110,7 @@ def test_tag():
assert "resource_group_tag_value_2" in response["Tags"]["resource_group_tag_key_2"]
-@mock_resourcegroups
+@mock_aws
def test_untag():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -123,7 +123,7 @@ def test_untag():
assert len(response["Tags"]) == 0
-@mock_resourcegroups
+@mock_aws
def test_update_group():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -138,7 +138,7 @@ def test_update_group():
assert "description_2" in response["Group"]["Description"]
-@mock_resourcegroups
+@mock_aws
def test_get_group_configuration():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -168,7 +168,7 @@ def test_get_group_configuration():
)
-@mock_resourcegroups
+@mock_aws
def test_create_group_with_configuration():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
@@ -205,7 +205,7 @@ def test_create_group_with_configuration():
assert "resource_group_tag_value" in response["Tags"]["resource_group_tag_key"]
-@mock_resourcegroups
+@mock_aws
def test_update_group_query():
resource_groups = boto3.client("resource-groups", region_name="us-east-1")
diff --git a/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_glue.py b/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_glue.py
index 1c1915316..627a2cd31 100644
--- a/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_glue.py
+++ b/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_glue.py
@@ -2,12 +2,11 @@ from uuid import uuid4
import boto3
-from moto import mock_glue, mock_resourcegroupstaggingapi
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID
-@mock_glue
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_glue_jobs():
glue = boto3.client("glue", region_name="us-west-1")
tag_key = str(uuid4())[0:6]
diff --git a/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_logs.py b/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_logs.py
index e9190dc51..869161ad1 100644
--- a/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_logs.py
+++ b/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_logs.py
@@ -2,11 +2,10 @@ import unittest
import boto3
-from moto import mock_logs, mock_resourcegroupstaggingapi
+from moto import mock_aws
-@mock_logs
-@mock_resourcegroupstaggingapi
+@mock_aws
class TestLogsTagging(unittest.TestCase):
def setUp(self) -> None:
self.logs = boto3.client("logs", region_name="us-east-2")
diff --git a/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_rds.py b/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_rds.py
index ab0c132e8..fc54c0f63 100644
--- a/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_rds.py
+++ b/tests/test_resourcegroupstaggingapi/test_resourcegroupstagging_rds.py
@@ -2,11 +2,10 @@ import unittest
import boto3
-from moto import mock_rds, mock_resourcegroupstaggingapi
+from moto import mock_aws
-@mock_rds
-@mock_resourcegroupstaggingapi
+@mock_aws
class TestRdsTagging(unittest.TestCase):
def setUp(self) -> None:
self.rds = boto3.client("rds", region_name="us-west-2")
diff --git a/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py b/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py
index 079466116..e01291123 100644
--- a/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py
+++ b/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py
@@ -3,26 +3,11 @@ import json
import boto3
from botocore.client import ClientError
-from moto import (
- mock_acm,
- mock_backup,
- mock_cloudformation,
- mock_ec2,
- mock_ecs,
- mock_elbv2,
- mock_iam,
- mock_kms,
- mock_lambda,
- mock_resourcegroupstaggingapi,
- mock_s3,
- mock_sqs,
-)
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID, EXAMPLE_AMI_ID2
-@mock_kms
-@mock_cloudformation
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_resources_cloudformation():
template = {
@@ -80,8 +65,7 @@ def test_get_resources_cloudformation():
assert stack_two in resp["ResourceTagMappingList"][0]["ResourceARN"]
-@mock_acm
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_resources_acm():
client = boto3.client("acm", region_name="us-east-1")
cert_blue = client.request_certificate(
@@ -118,8 +102,7 @@ def test_get_resources_acm():
)
-@mock_backup
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_resources_backup():
backup = boto3.client("backup", region_name="eu-central-1")
@@ -149,9 +132,7 @@ def test_get_resources_backup():
assert {"Key": "Test", "Value": "1"} in resp["ResourceTagMappingList"][0]["Tags"]
-@mock_ecs
-@mock_ec2
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_resources_ecs():
# ecs:cluster
@@ -296,8 +277,7 @@ def test_get_resources_ecs():
assert task_two not in resp["ResourceTagMappingList"][0]["ResourceARN"]
-@mock_ec2
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_resources_ec2():
client = boto3.client("ec2", region_name="eu-central-1")
@@ -348,8 +328,7 @@ def test_get_resources_ec2():
assert "instance/" in resp["ResourceTagMappingList"][0]["ResourceARN"]
-@mock_ec2
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_resources_ec2_vpc():
ec2 = boto3.resource("ec2", region_name="us-west-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
@@ -369,8 +348,7 @@ def test_get_resources_ec2_vpc():
assert_response(resp)
-@mock_ec2
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_tag_keys_ec2():
client = boto3.client("ec2", region_name="eu-central-1")
@@ -404,8 +382,7 @@ def test_get_tag_keys_ec2():
# TODO test pagenation
-@mock_ec2
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_tag_values_ec2():
client = boto3.client("ec2", region_name="eu-central-1")
@@ -455,10 +432,7 @@ def test_get_tag_values_ec2():
assert "MY_VALUE4" in resp["TagValues"]
-@mock_ec2
-@mock_elbv2
-@mock_kms
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_many_resources():
elbv2 = boto3.client("elbv2", region_name="us-east-1")
ec2 = boto3.resource("ec2", region_name="us-east-1")
@@ -522,9 +496,7 @@ def test_get_many_resources():
# TODO test pagination
-@mock_ec2
-@mock_elbv2
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_resources_target_group():
ec2 = boto3.resource("ec2", region_name="eu-central-1")
elbv2 = boto3.client("elbv2", region_name="eu-central-1")
@@ -563,8 +535,7 @@ def test_get_resources_target_group():
assert {"Key": "Test", "Value": "1"} in resp["ResourceTagMappingList"][0]["Tags"]
-@mock_s3
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_resources_s3():
# Tests pagination
s3_client = boto3.client("s3", region_name="eu-central-1")
@@ -601,8 +572,7 @@ def test_get_resources_s3():
assert len(response_keys) == 0
-@mock_ec2
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_multiple_tag_filters():
client = boto3.client("ec2", region_name="eu-central-1")
@@ -660,21 +630,18 @@ def test_multiple_tag_filters():
assert instance_2_id not in results[0]["ResourceARN"]
-@mock_lambda
-@mock_resourcegroupstaggingapi
-@mock_iam
+@mock_aws
def test_get_resources_lambda():
def get_role_name():
- with mock_iam():
- iam = boto3.client("iam", region_name="us-west-2")
- try:
- return iam.get_role(RoleName="my-role")["Role"]["Arn"]
- except ClientError:
- return iam.create_role(
- RoleName="my-role",
- AssumeRolePolicyDocument="some policy",
- Path="/my-path/",
- )["Role"]["Arn"]
+ iam = boto3.client("iam", region_name="us-west-2")
+ try:
+ return iam.get_role(RoleName="my-role")["Role"]["Arn"]
+ except ClientError:
+ return iam.create_role(
+ RoleName="my-role",
+ AssumeRolePolicyDocument="some policy",
+ Path="/my-path/",
+ )["Role"]["Arn"]
client = boto3.client("lambda", region_name="us-west-2")
@@ -748,8 +715,7 @@ def test_get_resources_lambda():
assert_response(resp, [rectangle_arn])
-@mock_sqs
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_get_resources_sqs():
sqs = boto3.resource("sqs", region_name="eu-central-1")
@@ -779,7 +745,7 @@ def test_get_resources_sqs():
assert {"Key": "Test", "Value": "1"} in resp["ResourceTagMappingList"][0]["Tags"]
-@mock_resourcegroupstaggingapi
+@mock_aws
def test_tag_resources_for_unknown_service():
rtapi = boto3.client("resourcegroupstaggingapi", region_name="us-west-2")
missing_resources = rtapi.tag_resources(
diff --git a/tests/test_robomaker/test_robomaker.py b/tests/test_robomaker/test_robomaker.py
index 48c952a54..66cbfb287 100644
--- a/tests/test_robomaker/test_robomaker.py
+++ b/tests/test_robomaker/test_robomaker.py
@@ -1,13 +1,12 @@
-"""Unit tests for robomaker-supported APIs."""
import boto3
-from moto import mock_robomaker
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_robomaker
+@mock_aws
def test_robot_application():
client = boto3.client("robomaker", region_name="eu-west-1")
app = client.create_robot_application(
diff --git a/tests/test_route53/test_route53.py b/tests/test_route53/test_route53.py
index a40418523..1ad8b90f7 100644
--- a/tests/test_route53/test_route53.py
+++ b/tests/test_route53/test_route53.py
@@ -4,10 +4,10 @@ import pytest
import requests
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_route53, settings
+from moto import mock_aws, settings
-@mock_route53
+@mock_aws
def test_create_hosted_zone():
conn = boto3.client("route53", region_name="us-east-1")
response = conn.create_hosted_zone(
@@ -31,7 +31,7 @@ def test_create_hosted_zone():
assert "testdns.aws.com." in requests.get(location).text
-@mock_route53
+@mock_aws
def test_get_hosted_zone():
conn = boto3.client("route53", region_name="us-east-1")
name = "testdns.aws.com."
@@ -44,7 +44,7 @@ def test_get_hosted_zone():
assert res["HostedZone"]["CallerReference"] == caller_ref
-@mock_route53
+@mock_aws
def test_list_hosted_zones():
conn = boto3.client("route53", region_name="us-east-1")
@@ -65,7 +65,7 @@ def test_list_hosted_zones():
assert zone2 in res
-@mock_route53
+@mock_aws
def test_delete_hosted_zone():
conn = boto3.client("route53", region_name="us-east-1")
@@ -80,7 +80,7 @@ def test_delete_hosted_zone():
assert len(res) == 1
-@mock_route53
+@mock_aws
def test_delete_hosted_zone_with_change_sets():
conn = boto3.client("route53", region_name="us-east-1")
@@ -114,14 +114,14 @@ def test_delete_hosted_zone_with_change_sets():
)
-@mock_route53
+@mock_aws
def test_get_hosted_zone_count_no_zones():
conn = boto3.client("route53", region_name="us-east-1")
zone_count = conn.get_hosted_zone_count()
assert zone_count["HostedZoneCount"] == 0
-@mock_route53
+@mock_aws
def test_get_hosted_zone_count_one_zone():
conn = boto3.client("route53", region_name="us-east-1")
zone = "a"
@@ -135,7 +135,7 @@ def test_get_hosted_zone_count_one_zone():
assert zone_count["HostedZoneCount"] == 1
-@mock_route53
+@mock_aws
def test_get_hosted_zone_count_many_zones():
conn = boto3.client("route53", region_name="us-east-1")
zones = {}
@@ -158,7 +158,7 @@ def test_get_hosted_zone_count_many_zones():
assert zone_count["HostedZoneCount"] == len(zone_indexes)
-@mock_route53
+@mock_aws
def test_get_unknown_hosted_zone():
conn = boto3.client("route53", region_name="us-east-1")
@@ -170,7 +170,7 @@ def test_get_unknown_hosted_zone():
assert err["Message"] == "No hosted zone found with ID: unknown"
-@mock_route53
+@mock_aws
def test_update_hosted_zone_comment():
conn = boto3.client("route53", region_name="us-east-1")
response = conn.create_hosted_zone(
@@ -184,7 +184,7 @@ def test_update_hosted_zone_comment():
assert resp["Config"]["Comment"] == "yolo"
-@mock_route53
+@mock_aws
def test_list_resource_record_set_unknown_zone():
conn = boto3.client("route53", region_name="us-east-1")
@@ -196,7 +196,7 @@ def test_list_resource_record_set_unknown_zone():
assert err["Message"] == "No hosted zone found with ID: abcd"
-@mock_route53
+@mock_aws
def test_list_resource_record_set_unknown_type():
conn = boto3.client("route53", region_name="us-east-1")
zone = conn.create_hosted_zone(
@@ -211,7 +211,7 @@ def test_list_resource_record_set_unknown_type():
assert err["Message"] == "Bad Request"
-@mock_route53
+@mock_aws
def test_use_health_check_in_resource_record_set():
conn = boto3.client("route53", region_name="us-east-1")
@@ -257,7 +257,7 @@ def test_use_health_check_in_resource_record_set():
assert record_sets[2]["HealthCheckId"] == check_id
-@mock_route53
+@mock_aws
def test_hosted_zone_comment_preserved():
conn = boto3.client("route53", region_name="us-east-1")
@@ -275,7 +275,7 @@ def test_hosted_zone_comment_preserved():
assert hosted_zones["HostedZones"][0]["Config"]["Comment"] == "test comment"
-@mock_route53
+@mock_aws
def test_deleting_weighted_route():
conn = boto3.client("route53", region_name="us-east-1")
@@ -332,7 +332,7 @@ def test_deleting_weighted_route():
assert cnames[-1]["SetIdentifier"] == "success-test-bar"
-@mock_route53
+@mock_aws
def test_deleting_latency_route():
conn = boto3.client("route53", region_name="us-east-1")
@@ -399,7 +399,7 @@ def test_deleting_latency_route():
assert cnames[-1]["Region"] == "us-west-1"
-@mock_route53
+@mock_aws
def test_list_or_change_tags_for_resource_request():
conn = boto3.client("route53", region_name="us-east-1")
health_check = conn.create_health_check(
@@ -487,8 +487,7 @@ def test_list_or_change_tags_for_resource_request():
assert response["ResourceTagSet"]["Tags"] == []
-@mock_ec2
-@mock_route53
+@mock_aws
def test_list_hosted_zones_by_name():
# Create mock VPC so we can get a VPC ID
ec2c = boto3.client("ec2", region_name="us-east-1")
@@ -552,7 +551,7 @@ def test_list_hosted_zones_by_name():
assert zones["HostedZones"][2]["Name"] == "test.a.org."
-@mock_route53
+@mock_aws
def test_list_hosted_zones_by_dns_name():
conn = boto3.client("route53", region_name="us-east-1")
conn.create_hosted_zone(
@@ -603,7 +602,7 @@ def test_list_hosted_zones_by_dns_name():
assert zones["HostedZones"][3]["CallerReference"] == str(hash("bar"))
-@mock_route53
+@mock_aws
def test_change_resource_record_sets_crud_valid():
conn = boto3.client("route53", region_name="us-east-1")
conn.create_hosted_zone(
@@ -728,7 +727,7 @@ def test_change_resource_record_sets_crud_valid():
assert len(response["ResourceRecordSets"]) == 2
-@mock_route53
+@mock_aws
@pytest.mark.parametrize("multi_value_answer", [True, False, None])
def test_change_resource_record_sets_crud_valid_with_special_xml_chars(
multi_value_answer,
@@ -833,7 +832,7 @@ def test_change_resource_record_sets_crud_valid_with_special_xml_chars(
assert len(response["ResourceRecordSets"]) == 2
-@mock_route53
+@mock_aws
def test_change_resource_record_set__delete_should_match_create():
# To delete a resource record set, you must specify all the same values that you specified when you created it.
client = boto3.client("route53", region_name="us-east-1")
@@ -883,7 +882,7 @@ def test_change_resource_record_set__delete_should_match_create():
)
-@mock_route53
+@mock_aws
def test_change_weighted_resource_record_sets():
conn = boto3.client("route53", region_name="us-east-2")
conn.create_hosted_zone(
@@ -995,7 +994,7 @@ def test_change_weighted_resource_record_sets():
assert record["Weight"] == 10
-@mock_route53
+@mock_aws
def test_failover_record_sets():
conn = boto3.client("route53", region_name="us-east-2")
conn.create_hosted_zone(Name="test.zone.", CallerReference=str(hash("test")))
@@ -1026,7 +1025,7 @@ def test_failover_record_sets():
assert record["Failover"] == "PRIMARY"
-@mock_route53
+@mock_aws
def test_geolocation_record_sets():
conn = boto3.client("route53", region_name="us-east-2")
conn.create_hosted_zone(Name="test.zone.", CallerReference=str(hash("test")))
@@ -1068,7 +1067,7 @@ def test_geolocation_record_sets():
assert rrs[3]["GeoLocation"] == {"CountryCode": "US", "SubdivisionCode": "NY"}
-@mock_route53
+@mock_aws
def test_change_resource_record_invalid():
conn = boto3.client("route53", region_name="us-east-1")
conn.create_hosted_zone(
@@ -1129,7 +1128,7 @@ def test_change_resource_record_invalid():
assert len(response["ResourceRecordSets"]) == 2
-@mock_route53
+@mock_aws
def test_change_resource_record_invalid_action_value():
conn = boto3.client("route53", region_name="us-east-1")
conn.create_hosted_zone(
@@ -1174,7 +1173,7 @@ def test_change_resource_record_invalid_action_value():
assert len(response["ResourceRecordSets"]) == 2
-@mock_route53
+@mock_aws
def test_change_resource_record_set_create__should_fail_when_record_already_exists():
ZONE = "cname.local"
FQDN = f"test.{ZONE}"
@@ -1210,7 +1209,7 @@ def test_change_resource_record_set_create__should_fail_when_record_already_exis
)
-@mock_route53
+@mock_aws
def test_change_resource_record_set__should_create_record_when_using_upsert():
route53_client = boto3.client("route53", region_name="us-east-1")
@@ -1252,7 +1251,7 @@ def test_change_resource_record_set__should_create_record_when_using_upsert():
assert response["ResourceRecordSets"][2] == resource_record
-@mock_route53
+@mock_aws
def test_list_resource_record_sets_name_type_filters():
conn = boto3.client("route53", region_name="us-east-1")
create_hosted_zone_response = conn.create_hosted_zone(
@@ -1310,7 +1309,7 @@ def test_list_resource_record_sets_name_type_filters():
assert desired_record in returned_records
-@mock_route53
+@mock_aws
def test_get_change():
conn = boto3.client("route53", region_name="us-east-2")
@@ -1321,7 +1320,7 @@ def test_get_change():
assert response["ChangeInfo"]["Status"] == "INSYNC"
-@mock_route53
+@mock_aws
def test_change_resource_record_sets_records_limit():
conn = boto3.client("route53", region_name="us-east-1")
conn.create_hosted_zone(
@@ -1441,7 +1440,7 @@ def test_change_resource_record_sets_records_limit():
assert err["Message"] == "Number of records limit of 1000 exceeded."
-@mock_route53
+@mock_aws
def test_list_resource_recordset_pagination():
conn = boto3.client("route53", region_name="us-east-1")
conn.create_hosted_zone(
@@ -1507,7 +1506,7 @@ def test_list_resource_recordset_pagination():
assert "NextRecordType" not in response
-@mock_route53
+@mock_aws
def test_get_dns_sec():
client = boto3.client("route53", region_name="us-east-1")
@@ -1518,7 +1517,7 @@ def test_get_dns_sec():
assert dns_sec["Status"] == {"ServeSignature": "NOT_SIGNING"}
-@mock_route53
+@mock_aws
@pytest.mark.parametrize(
"domain1,domain2",
(
diff --git a/tests/test_route53/test_route53_cloudformation.py b/tests/test_route53/test_route53_cloudformation.py
index c24a8f660..e95eee45f 100644
--- a/tests/test_route53/test_route53_cloudformation.py
+++ b/tests/test_route53/test_route53_cloudformation.py
@@ -3,7 +3,7 @@ from copy import deepcopy
import boto3
-from moto import mock_cloudformation, mock_ec2, mock_route53
+from moto import mock_aws
from tests.test_cloudformation.fixtures import (
route53_ec2_instance_with_public_ip,
route53_health_check,
@@ -44,8 +44,7 @@ template_record_set = {
}
-@mock_cloudformation
-@mock_route53
+@mock_aws
def test_create_stack_hosted_zone_by_id():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
conn = boto3.client("route53", region_name="us-east-1")
@@ -74,8 +73,7 @@ def test_create_stack_hosted_zone_by_id():
assert updated_zone["ResourceRecordSetCount"] == 3
-@mock_cloudformation
-@mock_route53
+@mock_aws
def test_route53_roundrobin():
cf = boto3.client("cloudformation", region_name="us-west-1")
route53 = boto3.client("route53", region_name="us-west-1")
@@ -113,9 +111,7 @@ def test_route53_roundrobin():
assert output["OutputValue"] == f"arn:aws:route53:::hostedzone/{zone_id}"
-@mock_cloudformation
-@mock_ec2
-@mock_route53
+@mock_aws
def test_route53_ec2_instance_with_public_ip():
route53 = boto3.client("route53", region_name="us-west-1")
ec2 = boto3.client("ec2", region_name="us-west-1")
@@ -146,8 +142,7 @@ def test_route53_ec2_instance_with_public_ip():
assert "Weight" not in record_set
-@mock_cloudformation
-@mock_route53
+@mock_aws
def test_route53_associate_health_check():
route53 = boto3.client("route53", region_name="us-west-1")
@@ -179,8 +174,7 @@ def test_route53_associate_health_check():
assert record_set["HealthCheckId"] == health_check_id
-@mock_cloudformation
-@mock_route53
+@mock_aws
def test_route53_with_update():
route53 = boto3.client("route53", region_name="us-west-1")
@@ -226,8 +220,7 @@ def test_route53_with_update():
assert record_set["ResourceRecords"][0]["Value"] == "my_other.example.com"
-@mock_cloudformation
-@mock_route53
+@mock_aws
def test_delete_route53_recordset():
cf = boto3.client("cloudformation", region_name="us-west-1")
diff --git a/tests/test_route53/test_route53_delegationsets.py b/tests/test_route53/test_route53_delegationsets.py
index 636fbb96d..a46ab317b 100644
--- a/tests/test_route53/test_route53_delegationsets.py
+++ b/tests/test_route53/test_route53_delegationsets.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_route53
+from moto import mock_aws
-@mock_route53
+@mock_aws
def test_list_reusable_delegation_set():
client = boto3.client("route53", region_name="us-east-1")
resp = client.list_reusable_delegation_sets()
@@ -14,7 +14,7 @@ def test_list_reusable_delegation_set():
assert resp["IsTruncated"] is False
-@mock_route53
+@mock_aws
def test_create_reusable_delegation_set():
client = boto3.client("route53", region_name="us-east-1")
resp = client.create_reusable_delegation_set(CallerReference="r3f3r3nc3")
@@ -27,7 +27,7 @@ def test_create_reusable_delegation_set():
assert len(resp["DelegationSet"]["NameServers"]) == 4
-@mock_route53
+@mock_aws
def test_create_reusable_delegation_set_from_hosted_zone():
client = boto3.client("route53", region_name="us-east-1")
response = client.create_hosted_zone(
@@ -43,7 +43,7 @@ def test_create_reusable_delegation_set_from_hosted_zone():
assert set(resp["DelegationSet"]["NameServers"]) == hosted_zone_name_servers
-@mock_route53
+@mock_aws
def test_create_reusable_delegation_set_from_hosted_zone_with_delegationsetid():
client = boto3.client("route53", region_name="us-east-1")
response = client.create_hosted_zone(
@@ -65,7 +65,7 @@ def test_create_reusable_delegation_set_from_hosted_zone_with_delegationsetid():
assert set(resp["DelegationSet"]["NameServers"]) == hosted_zone_name_servers
-@mock_route53
+@mock_aws
def test_get_reusable_delegation_set():
client = boto3.client("route53", region_name="us-east-1")
ds_id = client.create_reusable_delegation_set(CallerReference="r3f3r3nc3")[
@@ -81,7 +81,7 @@ def test_get_reusable_delegation_set():
assert len(resp["DelegationSet"]["NameServers"]) == 4
-@mock_route53
+@mock_aws
def test_get_reusable_delegation_set_unknown():
client = boto3.client("route53", region_name="us-east-1")
@@ -92,7 +92,7 @@ def test_get_reusable_delegation_set_unknown():
assert err["Message"] == "unknown"
-@mock_route53
+@mock_aws
def test_list_reusable_delegation_sets():
client = boto3.client("route53", region_name="us-east-1")
client.create_reusable_delegation_set(CallerReference="r3f3r3nc3")
@@ -103,7 +103,7 @@ def test_list_reusable_delegation_sets():
assert resp["IsTruncated"] is False
-@mock_route53
+@mock_aws
def test_delete_reusable_delegation_set():
client = boto3.client("route53", region_name="us-east-1")
ds_id = client.create_reusable_delegation_set(CallerReference="r3f3r3nc3")[
diff --git a/tests/test_route53/test_route53_healthchecks.py b/tests/test_route53/test_route53_healthchecks.py
index 38f5d61a4..b497cd354 100644
--- a/tests/test_route53/test_route53_healthchecks.py
+++ b/tests/test_route53/test_route53_healthchecks.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_route53
+from moto import mock_aws
-@mock_route53
+@mock_aws
def test_create_health_check():
client = boto3.client("route53", region_name="us-east-1")
@@ -45,7 +45,7 @@ def test_create_health_check():
assert "HealthThreshold" not in config
-@mock_route53
+@mock_aws
def test_create_health_check_with_additional_options():
client = boto3.client("route53", region_name="us-east-1")
@@ -81,7 +81,7 @@ def test_create_health_check_with_additional_options():
assert config["EnableSNI"] is True
-@mock_route53
+@mock_aws
def test_create_calculated_health_check():
client = boto3.client("route53", region_name="us-east-1")
@@ -114,7 +114,7 @@ def test_create_calculated_health_check():
assert "MeasureLatency" not in config
-@mock_route53
+@mock_aws
def test_create_calculated_health_check_with_children():
client = boto3.client("route53", region_name="us-east-1")
@@ -167,7 +167,7 @@ def test_create_calculated_health_check_with_children():
]
-@mock_route53
+@mock_aws
def test_get_health_check():
client = boto3.client("route53", region_name="us-east-1")
@@ -187,7 +187,7 @@ def test_get_health_check():
assert resp["HealthCheckVersion"] == 1
-@mock_route53
+@mock_aws
def test_get_unknown_health_check():
client = boto3.client("route53", region_name="us-east-1")
@@ -198,7 +198,7 @@ def test_get_unknown_health_check():
assert err["Message"] == "A health check with id unknown does not exist."
-@mock_route53
+@mock_aws
def test_list_health_checks():
conn = boto3.client("route53", region_name="us-east-1")
@@ -221,7 +221,7 @@ def test_list_health_checks():
assert conn.list_health_checks()["HealthChecks"] == [check]
-@mock_route53
+@mock_aws
def test_delete_health_checks():
conn = boto3.client("route53", region_name="us-east-1")
@@ -247,7 +247,7 @@ def test_delete_health_checks():
assert len(checks) == 0
-@mock_route53
+@mock_aws
def test_update_health_check():
client = boto3.client("route53", region_name="us-east-1")
@@ -289,7 +289,7 @@ def test_update_health_check():
assert config["Regions"] == ["us-east-1", "us-east-2", "us-west-1"]
-@mock_route53
+@mock_aws
def test_health_check_status():
client = boto3.client("route53", region_name="us-east-1")
diff --git a/tests/test_route53/test_route53_query_logging_config.py b/tests/test_route53/test_route53_query_logging_config.py
index 2b6e830fb..ac10f73b3 100644
--- a/tests/test_route53/test_route53_query_logging_config.py
+++ b/tests/test_route53/test_route53_query_logging_config.py
@@ -1,9 +1,8 @@
-"""Route53 unit tests specific to query_logging_config APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_logs, mock_route53
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.moto_api._internal import mock_random
@@ -37,8 +36,7 @@ def create_log_group_arn(logs_client, hosted_zone_test_name):
return log_group_arn
-@mock_logs
-@mock_route53
+@mock_aws
def test_create_query_logging_config_bad_args():
"""Test bad arguments to create_query_logging_config()."""
client = boto3.client("route53", region_name=TEST_REGION)
@@ -105,8 +103,7 @@ def test_create_query_logging_config_bad_args():
)
-@mock_logs
-@mock_route53
+@mock_aws
def test_create_query_logging_config_good_args():
"""Test a valid create_logging_config() request."""
client = boto3.client("route53", region_name=TEST_REGION)
@@ -131,8 +128,7 @@ def test_create_query_logging_config_good_args():
)
-@mock_logs
-@mock_route53
+@mock_aws
def test_delete_query_logging_config():
"""Test valid and invalid delete_query_logging_config requests."""
client = boto3.client("route53", region_name=TEST_REGION)
@@ -162,8 +158,7 @@ def test_delete_query_logging_config():
assert "The query logging configuration does not exist" in err["Message"]
-@mock_logs
-@mock_route53
+@mock_aws
def test_get_query_logging_config():
"""Test valid and invalid get_query_logging_config requests."""
client = boto3.client("route53", region_name=TEST_REGION)
@@ -194,8 +189,7 @@ def test_get_query_logging_config():
assert "The query logging configuration does not exist" in err["Message"]
-@mock_logs
-@mock_route53
+@mock_aws
def test_list_query_logging_configs_bad_args():
"""Test bad arguments to list_query_logging_configs()."""
client = boto3.client("route53", region_name=TEST_REGION)
@@ -231,8 +225,7 @@ def test_list_query_logging_configs_bad_args():
)
-@mock_logs
-@mock_route53
+@mock_aws
def test_list_query_logging_configs_good_args():
"""Test valid arguments to list_query_logging_configs()."""
client = boto3.client("route53", region_name=TEST_REGION)
diff --git a/tests/test_route53/test_route53_vpcs.py b/tests/test_route53/test_route53_vpcs.py
index 88e162fc7..6ee7ee52b 100644
--- a/tests/test_route53/test_route53_vpcs.py
+++ b/tests/test_route53/test_route53_vpcs.py
@@ -2,11 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_route53
+from moto import mock_aws
-@mock_ec2
-@mock_route53
+@mock_aws
def test_hosted_zone_private_zone_preserved():
# Create mock VPC so we can get a VPC ID
region = "us-east-1"
@@ -63,8 +62,7 @@ def test_hosted_zone_private_zone_preserved():
assert hosted_zones["HostedZones"][0]["Name"] == zone2_name
-@mock_ec2
-@mock_route53
+@mock_aws
def test_list_hosted_zones_by_vpc_with_multiple_vpcs():
# Create mock VPC so we can get a VPC ID
ec2c = boto3.client("ec2", region_name="us-east-1")
@@ -96,8 +94,7 @@ def test_list_hosted_zones_by_vpc_with_multiple_vpcs():
assert summary["Name"] == zones[index]["HostedZone"]["Name"]
-@mock_ec2
-@mock_route53
+@mock_aws
def test_list_hosted_zones_by_vpc():
# Create mock VPC so we can get a VPC ID
ec2c = boto3.client("ec2", region_name="us-east-1")
@@ -120,8 +117,7 @@ def test_list_hosted_zones_by_vpc():
assert returned_zone["Name"] == zone_b["HostedZone"]["Name"]
-@mock_ec2
-@mock_route53
+@mock_aws
def test_route53_associate_vpc():
ec2c = boto3.client("ec2", region_name="us-east-1")
vpc_id = ec2c.create_vpc(CidrBlock="10.1.0.0/16")["Vpc"]["VpcId"]
@@ -141,8 +137,7 @@ def test_route53_associate_vpc():
assert resp["ChangeInfo"]["Comment"] == "yolo"
-@mock_ec2
-@mock_route53
+@mock_aws
def test_route53_associate_vpc_with_public_Zone():
ec2c = boto3.client("ec2", region_name="us-east-1")
vpc_id = ec2c.create_vpc(CidrBlock="10.1.0.0/16")["Vpc"]["VpcId"]
@@ -167,8 +162,7 @@ def test_route53_associate_vpc_with_public_Zone():
)
-@mock_ec2
-@mock_route53
+@mock_aws
def test_route53_associate_and_disassociate_vpc():
ec2c = boto3.client("ec2", region_name="us-east-1")
vpc_id1 = ec2c.create_vpc(CidrBlock="10.1.0.0/16").get("Vpc").get("VpcId")
@@ -201,8 +195,7 @@ def test_route53_associate_and_disassociate_vpc():
assert {"VPCRegion": region, "VPCId": vpc_id2} in zone_vpcs
-@mock_ec2
-@mock_route53
+@mock_aws
def test_route53_disassociate_last_vpc():
ec2c = boto3.client("ec2", region_name="us-east-1")
vpc_id = ec2c.create_vpc(CidrBlock="10.1.0.0/16")["Vpc"]["VpcId"]
diff --git a/tests/test_route53resolver/test_route53resolver_endpoint.py b/tests/test_route53resolver/test_route53resolver_endpoint.py
index d9f38878c..3397b88af 100644
--- a/tests/test_route53resolver/test_route53resolver_endpoint.py
+++ b/tests/test_route53resolver/test_route53resolver_endpoint.py
@@ -1,4 +1,3 @@
-"""Unit tests for route53resolver endpoint-related APIs."""
from datetime import datetime, timezone
import boto3
@@ -6,9 +5,8 @@ import pytest
from botocore.config import Config
from botocore.exceptions import ClientError
-from moto import mock_route53resolver, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-from moto.ec2 import mock_ec2
from moto.moto_api._internal import mock_random
TEST_REGION = "us-east-1" if settings.TEST_SERVER_MODE else "us-west-2"
@@ -73,7 +71,7 @@ def create_test_endpoint(client, ec2_client, name=None, tags=None):
return resolver_endpoint["ResolverEndpoint"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_invalid_create_endpoint_args():
# Some validation is now part of botocore-1.34.3
# Disable validation to verify that Moto has the same validation
@@ -163,8 +161,7 @@ def test_route53resolver_invalid_create_endpoint_args():
) in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_create_endpoint_subnets():
# Some validation is now part of botocore-1.34.3
# Disable validation to verify that Moto has the same validation
@@ -243,8 +240,7 @@ def test_route53resolver_bad_create_endpoint_subnets():
) in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_create_endpoint_security_groups():
"""Test bad security group scenarios for create_resolver_endpoint API."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -299,8 +295,7 @@ def test_route53resolver_bad_create_endpoint_security_groups():
assert "Maximum of 10 security groups are allowed" in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_create_resolver_endpoint(): # pylint: disable=too-many-locals
"""Test good create_resolver_endpoint API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -351,8 +346,7 @@ def test_route53resolver_create_resolver_endpoint(): # pylint: disable=too-many
assert modification_time <= now
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_other_create_resolver_endpoint_errors():
"""Test other error scenarios for create_resolver_endpoint API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -393,8 +387,7 @@ def test_route53resolver_other_create_resolver_endpoint_errors():
assert f"Account '{ACCOUNT_ID}' has exceeded 'max-endpoints" in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_delete_resolver_endpoint():
"""Test good delete_resolver_endpoint API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -425,8 +418,7 @@ def test_route53resolver_delete_resolver_endpoint():
assert len(result["NetworkInterfaces"]) == 0
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_delete_resolver_endpoint():
"""Test delete_resolver_endpoint API calls with a bad ID."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -472,8 +464,7 @@ def test_route53resolver_bad_delete_resolver_endpoint():
) in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_get_resolver_endpoint():
"""Test good get_resolver_endpoint API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -497,7 +488,7 @@ def test_route53resolver_get_resolver_endpoint():
assert endpoint["ModificationTime"] == created_endpoint["ModificationTime"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_get_resolver_endpoint():
"""Test get_resolver_endpoint API calls with a bad ID."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -523,8 +514,7 @@ def test_route53resolver_bad_get_resolver_endpoint():
assert f"Resolver endpoint with ID '{random_num}' does not exist" in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_update_resolver_endpoint():
"""Test good update_resolver_endpoint API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -551,7 +541,7 @@ def test_route53resolver_update_resolver_endpoint():
assert endpoint["ModificationTime"] != created_endpoint["ModificationTime"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_update_resolver_endpoint():
"""Test update_resolver_endpoint API calls with a bad ID."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -578,8 +568,7 @@ def test_route53resolver_bad_update_resolver_endpoint():
assert f"Resolver endpoint with ID '{random_num}' does not exist" in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_list_resolver_endpoint_ip_addresses():
"""Test good list_resolver_endpoint_ip_addresses API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -629,8 +618,7 @@ def test_route53resolver_list_resolver_endpoint_ip_addresses():
assert "NextToken" not in response
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_list_resolver_endpoint_ip_addresses():
"""Test bad list_resolver_endpoint_ip_addresses API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -659,8 +647,7 @@ def test_route53resolver_bad_list_resolver_endpoint_ip_addresses():
) in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_list_resolver_endpoints():
"""Test good list_resolver_endpoints API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -700,8 +687,7 @@ def test_route53resolver_list_resolver_endpoints():
assert endpoint["Name"].startswith(f"A{idx + 1}")
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_list_resolver_endpoints_filters():
"""Test good list_resolver_endpoints API calls that use filters."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -802,7 +788,7 @@ def test_route53resolver_list_resolver_endpoints_filters():
assert len(response["ResolverEndpoints"]) == 0
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_list_resolver_endpoints_filters():
"""Test bad list_resolver_endpoints API calls that use filters."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -827,8 +813,7 @@ def test_route53resolver_bad_list_resolver_endpoints_filters():
assert "The filter 'HostVpcId' is invalid" in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_list_resolver_endpoints():
"""Test bad list_resolver_endpoints API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -848,8 +833,7 @@ def test_route53resolver_bad_list_resolver_endpoints():
) in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_associate_resolver_endpoint_ip_address():
client = boto3.client("route53resolver", region_name=TEST_REGION)
ec2_client = boto3.client("ec2", region_name=TEST_REGION)
@@ -877,7 +861,7 @@ def test_associate_resolver_endpoint_ip_address():
assert "10.0.2.126" in ip_addresses
-@mock_route53resolver
+@mock_aws
def test_associate_resolver_endpoint_ip_address__invalid_resolver():
client = boto3.client("route53resolver", region_name=TEST_REGION)
with pytest.raises(ClientError) as exc:
@@ -889,8 +873,7 @@ def test_associate_resolver_endpoint_ip_address__invalid_resolver():
assert err["Message"] == "Resolver endpoint with ID 'unknown' does not exist"
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_disassociate_resolver_endpoint_ip_address__using_ip():
client = boto3.client("route53resolver", region_name=TEST_REGION)
ec2_client = boto3.client("ec2", region_name=TEST_REGION)
@@ -918,8 +901,7 @@ def test_disassociate_resolver_endpoint_ip_address__using_ip():
assert (len(enis_after) + 1) == len(enis_before)
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_disassociate_resolver_endpoint_ip_address__using_ipid_and_subnet():
client = boto3.client("route53resolver", region_name=TEST_REGION)
ec2_client = boto3.client("ec2", region_name=TEST_REGION)
@@ -949,8 +931,7 @@ def test_disassociate_resolver_endpoint_ip_address__using_ipid_and_subnet():
assert resp["IpAddressCount"] == 2
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_disassociate_resolver_endpoint_ip_address__using_subnet_alone():
client = boto3.client("route53resolver", region_name=TEST_REGION)
ec2_client = boto3.client("ec2", region_name=TEST_REGION)
diff --git a/tests/test_route53resolver/test_route53resolver_rule.py b/tests/test_route53resolver/test_route53resolver_rule.py
index 23bf50a57..3cd5e178d 100644
--- a/tests/test_route53resolver/test_route53resolver_rule.py
+++ b/tests/test_route53resolver/test_route53resolver_rule.py
@@ -1,13 +1,11 @@
-"""Unit tests for route53resolver rule-related APIs."""
from datetime import datetime, timezone
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_route53resolver
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-from moto.ec2 import mock_ec2
from moto.moto_api._internal import mock_random
from .test_route53resolver_endpoint import TEST_REGION, create_test_endpoint, create_vpc
@@ -37,7 +35,7 @@ def create_test_rule(client, name=None, tags=None):
return resolver_rule["ResolverRule"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_invalid_create_rule_args():
"""Test invalid arguments to the create_resolver_rule API."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -121,8 +119,7 @@ def test_route53resolver_invalid_create_rule_args():
) in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_create_resolver_rule(): # pylint: disable=too-many-locals
"""Test good create_resolver_rule API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -176,8 +173,7 @@ def test_route53resolver_create_resolver_rule(): # pylint: disable=too-many-loc
assert modification_time <= now
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_create_resolver_rule():
"""Test error scenarios for create_resolver_rule API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -275,7 +271,7 @@ def test_route53resolver_bad_create_resolver_rule():
assert f"Account '{ACCOUNT_ID}' has exceeded 'max-rules" in err["Message"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_delete_resolver_rule():
"""Test good delete_resolver_rule API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -298,8 +294,7 @@ def test_route53resolver_delete_resolver_rule():
assert rule["CreationTime"] == created_rule["CreationTime"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_delete_resolver_rule():
"""Test delete_resolver_rule API calls with a bad ID."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -338,7 +333,7 @@ def test_route53resolver_bad_delete_resolver_rule():
) in err["Message"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_get_resolver_rule():
"""Test good get_resolver_rule API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -362,7 +357,7 @@ def test_route53resolver_get_resolver_rule():
assert rule["ModificationTime"] == created_rule["ModificationTime"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_get_resolver_rule():
"""Test get_resolver_rule API calls with a bad ID."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -388,7 +383,7 @@ def test_route53resolver_bad_get_resolver_rule():
assert f"Resolver rule with ID '{random_num}' does not exist" in err["Message"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_list_resolver_rules():
"""Test good list_resolver_rules API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -427,8 +422,7 @@ def test_route53resolver_list_resolver_rules():
assert rule["Name"].startswith(f"A{idx + 1}")
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_list_resolver_rules_filters():
"""Test good list_resolver_rules API calls that use filters."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -509,7 +503,7 @@ def test_route53resolver_list_resolver_rules_filters():
assert len(response["ResolverRules"]) == 0
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_list_resolver_rules_filters():
"""Test bad list_resolver_rules API calls that use filters."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -526,7 +520,7 @@ def test_route53resolver_bad_list_resolver_rules_filters():
assert "The filter 'foo' is invalid" in err["Message"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_list_resolver_rules():
"""Test bad list_resolver_rules API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
diff --git a/tests/test_route53resolver/test_route53resolver_rule_associations.py b/tests/test_route53resolver/test_route53resolver_rule_associations.py
index 048b6a5da..8275d4898 100644
--- a/tests/test_route53resolver/test_route53resolver_rule_associations.py
+++ b/tests/test_route53resolver/test_route53resolver_rule_associations.py
@@ -1,10 +1,8 @@
-"""Unit tests for route53resolver rule association-related APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_route53resolver
-from moto.ec2 import mock_ec2
+from moto import mock_aws
from moto.moto_api._internal import mock_random
from .test_route53resolver_endpoint import TEST_REGION, create_vpc
@@ -25,7 +23,7 @@ def create_test_rule_association(
)["ResolverRuleAssociation"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_invalid_associate_resolver_rule_args():
"""Test invalid arguments to the associate_resolver_rule API."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -59,8 +57,7 @@ def test_route53resolver_invalid_associate_resolver_rule_args():
) in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_associate_resolver_rule():
"""Test good associate_resolver_rule API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -80,8 +77,7 @@ def test_route53resolver_associate_resolver_rule():
assert "StatusMessage" in rule_association
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_other_associate_resolver_rule_errors():
"""Test good associate_resolver_rule API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -122,8 +118,7 @@ def test_route53resolver_other_associate_resolver_rule_errors():
# 2000 VPCs and rule associations.
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_disassociate_resolver_rule():
"""Test good disassociate_resolver_rule API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -144,8 +139,7 @@ def test_route53resolver_disassociate_resolver_rule():
assert "Deleting" in association["StatusMessage"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_disassociate_resolver_rule():
"""Test disassociate_resolver_rule API calls with a bad ID."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -206,8 +200,7 @@ def test_route53resolver_bad_disassociate_resolver_rule():
) in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_get_resolver_rule_association():
"""Test good get_resolver_rule_association API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -229,7 +222,7 @@ def test_route53resolver_get_resolver_rule_association():
assert association["StatusMessage"] == created_association["StatusMessage"]
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_get_resolver_rule_association():
"""Test get_resolver_rule_association API calls with a bad ID."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -255,8 +248,7 @@ def test_route53resolver_bad_get_resolver_rule_association():
assert f"ResolverRuleAssociation '{random_num}' does not Exist" in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_list_resolver_rule_associations():
"""Test good list_resolver_rule_associations API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -297,8 +289,7 @@ def test_route53resolver_list_resolver_rule_associations():
assert association["Name"].startswith(f"A{idx + 1}")
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_list_resolver_rule_associations_filters():
"""Test good list_resolver_rule_associations API calls that use filters."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -364,7 +355,7 @@ def test_route53resolver_list_resolver_rule_associations_filters():
assert len(response["ResolverRuleAssociations"]) == 0
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_list_resolver_rule_associations_filters():
"""Test bad list_resolver_rule_associations API calls that use filters."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -391,8 +382,7 @@ def test_route53resolver_bad_list_resolver_rule_associations_filters():
assert "The filter 'VpcId' is invalid" in err["Message"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_list_resolver_rule_associations():
"""Test bad list_resolver_rule_associations API calls."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
diff --git a/tests/test_route53resolver/test_route53resolver_tags.py b/tests/test_route53resolver/test_route53resolver_tags.py
index d42def924..cd888d55d 100644
--- a/tests/test_route53resolver/test_route53resolver_tags.py
+++ b/tests/test_route53resolver/test_route53resolver_tags.py
@@ -1,17 +1,14 @@
-"""Route53Resolver-related unit tests focusing on tag-related functionality."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_route53resolver
-from moto.ec2 import mock_ec2
+from moto import mock_aws
from moto.route53resolver.models import ResolverEndpoint
from .test_route53resolver_endpoint import TEST_REGION, create_test_endpoint
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_tag_resource():
"""Test the addition of tags to a resource."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -61,8 +58,7 @@ def test_route53resolver_tag_resource():
assert result["Tags"] == added_tags
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_untag_resource():
"""Test the removal of tags to a resource."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -85,8 +81,7 @@ def test_route53resolver_untag_resource():
assert "NextToken" not in result
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_list_tags_for_resource():
"""Test ability to list all tags for a resource."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
@@ -119,8 +114,7 @@ def test_route53resolver_list_tags_for_resource():
assert result["NextToken"]
-@mock_ec2
-@mock_route53resolver
+@mock_aws
def test_route53resolver_bad_list_tags_for_resource():
"""Test ability to list all tags for a resource."""
client = boto3.client("route53resolver", region_name=TEST_REGION)
diff --git a/tests/test_s3/__init__.py b/tests/test_s3/__init__.py
index fe81a5438..e7f48e059 100644
--- a/tests/test_s3/__init__.py
+++ b/tests/test_s3/__init__.py
@@ -4,7 +4,7 @@ from uuid import uuid4
import boto3
-from moto import mock_s3, mock_s3control, mock_sts
+from moto import mock_aws
from moto.s3.responses import DEFAULT_REGION_NAME
@@ -14,7 +14,7 @@ def s3_aws_verified(func):
Can be run against AWS at any time by setting:
MOTO_TEST_ALLOW_AWS_REQUEST=true
- If this environment variable is not set, the function runs in a `mock_s3` context.
+ If this environment variable is not set, the function runs in a `mock_aws` context.
This decorator will:
- Create a bucket
@@ -24,7 +24,6 @@ def s3_aws_verified(func):
@wraps(func)
def pagination_wrapper():
- client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = str(uuid4())
allow_aws_request = (
@@ -33,13 +32,15 @@ def s3_aws_verified(func):
if allow_aws_request:
print(f"Test {func} will create {bucket_name}")
- resp = create_bucket_and_test(bucket_name, client)
+ resp = create_bucket_and_test(bucket_name)
else:
- with mock_s3(), mock_sts(), mock_s3control():
- resp = create_bucket_and_test(bucket_name, client)
+ with mock_aws():
+ resp = create_bucket_and_test(bucket_name)
return resp
- def create_bucket_and_test(bucket_name, client):
+ def create_bucket_and_test(bucket_name):
+ client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
+
client.create_bucket(Bucket=bucket_name)
client.put_bucket_tagging(
Bucket=bucket_name,
diff --git a/tests/test_s3/test_s3.py b/tests/test_s3/test_s3.py
index 6b6312355..550dd720f 100644
--- a/tests/test_s3/test_s3.py
+++ b/tests/test_s3/test_s3.py
@@ -18,7 +18,7 @@ from botocore.handlers import disable_signing
from freezegun import freeze_time
import moto.s3.models as s3model
-from moto import mock_config, mock_s3, moto_proxy, settings
+from moto import mock_aws, moto_proxy, settings
from moto.core.utils import utcnow
from moto.moto_api import state_manager
from moto.s3.responses import DEFAULT_REGION_NAME
@@ -40,7 +40,7 @@ class MyModel:
)
-@mock_s3
+@mock_aws
def test_keys_are_pickleable():
"""Keys must be pickleable due to boto3 implementation details."""
key = s3model.FakeKey("name", b"data!", account_id=DEFAULT_ACCOUNT_ID)
@@ -52,7 +52,7 @@ def test_keys_are_pickleable():
assert loaded.account_id == key.account_id
-@mock_s3
+@mock_aws
def test_my_model_save():
# Create Bucket so that test can run
conn = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
@@ -67,7 +67,7 @@ def test_my_model_save():
assert body == "is awesome"
-@mock_s3
+@mock_aws
def test_object_metadata():
"""Metadata keys can contain certain special characters like dash and dot"""
# Create Bucket so that test can run
@@ -85,7 +85,7 @@ def test_object_metadata():
assert meta == metadata
-@mock_s3
+@mock_aws
def test_resource_get_object_returns_etag():
conn = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
conn.create_bucket(Bucket="mybucket")
@@ -98,7 +98,7 @@ def test_resource_get_object_returns_etag():
)
-@mock_s3
+@mock_aws
def test_key_save_to_missing_bucket():
s3_resource = boto3.resource("s3")
@@ -111,7 +111,7 @@ def test_key_save_to_missing_bucket():
)
-@mock_s3
+@mock_aws
def test_missing_key_request():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Only test status code in DecoratorMode")
@@ -122,7 +122,7 @@ def test_missing_key_request():
assert response.status_code == 404
-@mock_s3
+@mock_aws
def test_empty_key():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -136,7 +136,7 @@ def test_empty_key():
assert resp["Body"].read() == b""
-@mock_s3
+@mock_aws
def test_key_name_encoding_in_listing():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -162,7 +162,7 @@ def test_key_name_encoding_in_listing():
assert key_received == name
-@mock_s3
+@mock_aws
def test_empty_key_set_on_existing_key():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -182,7 +182,7 @@ def test_empty_key_set_on_existing_key():
assert resp["Body"].read() == b""
-@mock_s3
+@mock_aws
def test_large_key_save():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -195,7 +195,7 @@ def test_large_key_save():
assert resp["Body"].read() == b"foobar" * 100000
-@mock_s3
+@mock_aws
def test_set_metadata():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -209,7 +209,7 @@ def test_set_metadata():
@freeze_time("2012-01-01 12:00:00")
-@mock_s3
+@mock_aws
def test_last_modified():
# See https://github.com/boto/boto/issues/466
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
@@ -230,7 +230,7 @@ def test_last_modified():
assert as_header == "Sun, 01 Jan 2012 12:00:00 GMT"
-@mock_s3
+@mock_aws
def test_missing_bucket():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
with pytest.raises(ClientError) as ex:
@@ -244,7 +244,7 @@ def test_missing_bucket():
assert ex.value.response["Error"]["Message"] == "Not Found"
-@mock_s3
+@mock_aws
def test_create_existing_bucket():
"""Creating a bucket that already exists should raise an Error."""
client = boto3.client("s3", region_name="us-west-2")
@@ -261,7 +261,7 @@ def test_create_existing_bucket():
)
-@mock_s3
+@mock_aws
def test_create_existing_bucket_in_us_east_1():
"""Creating a bucket that already exists in us-east-1 returns the bucket.
@@ -276,7 +276,7 @@ def test_create_existing_bucket_in_us_east_1():
client.create_bucket(Bucket="foobar")
-@mock_s3
+@mock_aws
def test_bucket_deletion():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -305,7 +305,7 @@ def test_bucket_deletion():
)
-@mock_s3
+@mock_aws
def test_get_all_buckets():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
client.create_bucket(Bucket="foobar")
@@ -314,7 +314,7 @@ def test_get_all_buckets():
assert len(client.list_buckets()["Buckets"]) == 2
-@mock_s3
+@mock_aws
def test_post_to_bucket():
if not settings.TEST_DECORATOR_MODE:
# ServerMode does not allow unauthorized requests
@@ -331,7 +331,7 @@ def test_post_to_bucket():
assert resp["Body"].read() == b"nothing"
-@mock_s3
+@mock_aws
def test_post_with_metadata_to_bucket():
if not settings.TEST_DECORATOR_MODE:
# ServerMode does not allow unauthorized requests
@@ -348,7 +348,7 @@ def test_post_with_metadata_to_bucket():
assert resp["Metadata"] == {"test": "metadata"}
-@mock_s3
+@mock_aws
def test_delete_versioned_objects():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket = "test"
@@ -405,7 +405,7 @@ def test_delete_versioned_objects():
assert delete_markers is None
-@mock_s3
+@mock_aws
def test_delete_missing_key():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket = s3_resource.Bucket("foobar")
@@ -435,7 +435,7 @@ def test_delete_missing_key():
assert {o.key for o in objects} == set(["key2", "key4"])
-@mock_s3
+@mock_aws
def test_delete_empty_keys_list():
with pytest.raises(ClientError) as err:
boto3.client("s3").delete_objects(Bucket="foobar", Delete={"Objects": []})
@@ -443,7 +443,7 @@ def test_delete_empty_keys_list():
@pytest.mark.parametrize("name", ["firstname.lastname", "with-dash"])
-@mock_s3
+@mock_aws
def test_bucket_name_with_special_chars(name):
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -459,7 +459,7 @@ def test_bucket_name_with_special_chars(name):
@pytest.mark.parametrize(
"key", ["normal", "test_list_keys_2/x?y", "/the-key-unîcode/test"]
)
-@mock_s3
+@mock_aws
def test_key_with_special_characters(key):
if settings.test_proxy_mode():
raise SkipTest("Keys starting with a / don't work well in ProxyMode")
@@ -477,7 +477,7 @@ def test_key_with_special_characters(key):
assert resp["Body"].read() == b"value"
-@mock_s3
+@mock_aws
def test_bucket_key_listing_order():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "test_bucket"
@@ -517,7 +517,7 @@ def test_bucket_key_listing_order():
assert keys == []
-@mock_s3
+@mock_aws
def test_key_with_reduced_redundancy():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "test_bucket"
@@ -534,7 +534,7 @@ def test_key_with_reduced_redundancy():
@freeze_time("2012-01-01 12:00:00")
-@mock_s3
+@mock_aws
def test_restore_key():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket = s3_resource.Bucket("foobar")
@@ -561,7 +561,7 @@ def test_restore_key():
@freeze_time("2012-01-01 12:00:00")
-@mock_s3
+@mock_aws
def test_restore_key_transition():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Can't set transition directly in ServerMode")
@@ -592,7 +592,7 @@ def test_restore_key_transition():
state_manager.unset_transition(model_name="s3::keyrestore")
-@mock_s3
+@mock_aws
def test_cannot_restore_standard_class_object():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket = s3_resource.Bucket("foobar")
@@ -610,7 +610,7 @@ def test_cannot_restore_standard_class_object():
)
-@mock_s3
+@mock_aws
def test_get_versioning_status():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket = s3_resource.Bucket("foobar")
@@ -626,7 +626,7 @@ def test_get_versioning_status():
assert version_info.status == "Suspended"
-@mock_s3
+@mock_aws
def test_key_version():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -646,7 +646,49 @@ def test_key_version():
assert key["VersionId"] == versions[-1]
-@mock_s3
+@mock_aws
+def test_list_versions():
+ s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
+ client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
+ bucket = s3_resource.Bucket("foobar")
+ bucket.create()
+ bucket.Versioning().enable()
+
+ key_versions = []
+
+ key = bucket.put_object(Key="the-key", Body=b"Version 1")
+ key_versions.append(key.version_id)
+ key = bucket.put_object(Key="the-key", Body=b"Version 2")
+ key_versions.append(key.version_id)
+ assert len(key_versions) == 2
+
+ versions = client.list_object_versions(Bucket="foobar")["Versions"]
+ assert len(versions) == 2
+
+ assert versions[0]["Key"] == "the-key"
+ assert versions[0]["VersionId"] == key_versions[1]
+ resp = client.get_object(Bucket="foobar", Key="the-key")
+ assert resp["Body"].read() == b"Version 2"
+ resp = client.get_object(
+ Bucket="foobar", Key="the-key", VersionId=versions[0]["VersionId"]
+ )
+ assert resp["Body"].read() == b"Version 2"
+
+ assert versions[1]["Key"] == "the-key"
+ assert versions[1]["VersionId"] == key_versions[0]
+ resp = client.get_object(
+ Bucket="foobar", Key="the-key", VersionId=versions[1]["VersionId"]
+ )
+ assert resp["Body"].read() == b"Version 1"
+
+ bucket.put_object(Key="the2-key", Body=b"Version 1")
+
+ assert len(list(bucket.objects.all())) == 2
+ versions = client.list_object_versions(Bucket="foobar", Prefix="the2")["Versions"]
+ assert len(versions) == 1
+
+
+@mock_aws
def test_acl_setting():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -669,7 +711,7 @@ def test_acl_setting():
} in grants
-@mock_s3
+@mock_aws
def test_acl_setting_via_headers():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -691,7 +733,7 @@ def test_acl_setting_via_headers():
} in grants
-@mock_s3
+@mock_aws
def test_acl_switching():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -712,7 +754,7 @@ def test_acl_switching():
} not in grants
-@mock_s3
+@mock_aws
def test_acl_switching_nonexistent_key():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -723,7 +765,7 @@ def test_acl_switching_nonexistent_key():
assert exc.value.response["Error"]["Code"] == "NoSuchKey"
-@mock_s3
+@mock_aws
def test_streaming_upload_from_file_to_presigned_url():
s3_resource = boto3.resource("s3", region_name="us-east-1")
bucket = s3_resource.Bucket("test-bucket")
@@ -742,7 +784,7 @@ def test_streaming_upload_from_file_to_presigned_url():
assert response.status_code == 200
-@mock_s3
+@mock_aws
def test_upload_from_file_to_presigned_url():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -768,7 +810,7 @@ def test_upload_from_file_to_presigned_url():
os.remove("text.txt")
-@mock_s3
+@mock_aws
def test_upload_file_with_checksum_algorithm():
random_bytes = (
b"\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00"
@@ -789,7 +831,7 @@ def test_upload_file_with_checksum_algorithm():
assert random_bytes == actual_content
-@mock_s3
+@mock_aws
def test_put_chunked_with_v4_signature_in_body():
bucket_name = "mybucket"
file_name = "file"
@@ -833,7 +875,7 @@ def test_put_chunked_with_v4_signature_in_body():
assert etag == boto_etag
-@mock_s3
+@mock_aws
def test_s3_object_in_private_bucket():
s3_resource = boto3.resource("s3")
bucket = s3_resource.Bucket("test-bucket")
@@ -858,7 +900,7 @@ def test_s3_object_in_private_bucket():
assert contents == b"ABCD"
-@mock_s3
+@mock_aws
def test_unicode_key():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket = s3_resource.Bucket("mybucket")
@@ -872,7 +914,7 @@ def test_unicode_key():
assert fetched_key.get()["Body"].read().decode("utf-8") == "Hello world!"
-@mock_s3
+@mock_aws
def test_unicode_value():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket = s3_resource.Bucket("mybucket")
@@ -884,7 +926,7 @@ def test_unicode_value():
assert key.get()["Body"].read().decode("utf-8") == "こんにちは.jpg"
-@mock_s3
+@mock_aws
def test_setting_content_encoding():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket = s3_resource.Bucket("mybucket")
@@ -896,7 +938,7 @@ def test_setting_content_encoding():
assert key.content_encoding == "gzip"
-@mock_s3
+@mock_aws
def test_bucket_location_default():
cli = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -905,7 +947,7 @@ def test_bucket_location_default():
assert cli.get_bucket_location(Bucket=bucket_name)["LocationConstraint"] is None
-@mock_s3
+@mock_aws
def test_bucket_location_nondefault():
cli = boto3.client("s3", region_name="eu-central-1")
bucket_name = "mybucket"
@@ -920,7 +962,7 @@ def test_bucket_location_nondefault():
)
-@mock_s3
+@mock_aws
def test_s3_location_should_error_outside_useast1():
s3_client = boto3.client("s3", region_name="eu-west-1")
@@ -934,7 +976,7 @@ def test_s3_location_should_error_outside_useast1():
)
-@mock_s3
+@mock_aws
def test_ranged_get():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket = s3_resource.Bucket("mybucket")
@@ -1020,7 +1062,7 @@ def test_ranged_get():
assert ex.value.response["Error"]["RangeRequested"] == "bytes=101-200"
-@mock_s3
+@mock_aws
def test_policy():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -1065,7 +1107,7 @@ def test_policy():
assert ex.value.response["Error"]["Code"] == "NoSuchBucketPolicy"
-@mock_s3
+@mock_aws
def test_website_configuration_xml():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -1097,7 +1139,7 @@ def test_website_configuration_xml():
assert "ErrorDocument" not in site_info
-@mock_s3
+@mock_aws
def test_client_get_object_returns_etag():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1106,7 +1148,7 @@ def test_client_get_object_returns_etag():
assert resp["ETag"] == '"d32bda93738f7e03adb22e66c90fbc04"'
-@mock_s3
+@mock_aws
def test_website_redirect_location():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1123,7 +1165,7 @@ def test_website_redirect_location():
assert resp["WebsiteRedirectLocation"] == url
-@mock_s3
+@mock_aws
def test_delimiter_optional_in_response():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1134,7 +1176,7 @@ def test_delimiter_optional_in_response():
assert resp.get("Delimiter") == "/"
-@mock_s3
+@mock_aws
def test_list_objects_with_pagesize_0():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1145,7 +1187,7 @@ def test_list_objects_with_pagesize_0():
assert "Contents" not in resp
-@mock_s3
+@mock_aws
def test_list_objects_truncated_response():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1191,7 +1233,7 @@ def test_list_objects_truncated_response():
assert "NextMarker" not in resp
-@mock_s3
+@mock_aws
def test_list_keys_xml_escaped():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1211,7 +1253,7 @@ def test_list_keys_xml_escaped():
assert "Owner" not in resp["Contents"][0]
-@mock_s3
+@mock_aws
def test_list_objects_v2_common_prefix_pagination():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1240,7 +1282,7 @@ def test_list_objects_v2_common_prefix_pagination():
assert prefixes == [k[: k.rindex("/") + 1] for k in keys]
-@mock_s3
+@mock_aws
def test_list_objects_v2_common_invalid_continuation_token():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1266,7 +1308,7 @@ def test_list_objects_v2_common_invalid_continuation_token():
)
-@mock_s3
+@mock_aws
def test_list_objects_v2_truncated_response():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1323,7 +1365,7 @@ def test_list_objects_v2_truncated_response():
assert "NextContinuationToken" not in resp
-@mock_s3
+@mock_aws
def test_list_objects_v2_truncated_response_start_after():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1365,7 +1407,7 @@ def test_list_objects_v2_truncated_response_start_after():
assert "Owner" not in listed_object
-@mock_s3
+@mock_aws
def test_list_objects_v2_fetch_owner():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1379,7 +1421,7 @@ def test_list_objects_v2_fetch_owner():
assert len(owner.keys()) == 2
-@mock_s3
+@mock_aws
def test_list_objects_v2_truncate_combined_keys_and_folders():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1411,7 +1453,7 @@ def test_list_objects_v2_truncate_combined_keys_and_folders():
assert resp["CommonPrefixes"][0]["Prefix"] == "3/"
-@mock_s3
+@mock_aws
def test_list_objects_v2_checksum_algo():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -1441,7 +1483,7 @@ def test_list_objects_v2_checksum_algo():
assert resp[2]["ChecksumAlgorithm"] == ["SHA256"]
-@mock_s3
+@mock_aws
def test_bucket_create():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
s3_resource.create_bucket(Bucket="blah")
@@ -1454,7 +1496,7 @@ def test_bucket_create():
)
-@mock_s3
+@mock_aws
def test_bucket_create_force_us_east_1():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
with pytest.raises(ClientError) as exc:
@@ -1465,7 +1507,7 @@ def test_bucket_create_force_us_east_1():
assert exc.value.response["Error"]["Code"] == "InvalidLocationConstraint"
-@mock_s3
+@mock_aws
def test_bucket_create_eu_central():
s3_resource = boto3.resource("s3", region_name="eu-central-1")
s3_resource.create_bucket(
@@ -1480,7 +1522,7 @@ def test_bucket_create_eu_central():
)
-@mock_s3
+@mock_aws
def test_bucket_create_empty_bucket_configuration_should_return_malformed_xml_error():
s3_resource = boto3.resource("s3", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -1489,7 +1531,7 @@ def test_bucket_create_empty_bucket_configuration_should_return_malformed_xml_er
assert exc.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_s3
+@mock_aws
def test_head_object():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
s3_resource.create_bucket(Bucket="blah")
@@ -1507,7 +1549,7 @@ def test_head_object():
assert exc.value.response["Error"]["Code"] == "404"
-@mock_s3
+@mock_aws
def test_get_object():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
s3_resource.create_bucket(Bucket="blah")
@@ -1524,7 +1566,7 @@ def test_get_object():
assert exc.value.response["Error"]["Code"] == "NoSuchKey"
-@mock_s3
+@mock_aws
def test_s3_content_type():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
my_bucket = s3_resource.Bucket("my-cool-bucket")
@@ -1540,7 +1582,7 @@ def test_s3_content_type():
assert s3_resource.Object(my_bucket.name, s3_path).content_type == content_type
-@mock_s3
+@mock_aws
def test_get_missing_object_with_part_number():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
s3_resource.create_bucket(Bucket="blah")
@@ -1553,7 +1595,7 @@ def test_get_missing_object_with_part_number():
assert exc.value.response["Error"]["Code"] == "404"
-@mock_s3
+@mock_aws
def test_head_object_with_versioning():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
bucket = s3_resource.create_bucket(Bucket="blah")
@@ -1583,7 +1625,7 @@ def test_head_object_with_versioning():
assert old_head_object["VersionId"] != head_object["VersionId"]
-@mock_s3
+@mock_aws
def test_deleted_versionings_list():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -1600,7 +1642,7 @@ def test_deleted_versionings_list():
assert len(listed["Contents"]) == 1
-@mock_s3
+@mock_aws
def test_delete_objects_for_specific_version_id():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
client.create_bucket(Bucket="blah")
@@ -1623,7 +1665,7 @@ def test_delete_objects_for_specific_version_id():
assert len(listed["Contents"]) == 1
-@mock_s3
+@mock_aws
def test_delete_versioned_bucket():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -1752,7 +1794,7 @@ def test_delete_versioned_bucket_returns_metadata(name=None):
assert del_mrk4["VersionId"] == del_mrk2["VersionId"]
-@mock_s3
+@mock_aws
def test_get_object_if_modified_since_refresh():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "blah"
@@ -1774,7 +1816,7 @@ def test_get_object_if_modified_since_refresh():
assert err_value.response["Error"] == {"Code": "304", "Message": "Not Modified"}
-@mock_s3
+@mock_aws
def test_get_object_if_modified_since():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "blah"
@@ -1794,7 +1836,7 @@ def test_get_object_if_modified_since():
assert err_value.response["Error"] == {"Code": "304", "Message": "Not Modified"}
-@mock_s3
+@mock_aws
def test_get_object_if_unmodified_since():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "blah"
@@ -1815,7 +1857,7 @@ def test_get_object_if_unmodified_since():
assert err_value.response["Error"]["Condition"] == "If-Unmodified-Since"
-@mock_s3
+@mock_aws
def test_get_object_if_match():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "blah"
@@ -1832,7 +1874,7 @@ def test_get_object_if_match():
assert err_value.response["Error"]["Condition"] == "If-Match"
-@mock_s3
+@mock_aws
def test_get_object_if_none_match():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "blah"
@@ -1848,7 +1890,7 @@ def test_get_object_if_none_match():
assert err_value.response["Error"] == {"Code": "304", "Message": "Not Modified"}
-@mock_s3
+@mock_aws
def test_head_object_if_modified_since():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "blah"
@@ -1868,7 +1910,7 @@ def test_head_object_if_modified_since():
assert err_value.response["Error"] == {"Code": "304", "Message": "Not Modified"}
-@mock_s3
+@mock_aws
def test_head_object_if_modified_since_refresh():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "blah"
@@ -1890,7 +1932,7 @@ def test_head_object_if_modified_since_refresh():
assert err_value.response["Error"] == {"Code": "304", "Message": "Not Modified"}
-@mock_s3
+@mock_aws
def test_head_object_if_unmodified_since():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "blah"
@@ -1913,7 +1955,7 @@ def test_head_object_if_unmodified_since():
}
-@mock_s3
+@mock_aws
def test_head_object_if_match():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "blah"
@@ -1932,7 +1974,7 @@ def test_head_object_if_match():
}
-@mock_s3
+@mock_aws
def test_head_object_if_none_match():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "blah"
@@ -1948,7 +1990,7 @@ def test_head_object_if_none_match():
assert err_value.response["Error"] == {"Code": "304", "Message": "Not Modified"}
-@mock_s3
+@mock_aws
def test_put_bucket_cors():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -2010,7 +2052,7 @@ def test_put_bucket_cors():
assert err_value.response["Error"]["Code"] == "MalformedXML"
-@mock_s3
+@mock_aws
def test_get_bucket_cors():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -2081,7 +2123,7 @@ def test_delete_bucket_cors(bucket_name=None):
)
-@mock_s3
+@mock_aws
def test_put_bucket_notification():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="bucket")
@@ -2277,7 +2319,7 @@ def test_put_bucket_notification():
assert not result.get("LambdaFunctionConfigurations")
-@mock_s3
+@mock_aws
def test_put_bucket_notification_errors():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="bucket")
@@ -2340,7 +2382,7 @@ def test_put_bucket_notification_errors():
)
-@mock_s3
+@mock_aws
def test_delete_markers():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -2383,7 +2425,7 @@ def test_delete_markers():
assert oldest["Key"] == "key-with-versions-and-unicode-ó"
-@mock_s3
+@mock_aws
def test_multiple_delete_markers():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -2432,7 +2474,7 @@ def test_multiple_delete_markers():
assert oldest["Key"] == "key-with-versions-and-unicode-ó"
-@mock_s3
+@mock_aws
def test_get_stream_gzipped():
payload = b"this is some stuff here"
@@ -2472,7 +2514,7 @@ TEST_XML = """\
"""
-@mock_s3
+@mock_aws
def test_bucket_name_too_long():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
with pytest.raises(ClientError) as exc:
@@ -2480,7 +2522,7 @@ def test_bucket_name_too_long():
assert exc.value.response["Error"]["Code"] == "InvalidBucketName"
-@mock_s3
+@mock_aws
def test_bucket_name_too_short():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
with pytest.raises(ClientError) as exc:
@@ -2488,7 +2530,7 @@ def test_bucket_name_too_short():
assert exc.value.response["Error"]["Code"] == "InvalidBucketName"
-@mock_s3
+@mock_aws
def test_accelerated_none_when_unspecified():
bucket_name = "some_bucket"
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -2497,7 +2539,7 @@ def test_accelerated_none_when_unspecified():
assert "Status" not in resp
-@mock_s3
+@mock_aws
def test_can_enable_bucket_acceleration():
bucket_name = "some_bucket"
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -2511,7 +2553,7 @@ def test_can_enable_bucket_acceleration():
assert resp["Status"] == "Enabled"
-@mock_s3
+@mock_aws
def test_can_suspend_bucket_acceleration():
bucket_name = "some_bucket"
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -2528,7 +2570,7 @@ def test_can_suspend_bucket_acceleration():
assert resp["Status"] == "Suspended"
-@mock_s3
+@mock_aws
def test_suspending_acceleration_on_not_configured_bucket_does_nothing():
bucket_name = "some_bucket"
s3_client = boto3.client("s3")
@@ -2544,7 +2586,7 @@ def test_suspending_acceleration_on_not_configured_bucket_does_nothing():
assert "Status" not in resp
-@mock_s3
+@mock_aws
def test_accelerate_configuration_status_validation():
bucket_name = "some_bucket"
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -2556,7 +2598,7 @@ def test_accelerate_configuration_status_validation():
assert exc.value.response["Error"]["Code"] == "MalformedXML"
-@mock_s3
+@mock_aws
def test_accelerate_configuration_is_not_supported_when_bucket_name_has_dots():
bucket_name = "some.bucket.with.dots"
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -2580,12 +2622,12 @@ def store_and_read_back_a_key(key):
assert response["Body"].read() == body
-@mock_s3
+@mock_aws
def test_paths_with_leading_slashes_work():
store_and_read_back_a_key("/a-key")
-@mock_s3
+@mock_aws
def test_root_dir_with_empty_name_works():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Does not work in server mode due to error in Workzeug")
@@ -2593,7 +2635,7 @@ def test_root_dir_with_empty_name_works():
@pytest.mark.parametrize("bucket_name", ["mybucket", "my.bucket"])
-@mock_s3
+@mock_aws
def test_leading_slashes_not_removed(bucket_name):
"""Make sure that leading slashes are not removed internally."""
if settings.test_proxy_mode():
@@ -2619,7 +2661,7 @@ def test_leading_slashes_not_removed(bucket_name):
@pytest.mark.parametrize(
"key", ["foo/bar/baz", "foo", "foo/run_dt%3D2019-01-01%252012%253A30%253A00"]
)
-@mock_s3
+@mock_aws
def test_delete_objects_with_url_encoded_key(key):
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -2645,7 +2687,7 @@ def test_delete_objects_with_url_encoded_key(key):
assert_deleted()
-@mock_s3
+@mock_aws
def test_delete_objects_unknown_key():
bucket_name = "test-moto-issue-1581"
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -2661,8 +2703,7 @@ def test_delete_objects_unknown_key():
client.delete_bucket(Bucket=bucket_name)
-@mock_s3
-@mock_config
+@mock_aws
def test_public_access_block():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
client.create_bucket(Bucket="mybucket")
@@ -2754,7 +2795,7 @@ def test_public_access_block():
assert exc.value.response["Error"]["Code"] == "NoSuchPublicAccessBlockConfiguration"
-@mock_s3
+@mock_aws
def test_creating_presigned_post():
bucket = "presigned-test"
s3_client = boto3.client("s3", region_name="us-east-1")
@@ -2800,7 +2841,7 @@ def test_creating_presigned_post():
assert s3_client.get_object(Bucket=bucket, Key=real_key)["Body"].read() == fdata
-@mock_s3
+@mock_aws
def test_presigned_put_url_with_approved_headers():
bucket = str(uuid.uuid4())
key = "file.txt"
@@ -2858,7 +2899,7 @@ def test_presigned_put_url_with_approved_headers():
s3_client.delete_bucket(Bucket=bucket)
-@mock_s3
+@mock_aws
def test_presigned_put_url_with_custom_headers():
bucket = str(uuid.uuid4())
key = "file.txt"
@@ -2890,7 +2931,7 @@ def test_presigned_put_url_with_custom_headers():
s3_client.delete_bucket(Bucket=bucket)
-@mock_s3
+@mock_aws
def test_request_partial_content_should_contain_content_length():
bucket = "bucket"
object_key = "key"
@@ -2903,7 +2944,7 @@ def test_request_partial_content_should_contain_content_length():
assert response["ContentLength"] == 9
-@mock_s3
+@mock_aws
def test_request_partial_content_should_contain_actual_content_length():
bucket = "bucket"
object_key = "key"
@@ -2924,7 +2965,7 @@ def test_request_partial_content_should_contain_actual_content_length():
assert exc.response["Error"]["RangeRequested"] == requested_range
-@mock_s3
+@mock_aws
def test_get_unknown_version_should_throw_specific_error():
bucket_name = "my_bucket"
object_key = "hello.txt"
@@ -2943,7 +2984,7 @@ def test_get_unknown_version_should_throw_specific_error():
)
-@mock_s3
+@mock_aws
def test_request_partial_content_without_specifying_range_should_return_full_object():
bucket = "bucket"
object_key = "key"
@@ -2956,7 +2997,7 @@ def test_request_partial_content_without_specifying_range_should_return_full_obj
assert response["ContentLength"] == 30
-@mock_s3
+@mock_aws
def test_object_headers():
bucket = "my-bucket"
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -2984,7 +3025,7 @@ def test_object_headers():
if settings.TEST_SERVER_MODE:
- @mock_s3
+ @mock_aws
def test_upload_data_without_content_type():
bucket = "mybucket"
s3_client = boto3.client("s3")
@@ -2998,7 +3039,7 @@ if settings.TEST_SERVER_MODE:
assert data == data_input
-@mock_s3
+@mock_aws
@pytest.mark.parametrize(
"prefix", ["file", "file+else", "file&another", "file another"]
)
@@ -3019,7 +3060,7 @@ def test_get_object_versions_with_prefix(prefix):
assert versions["Prefix"] == prefix
-@mock_s3
+@mock_aws
def test_create_bucket_duplicate():
bucket_name = "same-bucket-test-1371"
alternate_region = "eu-north-1"
@@ -3090,7 +3131,7 @@ def test_create_bucket_duplicate():
assert err["BucketName"] == bucket_name
-@mock_s3
+@mock_aws
def test_delete_objects_with_empty_keyname():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
@@ -3142,7 +3183,7 @@ def test_delete_objects_percent_encoded(bucket_name=None):
assert "Contents" not in client.list_objects(Bucket=bucket_name)
-@mock_s3
+@mock_aws
def test_head_object_should_return_default_content_type():
s3_resource = boto3.resource("s3", region_name="us-east-1")
s3_resource.create_bucket(Bucket="testbucket")
@@ -3163,7 +3204,7 @@ def test_head_object_should_return_default_content_type():
)
-@mock_s3
+@mock_aws
def test_request_partial_content_should_contain_all_metadata():
# github.com/getmoto/moto/issues/4203
bucket = "bucket"
@@ -3184,7 +3225,7 @@ def test_request_partial_content_should_contain_all_metadata():
assert response["ContentRange"] == f"bytes {query_range}/{len(body)}"
-@mock_s3
+@mock_aws
def test_head_versioned_key_in_not_versioned_bucket():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
client.create_bucket(Bucket="simple-bucked")
@@ -3198,7 +3239,7 @@ def test_head_versioned_key_in_not_versioned_bucket():
assert response["Error"]["Code"] == "400"
-@mock_s3
+@mock_aws
def test_prefix_encoding():
bucket_name = "encoding-bucket"
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -3221,7 +3262,7 @@ def test_prefix_encoding():
assert ["foo%2Fbar/", "foo/"] == folders
-@mock_s3
+@mock_aws
@pytest.mark.parametrize("algorithm", ["CRC32", "CRC32C", "SHA1", "SHA256"])
def test_checksum_response(algorithm):
bucket_name = "checksum-bucket"
diff --git a/tests/test_s3/test_s3_acl.py b/tests/test_s3/test_s3_acl.py
index 032b2de0e..1f6ecb180 100644
--- a/tests/test_s3/test_s3_acl.py
+++ b/tests/test_s3/test_s3_acl.py
@@ -7,7 +7,7 @@ import requests
from botocore.exceptions import ClientError
from botocore.handlers import disable_signing
-from moto import mock_s3, settings
+from moto import mock_aws, settings
from .test_s3 import add_proxy_details
@@ -22,7 +22,7 @@ DEFAULT_REGION_NAME = "us-east-1"
)
@pytest.mark.parametrize("has_quotes", [True, False])
@pytest.mark.parametrize("readwrite", ["Read", "Write"])
-@mock_s3
+@mock_aws
def test_put_object_acl_using_grant(readwrite, type_key, value, has_quotes):
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -47,7 +47,7 @@ def test_put_object_acl_using_grant(readwrite, type_key, value, has_quotes):
assert grants[0]["Permission"] == readwrite.upper()
-@mock_s3
+@mock_aws
def test_acl_switching_boto3():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -68,7 +68,7 @@ def test_acl_switching_boto3():
} not in grants
-@mock_s3
+@mock_aws
def test_acl_switching_nonexistent_key():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="mybucket")
@@ -79,7 +79,7 @@ def test_acl_switching_nonexistent_key():
assert exc.value.response["Error"]["Code"] == "NoSuchKey"
-@mock_s3
+@mock_aws
def test_s3_object_in_public_bucket():
s3_resource = boto3.resource("s3")
bucket = s3_resource.Bucket("test-bucket")
@@ -105,7 +105,7 @@ def test_s3_object_in_public_bucket():
assert exc.value.response["Error"]["Code"] == "403"
-@mock_s3
+@mock_aws
def test_s3_object_in_public_bucket_using_multiple_presigned_urls():
s3_resource = boto3.resource("s3")
bucket = s3_resource.Bucket("test-bucket")
@@ -126,7 +126,7 @@ def test_s3_object_in_public_bucket_using_multiple_presigned_urls():
assert response.status_code == 200, f"Failed on req number {i}"
-@mock_s3
+@mock_aws
def test_s3_object_in_private_bucket():
s3_resource = boto3.resource("s3")
bucket = s3_resource.Bucket("test-bucket")
@@ -151,7 +151,7 @@ def test_s3_object_in_private_bucket():
assert contents == b"ABCD"
-@mock_s3
+@mock_aws
def test_put_bucket_acl_body():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="bucket")
@@ -251,7 +251,7 @@ def test_put_bucket_acl_body():
assert not result.get("Grants")
-@mock_s3
+@mock_aws
def test_object_acl_with_presigned_post():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -286,7 +286,7 @@ def test_object_acl_with_presigned_post():
os.remove("text.txt")
-@mock_s3
+@mock_aws
def test_acl_setting_boto3():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -309,7 +309,7 @@ def test_acl_setting_boto3():
} in grants
-@mock_s3
+@mock_aws
def test_acl_setting_via_headers_boto3():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -331,7 +331,7 @@ def test_acl_setting_via_headers_boto3():
} in grants
-@mock_s3
+@mock_aws
def test_raise_exception_for_grant_and_acl():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
diff --git a/tests/test_s3/test_s3_auth.py b/tests/test_s3/test_s3_auth.py
index 338f4e6e0..e552da995 100644
--- a/tests/test_s3/test_s3_auth.py
+++ b/tests/test_s3/test_s3_auth.py
@@ -5,13 +5,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_iam, mock_s3, mock_sts, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core import set_initial_no_auth_action_count
-from moto.s3.responses import DEFAULT_REGION_NAME
+
+DEFAULT_REGION_NAME = "us-east-1"
-@mock_s3
+@mock_aws
@set_initial_no_auth_action_count(0)
def test_load_unexisting_object_without_auth_should_return_403():
if not settings.TEST_DECORATOR_MODE:
@@ -31,7 +32,7 @@ def test_load_unexisting_object_without_auth_should_return_403():
@set_initial_no_auth_action_count(4)
-@mock_s3
+@mock_aws
def test_head_bucket_with_correct_credentials():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Auth decorator does not work in server mode")
@@ -63,7 +64,7 @@ def test_head_bucket_with_correct_credentials():
@set_initial_no_auth_action_count(4)
-@mock_s3
+@mock_aws
def test_head_bucket_with_incorrect_credentials():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Auth decorator does not work in server mode")
@@ -104,7 +105,6 @@ def my_head_bucket(bucket, aws_access_key_id, aws_secret_access_key):
s3_client.head_bucket(Bucket=bucket)
-@mock_iam
def create_user_with_access_key_and_policy(user_name="test-user"):
"""
Should create a user with attached policy allowing read/write operations on S3.
@@ -128,8 +128,6 @@ def create_user_with_access_key_and_policy(user_name="test-user"):
return client.create_access_key(UserName=user_name)["AccessKey"]
-@mock_iam
-@mock_sts
def create_role_with_attached_policy_and_assume_it(
role_name,
trust_policy_document,
@@ -152,9 +150,7 @@ def create_role_with_attached_policy_and_assume_it(
@set_initial_no_auth_action_count(7)
-@mock_iam
-@mock_s3
-@mock_sts
+@mock_aws
def test_delete_objects_without_access_throws_custom_error():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Auth decorator does not work in server mode")
diff --git a/tests/test_s3/test_s3_classdecorator.py b/tests/test_s3/test_s3_classdecorator.py
index 6401091cd..77e134434 100644
--- a/tests/test_s3/test_s3_classdecorator.py
+++ b/tests/test_s3/test_s3_classdecorator.py
@@ -2,10 +2,10 @@ import unittest
import boto3
-from moto import mock_s3
+from moto import mock_aws
-@mock_s3
+@mock_aws
class ClassDecoratorTest(unittest.TestCase):
"""
https://github.com/getmoto/moto/issues/3535
diff --git a/tests/test_s3/test_s3_cloudformation.py b/tests/test_s3/test_s3_cloudformation.py
index 6a1f01490..d390adae6 100644
--- a/tests/test_s3/test_s3_cloudformation.py
+++ b/tests/test_s3/test_s3_cloudformation.py
@@ -3,11 +3,10 @@ import re
import boto3
-from moto import mock_cloudformation, mock_s3
+from moto import mock_aws
-@mock_s3
-@mock_cloudformation
+@mock_aws
def test_s3_bucket_cloudformation_basic():
s3_client = boto3.client("s3", region_name="us-east-1")
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -24,8 +23,7 @@ def test_s3_bucket_cloudformation_basic():
s3_client.head_bucket(Bucket=stack_description["Outputs"][0]["OutputValue"])
-@mock_s3
-@mock_cloudformation
+@mock_aws
def test_s3_bucket_cloudformation_with_properties():
s3_client = boto3.client("s3", region_name="us-east-1")
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -66,8 +64,7 @@ def test_s3_bucket_cloudformation_with_properties():
)
-@mock_s3
-@mock_cloudformation
+@mock_aws
def test_s3_bucket_cloudformation_update_no_interruption():
s3_client = boto3.client("s3", region_name="us-east-1")
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -115,8 +112,7 @@ def test_s3_bucket_cloudformation_update_no_interruption():
)
-@mock_s3
-@mock_cloudformation
+@mock_aws
def test_s3_bucket_cloudformation_update_replacement():
s3_client = boto3.client("s3", region_name="us-east-1")
cf_client = boto3.client("cloudformation", region_name="us-east-1")
@@ -147,8 +143,7 @@ def test_s3_bucket_cloudformation_update_replacement():
s3_client.head_bucket(Bucket=stack_description["Outputs"][0]["OutputValue"])
-@mock_s3
-@mock_cloudformation
+@mock_aws
def test_s3_bucket_cloudformation_outputs():
region_name = "us-east-1"
s3_client = boto3.client("s3", region_name=region_name)
diff --git a/tests/test_s3/test_s3_config.py b/tests/test_s3/test_s3_config.py
index c4c64d200..da40514bd 100644
--- a/tests/test_s3/test_s3_config.py
+++ b/tests/test_s3/test_s3_config.py
@@ -1,17 +1,23 @@
import json
+import unittest
import pytest
-from moto import mock_s3
+from moto import mock_aws, settings
from moto.core.exceptions import InvalidNextTokenException
from moto.s3.config import s3_config_query
from tests import DEFAULT_ACCOUNT_ID
-s3_config_query_backend = s3_config_query.backends[DEFAULT_ACCOUNT_ID]["global"]
+# Integration tests would use `boto3.client("config").list_discovered_resources`
+# We're testing the backend here directly, because it is much quicker
-@mock_s3
+@mock_aws
def test_s3_public_access_block_to_config_dict():
+ if not settings.TEST_DECORATOR_MODE:
+ raise unittest.SkipTest("Not using boto3 - no point in testing server-mode")
+ s3_config_query_backend = s3_config_query.backends[DEFAULT_ACCOUNT_ID]["global"]
+
# With 1 bucket in us-west-2:
s3_config_query_backend.create_bucket("bucket1", "us-west-2")
@@ -43,8 +49,12 @@ def test_s3_public_access_block_to_config_dict():
)
-@mock_s3
+@mock_aws
def test_list_config_discovered_resources():
+ if not settings.TEST_DECORATOR_MODE:
+ raise unittest.SkipTest("Not using boto3 - no point in testing server-mode")
+ s3_config_query_backend = s3_config_query.backends[DEFAULT_ACCOUNT_ID]["global"]
+
# Without any buckets:
assert s3_config_query.list_config_service_resources(
"global", "global", None, None, 100, None
@@ -138,8 +148,12 @@ def test_list_config_discovered_resources():
assert "The nextToken provided is invalid" in inte.value.message
-@mock_s3
+@mock_aws
def test_s3_lifecycle_config_dict():
+ if not settings.TEST_DECORATOR_MODE:
+ raise unittest.SkipTest("Not using boto3 - no point in testing server-mode")
+ s3_config_query_backend = s3_config_query.backends[DEFAULT_ACCOUNT_ID]["global"]
+
# With 1 bucket in us-west-2:
s3_config_query_backend.create_bucket("bucket1", "us-west-2")
@@ -278,8 +292,12 @@ def test_s3_lifecycle_config_dict():
}
-@mock_s3
+@mock_aws
def test_s3_notification_config_dict():
+ if not settings.TEST_DECORATOR_MODE:
+ raise unittest.SkipTest("Not using boto3 - no point in testing server-mode")
+ s3_config_query_backend = s3_config_query.backends[DEFAULT_ACCOUNT_ID]["global"]
+
# With 1 bucket in us-west-2:
s3_config_query_backend.create_bucket("bucket1", "us-west-2")
@@ -375,8 +393,12 @@ def test_s3_notification_config_dict():
}
-@mock_s3
+@mock_aws
def test_s3_acl_to_config_dict():
+ if not settings.TEST_DECORATOR_MODE:
+ raise unittest.SkipTest("Not using boto3 - no point in testing server-mode")
+ s3_config_query_backend = s3_config_query.backends[DEFAULT_ACCOUNT_ID]["global"]
+
from moto.s3.models import OWNER, FakeAcl, FakeGrant, FakeGrantee
# With 1 bucket in us-west-2:
@@ -446,8 +468,12 @@ def test_s3_acl_to_config_dict():
}
-@mock_s3
+@mock_aws
def test_s3_config_dict():
+ if not settings.TEST_DECORATOR_MODE:
+ raise unittest.SkipTest("Not using boto3 - no point in testing server-mode")
+ s3_config_query_backend = s3_config_query.backends[DEFAULT_ACCOUNT_ID]["global"]
+
from moto.s3.models import OWNER, FakeAcl, FakeGrant, FakeGrantee
# Without any buckets:
diff --git a/tests/test_s3/test_s3_copyobject.py b/tests/test_s3/test_s3_copyobject.py
index 90bfde46f..527cda3dd 100644
--- a/tests/test_s3/test_s3_copyobject.py
+++ b/tests/test_s3/test_s3_copyobject.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.client import ClientError
-from moto import mock_kms, mock_s3
+from moto import mock_aws
from moto.s3.responses import DEFAULT_REGION_NAME
from . import s3_aws_verified
@@ -19,7 +19,7 @@ from . import s3_aws_verified
"key-with%2Fembedded%2Furl%2Fencoding",
],
)
-@mock_s3
+@mock_aws
def test_copy_key_boto3(key_name):
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -122,7 +122,7 @@ def test_copy_key_boto3_with_args__using_multipart(bucket=None):
assert obj["WebsiteRedirectLocation"] == "http://getmoto.org/"
-@mock_s3
+@mock_aws
def test_copy_key_with_version_boto3():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -149,7 +149,7 @@ def test_copy_key_with_version_boto3():
assert resp["Body"].read() == b"some value"
-@mock_s3
+@mock_aws
def test_copy_object_with_bucketkeyenabled_returns_the_value():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -185,7 +185,7 @@ def test_copy_object_with_bucketkeyenabled_returns_the_value():
)
-@mock_s3
+@mock_aws
def test_copy_key_with_metadata():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -204,7 +204,7 @@ def test_copy_key_with_metadata():
assert resp["ETag"] == initial["ETag"]
-@mock_s3
+@mock_aws
def test_copy_key_replace_metadata():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -226,7 +226,7 @@ def test_copy_key_replace_metadata():
assert resp["ETag"] == initial["ETag"]
-@mock_s3
+@mock_aws
def test_copy_key_without_changes_should_error():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "my_bucket"
@@ -250,7 +250,7 @@ def test_copy_key_without_changes_should_error():
)
-@mock_s3
+@mock_aws
def test_copy_key_without_changes_should_not_error():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "my_bucket"
@@ -274,7 +274,7 @@ def test_copy_key_without_changes_should_not_error():
assert new_object["Metadata"] == {"some-key": "some-value"}
-@mock_s3
+@mock_aws
def test_copy_key_reduced_redundancy():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -295,7 +295,7 @@ def test_copy_key_reduced_redundancy():
assert keys["the-key"].storage_class == "STANDARD"
-@mock_s3
+@mock_aws
def test_copy_non_existing_file():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
src = "srcbucket"
@@ -314,7 +314,7 @@ def test_copy_non_existing_file():
assert err["Key"] == "foofoofoo"
-@mock_s3
+@mock_aws
def test_copy_object_with_versioning():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -378,7 +378,7 @@ def test_copy_object_with_versioning():
assert data == b"test2"
-@mock_s3
+@mock_aws
def test_copy_object_from_unversioned_to_versioned_bucket():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -402,7 +402,7 @@ def test_copy_object_from_unversioned_to_versioned_bucket():
assert obj2_version_new is not None
-@mock_s3
+@mock_aws
def test_copy_object_with_replacement_tagging():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
client.create_bucket(Bucket="mybucket")
@@ -443,8 +443,7 @@ def test_copy_object_with_replacement_tagging():
assert tags2 == [{"Key": "tag", "Value": "old"}]
-@mock_s3
-@mock_kms
+@mock_aws
def test_copy_object_with_kms_encryption():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
kms_client = boto3.client("kms", region_name=DEFAULT_REGION_NAME)
@@ -468,8 +467,7 @@ def test_copy_object_with_kms_encryption():
assert result["ServerSideEncryption"] == "aws:kms"
-@mock_s3
-@mock_kms
+@mock_aws
def test_copy_object_in_place_with_encryption():
kms_client = boto3.client("kms", region_name=DEFAULT_REGION_NAME)
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
@@ -529,7 +527,7 @@ def test_copy_object_in_place_with_encryption():
assert resp["ServerSideEncryption"] == "AES256"
-@mock_s3
+@mock_aws
def test_copy_object_in_place_with_storage_class():
"""Validate setting StorageClass allows a copy in place.
@@ -555,7 +553,7 @@ def test_copy_object_in_place_with_storage_class():
assert resp["StorageClass"] == "STANDARD"
-@mock_s3
+@mock_aws
def test_copy_object_does_not_copy_storage_class():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -576,7 +574,7 @@ def test_copy_object_does_not_copy_storage_class():
assert keys[dest_key].storage_class == "STANDARD"
-@mock_s3
+@mock_aws
def test_copy_object_does_not_copy_acl():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -607,7 +605,7 @@ def test_copy_object_does_not_copy_acl():
assert default_acl["Grants"] == dest_acl["Grants"]
-@mock_s3
+@mock_aws
def test_copy_object_in_place_with_metadata():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -644,7 +642,7 @@ def test_copy_object_in_place_with_metadata():
assert result["Metadata"] == {}
-@mock_s3
+@mock_aws
def test_copy_objet_legal_hold():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "testbucket"
@@ -676,7 +674,7 @@ def test_copy_objet_legal_hold():
assert "ObjectLockLegalHoldStatus" not in head_object
-@mock_s3
+@mock_aws
def test_s3_copy_object_lock():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "testbucket"
@@ -718,7 +716,7 @@ def test_s3_copy_object_lock():
assert "ObjectLockRetainUntilDate" not in head_object
-@mock_s3
+@mock_aws
def test_copy_object_in_place_website_redirect_location():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "testbucket"
@@ -749,7 +747,7 @@ def test_copy_object_in_place_website_redirect_location():
assert head_object["WebsiteRedirectLocation"] == "/test/direct"
-@mock_s3
+@mock_aws
def test_copy_object_in_place_with_bucket_encryption():
# If a bucket has encryption configured, it will allow copy in place per default
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -785,7 +783,7 @@ def test_copy_object_in_place_with_bucket_encryption():
assert response["ServerSideEncryption"] == "AES256"
-@mock_s3
+@mock_aws
@pytest.mark.parametrize(
"algorithm",
["CRC32", "SHA1", "SHA256"],
@@ -832,7 +830,7 @@ def test_copy_key_boto3_with_both_sha256_checksum(algorithm):
assert resp["CopyObjectResult"][checksum_key] == checksum_by_boto
-@mock_s3
+@mock_aws
@pytest.mark.parametrize(
"algorithm, checksum",
[
@@ -869,7 +867,7 @@ def test_copy_object_calculates_checksum(algorithm, checksum):
assert resp["CopyObjectResult"][checksum_key] == checksum
-@mock_s3
+@mock_aws
def test_copy_object_keeps_checksum():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
source_key = "source-key"
diff --git a/tests/test_s3/test_s3_cross_account.py b/tests/test_s3/test_s3_cross_account.py
index 78cc1e38c..7b3b8ba08 100644
--- a/tests/test_s3/test_s3_cross_account.py
+++ b/tests/test_s3/test_s3_cross_account.py
@@ -5,11 +5,11 @@ import boto3
import pytest
from botocore.client import ClientError
-from moto import mock_s3, settings
+from moto import mock_aws, settings
from moto.s3.responses import DEFAULT_REGION_NAME
-@mock_s3
+@mock_aws
def test_cross_account_region_access():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Multi-accounts env config only works serverside")
diff --git a/tests/test_s3/test_s3_custom_endpoint.py b/tests/test_s3/test_s3_custom_endpoint.py
index dc40edd51..e3384f873 100644
--- a/tests/test_s3/test_s3_custom_endpoint.py
+++ b/tests/test_s3/test_s3_custom_endpoint.py
@@ -5,7 +5,7 @@ from unittest.mock import patch
import boto3
import pytest
-from moto import mock_s3, settings
+from moto import mock_aws, settings
DEFAULT_REGION_NAME = "us-east-1"
CUSTOM_ENDPOINT = "https://s3.local.some-test-domain.de"
@@ -19,7 +19,7 @@ def test_create_and_list_buckets(url):
# Have to inline this, as the URL-param is not available as a context decorator
with patch.dict(os.environ, {"MOTO_S3_CUSTOM_ENDPOINTS": url}):
# Mock needs to be started after the environment variable is patched in
- with mock_s3():
+ with mock_aws():
bucket = "mybucket"
conn = boto3.resource(
"s3", endpoint_url=url, region_name=DEFAULT_REGION_NAME
@@ -41,7 +41,7 @@ def test_create_and_list_buckets_with_multiple_supported_endpoints(url):
{"MOTO_S3_CUSTOM_ENDPOINTS": f"{CUSTOM_ENDPOINT},{CUSTOM_ENDPOINT_2}"},
):
# Mock needs to be started after the environment variable is patched in
- with mock_s3():
+ with mock_aws():
bucket = "mybucket"
conn = boto3.resource(
"s3", endpoint_url=url, region_name=DEFAULT_REGION_NAME
@@ -54,12 +54,12 @@ def test_create_and_list_buckets_with_multiple_supported_endpoints(url):
@pytest.mark.parametrize("url", [CUSTOM_ENDPOINT, CUSTOM_ENDPOINT_2])
-@mock_s3
+@mock_aws
def test_put_and_get_object(url):
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Unable to set ENV VAR in ServerMode")
with patch.dict(os.environ, {"MOTO_S3_CUSTOM_ENDPOINTS": url}):
- with mock_s3():
+ with mock_aws():
bucket = "mybucket"
key = "file.txt"
contents = "file contents"
@@ -77,12 +77,12 @@ def test_put_and_get_object(url):
@pytest.mark.parametrize("url", [CUSTOM_ENDPOINT, CUSTOM_ENDPOINT_2])
-@mock_s3
+@mock_aws
def test_put_and_list_objects(url):
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Unable to set ENV VAR in ServerMode")
with patch.dict(os.environ, {"MOTO_S3_CUSTOM_ENDPOINTS": url}):
- with mock_s3():
+ with mock_aws():
bucket = "mybucket"
s3_client = boto3.client(
diff --git a/tests/test_s3/test_s3_encryption.py b/tests/test_s3/test_s3_encryption.py
index b0662f43c..d2e387a34 100644
--- a/tests/test_s3/test_s3_encryption.py
+++ b/tests/test_s3/test_s3_encryption.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_s3
+from moto import mock_aws
-@mock_s3
+@mock_aws
def test_encryption_on_new_bucket_fails():
conn = boto3.client("s3", region_name="us-east-1")
conn.create_bucket(Bucket="mybucket")
@@ -20,7 +20,7 @@ def test_encryption_on_new_bucket_fails():
assert err["BucketName"] == "mybucket"
-@mock_s3
+@mock_aws
def test_put_and_get_encryption():
# Create Bucket so that test can run
conn = boto3.client("s3", region_name="us-east-1")
@@ -48,7 +48,7 @@ def test_put_and_get_encryption():
assert resp["ServerSideEncryptionConfiguration"] == return_config
-@mock_s3
+@mock_aws
def test_delete_and_get_encryption():
# Create Bucket so that test can run
conn = boto3.client("s3", region_name="us-east-1")
@@ -77,7 +77,7 @@ def test_delete_and_get_encryption():
assert err["Code"] == "ServerSideEncryptionConfigurationNotFoundError"
-@mock_s3
+@mock_aws
def test_encryption_status_on_new_objects():
bucket_name = str(uuid4())
s3_client = boto3.client("s3", region_name="us-east-1")
@@ -103,7 +103,7 @@ def test_encryption_status_on_new_objects():
assert res["ServerSideEncryption"] == "AES256"
-@mock_s3
+@mock_aws
def test_encryption_status_on_copied_objects():
bucket_name = str(uuid4())
s3_client = boto3.client("s3", region_name="us-east-1")
@@ -128,7 +128,7 @@ def test_encryption_status_on_copied_objects():
assert res["ServerSideEncryption"] == "AES256"
-@mock_s3
+@mock_aws
def test_encryption_bucket_key_for_aes_not_returned():
bucket_name = str(uuid4())
s3_client = boto3.client("s3", region_name="us-east-1")
diff --git a/tests/test_s3/test_s3_file_handles.py b/tests/test_s3/test_s3_file_handles.py
index c738ff1e5..e5a6796ed 100644
--- a/tests/test_s3/test_s3_file_handles.py
+++ b/tests/test_s3/test_s3_file_handles.py
@@ -6,7 +6,7 @@ from unittest import SkipTest, TestCase
import boto3
-from moto import mock_s3, settings
+from moto import mock_aws, settings
from moto.dynamodb.models import DynamoDBBackend
from moto.s3 import models as s3model
from moto.s3 import s3_backends
@@ -234,30 +234,30 @@ class TestS3FileHandleClosuresUsingMocks(TestCase):
self.s3_client = boto3.client("s3", "us-east-1")
@verify_zero_warnings
- @mock_s3
+ @mock_aws
def test_use_decorator(self):
self.s3_client.create_bucket(Bucket="foo")
self.s3_client.put_object(Bucket="foo", Key="bar", Body="stuff")
@verify_zero_warnings
- @mock_s3
+ @mock_aws
def test_use_decorator_and_context_mngt(self):
- with mock_s3():
+ with mock_aws():
self.s3_client.create_bucket(Bucket="foo")
self.s3_client.put_object(Bucket="foo", Key="bar", Body="stuff")
@verify_zero_warnings
def test_use_multiple_context_managers(self):
- with mock_s3():
+ with mock_aws():
self.s3_client.create_bucket(Bucket="foo")
self.s3_client.put_object(Bucket="foo", Key="bar", Body="stuff")
- with mock_s3():
+ with mock_aws():
pass
@verify_zero_warnings
def test_create_multipart(self):
- with mock_s3():
+ with mock_aws():
self.s3_client.create_bucket(Bucket="foo")
self.s3_client.put_object(Bucket="foo", Key="k1", Body="stuff")
@@ -270,22 +270,22 @@ class TestS3FileHandleClosuresUsingMocks(TestCase):
UploadId=mpart["UploadId"],
)
- with mock_s3():
+ with mock_aws():
pass
@verify_zero_warnings
def test_overwrite_file(self):
- with mock_s3():
+ with mock_aws():
self.s3_client.create_bucket(Bucket="foo")
self.s3_client.put_object(Bucket="foo", Key="k1", Body="stuff")
self.s3_client.put_object(Bucket="foo", Key="k1", Body="b" * 10_000_000)
- with mock_s3():
+ with mock_aws():
pass
@verify_zero_warnings
def test_delete_object_with_version(self):
- with mock_s3():
+ with mock_aws():
self.s3_client.create_bucket(Bucket="foo")
self.s3_client.put_bucket_versioning(
Bucket="foo",
@@ -299,7 +299,7 @@ class TestS3FileHandleClosuresUsingMocks(TestCase):
@verify_zero_warnings
def test_update_versioned_object__while_looping(self):
for _ in (1, 2):
- with mock_s3():
+ with mock_aws():
self.s3_client.create_bucket(Bucket="foo")
self.s3_client.put_bucket_versioning(
Bucket="foo",
diff --git a/tests/test_s3/test_s3_lambda_integration.py b/tests/test_s3/test_s3_lambda_integration.py
index 0762148db..08859f550 100644
--- a/tests/test_s3/test_s3_lambda_integration.py
+++ b/tests/test_s3/test_s3_lambda_integration.py
@@ -4,7 +4,7 @@ from uuid import uuid4
import boto3
import pytest
-from moto import mock_lambda, mock_logs, mock_s3, mock_sns, mock_sqs
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests.markers import requires_docker
from tests.test_awslambda.utilities import (
@@ -16,9 +16,7 @@ from tests.test_awslambda.utilities import (
REGION_NAME = "us-east-1"
-@mock_lambda
-@mock_logs
-@mock_s3
+@mock_aws
@pytest.mark.parametrize(
"match_events,actual_event",
[
@@ -106,8 +104,7 @@ def test_objectcreated_put__invokes_lambda(match_events, actual_event):
assert records[0]["s3"]["object"]["size"] == 15
-@mock_logs
-@mock_s3
+@mock_aws
def test_objectcreated_put__unknown_lambda_is_handled_gracefully():
s3_res = boto3.resource("s3", region_name=REGION_NAME)
s3_client = boto3.client("s3", region_name=REGION_NAME)
@@ -139,8 +136,7 @@ def test_objectcreated_put__unknown_lambda_is_handled_gracefully():
assert resp["Body"].read() == b"bodyofnewobject"
-@mock_s3
-@mock_sqs
+@mock_aws
def test_object_copy__sends_to_queue():
s3_res = boto3.resource("s3", region_name=REGION_NAME)
s3_client = boto3.client("s3", region_name=REGION_NAME)
@@ -206,8 +202,7 @@ def test_object_copy__sends_to_queue():
assert records[0]["s3"]["object"]["size"] == 15
-@mock_s3
-@mock_sqs
+@mock_aws
def test_object_put__sends_to_queue__using_filter():
s3_res = boto3.resource("s3", region_name=REGION_NAME)
s3_client = boto3.client("s3", region_name=REGION_NAME)
@@ -286,9 +281,7 @@ def test_object_put__sends_to_queue__using_filter():
_ = [m.delete() for m in messages]
-@mock_s3
-@mock_sns
-@mock_sqs
+@mock_aws
def test_put_bucket_notification_sns_sqs():
s3_client = boto3.client("s3", region_name=REGION_NAME)
s3_client.create_bucket(Bucket="bucket")
@@ -361,7 +354,7 @@ def test_put_bucket_notification_sns_sqs():
assert s3_message_body["Records"][0]["eventName"] == "ObjectCreated:Put"
-@mock_s3
+@mock_aws
def test_put_bucket_notification_sns_error():
s3_client = boto3.client("s3", region_name=REGION_NAME)
s3_client.create_bucket(Bucket="bucket")
diff --git a/tests/test_s3/test_s3_lifecycle.py b/tests/test_s3/test_s3_lifecycle.py
index fb80ee134..b43789139 100644
--- a/tests/test_s3/test_s3_lifecycle.py
+++ b/tests/test_s3/test_s3_lifecycle.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_s3
+from moto import mock_aws
-@mock_s3
+@mock_aws
def test_lifecycle_with_filters():
client = boto3.client("s3")
client.create_bucket(
@@ -221,7 +221,7 @@ def test_lifecycle_with_filters():
assert result[1]["ID"] == "Tags"
-@mock_s3
+@mock_aws
def test_lifecycle_with_eodm():
client = boto3.client("s3")
client.create_bucket(
@@ -271,7 +271,7 @@ def test_lifecycle_with_eodm():
assert err.value.response["Error"]["Code"] == "MalformedXML"
-@mock_s3
+@mock_aws
def test_lifecycle_with_nve():
client = boto3.client("s3")
client.create_bucket(
@@ -307,7 +307,7 @@ def test_lifecycle_with_nve():
# TODO: Add test for failures due to missing children
-@mock_s3
+@mock_aws
def test_lifecycle_with_nvt():
client = boto3.client("s3")
client.create_bucket(
@@ -375,7 +375,7 @@ def test_lifecycle_with_nvt():
assert err.value.response["Error"]["Code"] == "MalformedXML"
-@mock_s3
+@mock_aws
def test_lifecycle_with_multiple_nvt():
client = boto3.client("s3")
client.create_bucket(
@@ -410,7 +410,7 @@ def test_lifecycle_with_multiple_nvt():
}
-@mock_s3
+@mock_aws
def test_lifecycle_with_multiple_transitions():
client = boto3.client("s3")
client.create_bucket(
@@ -445,7 +445,7 @@ def test_lifecycle_with_multiple_transitions():
}
-@mock_s3
+@mock_aws
def test_lifecycle_with_aimu():
client = boto3.client("s3")
client.create_bucket(
@@ -486,7 +486,7 @@ def test_lifecycle_with_aimu():
# TODO: Add test for failures due to missing children
-@mock_s3
+@mock_aws
def test_lifecycle_with_glacier_transition_boto3():
s3_resource = boto3.resource("s3", region_name="us-east-1")
client = boto3.client("s3", region_name="us-east-1")
@@ -517,7 +517,7 @@ def test_lifecycle_with_glacier_transition_boto3():
assert "Date" not in transition
-@mock_s3
+@mock_aws
def test_lifecycle_multi_boto3():
s3_resource = boto3.resource("s3", region_name="us-east-1")
client = boto3.client("s3", region_name="us-east-1")
@@ -589,7 +589,7 @@ def test_lifecycle_multi_boto3():
assert False, "Invalid rule id"
-@mock_s3
+@mock_aws
def test_lifecycle_delete_boto3():
s3_resource = boto3.resource("s3", region_name="us-east-1")
client = boto3.client("s3", region_name="us-east-1")
diff --git a/tests/test_s3/test_s3_list_object_versions.py b/tests/test_s3/test_s3_list_object_versions.py
index 8df6133dc..4ee8facfa 100644
--- a/tests/test_s3/test_s3_list_object_versions.py
+++ b/tests/test_s3/test_s3_list_object_versions.py
@@ -3,13 +3,13 @@ from uuid import uuid4
import boto3
import pytest
-from moto import mock_s3
+from moto import mock_aws
from moto.s3.responses import DEFAULT_REGION_NAME
from . import s3_aws_verified
-@mock_s3
+@mock_aws
def test_list_versions():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -51,7 +51,7 @@ def test_list_versions():
assert len(versions) == 1
-@mock_s3
+@mock_aws
def test_list_object_versions():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "000" + str(uuid4())
@@ -192,7 +192,7 @@ def test_list_object_versions_with_delimiter(bucket_name=None):
assert len(response["Versions"]) == 24
-@mock_s3
+@mock_aws
def test_list_object_versions_with_delimiter_for_deleted_objects():
bucket_name = "tests_bucket"
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -241,7 +241,7 @@ def test_list_object_versions_with_delimiter_for_deleted_objects():
assert [dm["Key"] for dm in del_objs["DeleteMarkers"]] == ["del_obj_0"]
-@mock_s3
+@mock_aws
def test_list_object_versions_with_versioning_disabled():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -265,7 +265,7 @@ def test_list_object_versions_with_versioning_disabled():
assert response["Body"].read() == items[-1]
-@mock_s3
+@mock_aws
def test_list_object_versions_with_versioning_enabled_late():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -529,7 +529,7 @@ def test_list_object_versions_with_paging_and_delimiter(bucket_name=None):
assert "NextVersionIdMarker" not in page3
-@mock_s3
+@mock_aws
def test_bad_prefix_list_object_versions():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
diff --git a/tests/test_s3/test_s3_locales.py b/tests/test_s3/test_s3_locales.py
index 06aca5c36..a67291094 100644
--- a/tests/test_s3/test_s3_locales.py
+++ b/tests/test_s3/test_s3_locales.py
@@ -4,10 +4,10 @@ from unittest import SkipTest
import boto3
from freezegun import freeze_time
-from moto import mock_s3, settings
+from moto import mock_aws, settings
-@mock_s3
+@mock_aws
def test_rfc_returns_valid_date_for_every_possible_weekday_and_month():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Freezing time only possible in DecoratorMode")
diff --git a/tests/test_s3/test_s3_lock.py b/tests/test_s3/test_s3_lock.py
index e56554185..83589ccfd 100644
--- a/tests/test_s3/test_s3_lock.py
+++ b/tests/test_s3/test_s3_lock.py
@@ -6,12 +6,12 @@ import pytest
from botocore.client import ClientError
from botocore.config import Config
-from moto import mock_s3
+from moto import mock_aws
from moto.core.utils import utcnow
from moto.s3.responses import DEFAULT_REGION_NAME
-@mock_s3
+@mock_aws
def test_locked_object():
s3_client = boto3.client("s3", config=Config(region_name=DEFAULT_REGION_NAME))
@@ -48,7 +48,7 @@ def test_locked_object():
s3_client.delete_bucket(Bucket=bucket_name)
-@mock_s3
+@mock_aws
def test_fail_locked_object():
bucket_name = "locked-bucket2"
key_name = "file.txt"
@@ -75,7 +75,7 @@ def test_fail_locked_object():
s3_client.delete_bucket(Bucket=bucket_name)
-@mock_s3
+@mock_aws
def test_put_object_lock():
s3_client = boto3.client("s3", config=Config(region_name=DEFAULT_REGION_NAME))
@@ -113,7 +113,7 @@ def test_put_object_lock():
s3_client.delete_bucket(Bucket=bucket_name)
-@mock_s3
+@mock_aws
def test_put_object_legal_hold():
s3_client = boto3.client("s3", config=Config(region_name=DEFAULT_REGION_NAME))
@@ -154,7 +154,7 @@ def test_put_object_legal_hold():
s3_client.delete_bucket(Bucket=bucket_name)
-@mock_s3
+@mock_aws
def test_put_default_lock():
# do not run this test in aws, it will block the deletion for a whole day
@@ -199,7 +199,7 @@ def test_put_default_lock():
)
-@mock_s3
+@mock_aws
def test_put_object_legal_hold_with_versions():
s3_client = boto3.client("s3", config=Config(region_name=DEFAULT_REGION_NAME))
@@ -261,7 +261,7 @@ def test_put_object_legal_hold_with_versions():
s3_client.delete_bucket(Bucket=bucket_name)
-@mock_s3
+@mock_aws
def test_put_object_lock_with_versions():
s3_client = boto3.client("s3", config=Config(region_name=DEFAULT_REGION_NAME))
diff --git a/tests/test_s3/test_s3_logging.py b/tests/test_s3/test_s3_logging.py
index 1ade74b1a..152b6fdec 100644
--- a/tests/test_s3/test_s3_logging.py
+++ b/tests/test_s3/test_s3_logging.py
@@ -6,14 +6,14 @@ import boto3
import pytest
from botocore.client import ClientError
-from moto import mock_s3, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID
from moto.s3 import s3_backends
from moto.s3.models import FakeBucket
from moto.s3.responses import DEFAULT_REGION_NAME
-@mock_s3
+@mock_aws
def test_put_bucket_logging():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -196,7 +196,7 @@ def test_put_bucket_logging():
assert err.value.response["Error"]["Code"] == "MalformedXML"
-@mock_s3
+@mock_aws
def test_log_file_is_created():
# Create necessary buckets
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -270,7 +270,7 @@ def test_log_file_is_created():
assert any(c for c in contents if "REST.PUT.BUCKET" in c)
-@mock_s3
+@mock_aws
def test_invalid_bucket_logging_when_permissions_are_false():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Can't patch permission logic in ServerMode")
@@ -296,7 +296,7 @@ def test_invalid_bucket_logging_when_permissions_are_false():
assert "log-delivery" in err.value.response["Error"]["Message"]
-@mock_s3
+@mock_aws
def test_valid_bucket_logging_when_permissions_are_true():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Can't patch permission logic in ServerMode")
@@ -325,7 +325,7 @@ def test_valid_bucket_logging_when_permissions_are_true():
assert result["LoggingEnabled"]["TargetPrefix"] == f"{bucket_name}/"
-@mock_s3
+@mock_aws
def test_bucket_policy_not_set():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Can't patch permission logic in ServerMode")
@@ -345,7 +345,7 @@ def test_bucket_policy_not_set():
)
-@mock_s3
+@mock_aws
def test_bucket_policy_principal():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Can't patch permission logic in ServerMode")
@@ -400,7 +400,7 @@ def test_bucket_policy_principal():
)
-@mock_s3
+@mock_aws
def test_bucket_policy_effect():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Can't patch permission logic in ServerMode")
@@ -454,7 +454,7 @@ def test_bucket_policy_effect():
)
-@mock_s3
+@mock_aws
def test_bucket_policy_action():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Can't patch permission logic in ServerMode")
@@ -506,7 +506,7 @@ def test_bucket_policy_action():
)
-@mock_s3
+@mock_aws
def test_bucket_policy_resource():
if not settings.TEST_DECORATOR_MODE:
raise SkipTest("Can't patch permission logic in ServerMode")
diff --git a/tests/test_s3/test_s3_metadata.py b/tests/test_s3/test_s3_metadata.py
index 0cfedd0ef..97b659543 100644
--- a/tests/test_s3/test_s3_metadata.py
+++ b/tests/test_s3/test_s3_metadata.py
@@ -1,10 +1,10 @@
import boto3
-from moto import mock_s3
+from moto import mock_aws
from moto.s3.responses import DEFAULT_REGION_NAME
-@mock_s3
+@mock_aws
def test_s3_returns_requestid():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
resp = s3_client.create_bucket(Bucket="mybucket")
diff --git a/tests/test_s3/test_s3_multipart.py b/tests/test_s3/test_s3_multipart.py
index 821c062e4..99025a41f 100644
--- a/tests/test_s3/test_s3_multipart.py
+++ b/tests/test_s3/test_s3_multipart.py
@@ -10,7 +10,7 @@ import requests
from botocore.client import ClientError
import moto.s3.models as s3model
-from moto import mock_s3, settings
+from moto import mock_aws, settings
from moto.s3.responses import DEFAULT_REGION_NAME
from moto.settings import (
S3_UPLOAD_PART_MIN_SIZE,
@@ -44,7 +44,7 @@ def reduced_min_part_size(func):
return wrapped
-@mock_s3
+@mock_aws
def test_default_key_buffer_size():
# save original DEFAULT_KEY_BUFFER_SIZE environment variable content
original_default_key_buffer_size = os.environ.get(
@@ -72,7 +72,7 @@ def test_default_key_buffer_size():
os.environ["MOTO_S3_DEFAULT_KEY_BUFFER_SIZE"] = original_default_key_buffer_size
-@mock_s3
+@mock_aws
def test_multipart_upload_too_small():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -113,7 +113,7 @@ def test_multipart_upload_too_small():
@pytest.mark.parametrize("key", ["the-key", "the%20key"])
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_upload(key: str):
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
@@ -154,7 +154,7 @@ def test_multipart_upload(key: str):
assert response["Body"].read() == part1 + part2
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_upload_out_of_order():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
@@ -195,7 +195,7 @@ def test_multipart_upload_out_of_order():
assert response["Body"].read() == part1 + part2
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_upload_with_headers():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
@@ -251,7 +251,7 @@ def test_multipart_upload_with_headers():
"key-with%2Fembedded%2Furl%2Fencoding",
],
)
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_upload_with_copy_key(original_key_name):
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -290,7 +290,7 @@ def test_multipart_upload_with_copy_key(original_key_name):
assert response["Body"].read() == part1 + b"key_"
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_upload_cancel():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -317,7 +317,7 @@ def test_multipart_upload_cancel():
assert "Uploads" not in s3_client.list_multipart_uploads(Bucket="foobar")
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_etag_quotes_stripped():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -358,7 +358,7 @@ def test_multipart_etag_quotes_stripped():
assert response["Body"].read() == part1 + b"key_"
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_duplicate_upload():
s3_resource = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
@@ -407,7 +407,7 @@ def test_multipart_duplicate_upload():
assert response["Body"].read() == part1 + part2
-@mock_s3
+@mock_aws
def test_list_multiparts():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="foobar")
@@ -437,7 +437,7 @@ def test_list_multiparts():
assert "Uploads" not in res
-@mock_s3
+@mock_aws
def test_multipart_should_throw_nosuchupload_if_there_are_no_parts():
bucket = boto3.resource("s3", region_name=DEFAULT_REGION_NAME).Bucket(
"randombucketname"
@@ -459,7 +459,7 @@ def test_multipart_should_throw_nosuchupload_if_there_are_no_parts():
assert err["UploadId"] == multipart_upload.id
-@mock_s3
+@mock_aws
def test_multipart_wrong_partnumber():
bucket_name = "mputest-3593"
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -486,7 +486,7 @@ def test_multipart_wrong_partnumber():
)
-@mock_s3
+@mock_aws
def test_multipart_upload_with_tags():
bucket = "mybucket"
key = "test/multipartuploadtag/file.txt"
@@ -513,7 +513,7 @@ def test_multipart_upload_with_tags():
assert actual == {"a": "b"}
-@mock_s3
+@mock_aws
def test_multipart_upload_should_return_part_10000():
bucket = "dummybucket"
s3_client = boto3.client("s3", "us-east-1")
@@ -538,7 +538,7 @@ def test_multipart_upload_should_return_part_10000():
assert part_nrs == [1, 2, 10000]
-@mock_s3
+@mock_aws
def test_multipart_upload_without_parts():
bucket = "dummybucket"
s3_client = boto3.client("s3", "us-east-1")
@@ -553,7 +553,7 @@ def test_multipart_upload_without_parts():
assert list_parts_result["IsTruncated"] is False
-@mock_s3
+@mock_aws
@pytest.mark.parametrize("part_nr", [10001, 10002, 20000])
def test_s3_multipart_upload_cannot_upload_part_over_10000(part_nr):
bucket = "dummy"
@@ -578,7 +578,7 @@ def test_s3_multipart_upload_cannot_upload_part_over_10000(part_nr):
assert err["ArgumentValue"] == f"{part_nr}"
-@mock_s3
+@mock_aws
def test_s3_abort_multipart_data_with_invalid_upload_and_key():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -597,7 +597,7 @@ def test_s3_abort_multipart_data_with_invalid_upload_and_key():
assert err["UploadId"] == "dummy_upload_id"
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_etag():
# Create Bucket so that test can run
@@ -645,7 +645,7 @@ def test_multipart_etag():
assert resp["ETag"] == EXPECTED_ETAG
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_version():
# Create Bucket so that test can run
@@ -695,7 +695,7 @@ def test_multipart_version():
assert re.match("[-a-z0-9]+", response["VersionId"])
-@mock_s3
+@mock_aws
@pytest.mark.parametrize(
"part_nr,msg,msg2",
[
@@ -737,7 +737,7 @@ def test_multipart_list_parts_invalid_argument(part_nr, msg, msg2):
assert err_rsp["Message"] == msg2
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_list_parts():
s3_client = boto3.client("s3", region_name="us-east-1")
@@ -846,7 +846,7 @@ def test_multipart_list_parts():
)
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_multipart_part_size():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -882,7 +882,7 @@ def test_multipart_part_size():
assert obj["ContentLength"] == REDUCED_PART_SIZE + i
-@mock_s3
+@mock_aws
def test_complete_multipart_with_empty_partlist():
"""Verify InvalidXML-error sent for MultipartUpload with empty part list."""
bucket = "testbucketthatcompletesmultipartuploadwithoutparts"
@@ -906,7 +906,7 @@ def test_complete_multipart_with_empty_partlist():
)
-@mock_s3
+@mock_aws
def test_ssm_key_headers_in_create_multipart():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -946,7 +946,7 @@ def test_ssm_key_headers_in_create_multipart():
assert complete_multipart_response["SSEKMSKeyId"] == kms_key_id
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_generate_presigned_url_on_multipart_upload_without_acl():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -992,7 +992,7 @@ def test_generate_presigned_url_on_multipart_upload_without_acl():
assert res.status_code == 200
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_head_object_returns_part_count():
bucket = "telstra-energy-test"
@@ -1032,7 +1032,7 @@ def test_head_object_returns_part_count():
assert "PartsCount" not in resp
-@mock_s3
+@mock_aws
@reduced_min_part_size
def test_generate_presigned_url_for_multipart_upload():
if not settings.TEST_DECORATOR_MODE:
diff --git a/tests/test_s3/test_s3_object_attributes.py b/tests/test_s3/test_s3_object_attributes.py
index b2d18528b..30a279d1a 100644
--- a/tests/test_s3/test_s3_object_attributes.py
+++ b/tests/test_s3/test_s3_object_attributes.py
@@ -3,10 +3,10 @@ from uuid import uuid4
import boto3
import pytest
-from moto import mock_s3
+from moto import mock_aws
-@mock_s3
+@mock_aws
class TestS3ObjectAttributes:
def setup_method(self, *args) -> None: # pylint: disable=unused-argument
self.bucket_name = str(uuid4())
diff --git a/tests/test_s3/test_s3_ownership.py b/tests/test_s3/test_s3_ownership.py
index fc4913ef9..4f2f845f7 100644
--- a/tests/test_s3/test_s3_ownership.py
+++ b/tests/test_s3/test_s3_ownership.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.client import ClientError
-from moto import mock_s3
+from moto import mock_aws
from moto.s3.responses import DEFAULT_REGION_NAME
-@mock_s3
+@mock_aws
def test_create_bucket_with_ownership():
bucket = "bucket-with-owner"
ownership = "BucketOwnerPreferred"
@@ -17,7 +17,7 @@ def test_create_bucket_with_ownership():
assert response["OwnershipControls"]["Rules"][0]["ObjectOwnership"] == ownership
-@mock_s3
+@mock_aws
def test_put_ownership_to_bucket():
bucket = "bucket-updated-with-owner"
ownership = "ObjectWriter"
@@ -32,7 +32,7 @@ def test_put_ownership_to_bucket():
assert response["OwnershipControls"]["Rules"][0]["ObjectOwnership"] == ownership
-@mock_s3
+@mock_aws
def test_delete_ownership_from_bucket():
bucket = "bucket-with-owner-removed"
ownership = "BucketOwnerEnforced"
diff --git a/tests/test_s3/test_s3_replication.py b/tests/test_s3/test_s3_replication.py
index 3c7d5f2b2..50b587554 100644
--- a/tests/test_s3/test_s3_replication.py
+++ b/tests/test_s3/test_s3_replication.py
@@ -4,12 +4,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_s3
+from moto import mock_aws
DEFAULT_REGION_NAME = "us-east-1"
-@mock_s3
+@mock_aws
def test_get_bucket_replication_for_unexisting_bucket():
bucket_name = str(uuid4())
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -21,7 +21,7 @@ def test_get_bucket_replication_for_unexisting_bucket():
assert err["BucketName"] == bucket_name
-@mock_s3
+@mock_aws
def test_get_bucket_replication_bucket_without_replication():
bucket_name = str(uuid4())
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -35,7 +35,7 @@ def test_get_bucket_replication_bucket_without_replication():
assert err["BucketName"] == bucket_name
-@mock_s3
+@mock_aws
def test_delete_bucket_replication_unknown_bucket():
bucket_name = str(uuid4())
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -47,7 +47,7 @@ def test_delete_bucket_replication_unknown_bucket():
assert err["BucketName"] == bucket_name
-@mock_s3
+@mock_aws
def test_delete_bucket_replication_bucket_without_replication():
bucket_name = str(uuid4())
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -57,7 +57,7 @@ def test_delete_bucket_replication_bucket_without_replication():
s3_client.delete_bucket_replication(Bucket=bucket_name)
-@mock_s3
+@mock_aws
def test_create_replication_without_versioning():
bucket_name = str(uuid4())
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -81,7 +81,7 @@ def test_create_replication_without_versioning():
assert err["BucketName"] == bucket_name
-@mock_s3
+@mock_aws
def test_create_and_retrieve_replication_with_single_rules():
bucket_name = str(uuid4())
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -133,7 +133,7 @@ def test_create_and_retrieve_replication_with_single_rules():
assert err["BucketName"] == bucket_name
-@mock_s3
+@mock_aws
def test_create_and_retrieve_replication_with_multiple_rules():
bucket_name = str(uuid4())
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
diff --git a/tests/test_s3/test_s3_storageclass.py b/tests/test_s3/test_s3_storageclass.py
index f342fefdb..b680c713d 100644
--- a/tests/test_s3/test_s3_storageclass.py
+++ b/tests/test_s3/test_s3_storageclass.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_s3
+from moto import mock_aws
-@mock_s3
+@mock_aws
def test_s3_storage_class_standard():
s3_client = boto3.client("s3", region_name="us-east-1")
s3_client.create_bucket(Bucket="Bucket")
@@ -19,7 +19,7 @@ def test_s3_storage_class_standard():
assert list_of_objects["Contents"][0]["StorageClass"] == "STANDARD"
-@mock_s3
+@mock_aws
def test_s3_storage_class_infrequent_access():
s3_client = boto3.client("s3")
s3_client.create_bucket(
@@ -40,7 +40,7 @@ def test_s3_storage_class_infrequent_access():
assert objs["Contents"][0]["StorageClass"] == "STANDARD_IA"
-@mock_s3
+@mock_aws
def test_s3_storage_class_intelligent_tiering():
s3_client = boto3.client("s3")
@@ -59,7 +59,7 @@ def test_s3_storage_class_intelligent_tiering():
assert objects["Contents"][0]["StorageClass"] == "INTELLIGENT_TIERING"
-@mock_s3
+@mock_aws
def test_s3_storage_class_copy():
s3_client = boto3.client("s3", region_name="us-east-1")
s3_client.create_bucket(Bucket="Bucket")
@@ -84,7 +84,7 @@ def test_s3_storage_class_copy():
assert list_of_copied_objects["Contents"][0]["StorageClass"] == "ONEZONE_IA"
-@mock_s3
+@mock_aws
def test_s3_invalid_copied_storage_class():
s3_client = boto3.client("s3", region_name="us-east-1")
s3_client.create_bucket(Bucket="Bucket")
@@ -116,7 +116,7 @@ def test_s3_invalid_copied_storage_class():
)
-@mock_s3
+@mock_aws
def test_s3_invalid_storage_class():
s3_client = boto3.client("s3")
s3_client.create_bucket(
@@ -136,7 +136,7 @@ def test_s3_invalid_storage_class():
)
-@mock_s3
+@mock_aws
def test_s3_default_storage_class():
s3_client = boto3.client("s3")
s3_client.create_bucket(
@@ -151,7 +151,7 @@ def test_s3_default_storage_class():
assert list_of_objects["Contents"][0]["StorageClass"] == "STANDARD"
-@mock_s3
+@mock_aws
def test_s3_copy_object_error_for_glacier_storage_class_not_restored():
s3_client = boto3.client("s3")
s3_client.create_bucket(
@@ -172,7 +172,7 @@ def test_s3_copy_object_error_for_glacier_storage_class_not_restored():
assert exc.value.response["Error"]["Code"] == "ObjectNotInActiveTierError"
-@mock_s3
+@mock_aws
def test_s3_copy_object_error_for_deep_archive_storage_class_not_restored():
s3_client = boto3.client("s3")
s3_client.create_bucket(
@@ -193,7 +193,7 @@ def test_s3_copy_object_error_for_deep_archive_storage_class_not_restored():
assert exc.value.response["Error"]["Code"] == "ObjectNotInActiveTierError"
-@mock_s3
+@mock_aws
def test_s3_copy_object_for_glacier_storage_class_restored():
s3_client = boto3.client("s3", region_name="us-east-1")
s3_client.create_bucket(Bucket="Bucket")
@@ -222,7 +222,7 @@ def test_s3_copy_object_for_glacier_storage_class_restored():
)
-@mock_s3
+@mock_aws
def test_s3_copy_object_for_deep_archive_storage_class_restored():
s3_client = boto3.client("s3", region_name="us-east-1")
s3_client.create_bucket(Bucket="Bucket")
@@ -261,7 +261,7 @@ def test_s3_copy_object_for_deep_archive_storage_class_restored():
)
-@mock_s3
+@mock_aws
def test_s3_get_object_from_glacier():
s3_client = boto3.client("s3", region_name="us-east-1")
bucket_name = "tests3getobjectfromglacier"
diff --git a/tests/test_s3/test_s3_tagging.py b/tests/test_s3/test_s3_tagging.py
index bef48d7e5..a94fe6c5d 100644
--- a/tests/test_s3/test_s3_tagging.py
+++ b/tests/test_s3/test_s3_tagging.py
@@ -3,14 +3,14 @@ import pytest
import requests
from botocore.client import ClientError
-from moto import mock_s3, settings
+from moto import mock_aws, settings
from moto.s3.responses import DEFAULT_REGION_NAME
from . import s3_aws_verified
from .test_s3 import add_proxy_details
-@mock_s3
+@mock_aws
def test_get_bucket_tagging_unknown_bucket():
client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
@@ -142,7 +142,7 @@ def test_get_bucket_tagging(bucket_name=None):
assert err["Message"] == "The TagSet does not exist"
-@mock_s3
+@mock_aws
def test_delete_bucket_tagging():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -233,7 +233,7 @@ def test_put_object_tagging(bucket_name=None):
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_s3
+@mock_aws
def test_put_object_tagging_on_earliest_version():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -305,7 +305,7 @@ def test_put_object_tagging_on_earliest_version():
assert resp["TagSet"] == []
-@mock_s3
+@mock_aws
def test_put_object_tagging_on_both_version():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -390,7 +390,7 @@ def test_put_object_tagging_on_both_version():
]
-@mock_s3
+@mock_aws
def test_put_object_tagging_with_single_tag():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -408,7 +408,7 @@ def test_put_object_tagging_with_single_tag():
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_s3
+@mock_aws
def test_get_object_tagging():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
bucket_name = "mybucket"
@@ -437,7 +437,7 @@ def test_get_object_tagging():
assert {"Key": "item2", "Value": "bar"} in resp["TagSet"]
-@mock_s3
+@mock_aws
def test_objects_tagging_with_same_key_name():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
key_name = "file.txt"
@@ -465,7 +465,7 @@ def test_objects_tagging_with_same_key_name():
assert variable2 == "two"
-@mock_s3
+@mock_aws
def test_generate_url_for_tagged_object():
s3_client = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
s3_client.create_bucket(Bucket="my-bucket")
diff --git a/tests/test_s3/test_server.py b/tests/test_s3/test_server.py
index 7af3fe21e..e7cedeceb 100644
--- a/tests/test_s3/test_server.py
+++ b/tests/test_s3/test_server.py
@@ -1,4 +1,3 @@
-"""Test different server responses."""
import io
from unittest.mock import patch
from urllib.parse import parse_qs, urlparse
diff --git a/tests/test_s3bucket_path/test_server.py b/tests/test_s3bucket_path/test_server.py
index c70f441db..d49a7fcd4 100644
--- a/tests/test_s3bucket_path/test_server.py
+++ b/tests/test_s3bucket_path/test_server.py
@@ -1,4 +1,3 @@
-"""Test the different server responses."""
from flask.testing import FlaskClient
import moto.server as server
@@ -13,7 +12,7 @@ class AuthenticatedClient(FlaskClient):
def authenticated_client():
- backend = server.create_backend_app("s3bucket_path")
+ backend = server.create_backend_app("s3")
backend.test_client_class = AuthenticatedClient
return backend.test_client()
diff --git a/tests/test_s3control/test_s3control.py b/tests/test_s3control/test_s3control.py
index f7c95cd69..3d3ee982f 100644
--- a/tests/test_s3control/test_s3control.py
+++ b/tests/test_s3control/test_s3control.py
@@ -3,10 +3,10 @@ import pytest
from boto3 import Session
from botocore.client import ClientError
-from moto import mock_s3control
+from moto import mock_aws
-@mock_s3control
+@mock_aws
def test_get_public_access_block_for_account():
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
diff --git a/tests/test_s3control/test_s3control_access_points.py b/tests/test_s3control/test_s3control_access_points.py
index 7f3295cb5..86513781d 100644
--- a/tests/test_s3control/test_s3control_access_points.py
+++ b/tests/test_s3control/test_s3control_access_points.py
@@ -5,11 +5,11 @@ import boto3
import pytest
from botocore.client import ClientError
-from moto import mock_s3control
+from moto import mock_aws
from tests.test_s3 import s3_aws_verified
-@mock_s3control
+@mock_aws
def test_get_unknown_access_point():
client = boto3.client("s3control", region_name="ap-southeast-1")
@@ -21,7 +21,7 @@ def test_get_unknown_access_point():
assert err["AccessPointName"] == "ap_name"
-@mock_s3control
+@mock_aws
def test_get_access_point_minimal():
client = boto3.client("s3control", region_name="ap-southeast-1")
client.create_access_point(
@@ -57,7 +57,7 @@ def test_get_access_point_minimal():
)
-@mock_s3control
+@mock_aws
def test_get_access_point_full():
client = boto3.client("s3control", region_name="ap-southeast-1")
client.create_access_point(
diff --git a/tests/test_s3control/test_s3control_accesspoint_policy.py b/tests/test_s3control/test_s3control_accesspoint_policy.py
index 0f4270468..e863b7f2e 100644
--- a/tests/test_s3control/test_s3control_accesspoint_policy.py
+++ b/tests/test_s3control/test_s3control_accesspoint_policy.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.client import ClientError
-from moto import mock_s3control
+from moto import mock_aws
-@mock_s3control
+@mock_aws
def test_get_access_point_policy():
client = boto3.client("s3control", region_name="us-west-2")
client.create_access_point(
@@ -35,7 +35,7 @@ def test_get_access_point_policy():
assert resp["Policy"] == policy
-@mock_s3control
+@mock_aws
def test_get_unknown_access_point_policy():
client = boto3.client("s3control", region_name="ap-southeast-1")
client.create_access_point(
@@ -50,7 +50,7 @@ def test_get_unknown_access_point_policy():
assert err["AccessPointName"] == "ap_name"
-@mock_s3control
+@mock_aws
def test_get_access_point_policy_status():
client = boto3.client("s3control", region_name="us-west-2")
client.create_access_point(
@@ -82,7 +82,7 @@ def test_get_access_point_policy_status():
assert resp["PolicyStatus"] == {"IsPublic": True}
-@mock_s3control
+@mock_aws
def test_delete_access_point_policy():
client = boto3.client("s3control", region_name="us-west-2")
client.create_access_point(
@@ -102,7 +102,7 @@ def test_delete_access_point_policy():
assert err["Code"] == "NoSuchAccessPointPolicy"
-@mock_s3control
+@mock_aws
def test_get_unknown_access_point_policy_status():
client = boto3.client("s3control", region_name="ap-southeast-1")
client.create_access_point(
diff --git a/tests/test_s3control/test_s3control_config_integration.py b/tests/test_s3control/test_s3control_config_integration.py
index fb2214678..b85f6342e 100644
--- a/tests/test_s3control/test_s3control_config_integration.py
+++ b/tests/test_s3control/test_s3control_config_integration.py
@@ -5,7 +5,7 @@ import pytest
from boto3 import Session
from botocore.client import ClientError
-from moto import mock_config, mock_s3control, settings
+from moto import mock_aws, settings
# All tests for s3-control cannot be run under the server without a modification of the
# hosts file on your system. This is due to the fact that the URL to the host is in the form of:
@@ -15,8 +15,7 @@ from moto import mock_config, mock_s3control, settings
if not settings.TEST_SERVER_MODE:
- @mock_s3control
- @mock_config
+ @mock_aws
def test_config_list_account_pab():
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
@@ -186,8 +185,7 @@ if not settings.TEST_SERVER_MODE:
)
assert not result["ResourceIdentifiers"]
- @mock_s3control
- @mock_config
+ @mock_aws
def test_config_get_account_pab():
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
diff --git a/tests/test_s3control/test_s3control_s3.py b/tests/test_s3control/test_s3control_s3.py
index b3c12d7d0..976fbe126 100644
--- a/tests/test_s3control/test_s3control_s3.py
+++ b/tests/test_s3control/test_s3control_s3.py
@@ -1,7 +1,6 @@
-"""Test that using both s3 and s3control do not interfere"""
import boto3
-from moto import mock_s3, mock_s3control, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
REGION = "us-east-1"
@@ -9,8 +8,7 @@ REGION = "us-east-1"
if not settings.TEST_SERVER_MODE:
- @mock_s3
- @mock_s3control
+ @mock_aws
def test_pab_are_kept_separate():
client = boto3.client("s3control", region_name=REGION)
s3_client = boto3.client("s3", region_name=REGION)
@@ -52,8 +50,7 @@ if not settings.TEST_SERVER_MODE:
"RestrictPublicBuckets": False,
}
- @mock_s3control
- @mock_s3
+ @mock_aws
def test_pab_are_kept_separate_with_inverse_mocks():
client = boto3.client("s3control", region_name=REGION)
s3_client = boto3.client("s3", region_name=REGION)
@@ -95,8 +92,7 @@ if not settings.TEST_SERVER_MODE:
"RestrictPublicBuckets": False,
}
- @mock_s3
- @mock_s3control
+ @mock_aws
def test_access_point_read_write():
# Setup
bucket = "test-bucket"
diff --git a/tests/test_sagemaker/test_sagemaker_cloudformation.py b/tests/test_sagemaker/test_sagemaker_cloudformation.py
index b456ede50..b7749d98b 100644
--- a/tests/test_sagemaker/test_sagemaker_cloudformation.py
+++ b/tests/test_sagemaker/test_sagemaker_cloudformation.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudformation, mock_sagemaker
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .cloudformation_test_configs import (
@@ -25,8 +25,7 @@ def _get_stack_outputs(cf_client, stack_name):
}
-@mock_cloudformation
-@mock_sagemaker
+@mock_aws
@pytest.mark.parametrize(
"test_config",
[
@@ -57,8 +56,7 @@ def test_sagemaker_cloudformation_create(test_config):
assert len(provisioned_resource["PhysicalResourceId"]) > 0
-@mock_cloudformation
-@mock_sagemaker
+@mock_aws
@pytest.mark.parametrize(
"test_config",
[
@@ -90,8 +88,7 @@ def test_sagemaker_cloudformation_get_attr(test_config):
assert outputs["Arn"] == resource_description[test_config.arn_parameter]
-@mock_cloudformation
-@mock_sagemaker
+@mock_aws
@pytest.mark.parametrize(
"test_config,error_message",
[
@@ -133,8 +130,7 @@ def test_sagemaker_cloudformation_notebook_instance_delete(test_config, error_me
assert error_message in ce.value.response["Error"]["Message"]
-@mock_cloudformation
-@mock_sagemaker
+@mock_aws
def test_sagemaker_cloudformation_notebook_instance_update():
cf = boto3.client("cloudformation", region_name="us-east-1")
sm = boto3.client("sagemaker", region_name="us-east-1")
@@ -175,8 +171,7 @@ def test_sagemaker_cloudformation_notebook_instance_update():
assert updated_instance_type == resource_description["InstanceType"]
-@mock_cloudformation
-@mock_sagemaker
+@mock_aws
def test_sagemaker_cloudformation_notebook_instance_lifecycle_config_update():
cf = boto3.client("cloudformation", region_name="us-east-1")
sm = boto3.client("sagemaker", region_name="us-east-1")
@@ -219,8 +214,7 @@ def test_sagemaker_cloudformation_notebook_instance_lifecycle_config_update():
assert updated_on_create_script == resource_description["OnCreate"][0]["Content"]
-@mock_cloudformation
-@mock_sagemaker
+@mock_aws
def test_sagemaker_cloudformation_model_update():
cf = boto3.client("cloudformation", region_name="us-east-1")
sm = boto3.client("sagemaker", region_name="us-east-1")
@@ -266,8 +260,7 @@ def test_sagemaker_cloudformation_model_update():
)
-@mock_cloudformation
-@mock_sagemaker
+@mock_aws
def test_sagemaker_cloudformation_endpoint_config_update():
cf = boto3.client("cloudformation", region_name="us-east-1")
sm = boto3.client("sagemaker", region_name="us-east-1")
@@ -315,8 +308,7 @@ def test_sagemaker_cloudformation_endpoint_config_update():
)
-@mock_cloudformation
-@mock_sagemaker
+@mock_aws
def test_sagemaker_cloudformation_endpoint_update():
cf = boto3.client("cloudformation", region_name="us-east-1")
sm = boto3.client("sagemaker", region_name="us-east-1")
diff --git a/tests/test_sagemaker/test_sagemaker_endpoint.py b/tests/test_sagemaker/test_sagemaker_endpoint.py
index 647c310ef..755603061 100644
--- a/tests/test_sagemaker/test_sagemaker_endpoint.py
+++ b/tests/test_sagemaker/test_sagemaker_endpoint.py
@@ -6,7 +6,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sagemaker
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
TEST_REGION_NAME = "us-east-1"
@@ -44,7 +44,7 @@ TEST_SERVERLESS_PRODUCTION_VARIANTS = [
@pytest.fixture(name="sagemaker_client")
def fixture_sagemaker_client():
- with mock_sagemaker():
+ with mock_aws():
yield boto3.client("sagemaker", region_name=TEST_REGION_NAME)
diff --git a/tests/test_sagemaker/test_sagemaker_experiment.py b/tests/test_sagemaker/test_sagemaker_experiment.py
index 80f481162..d22fb0984 100644
--- a/tests/test_sagemaker/test_sagemaker_experiment.py
+++ b/tests/test_sagemaker/test_sagemaker_experiment.py
@@ -1,7 +1,7 @@
import boto3
import pytest
-from moto import mock_sagemaker
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
TEST_REGION_NAME = "us-east-1"
@@ -10,7 +10,7 @@ TEST_EXPERIMENT_NAME = "MyExperimentName"
@pytest.fixture(name="sagemaker_client")
def fixture_sagemaker_client():
- with mock_sagemaker():
+ with mock_aws():
yield boto3.client("sagemaker", region_name=TEST_REGION_NAME)
diff --git a/tests/test_sagemaker/test_sagemaker_feature_groups.py b/tests/test_sagemaker/test_sagemaker_feature_groups.py
index 029b042c3..d6a82901d 100644
--- a/tests/test_sagemaker/test_sagemaker_feature_groups.py
+++ b/tests/test_sagemaker/test_sagemaker_feature_groups.py
@@ -6,13 +6,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sagemaker
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_sagemaker
+@mock_aws
def test_create_feature_group():
client = boto3.client("sagemaker", region_name="us-east-2")
resp = client.create_feature_group(
@@ -60,7 +60,7 @@ def test_create_feature_group():
)
-@mock_sagemaker
+@mock_aws
def test_describe_feature_group():
client = boto3.client("sagemaker", region_name="us-east-2")
feature_group_name = "some-feature-group-name"
diff --git a/tests/test_sagemaker/test_sagemaker_model_package_groups.py b/tests/test_sagemaker/test_sagemaker_model_package_groups.py
index d9d50a261..9ed8c30a6 100644
--- a/tests/test_sagemaker/test_sagemaker_model_package_groups.py
+++ b/tests/test_sagemaker/test_sagemaker_model_package_groups.py
@@ -1,4 +1,3 @@
-"""Unit tests for sagemaker-supported APIs."""
import uuid
from datetime import datetime
from unittest import SkipTest
@@ -9,13 +8,13 @@ from botocore.exceptions import ClientError
from dateutil.tz import tzutc # type: ignore
from freezegun import freeze_time
-from moto import mock_sagemaker, settings
+from moto import mock_aws, settings
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_sagemaker
+@mock_aws
def test_create_model_package_group():
client = boto3.client("sagemaker", region_name="us-east-2")
resp = client.create_model_package_group(
@@ -31,7 +30,7 @@ def test_create_model_package_group():
)
-@mock_sagemaker
+@mock_aws
def test_list_model_package_groups():
client = boto3.client("sagemaker", region_name="eu-west-1")
group1 = "test-model-package-group-1"
@@ -64,7 +63,7 @@ def test_list_model_package_groups():
assert "NextToken" not in resp
-@mock_sagemaker
+@mock_aws
def test_list_model_package_groups_creation_time_before():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't freeze time in ServerMode")
@@ -84,7 +83,7 @@ def test_list_model_package_groups_creation_time_before():
assert len(resp["ModelPackageGroupSummaryList"]) == 1
-@mock_sagemaker
+@mock_aws
def test_list_model_package_groups_creation_time_after():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't freeze time in ServerMode")
@@ -104,7 +103,7 @@ def test_list_model_package_groups_creation_time_after():
assert len(resp["ModelPackageGroupSummaryList"]) == 1
-@mock_sagemaker
+@mock_aws
def test_list_model_package_groups_name_contains():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package_group(
@@ -124,7 +123,7 @@ def test_list_model_package_groups_name_contains():
assert len(resp["ModelPackageGroupSummaryList"]) == 2
-@mock_sagemaker
+@mock_aws
def test_list_model_package_groups_sort_by():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package_group(
@@ -147,7 +146,7 @@ def test_list_model_package_groups_sort_by():
)
-@mock_sagemaker
+@mock_aws
def test_list_model_package_groups_sort_order():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package_group(
@@ -170,7 +169,7 @@ def test_list_model_package_groups_sort_order():
)
-@mock_sagemaker
+@mock_aws
def test_describe_model_package_group():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't freeze time in ServerMode")
@@ -195,7 +194,7 @@ def test_describe_model_package_group():
assert resp["CreationTime"] == datetime(2020, 1, 1, 0, 0, 0, tzinfo=tzutc())
-@mock_sagemaker
+@mock_aws
def test_describe_model_package_group_not_exists():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't freeze time in ServerMode")
@@ -210,7 +209,7 @@ def test_describe_model_package_group_not_exists():
assert "does not exist" in e.value.response["Error"]["Message"]
-@mock_sagemaker
+@mock_aws
def test_list_tags_model_package_group():
region_name = "eu-west-1"
model_package_group_name = "test-model-package-group"
@@ -239,7 +238,7 @@ def test_list_tags_model_package_group():
assert tags_from_paginator == tags
-@mock_sagemaker
+@mock_aws
def test_delete_tags_model_package_group():
region_name = "eu-west-1"
model_package_group_name = "test-model-package-group"
diff --git a/tests/test_sagemaker/test_sagemaker_model_packages.py b/tests/test_sagemaker/test_sagemaker_model_packages.py
index 5d6b0d240..585eccec7 100644
--- a/tests/test_sagemaker/test_sagemaker_model_packages.py
+++ b/tests/test_sagemaker/test_sagemaker_model_packages.py
@@ -1,4 +1,3 @@
-"""Unit tests for sagemaker-supported APIs."""
from datetime import datetime
from unittest import SkipTest, TestCase
@@ -8,7 +7,7 @@ from botocore.exceptions import ClientError
from dateutil.tz import tzutc # type: ignore
from freezegun import freeze_time
-from moto import mock_sagemaker, settings
+from moto import mock_aws, settings
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
@@ -17,7 +16,7 @@ from moto.sagemaker.models import ModelPackage
from moto.sagemaker.utils import validate_model_approval_status
-@mock_sagemaker
+@mock_aws
def test_list_model_packages():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package(
@@ -52,7 +51,7 @@ def test_list_model_packages():
)
-@mock_sagemaker
+@mock_aws
def test_list_model_packages_creation_time_before():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't freeze time in ServerMode")
@@ -72,7 +71,7 @@ def test_list_model_packages_creation_time_before():
assert len(resp["ModelPackageSummaryList"]) == 1
-@mock_sagemaker
+@mock_aws
def test_list_model_packages_creation_time_after():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't freeze time in ServerMode")
@@ -92,7 +91,7 @@ def test_list_model_packages_creation_time_after():
assert len(resp["ModelPackageSummaryList"]) == 1
-@mock_sagemaker
+@mock_aws
def test_list_model_packages_name_contains():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package(
@@ -112,7 +111,7 @@ def test_list_model_packages_name_contains():
assert len(resp["ModelPackageSummaryList"]) == 2
-@mock_sagemaker
+@mock_aws
def test_list_model_packages_approval_status():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package(
@@ -130,7 +129,7 @@ def test_list_model_packages_approval_status():
assert len(resp["ModelPackageSummaryList"]) == 1
-@mock_sagemaker
+@mock_aws
def test_list_model_packages_model_package_group_name():
client = boto3.client("sagemaker", region_name="eu-west-1")
group1 = "test-model-package-group"
@@ -166,7 +165,7 @@ def test_list_model_packages_model_package_group_name():
assert "NextToken" not in resp
-@mock_sagemaker
+@mock_aws
def test_list_model_packages_model_package_type():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package_group(ModelPackageGroupName="test-model-package-group")
@@ -183,7 +182,7 @@ def test_list_model_packages_model_package_type():
assert len(resp["ModelPackageSummaryList"]) == 1
-@mock_sagemaker
+@mock_aws
def test_list_model_packages_sort_by():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package(
@@ -204,7 +203,7 @@ def test_list_model_packages_sort_by():
)
-@mock_sagemaker
+@mock_aws
def test_list_model_packages_sort_order():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package(
@@ -225,7 +224,7 @@ def test_list_model_packages_sort_order():
)
-@mock_sagemaker
+@mock_aws
def test_describe_model_package_default():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't freeze time in ServerMode")
@@ -267,7 +266,7 @@ def test_describe_model_package_default():
assert resp["CertifyForMarketplace"] is False
-@mock_sagemaker
+@mock_aws
def test_describe_model_package_with_create_model_package_arguments():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package(
@@ -293,7 +292,7 @@ def test_describe_model_package_with_create_model_package_arguments():
assert resp["MetadataProperties"]["Repository"] == "test-repo"
-@mock_sagemaker
+@mock_aws
def test_update_model_package():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package_group(ModelPackageGroupName="test-model-package-group")
@@ -319,7 +318,7 @@ def test_update_model_package():
assert resp["CustomerMetadataProperties"].get("test-key-to-remove") is None
-@mock_sagemaker
+@mock_aws
def test_update_model_package_given_additional_inference_specifications_to_add():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package_group(ModelPackageGroupName="test-model-package-group")
@@ -367,7 +366,7 @@ def test_update_model_package_given_additional_inference_specifications_to_add()
)
-@mock_sagemaker
+@mock_aws
def test_update_model_package_should_update_last_modified_information():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't freeze time in ServerMode")
@@ -409,7 +408,7 @@ def test_validate_supported_realtime_inference_instance_types_should_raise_error
assert "not-a-supported-realtime-inference-instances-types" in str(exc.value)
-@mock_sagemaker
+@mock_aws
def test_create_model_package():
client = boto3.client("sagemaker", region_name="eu-west-1")
resp = client.create_model_package(
@@ -422,7 +421,7 @@ def test_create_model_package():
)
-@mock_sagemaker
+@mock_aws
def test_create_model_package_should_raise_error_when_model_package_group_name_and_model_package_group_name_are_not_provided():
client = boto3.client("sagemaker", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -432,7 +431,7 @@ def test_create_model_package_should_raise_error_when_model_package_group_name_a
assert "Missing ARN." in str(exc.value)
-@mock_sagemaker
+@mock_aws
def test_create_model_package_should_raise_error_when_package_name_and_group_are_provided():
client = boto3.client("sagemaker", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -447,7 +446,7 @@ def test_create_model_package_should_raise_error_when_package_name_and_group_are
)
-@mock_sagemaker
+@mock_aws
def test_create_model_package_should_raise_error_when_model_package_group_provided_not_exist():
client = boto3.client("sagemaker", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -479,7 +478,7 @@ def test_utils_validate_model_approval_status_should_raise_error_if_model_approv
)
-@mock_sagemaker
+@mock_aws
def test_create_model_package_in_model_package_group():
client = boto3.client("sagemaker", region_name="eu-west-1")
client.create_model_package_group(ModelPackageGroupName="test-model-package-group")
diff --git a/tests/test_sagemaker/test_sagemaker_models.py b/tests/test_sagemaker/test_sagemaker_models.py
index 41be9a582..5981503e8 100644
--- a/tests/test_sagemaker/test_sagemaker_models.py
+++ b/tests/test_sagemaker/test_sagemaker_models.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sagemaker
+from moto import mock_aws
from moto.sagemaker.models import VpcConfig
TEST_REGION_NAME = "us-east-1"
@@ -14,7 +14,7 @@ TEST_MODEL_NAME = "MyModelName"
@pytest.fixture(name="sagemaker_client")
def fixture_sagemaker_client():
- with mock_sagemaker():
+ with mock_aws():
yield boto3.client("sagemaker", region_name=TEST_REGION_NAME)
diff --git a/tests/test_sagemaker/test_sagemaker_notebooks.py b/tests/test_sagemaker/test_sagemaker_notebooks.py
index 034261d15..d24f866cd 100644
--- a/tests/test_sagemaker/test_sagemaker_notebooks.py
+++ b/tests/test_sagemaker/test_sagemaker_notebooks.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sagemaker
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
TEST_REGION_NAME = "us-east-1"
@@ -28,7 +28,7 @@ FAKE_INSTANCE_TYPE_PARAM = "ml.t2.medium"
@pytest.fixture(name="client")
def fixture_sagemaker_client():
- with mock_sagemaker():
+ with mock_aws():
yield boto3.client("sagemaker", region_name=TEST_REGION_NAME)
diff --git a/tests/test_sagemaker/test_sagemaker_pipeline.py b/tests/test_sagemaker/test_sagemaker_pipeline.py
index 31443b26b..76a475058 100644
--- a/tests/test_sagemaker/test_sagemaker_pipeline.py
+++ b/tests/test_sagemaker/test_sagemaker_pipeline.py
@@ -8,9 +8,8 @@ import boto3
import botocore
import pytest
-from moto import mock_sagemaker, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-from moto.s3 import mock_s3
from moto.sagemaker.exceptions import ValidationError
from moto.sagemaker.models import FakePipeline, sagemaker_backends
from moto.sagemaker.utils import (
@@ -45,7 +44,7 @@ def setup_s3_pipeline_definition(bucket_name, object_key, pipeline_definition):
@pytest.fixture(name="sagemaker_client")
def fixture_sagemaker_client():
- with mock_sagemaker():
+ with mock_aws():
yield boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -283,7 +282,7 @@ def test_load_pipeline_definition_from_s3():
object_key = "some/object/key.json"
pipeline_definition = {"key": "value"}
- with mock_s3():
+ with mock_aws():
with setup_s3_pipeline_definition(
bucket_name,
object_key,
diff --git a/tests/test_sagemaker/test_sagemaker_processing.py b/tests/test_sagemaker/test_sagemaker_processing.py
index bf68895f5..474acf34a 100644
--- a/tests/test_sagemaker/test_sagemaker_processing.py
+++ b/tests/test_sagemaker/test_sagemaker_processing.py
@@ -5,7 +5,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sagemaker
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
FAKE_ROLE_ARN = f"arn:aws:iam::{ACCOUNT_ID}:role/FakeRole"
@@ -16,7 +16,7 @@ TEST_REGION_NAME = "us-east-1"
@pytest.fixture(name="sagemaker_client")
def fixture_sagemaker_client():
- with mock_sagemaker():
+ with mock_aws():
yield boto3.client("sagemaker", region_name=TEST_REGION_NAME)
diff --git a/tests/test_sagemaker/test_sagemaker_search.py b/tests/test_sagemaker/test_sagemaker_search.py
index ca20cd136..6a4fef741 100644
--- a/tests/test_sagemaker/test_sagemaker_search.py
+++ b/tests/test_sagemaker/test_sagemaker_search.py
@@ -2,14 +2,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sagemaker
+from moto import mock_aws
TEST_REGION_NAME = "us-east-1"
@pytest.fixture(name="sagemaker_client")
def fixture_sagemaker_client():
- with mock_sagemaker():
+ with mock_aws():
yield boto3.client("sagemaker", region_name=TEST_REGION_NAME)
diff --git a/tests/test_sagemaker/test_sagemaker_training.py b/tests/test_sagemaker/test_sagemaker_training.py
index d691619a8..411019237 100644
--- a/tests/test_sagemaker/test_sagemaker_training.py
+++ b/tests/test_sagemaker/test_sagemaker_training.py
@@ -5,7 +5,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sagemaker
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
FAKE_ROLE_ARN = f"arn:aws:iam::{ACCOUNT_ID}:role/FakeRole"
@@ -99,7 +99,7 @@ class MyTrainingJobModel:
return sagemaker.create_training_job(**params)
-@mock_sagemaker
+@mock_aws
def test_create_training_job():
sagemaker = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -218,7 +218,7 @@ def test_create_training_job():
assert "Timestamp" in resp["FinalMetricDataList"][0]
-@mock_sagemaker
+@mock_aws
def test_list_training_jobs():
client = boto3.client("sagemaker", region_name="us-east-1")
name = "blah"
@@ -236,7 +236,7 @@ def test_list_training_jobs():
assert training_jobs.get("NextToken") is None
-@mock_sagemaker
+@mock_aws
def test_list_training_jobs_multiple():
client = boto3.client("sagemaker", region_name="us-east-1")
name_job_1 = "blah"
@@ -260,14 +260,14 @@ def test_list_training_jobs_multiple():
assert training_jobs.get("NextToken") is None
-@mock_sagemaker
+@mock_aws
def test_list_training_jobs_none():
client = boto3.client("sagemaker", region_name="us-east-1")
training_jobs = client.list_training_jobs()
assert len(training_jobs["TrainingJobSummaries"]) == 0
-@mock_sagemaker
+@mock_aws
def test_list_training_jobs_should_validate_input():
client = boto3.client("sagemaker", region_name="us-east-1")
junk_status_equals = "blah"
@@ -292,7 +292,7 @@ def test_list_training_jobs_should_validate_input():
)
-@mock_sagemaker
+@mock_aws
def test_list_training_jobs_with_name_filters():
client = boto3.client("sagemaker", region_name="us-east-1")
for i in range(5):
@@ -310,7 +310,7 @@ def test_list_training_jobs_with_name_filters():
assert len(training_jobs_with_2["TrainingJobSummaries"]) == 2
-@mock_sagemaker
+@mock_aws
def test_list_training_jobs_paginated():
client = boto3.client("sagemaker", region_name="us-east-1")
for i in range(5):
@@ -340,7 +340,7 @@ def test_list_training_jobs_paginated():
assert xgboost_training_job_next.get("NextToken") is not None
-@mock_sagemaker
+@mock_aws
def test_list_training_jobs_paginated_with_target_in_middle():
client = boto3.client("sagemaker", region_name="us-east-1")
for i in range(5):
@@ -369,7 +369,7 @@ def test_list_training_jobs_paginated_with_target_in_middle():
assert vgg_training_job_10.get("NextToken") is None
-@mock_sagemaker
+@mock_aws
def test_list_training_jobs_paginated_with_fragmented_targets():
client = boto3.client("sagemaker", region_name="us-east-1")
for i in range(5):
@@ -400,7 +400,7 @@ def test_list_training_jobs_paginated_with_fragmented_targets():
assert training_jobs_with_2_next_next.get("NextToken") is None
-@mock_sagemaker
+@mock_aws
def test_add_tags_to_training_job():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
name = "blah"
@@ -420,7 +420,7 @@ def test_add_tags_to_training_job():
assert response["Tags"] == tags
-@mock_sagemaker
+@mock_aws
def test_delete_tags_from_training_job():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
name = "blah"
@@ -444,7 +444,7 @@ def test_delete_tags_from_training_job():
assert response["Tags"] == []
-@mock_sagemaker
+@mock_aws
def test_describe_unknown_training_job():
client = boto3.client("sagemaker", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
diff --git a/tests/test_sagemaker/test_sagemaker_transform.py b/tests/test_sagemaker/test_sagemaker_transform.py
index 956b21fd1..281593b44 100644
--- a/tests/test_sagemaker/test_sagemaker_transform.py
+++ b/tests/test_sagemaker/test_sagemaker_transform.py
@@ -5,7 +5,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sagemaker
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
FAKE_ROLE_ARN = f"arn:aws:iam::{ACCOUNT_ID}:role/FakeRole"
@@ -86,7 +86,7 @@ class MyTransformJobModel:
return sagemaker.create_transform_job(**params)
-@mock_sagemaker
+@mock_aws
def test_create_transform_job():
sagemaker = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
transform_job_name = "MyTransformJob"
@@ -171,7 +171,7 @@ def test_create_transform_job():
assert isinstance(resp["TransformEndTime"], datetime.datetime)
-@mock_sagemaker
+@mock_aws
def test_list_transform_jobs():
client = boto3.client("sagemaker", region_name="us-east-1")
name = "blah"
@@ -191,7 +191,7 @@ def test_list_transform_jobs():
assert transform_jobs.get("NextToken") is None
-@mock_sagemaker
+@mock_aws
def test_list_transform_jobs_multiple():
client = boto3.client("sagemaker", region_name="us-east-1")
name_job_1 = "blah"
@@ -215,14 +215,14 @@ def test_list_transform_jobs_multiple():
assert transform_jobs.get("NextToken") is None
-@mock_sagemaker
+@mock_aws
def test_list_transform_jobs_none():
client = boto3.client("sagemaker", region_name="us-east-1")
transform_jobs = client.list_transform_jobs()
assert len(transform_jobs["TransformJobSummaries"]) == 0
-@mock_sagemaker
+@mock_aws
def test_list_transform_jobs_should_validate_input():
client = boto3.client("sagemaker", region_name="us-east-1")
junk_status_equals = "blah"
@@ -247,7 +247,7 @@ def test_list_transform_jobs_should_validate_input():
)
-@mock_sagemaker
+@mock_aws
def test_list_transform_jobs_with_name_filters():
client = boto3.client("sagemaker", region_name="us-east-1")
for i in range(5):
@@ -265,7 +265,7 @@ def test_list_transform_jobs_with_name_filters():
assert len(transform_jobs_with_2["TransformJobSummaries"]) == 2
-@mock_sagemaker
+@mock_aws
def test_list_transform_jobs_paginated():
client = boto3.client("sagemaker", region_name="us-east-1")
for i in range(5):
@@ -295,7 +295,7 @@ def test_list_transform_jobs_paginated():
assert xgboost_transform_job_next.get("NextToken") is not None
-@mock_sagemaker
+@mock_aws
def test_list_transform_jobs_paginated_with_target_in_middle():
client = boto3.client("sagemaker", region_name="us-east-1")
for i in range(5):
@@ -327,7 +327,7 @@ def test_list_transform_jobs_paginated_with_target_in_middle():
assert vgg_transform_job_10.get("NextToken") is None
-@mock_sagemaker
+@mock_aws
def test_list_transform_jobs_paginated_with_fragmented_targets():
client = boto3.client("sagemaker", region_name="us-east-1")
for i in range(5):
@@ -357,7 +357,7 @@ def test_list_transform_jobs_paginated_with_fragmented_targets():
assert transform_jobs_with_2_next_next.get("NextToken") is None
-@mock_sagemaker
+@mock_aws
def test_add_tags_to_transform_job():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
name = "blah"
@@ -378,7 +378,7 @@ def test_add_tags_to_transform_job():
assert response["Tags"] == tags
-@mock_sagemaker
+@mock_aws
def test_delete_tags_from_transform_job():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
name = "blah"
@@ -403,7 +403,7 @@ def test_delete_tags_from_transform_job():
assert response["Tags"] == []
-@mock_sagemaker
+@mock_aws
def test_describe_unknown_transform_job():
client = boto3.client("sagemaker", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
diff --git a/tests/test_sagemaker/test_sagemaker_trial.py b/tests/test_sagemaker/test_sagemaker_trial.py
index a727aabb9..80f85945d 100644
--- a/tests/test_sagemaker/test_sagemaker_trial.py
+++ b/tests/test_sagemaker/test_sagemaker_trial.py
@@ -2,13 +2,13 @@ import uuid
import boto3
-from moto import mock_sagemaker
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
TEST_REGION_NAME = "us-east-1"
-@mock_sagemaker
+@mock_aws
def test_create_trial():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -32,7 +32,7 @@ def test_create_trial():
)
-@mock_sagemaker
+@mock_aws
def test_list_trials():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -64,7 +64,7 @@ def test_list_trials():
assert resp.get("NextToken") is None
-@mock_sagemaker
+@mock_aws
def test_list_trials_by_trial_component_name():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -86,7 +86,7 @@ def test_list_trials_by_trial_component_name():
assert len(resp["TrialSummaries"]) == 0
-@mock_sagemaker
+@mock_aws
def test_delete_trial():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -106,7 +106,7 @@ def test_delete_trial():
assert len(resp["TrialSummaries"]) == 0
-@mock_sagemaker
+@mock_aws
def test_add_tags_to_trial():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -133,7 +133,7 @@ def test_add_tags_to_trial():
assert resp["Tags"] == tags
-@mock_sagemaker
+@mock_aws
def test_delete_tags_to_trial():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -162,7 +162,7 @@ def test_delete_tags_to_trial():
assert resp["Tags"] == []
-@mock_sagemaker
+@mock_aws
def test_list_trial_tags():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
diff --git a/tests/test_sagemaker/test_sagemaker_trial_component.py b/tests/test_sagemaker/test_sagemaker_trial_component.py
index 6f33596e9..95cfdd7c7 100644
--- a/tests/test_sagemaker/test_sagemaker_trial_component.py
+++ b/tests/test_sagemaker/test_sagemaker_trial_component.py
@@ -4,13 +4,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sagemaker
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
TEST_REGION_NAME = "us-east-1"
-@mock_sagemaker
+@mock_aws
def test_create__trial_component():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -32,7 +32,7 @@ def test_create__trial_component():
)
-@mock_sagemaker
+@mock_aws
def test_list_trial_components():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -60,7 +60,7 @@ def test_list_trial_components():
assert resp.get("NextToken") is None
-@mock_sagemaker
+@mock_aws
def test_delete__trial_component():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -76,7 +76,7 @@ def test_delete__trial_component():
assert len(resp["TrialComponentSummaries"]) == 0
-@mock_sagemaker
+@mock_aws
def test_add_tags_to_trial_component():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -99,7 +99,7 @@ def test_add_tags_to_trial_component():
assert resp["Tags"] == tags
-@mock_sagemaker
+@mock_aws
def test_delete_tags_to_trial_component():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -124,7 +124,7 @@ def test_delete_tags_to_trial_component():
assert resp["Tags"] == []
-@mock_sagemaker
+@mock_aws
def test_list_trial_component_tags():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -151,7 +151,7 @@ def test_list_trial_component_tags():
assert response["Tags"] == tags[50:]
-@mock_sagemaker
+@mock_aws
def test_associate_trial_component():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
@@ -206,7 +206,7 @@ def test_associate_trial_component():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_sagemaker
+@mock_aws
def test_disassociate_trial_component():
client = boto3.client("sagemaker", region_name=TEST_REGION_NAME)
diff --git a/tests/test_sagemakerruntime/test_sagemakerruntime.py b/tests/test_sagemakerruntime/test_sagemakerruntime.py
index 9ccece62a..0d6633a8b 100644
--- a/tests/test_sagemakerruntime/test_sagemakerruntime.py
+++ b/tests/test_sagemakerruntime/test_sagemakerruntime.py
@@ -3,14 +3,14 @@ import json
import boto3
import requests
-from moto import mock_s3, mock_sagemakerruntime, settings
+from moto import mock_aws, settings
from moto.s3.utils import bucket_and_name_from_url
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_sagemakerruntime
+@mock_aws
def test_invoke_endpoint__default_results():
client = boto3.client("sagemaker-runtime", region_name="ap-southeast-1")
body = client.invoke_endpoint(
@@ -21,7 +21,7 @@ def test_invoke_endpoint__default_results():
assert body["CustomAttributes"] == "custom_attributes"
-@mock_sagemakerruntime
+@mock_aws
def test_invoke_endpoint():
client = boto3.client("sagemaker-runtime", region_name="us-east-1")
base_url = (
@@ -59,8 +59,7 @@ def test_invoke_endpoint():
assert body["Body"].read() == b"second body"
-@mock_s3
-@mock_sagemakerruntime
+@mock_aws
def test_invoke_endpoint_async():
client = boto3.client("sagemaker-runtime", region_name="us-east-1")
base_url = (
diff --git a/tests/test_scheduler/test_schedule_groups.py b/tests/test_scheduler/test_schedule_groups.py
index fae0e455f..9b40261de 100644
--- a/tests/test_scheduler/test_schedule_groups.py
+++ b/tests/test_scheduler/test_schedule_groups.py
@@ -1,16 +1,15 @@
-"""Unit tests for scheduler-supported APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_scheduler
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_scheduler
+@mock_aws
def test_create_get_delete_schedule_group():
client = boto3.client("scheduler", region_name="eu-west-1")
arn = client.create_schedule_group(Name="sg")["ScheduleGroupArn"]
@@ -30,7 +29,7 @@ def test_create_get_delete_schedule_group():
assert err["Code"] == "ResourceNotFoundException"
-@mock_scheduler
+@mock_aws
def test_list_schedule_groups():
client = boto3.client("scheduler", region_name="ap-southeast-1")
diff --git a/tests/test_scheduler/test_scheduler.py b/tests/test_scheduler/test_scheduler.py
index c613cb5f6..04c7d4f7f 100644
--- a/tests/test_scheduler/test_scheduler.py
+++ b/tests/test_scheduler/test_scheduler.py
@@ -1,18 +1,17 @@
-"""Unit tests for scheduler-supported APIs."""
from datetime import datetime
import boto3
import pytest
from botocore.client import ClientError
-from moto import mock_scheduler
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_scheduler
+@mock_aws
def test_create_get_schedule():
client = boto3.client("scheduler", region_name="eu-west-1")
arn = client.create_schedule(
@@ -51,7 +50,7 @@ def test_create_get_schedule():
assert resp["CreationDate"] == resp["LastModificationDate"]
-@mock_scheduler
+@mock_aws
def test_create_get_delete__in_different_group():
client = boto3.client("scheduler", region_name="eu-west-1")
@@ -94,7 +93,7 @@ def test_create_get_delete__in_different_group():
],
ids=["without_group", "with_group"],
)
-@mock_scheduler
+@mock_aws
def test_update_schedule(extra_kwargs):
client = boto3.client("scheduler", region_name="eu-west-1")
@@ -145,7 +144,7 @@ def test_update_schedule(extra_kwargs):
assert schedule["CreationDate"] != schedule["LastModificationDate"]
-@mock_scheduler
+@mock_aws
def test_create_duplicate_schedule():
client = boto3.client("scheduler", region_name="us-east-1")
params = {
@@ -165,7 +164,7 @@ def test_create_duplicate_schedule():
assert err["Message"] == "Schedule schedule1 already exists."
-@mock_scheduler
+@mock_aws
def test_get_schedule_for_unknown_group():
client = boto3.client("scheduler", region_name="eu-west-1")
@@ -175,7 +174,7 @@ def test_get_schedule_for_unknown_group():
assert err["Code"] == "ResourceNotFoundException"
-@mock_scheduler
+@mock_aws
def test_get_schedule_for_none_existing_schedule():
client = boto3.client("scheduler", region_name="eu-west-1")
@@ -186,7 +185,7 @@ def test_get_schedule_for_none_existing_schedule():
assert err["Message"] == "Schedule my-schedule does not exist."
-@mock_scheduler
+@mock_aws
def test_list_schedules():
client = boto3.client("scheduler", region_name="eu-west-1")
@@ -219,7 +218,7 @@ def test_list_schedules():
assert len(schedules) == 4
-@mock_scheduler
+@mock_aws
def test_delete_schedule_for_none_existing_schedule():
client = boto3.client("scheduler", region_name="eu-west-1")
diff --git a/tests/test_scheduler/test_scheduler_tags.py b/tests/test_scheduler/test_scheduler_tags.py
index c1c7d25d0..2a696d303 100644
--- a/tests/test_scheduler/test_scheduler_tags.py
+++ b/tests/test_scheduler/test_scheduler_tags.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_scheduler
+from moto import mock_aws
-@mock_scheduler
+@mock_aws
def test_schedule_tags():
client = boto3.client("scheduler", "us-east-1")
arn = client.create_schedule(
@@ -36,7 +36,7 @@ def test_schedule_tags():
assert resp["Tags"] == [{"Key": "k2", "Value": "v2"}]
-@mock_scheduler
+@mock_aws
def test_schedule_group_tags():
client = boto3.client("scheduler", "us-east-1")
arn = client.create_schedule_group(
diff --git a/tests/test_sdb/test_sdb_attributes.py b/tests/test_sdb/test_sdb_attributes.py
index 337279bb2..f7ea5a88f 100644
--- a/tests/test_sdb/test_sdb_attributes.py
+++ b/tests/test_sdb/test_sdb_attributes.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sdb
+from moto import mock_aws
-@mock_sdb
+@mock_aws
def test_put_attributes_unknown_domain():
sdb = boto3.client("sdb", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -18,7 +18,7 @@ def test_put_attributes_unknown_domain():
assert "BoxUsage" in err
-@mock_sdb
+@mock_aws
def test_put_attributes_invalid_domain():
sdb = boto3.client("sdb", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -31,7 +31,7 @@ def test_put_attributes_invalid_domain():
assert "BoxUsage" in err
-@mock_sdb
+@mock_aws
def test_get_attributes_unknown_domain():
sdb = boto3.client("sdb", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -42,7 +42,7 @@ def test_get_attributes_unknown_domain():
assert "BoxUsage" in err
-@mock_sdb
+@mock_aws
def test_get_attributes_invalid_domain():
sdb = boto3.client("sdb", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -53,7 +53,7 @@ def test_get_attributes_invalid_domain():
assert "BoxUsage" in err
-@mock_sdb
+@mock_aws
def test_put_and_get_attributes():
name = "mydomain"
sdb = boto3.client("sdb", region_name="eu-west-1")
@@ -67,7 +67,7 @@ def test_put_and_get_attributes():
assert attrs == [{"Name": "a", "Value": "b"}]
-@mock_sdb
+@mock_aws
def test_put_multiple_and_get_attributes():
name = "mydomain"
sdb = boto3.client("sdb", region_name="eu-west-1")
@@ -97,7 +97,7 @@ def test_put_multiple_and_get_attributes():
assert attrs == [{"Name": "a", "Value": "val"}]
-@mock_sdb
+@mock_aws
def test_put_replace_and_get_attributes():
name = "mydomain"
sdb = boto3.client("sdb", region_name="eu-west-1")
@@ -128,7 +128,7 @@ def test_put_replace_and_get_attributes():
assert {"Name": "d", "Value": "g"} in attrs
-@mock_sdb
+@mock_aws
def test_put_and_get_multiple_attributes():
name = "mydomain"
sdb = boto3.client("sdb", region_name="eu-west-1")
@@ -144,7 +144,7 @@ def test_put_and_get_multiple_attributes():
assert attrs == [{"Name": "a", "Value": "b"}, {"Name": "attr2", "Value": "myvalue"}]
-@mock_sdb
+@mock_aws
def test_get_attributes_by_name():
name = "mydomain"
sdb = boto3.client("sdb", region_name="eu-west-1")
diff --git a/tests/test_sdb/test_sdb_domains.py b/tests/test_sdb/test_sdb_domains.py
index 6a9265264..64ee1e6a6 100644
--- a/tests/test_sdb/test_sdb_domains.py
+++ b/tests/test_sdb/test_sdb_domains.py
@@ -2,10 +2,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sdb
+from moto import mock_aws
-@mock_sdb
+@mock_aws
@pytest.mark.parametrize("name", ["", "a", "a#", "aaa#", "as@asdff", "asf'qwer"])
def test_create_domain_invalid(name):
# Error handling is always the same
@@ -18,7 +18,7 @@ def test_create_domain_invalid(name):
assert "BoxUsage" in err
-@mock_sdb
+@mock_aws
@pytest.mark.parametrize(
"name", ["abc", "ABc", "a00", "as-df", "jk_kl", "qw.rt", "asfljaejadslfsl"]
)
@@ -28,7 +28,7 @@ def test_create_domain_valid(name):
sdb.create_domain(DomainName=name)
-@mock_sdb
+@mock_aws
def test_create_domain_and_list():
sdb = boto3.client("sdb", region_name="eu-west-1")
sdb.create_domain(DomainName="mydomain")
@@ -37,7 +37,7 @@ def test_create_domain_and_list():
assert all_domains == ["mydomain"]
-@mock_sdb
+@mock_aws
def test_delete_domain():
sdb = boto3.client("sdb", region_name="eu-west-1")
sdb.create_domain(DomainName="mydomain")
@@ -47,7 +47,7 @@ def test_delete_domain():
assert "DomainNames" not in all_domains
-@mock_sdb
+@mock_aws
def test_delete_domain_unknown():
sdb = boto3.client("sdb", region_name="eu-west-1")
sdb.delete_domain(DomainName="unknown")
@@ -56,7 +56,7 @@ def test_delete_domain_unknown():
assert "DomainNames" not in all_domains
-@mock_sdb
+@mock_aws
def test_delete_domain_invalid():
sdb = boto3.client("sdb", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
diff --git a/tests/test_sdb/test_server.py b/tests/test_sdb/test_server.py
index 343198af6..dede2a26e 100644
--- a/tests/test_sdb/test_server.py
+++ b/tests/test_sdb/test_server.py
@@ -1,9 +1,8 @@
-"""Test different server responses."""
import moto.server as server
-from moto import mock_sdb
+from moto import mock_aws
-@mock_sdb
+@mock_aws
def test_sdb_list():
backend = server.create_backend_app("sdb")
test_client = backend.test_client()
diff --git a/tests/test_secretsmanager/test_list_secrets.py b/tests/test_secretsmanager/test_list_secrets.py
index a69510e95..3efcfe53e 100644
--- a/tests/test_secretsmanager/test_list_secrets.py
+++ b/tests/test_secretsmanager/test_list_secrets.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from datetime import datetime
import boto3
@@ -6,14 +5,14 @@ import pytest
from botocore.exceptions import ClientError
from dateutil.tz import tzlocal
-from moto import mock_secretsmanager
+from moto import mock_aws
def boto_client():
return boto3.client("secretsmanager", region_name="us-west-2")
-@mock_secretsmanager
+@mock_aws
def test_empty():
conn = boto_client()
@@ -22,7 +21,7 @@ def test_empty():
assert secrets["SecretList"] == []
-@mock_secretsmanager
+@mock_aws
def test_list_secrets():
conn = boto_client()
@@ -49,7 +48,7 @@ def test_list_secrets():
assert secrets["SecretList"][1]["LastChangedDate"] <= datetime.now(tz=tzlocal())
-@mock_secretsmanager
+@mock_aws
def test_with_name_filter():
conn = boto_client()
@@ -62,7 +61,7 @@ def test_with_name_filter():
assert secret_names == ["foo"]
-@mock_secretsmanager
+@mock_aws
def test_with_tag_key_filter():
conn = boto_client()
@@ -77,7 +76,7 @@ def test_with_tag_key_filter():
assert secret_names == ["foo"]
-@mock_secretsmanager
+@mock_aws
def test_with_tag_value_filter():
conn = boto_client()
@@ -92,7 +91,7 @@ def test_with_tag_value_filter():
assert secret_names == ["foo"]
-@mock_secretsmanager
+@mock_aws
def test_with_description_filter():
conn = boto_client()
@@ -105,7 +104,7 @@ def test_with_description_filter():
assert secret_names == ["foo"]
-@mock_secretsmanager
+@mock_aws
def test_with_all_filter():
# The 'all' filter will match a secret that contains ANY field with
# the criteria. In other words an implicit OR.
@@ -131,7 +130,7 @@ def test_with_all_filter():
assert sorted(secret_names) == ["bar", "baz", "foo", "multi", "qux"]
-@mock_secretsmanager
+@mock_aws
def test_with_no_filter_key():
conn = boto_client()
@@ -142,7 +141,7 @@ def test_with_no_filter_key():
assert ire.value.response["Error"]["Message"] == "Invalid filter key"
-@mock_secretsmanager
+@mock_aws
def test_with_no_filter_values():
conn = boto_client()
@@ -157,7 +156,7 @@ def test_with_no_filter_values():
)
-@mock_secretsmanager
+@mock_aws
def test_with_invalid_filter_key():
conn = boto_client()
@@ -172,7 +171,7 @@ def test_with_invalid_filter_key():
)
-@mock_secretsmanager
+@mock_aws
def test_with_duplicate_filter_keys():
# Multiple filters with the same key combine with an implicit AND operator
@@ -194,7 +193,7 @@ def test_with_duplicate_filter_keys():
assert secret_names == ["foo"]
-@mock_secretsmanager
+@mock_aws
def test_with_multiple_filters():
# Multiple filters combine with an implicit AND operator
@@ -224,7 +223,7 @@ def test_with_multiple_filters():
assert secret_names == ["foo"]
-@mock_secretsmanager
+@mock_aws
def test_with_filter_with_multiple_values():
conn = boto_client()
@@ -238,7 +237,7 @@ def test_with_filter_with_multiple_values():
assert secret_names == ["foo", "bar"]
-@mock_secretsmanager
+@mock_aws
def test_with_filter_with_value_with_multiple_words():
conn = boto_client()
@@ -254,7 +253,7 @@ def test_with_filter_with_value_with_multiple_words():
assert secret_names == ["foo", "bar"]
-@mock_secretsmanager
+@mock_aws
def test_with_filter_with_negation():
conn = boto_client()
diff --git a/tests/test_secretsmanager/test_policy.py b/tests/test_secretsmanager/test_policy.py
index e5ce60f14..2ab42d2cf 100644
--- a/tests/test_secretsmanager/test_policy.py
+++ b/tests/test_secretsmanager/test_policy.py
@@ -4,10 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_secretsmanager
+from moto import mock_aws
-@mock_secretsmanager
+@mock_aws
def test_get_initial_policy():
client = boto3.client("secretsmanager", region_name="us-west-2")
client.create_secret(Name="test-secret")
@@ -18,7 +18,7 @@ def test_get_initial_policy():
assert "ResourcePolicy" not in resp
-@mock_secretsmanager
+@mock_aws
def test_put_resource_policy():
client = boto3.client("secretsmanager", region_name="us-west-2")
client.create_secret(Name="test-secret")
@@ -48,7 +48,7 @@ def test_put_resource_policy():
assert json.loads(resp["ResourcePolicy"]) == policy
-@mock_secretsmanager
+@mock_aws
def test_delete_resource_policy():
client = boto3.client("secretsmanager", region_name="us-west-2")
client.create_secret(Name="test-secret")
@@ -61,7 +61,7 @@ def test_delete_resource_policy():
assert "ResourcePolicy" not in resp
-@mock_secretsmanager
+@mock_aws
def test_policies_for_unknown_secrets():
client = boto3.client("secretsmanager", region_name="us-west-2")
diff --git a/tests/test_secretsmanager/test_secretsmanager.py b/tests/test_secretsmanager/test_secretsmanager.py
index 08c76d17e..bec994d1f 100644
--- a/tests/test_secretsmanager/test_secretsmanager.py
+++ b/tests/test_secretsmanager/test_secretsmanager.py
@@ -11,13 +11,13 @@ from botocore.exceptions import ClientError, ParamValidationError
from dateutil.tz import tzlocal
from freezegun import freeze_time
-from moto import mock_lambda, mock_secretsmanager, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
DEFAULT_SECRET_NAME = "test-secret7"
-@mock_secretsmanager
+@mock_aws
def test_get_secret_value():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -26,7 +26,7 @@ def test_get_secret_value():
assert result["SecretString"] == "foosecret"
-@mock_secretsmanager
+@mock_aws
def test_secret_arn():
region = "us-west-2"
conn = boto3.client("secretsmanager", region_name=region)
@@ -42,7 +42,7 @@ def test_secret_arn():
)
-@mock_secretsmanager
+@mock_aws
def test_create_secret_with_client_request_token():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -56,7 +56,7 @@ def test_create_secret_with_client_request_token():
assert create_dict["VersionId"] == version_id
-@mock_secretsmanager
+@mock_aws
def test_get_secret_value_by_arn():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -72,7 +72,7 @@ def test_get_secret_value_by_arn():
assert result["SecretString"] == secret_value
-@mock_secretsmanager
+@mock_aws
def test_get_secret_value_binary():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -81,7 +81,7 @@ def test_get_secret_value_binary():
assert result["SecretBinary"] == b"foosecret"
-@mock_secretsmanager
+@mock_aws
def test_get_secret_that_does_not_exist():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -94,7 +94,7 @@ def test_get_secret_that_does_not_exist():
)
-@mock_secretsmanager
+@mock_aws
def test_get_secret_that_does_not_match():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name="java-util-test-password", SecretString="foosecret")
@@ -108,7 +108,7 @@ def test_get_secret_that_does_not_match():
)
-@mock_secretsmanager
+@mock_aws
def test_get_secret_value_that_is_marked_deleted():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -120,7 +120,7 @@ def test_get_secret_value_that_is_marked_deleted():
conn.get_secret_value(SecretId="test-secret")
-@mock_secretsmanager
+@mock_aws
def test_get_secret_that_has_no_value():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -135,7 +135,7 @@ def test_get_secret_that_has_no_value():
)
-@mock_secretsmanager
+@mock_aws
def test_get_secret_version_that_does_not_exist():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -152,7 +152,7 @@ def test_get_secret_version_that_does_not_exist():
) == cm.value.response["Error"]["Message"]
-@mock_secretsmanager
+@mock_aws
def test_get_secret_version_stage_mismatch():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -179,7 +179,7 @@ def test_get_secret_version_stage_mismatch():
) == cm.value.response["Error"]["Message"]
-@mock_secretsmanager
+@mock_aws
def test_create_secret():
conn = boto3.client("secretsmanager", region_name="us-east-1")
@@ -190,7 +190,7 @@ def test_create_secret():
assert secret["SecretString"] == "foosecret"
-@mock_secretsmanager
+@mock_aws
def test_create_secret_with_tags():
conn = boto3.client("secretsmanager", region_name="us-east-1")
secret_name = "test-secret-with-tags"
@@ -211,7 +211,7 @@ def test_create_secret_with_tags():
]
-@mock_secretsmanager
+@mock_aws
def test_create_secret_with_description():
conn = boto3.client("secretsmanager", region_name="us-east-1")
secret_name = "test-secret-with-tags"
@@ -227,7 +227,7 @@ def test_create_secret_with_description():
assert secret_details["Description"] == "desc"
-@mock_secretsmanager
+@mock_aws
def test_create_secret_with_tags_and_description():
conn = boto3.client("secretsmanager", region_name="us-east-1")
secret_name = "test-secret-with-tags"
@@ -250,7 +250,7 @@ def test_create_secret_with_tags_and_description():
assert secret_details["Description"] == "desc"
-@mock_secretsmanager
+@mock_aws
def test_create_secret_without_value():
conn = boto3.client("secretsmanager", region_name="us-east-2")
secret_name = f"secret-{str(uuid4())[0:6]}"
@@ -292,7 +292,7 @@ def test_create_secret_without_value():
assert set(deleted.keys()) == {"ARN", "Name", "DeletionDate", "ResponseMetadata"}
-@mock_secretsmanager
+@mock_aws
def test_create_secret_that_has_no_value_and_then_update():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -308,7 +308,7 @@ def test_create_secret_that_has_no_value_and_then_update():
assert secret["SecretString"] == "barsecret"
-@mock_secretsmanager
+@mock_aws
def test_update_secret_without_value():
conn = boto3.client("secretsmanager", region_name="us-east-2")
secret_name = f"secret-{str(uuid4())[0:6]}"
@@ -352,7 +352,7 @@ def test_update_secret_without_value():
conn.delete_secret(SecretId=secret_name)
-@mock_secretsmanager
+@mock_aws
def test_delete_secret():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -371,7 +371,7 @@ def test_delete_secret():
assert secret_details["DeletedDate"] > datetime.fromtimestamp(1, timezone.utc)
-@mock_secretsmanager
+@mock_aws
def test_delete_secret_by_arn():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -390,7 +390,7 @@ def test_delete_secret_by_arn():
assert secret_details["DeletedDate"] > datetime.fromtimestamp(1, timezone.utc)
-@mock_secretsmanager
+@mock_aws
def test_delete_secret_force():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -406,7 +406,7 @@ def test_delete_secret_force():
conn.get_secret_value(SecretId="test-secret")
-@mock_secretsmanager
+@mock_aws
def test_delete_secret_force_no_such_secret():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -417,7 +417,7 @@ def test_delete_secret_force_no_such_secret():
assert deleted_secret["Name"] == DEFAULT_SECRET_NAME
-@mock_secretsmanager
+@mock_aws
def test_delete_secret_force_with_arn():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -435,7 +435,7 @@ def test_delete_secret_force_with_arn():
conn.get_secret_value(SecretId="test-secret")
-@mock_secretsmanager
+@mock_aws
def test_delete_secret_that_does_not_exist():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -443,7 +443,7 @@ def test_delete_secret_that_does_not_exist():
conn.delete_secret(SecretId="i-dont-exist")
-@mock_secretsmanager
+@mock_aws
def test_delete_secret_fails_with_both_force_delete_flag_and_recovery_window_flag():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -457,7 +457,7 @@ def test_delete_secret_fails_with_both_force_delete_flag_and_recovery_window_fla
)
-@mock_secretsmanager
+@mock_aws
def test_delete_secret_recovery_window_invalid_values():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -474,7 +474,7 @@ def test_delete_secret_recovery_window_invalid_values():
)
-@mock_secretsmanager
+@mock_aws
def test_delete_secret_force_no_such_secret_with_invalid_recovery_window():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -493,7 +493,7 @@ def test_delete_secret_force_no_such_secret_with_invalid_recovery_window():
)
-@mock_secretsmanager
+@mock_aws
def test_delete_secret_that_is_marked_deleted():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -505,7 +505,7 @@ def test_delete_secret_that_is_marked_deleted():
conn.delete_secret(SecretId="test-secret")
-@mock_secretsmanager
+@mock_aws
def test_get_random_password_default_length():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -513,7 +513,7 @@ def test_get_random_password_default_length():
assert len(random_password["RandomPassword"]) == 32
-@mock_secretsmanager
+@mock_aws
def test_get_random_password_default_requirements():
# When require_each_included_type, default true
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -526,7 +526,7 @@ def test_get_random_password_default_requirements():
assert any(c in string.punctuation for c in random_password["RandomPassword"])
-@mock_secretsmanager
+@mock_aws
def test_get_random_password_custom_length():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -534,7 +534,7 @@ def test_get_random_password_custom_length():
assert len(random_password["RandomPassword"]) == 50
-@mock_secretsmanager
+@mock_aws
def test_get_random_exclude_lowercase():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -542,7 +542,7 @@ def test_get_random_exclude_lowercase():
assert not any(c.islower() for c in random_password["RandomPassword"])
-@mock_secretsmanager
+@mock_aws
def test_get_random_exclude_uppercase():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -550,7 +550,7 @@ def test_get_random_exclude_uppercase():
assert not any(c.isupper() for c in random_password["RandomPassword"])
-@mock_secretsmanager
+@mock_aws
def test_get_random_exclude_characters_and_symbols():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -561,7 +561,7 @@ def test_get_random_exclude_characters_and_symbols():
assert len(random_password["RandomPassword"]) == 20
-@mock_secretsmanager
+@mock_aws
def test_get_random_exclude_numbers():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -569,7 +569,7 @@ def test_get_random_exclude_numbers():
assert not any(c.isdigit() for c in random_password["RandomPassword"])
-@mock_secretsmanager
+@mock_aws
def test_get_random_exclude_punctuation():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -579,7 +579,7 @@ def test_get_random_exclude_punctuation():
assert not any(c in string.punctuation for c in random_password["RandomPassword"])
-@mock_secretsmanager
+@mock_aws
def test_get_random_include_space_false():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -587,7 +587,7 @@ def test_get_random_include_space_false():
assert not any(c.isspace() for c in random_password["RandomPassword"])
-@mock_secretsmanager
+@mock_aws
def test_get_random_include_space_true():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -595,7 +595,7 @@ def test_get_random_include_space_true():
assert any(c.isspace() for c in random_password["RandomPassword"])
-@mock_secretsmanager
+@mock_aws
def test_get_random_require_each_included_type():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -608,7 +608,7 @@ def test_get_random_require_each_included_type():
assert any(c in string.digits for c in random_password["RandomPassword"])
-@mock_secretsmanager
+@mock_aws
def test_get_random_too_short_password():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -616,7 +616,7 @@ def test_get_random_too_short_password():
conn.get_random_password(PasswordLength=3)
-@mock_secretsmanager
+@mock_aws
def test_get_random_too_long_password():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -624,7 +624,7 @@ def test_get_random_too_long_password():
conn.get_random_password(PasswordLength=5555)
-@mock_secretsmanager
+@mock_aws
def test_describe_secret():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name="test-secret", SecretString="foosecret")
@@ -653,7 +653,7 @@ def test_describe_secret():
)
-@mock_secretsmanager
+@mock_aws
@pytest.mark.parametrize("name", ["testsecret", "test-secret"])
def test_describe_secret_with_arn(name):
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -675,7 +675,7 @@ def test_describe_secret_with_arn(name):
assert resp["Name"] == name
-@mock_secretsmanager
+@mock_aws
def test_describe_secret_with_KmsKeyId():
conn = boto3.client("secretsmanager", region_name="us-west-2")
results = conn.create_secret(
@@ -690,7 +690,7 @@ def test_describe_secret_with_KmsKeyId():
)
-@mock_secretsmanager
+@mock_aws
def test_describe_secret_that_does_not_exist():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -698,7 +698,7 @@ def test_describe_secret_that_does_not_exist():
conn.get_secret_value(SecretId="i-dont-exist")
-@mock_secretsmanager
+@mock_aws
def test_describe_secret_that_does_not_match():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name="test-secret", SecretString="foosecret")
@@ -707,7 +707,7 @@ def test_describe_secret_that_does_not_match():
conn.get_secret_value(SecretId="i-dont-match")
-@mock_secretsmanager
+@mock_aws
def test_restore_secret():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -728,7 +728,7 @@ def test_restore_secret():
assert "DeletedDate" not in described_secret_after
-@mock_secretsmanager
+@mock_aws
def test_restore_secret_that_is_not_deleted():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -739,7 +739,7 @@ def test_restore_secret_that_is_not_deleted():
assert restored_secret["Name"] == "test-secret"
-@mock_secretsmanager
+@mock_aws
def test_restore_secret_that_does_not_exist():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -747,14 +747,14 @@ def test_restore_secret_that_does_not_exist():
conn.restore_secret(SecretId="i-dont-exist")
-@mock_secretsmanager
+@mock_aws
def test_cancel_rotate_secret_with_invalid_secret_id():
conn = boto3.client("secretsmanager", region_name="us-east-1")
with pytest.raises(ClientError):
conn.cancel_rotate_secret(SecretId="invalid_id")
-@mock_secretsmanager
+@mock_aws
def test_cancel_rotate_secret_after_delete():
conn = boto3.client("secretsmanager", region_name="us-east-1")
conn.create_secret(
@@ -769,7 +769,7 @@ def test_cancel_rotate_secret_after_delete():
conn.cancel_rotate_secret(SecretId=DEFAULT_SECRET_NAME)
-@mock_secretsmanager
+@mock_aws
def test_cancel_rotate_secret_before_enable():
conn = boto3.client("secretsmanager", region_name="us-east-1")
conn.create_secret(
@@ -779,7 +779,7 @@ def test_cancel_rotate_secret_before_enable():
conn.cancel_rotate_secret(SecretId=DEFAULT_SECRET_NAME)
-@mock_secretsmanager
+@mock_aws
def test_cancel_rotate_secret():
if not settings.TEST_SERVER_MODE:
raise SkipTest("rotation requires a server to be running")
@@ -816,7 +816,7 @@ def test_cancel_rotate_secret():
assert cancelled_rotation["RotationLambdaARN"]
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret():
# Setup
frozen_time = datetime(2023, 5, 20, 10, 20, 30, tzinfo=tzlocal())
@@ -855,7 +855,7 @@ def test_rotate_secret():
)
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_without_secretstring():
# This test just verifies that Moto does not fail
conn = boto3.client("secretsmanager", region_name="us-east-2")
@@ -872,7 +872,7 @@ def test_rotate_secret_without_secretstring():
assert describe_secret["Description"] == "foodescription"
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_enable_rotation():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name=DEFAULT_SECRET_NAME, SecretString="foosecret")
@@ -890,7 +890,7 @@ def test_rotate_secret_enable_rotation():
assert rotated_description["RotationRules"]["AutomaticallyAfterDays"] == 42
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_that_is_marked_deleted():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -902,7 +902,7 @@ def test_rotate_secret_that_is_marked_deleted():
conn.rotate_secret(SecretId="test-secret")
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_that_does_not_exist():
conn = boto3.client("secretsmanager", "us-west-2")
@@ -910,7 +910,7 @@ def test_rotate_secret_that_does_not_exist():
conn.rotate_secret(SecretId="i-dont-exist")
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_that_does_not_match():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name="test-secret", SecretString="foosecret")
@@ -919,7 +919,7 @@ def test_rotate_secret_that_does_not_match():
conn.rotate_secret(SecretId="i-dont-match")
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_client_request_token_too_short():
# Test is intentionally empty. Boto3 catches too short ClientRequestToken
# and raises ParamValidationError before Moto can see it.
@@ -927,7 +927,7 @@ def test_rotate_secret_client_request_token_too_short():
assert True
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_client_request_token_too_long():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name=DEFAULT_SECRET_NAME, SecretString="foosecret")
@@ -941,7 +941,7 @@ def test_rotate_secret_client_request_token_too_long():
)
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_rotation_lambda_arn_too_long():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name=DEFAULT_SECRET_NAME, SecretString="foosecret")
@@ -953,7 +953,7 @@ def test_rotate_secret_rotation_lambda_arn_too_long():
)
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_rotation_period_zero():
# Test is intentionally empty. Boto3 catches zero day rotation period
# and raises ParamValidationError before Moto can see it.
@@ -961,7 +961,7 @@ def test_rotate_secret_rotation_period_zero():
assert True
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_rotation_period_too_long():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name=DEFAULT_SECRET_NAME, SecretString="foosecret")
@@ -1044,8 +1044,7 @@ def lambda_handler(event, context):
if settings.TEST_SERVER_MODE:
- @mock_lambda
- @mock_secretsmanager
+ @mock_aws
def test_rotate_secret_using_lambda():
from tests.test_awslambda.utilities import get_role_name
@@ -1096,7 +1095,7 @@ if settings.TEST_SERVER_MODE:
assert updated_secret["SecretString"] == "UpdatedValue"
-@mock_secretsmanager
+@mock_aws
def test_put_secret_value_on_non_existing_secret():
conn = boto3.client("secretsmanager", region_name="us-west-2")
with pytest.raises(ClientError) as cm:
@@ -1111,7 +1110,7 @@ def test_put_secret_value_on_non_existing_secret():
)
-@mock_secretsmanager
+@mock_aws
def test_put_secret_value_puts_new_secret():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name=DEFAULT_SECRET_NAME, SecretBinary=b"foosecret")
@@ -1130,7 +1129,7 @@ def test_put_secret_value_puts_new_secret():
assert get_secret_value_dict["SecretString"] == "foosecret"
-@mock_secretsmanager
+@mock_aws
def test_put_secret_binary_value_puts_new_secret():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name=DEFAULT_SECRET_NAME, SecretBinary=b"foosecret")
@@ -1149,7 +1148,7 @@ def test_put_secret_binary_value_puts_new_secret():
assert get_secret_value_dict["SecretBinary"] == b"foosecret"
-@mock_secretsmanager
+@mock_aws
def test_create_and_put_secret_binary_value_puts_new_secret():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name=DEFAULT_SECRET_NAME, SecretBinary=b"foosecret")
@@ -1163,7 +1162,7 @@ def test_create_and_put_secret_binary_value_puts_new_secret():
assert latest_secret["SecretBinary"] == b"foosecret_update"
-@mock_secretsmanager
+@mock_aws
def test_put_secret_binary_requires_either_string_or_binary():
conn = boto3.client("secretsmanager", region_name="us-west-2")
with pytest.raises(ClientError) as ire:
@@ -1175,7 +1174,7 @@ def test_put_secret_binary_requires_either_string_or_binary():
)
-@mock_secretsmanager
+@mock_aws
def test_put_secret_value_can_get_first_version_if_put_twice():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name=DEFAULT_SECRET_NAME, SecretBinary=b"foosecret")
@@ -1199,7 +1198,7 @@ def test_put_secret_value_can_get_first_version_if_put_twice():
assert first_secret_value == "first_secret"
-@mock_secretsmanager
+@mock_aws
def test_put_secret_value_versions_differ_if_same_secret_put_twice():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name=DEFAULT_SECRET_NAME, SecretBinary="foosecret")
@@ -1219,7 +1218,7 @@ def test_put_secret_value_versions_differ_if_same_secret_put_twice():
assert first_version_id != second_version_id
-@mock_secretsmanager
+@mock_aws
def test_put_secret_value_maintains_description_and_tags():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1252,7 +1251,7 @@ def test_put_secret_value_maintains_description_and_tags():
assert secret_details["VersionIdsToStages"][current_version_id] == ["AWSCURRENT"]
-@mock_secretsmanager
+@mock_aws
def test_can_list_secret_version_ids():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name=DEFAULT_SECRET_NAME, SecretBinary="foosecret")
@@ -1276,7 +1275,7 @@ def test_can_list_secret_version_ids():
assert [first_version_id, second_version_id].sort() == returned_version_ids.sort()
-@mock_secretsmanager
+@mock_aws
def test_put_secret_value_version_stages_response():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1302,7 +1301,7 @@ def test_put_secret_value_version_stages_response():
assert second_put_res_dict["VersionStages"] == second_version_stages
-@mock_secretsmanager
+@mock_aws
def test_put_secret_value_version_stages_pending_response():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1328,7 +1327,7 @@ def test_put_secret_value_version_stages_pending_response():
assert second_put_res_dict["VersionStages"] == second_version_stages
-@mock_secretsmanager
+@mock_aws
def test_after_put_secret_value_version_stages_can_get_current():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1358,7 +1357,7 @@ def test_after_put_secret_value_version_stages_can_get_current():
assert get_dict["VersionStages"] == ["AWSCURRENT"]
-@mock_secretsmanager
+@mock_aws
def test_after_put_secret_value_version_stages_can_get_current_with_custom_version_stage():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1406,7 +1405,7 @@ def test_after_put_secret_value_version_stages_can_get_current_with_custom_versi
assert versions_by_key[third_version_id]["VersionStages"] == ["SAMPLESTAGE1"]
-@mock_secretsmanager
+@mock_aws
def test_after_put_secret_value_version_stages_pending_can_get_current():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1436,7 +1435,7 @@ def test_after_put_secret_value_version_stages_pending_can_get_current():
assert get_dict["VersionStages"] == ["AWSCURRENT"]
-@mock_secretsmanager
+@mock_aws
@pytest.mark.parametrize("pass_arn", [True, False])
def test_update_secret(pass_arn):
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1469,7 +1468,7 @@ def test_update_secret(pass_arn):
assert conn.describe_secret(SecretId=secret_id)["Description"] == "new desc"
-@mock_secretsmanager
+@mock_aws
@pytest.mark.parametrize("pass_arn", [True, False])
def test_update_secret_updates_last_changed_dates(pass_arn):
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1498,7 +1497,7 @@ def test_update_secret_updates_last_changed_dates(pass_arn):
)
-@mock_secretsmanager
+@mock_aws
def test_update_secret_with_tags_and_description():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1535,7 +1534,7 @@ def test_update_secret_with_tags_and_description():
assert secret_details["Description"] == "desc"
-@mock_secretsmanager
+@mock_aws
def test_update_secret_with_KmsKeyId():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1569,7 +1568,7 @@ def test_update_secret_with_KmsKeyId():
assert secret_details["KmsKeyId"] == "bar_arn"
-@mock_secretsmanager
+@mock_aws
def test_update_secret_which_does_not_exit():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1582,7 +1581,7 @@ def test_update_secret_which_does_not_exit():
)
-@mock_secretsmanager
+@mock_aws
def test_update_secret_marked_as_deleted():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1597,7 +1596,7 @@ def test_update_secret_marked_as_deleted():
)
-@mock_secretsmanager
+@mock_aws
def test_update_secret_marked_as_deleted_after_restoring():
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1614,7 +1613,7 @@ def test_update_secret_marked_as_deleted_after_restoring():
assert updated_secret["VersionId"] != ""
-@mock_secretsmanager
+@mock_aws
@pytest.mark.parametrize("pass_arn", [True, False])
def test_tag_resource(pass_arn):
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1648,7 +1647,7 @@ def test_tag_resource(pass_arn):
)
-@mock_secretsmanager
+@mock_aws
@pytest.mark.parametrize("pass_arn", [True, False])
def test_untag_resource(pass_arn):
conn = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1677,7 +1676,7 @@ def test_untag_resource(pass_arn):
)
-@mock_secretsmanager
+@mock_aws
def test_secret_versions_to_stages_attribute_discrepancy():
client = boto3.client("secretsmanager", region_name="us-west-2")
@@ -1706,7 +1705,7 @@ def test_secret_versions_to_stages_attribute_discrepancy():
assert describe_vtos == list_vtos
-@mock_secretsmanager
+@mock_aws
def test_update_secret_with_client_request_token():
client = boto3.client("secretsmanager", region_name="us-west-2")
secret_name = "test-secret"
diff --git a/tests/test_secretsmanager/test_server.py b/tests/test_secretsmanager/test_server.py
index 60c8978d4..0d318ce2c 100644
--- a/tests/test_secretsmanager/test_server.py
+++ b/tests/test_secretsmanager/test_server.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import json
import unittest
@@ -6,7 +5,7 @@ import boto3
import pytest
import moto.server as server
-from moto import mock_iam, mock_lambda, mock_logs, mock_secretsmanager, settings
+from moto import mock_aws, settings
from tests.markers import requires_docker
from tests.test_awslambda.test_lambda import get_test_zip_file1
@@ -19,7 +18,7 @@ def skip_in_server_mode():
raise unittest.SkipTest("No point in testing this in ServerMode")
-@mock_secretsmanager
+@mock_aws
def test_get_secret_value():
backend = server.create_backend_app("secretsmanager")
@@ -41,7 +40,7 @@ def test_get_secret_value():
assert json_data["SecretString"] == "foo-secret"
-@mock_secretsmanager
+@mock_aws
def test_get_secret_that_does_not_exist():
backend = server.create_backend_app("secretsmanager")
@@ -57,7 +56,7 @@ def test_get_secret_that_does_not_exist():
assert json_data["__type"] == "ResourceNotFoundException"
-@mock_secretsmanager
+@mock_aws
def test_get_secret_that_does_not_match():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -77,7 +76,7 @@ def test_get_secret_that_does_not_match():
assert json_data["__type"] == "ResourceNotFoundException"
-@mock_secretsmanager
+@mock_aws
def test_get_secret_that_has_no_value():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -101,7 +100,7 @@ def test_get_secret_that_has_no_value():
assert json_data["__type"] == "ResourceNotFoundException"
-@mock_secretsmanager
+@mock_aws
def test_create_secret():
backend = server.create_backend_app("secretsmanager")
@@ -127,7 +126,7 @@ def test_create_secret():
assert json_data_2["Name"] == "test-secret-2"
-@mock_secretsmanager
+@mock_aws
def test_describe_secret():
backend = server.create_backend_app("secretsmanager")
@@ -166,7 +165,7 @@ def test_describe_secret():
assert json_data_2["Name"] == "test-secret-2"
-@mock_secretsmanager
+@mock_aws
def test_describe_secret_that_does_not_exist():
backend = server.create_backend_app("secretsmanager")
@@ -183,7 +182,7 @@ def test_describe_secret_that_does_not_exist():
assert json_data["__type"] == "ResourceNotFoundException"
-@mock_secretsmanager
+@mock_aws
def test_describe_secret_that_does_not_match():
backend = server.create_backend_app("secretsmanager")
@@ -205,7 +204,7 @@ def test_describe_secret_that_does_not_match():
assert json_data["__type"] == "ResourceNotFoundException"
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -233,7 +232,7 @@ def test_rotate_secret():
assert json_data["VersionId"] == client_request_token
-# @mock_secretsmanager
+# @mock_aws
# def test_rotate_secret_enable_rotation():
# backend = server.create_backend_app('secretsmanager')
# test_client = backend.test_client()
@@ -291,7 +290,7 @@ def test_rotate_secret():
# assert json_data['RotationRules']['AutomaticallyAfterDays'] == 42
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_that_does_not_exist():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -307,7 +306,7 @@ def test_rotate_secret_that_does_not_exist():
assert json_data["__type"] == "ResourceNotFoundException"
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_that_does_not_match():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -329,7 +328,7 @@ def test_rotate_secret_that_does_not_match():
assert json_data["__type"] == "ResourceNotFoundException"
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_that_is_still_rotating():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -373,7 +372,7 @@ def test_rotate_secret_that_is_still_rotating():
assert rotate_secret.status_code == 400
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_client_request_token_too_short():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -399,7 +398,7 @@ def test_rotate_secret_client_request_token_too_short():
assert json_data["__type"] == "InvalidParameterException"
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_client_request_token_too_long():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -427,7 +426,7 @@ def test_rotate_secret_client_request_token_too_long():
assert json_data["__type"] == "InvalidParameterException"
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_rotation_lambda_arn_too_long():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -453,10 +452,7 @@ def test_rotate_secret_rotation_lambda_arn_too_long():
assert json_data["__type"] == "InvalidParameterException"
-@mock_iam
-@mock_lambda
-@mock_logs
-@mock_secretsmanager
+@mock_aws
@requires_docker
def test_rotate_secret_lambda_invocations():
conn = boto3.client("iam", region_name="us-east-1")
@@ -501,10 +497,7 @@ def test_rotate_secret_lambda_invocations():
assert len(logs["logStreams"]) == 4
-@mock_iam
-@mock_lambda
-@mock_logs
-@mock_secretsmanager
+@mock_aws
def test_rotate_secret_with_incorrect_lambda_arn():
secretsmanager_backend = server.create_backend_app("secretsmanager")
secretsmanager_client = secretsmanager_backend.test_client()
@@ -526,7 +519,7 @@ def test_rotate_secret_with_incorrect_lambda_arn():
assert resp.status_code == 404
-@mock_secretsmanager
+@mock_aws
def test_put_secret_value_puts_new_secret():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -576,7 +569,7 @@ def test_put_secret_value_puts_new_secret():
assert second_secret_json_data["SecretString"] == "foosecret"
-@mock_secretsmanager
+@mock_aws
def test_put_secret_value_can_get_first_version_if_put_twice():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -634,7 +627,7 @@ def test_put_secret_value_can_get_first_version_if_put_twice():
assert get_first_secret_json_data["SecretString"] == first_secret_string
-@mock_secretsmanager
+@mock_aws
def test_put_secret_value_versions_differ_if_same_secret_put_twice():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -675,7 +668,7 @@ def test_put_secret_value_versions_differ_if_same_secret_put_twice():
assert first_secret_version_id != second_secret_version_id
-@mock_secretsmanager
+@mock_aws
def test_can_list_secret_version_ids():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -728,7 +721,7 @@ def test_can_list_secret_version_ids():
].sort() == returned_version_ids.sort()
-@mock_secretsmanager
+@mock_aws
def test_get_resource_policy_secret():
backend = server.create_backend_app("secretsmanager")
@@ -751,7 +744,7 @@ def test_get_resource_policy_secret():
assert json_data["Name"] == "test-secret"
-@mock_secretsmanager
+@mock_aws
@pytest.mark.parametrize("pass_arn", [True, False])
def test_update_secret_version_stage(pass_arn):
custom_stage = "CUSTOM_STAGE"
@@ -819,7 +812,7 @@ def test_update_secret_version_stage(pass_arn):
assert stages[new_version] == []
-@mock_secretsmanager
+@mock_aws
def test_update_secret_version_stage_currentversion_handling():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -876,7 +869,7 @@ def test_update_secret_version_stage_currentversion_handling():
assert stages[new_version] == ["AWSPREVIOUS"]
-@mock_secretsmanager
+@mock_aws
def test_update_secret_version_stage_validation():
backend = server.create_backend_app("secretsmanager")
test_client = backend.test_client()
@@ -932,7 +925,7 @@ def test_update_secret_version_stage_validation():
# needs further investigation.
#
-# @mock_secretsmanager
+# @mock_aws
# def test_rotate_secret_rotation_period_zero():
# backend = server.create_backend_app('secretsmanager')
# test_client = backend.test_client()
@@ -957,7 +950,7 @@ def test_update_secret_version_stage_validation():
# assert json_data['message'] == "RotationRules.AutomaticallyAfterDays must be within 1-1000."
# assert json_data['__type'] == 'InvalidParameterException'
-# @mock_secretsmanager
+# @mock_aws
# def test_rotate_secret_rotation_period_too_long():
# backend = server.create_backend_app('secretsmanager')
# test_client = backend.test_client()
diff --git a/tests/test_servicediscovery/test_servicediscovery_httpnamespaces.py b/tests/test_servicediscovery/test_servicediscovery_httpnamespaces.py
index 342c79c84..aa4fc7252 100644
--- a/tests/test_servicediscovery/test_servicediscovery_httpnamespaces.py
+++ b/tests/test_servicediscovery/test_servicediscovery_httpnamespaces.py
@@ -1,18 +1,17 @@
-"""Unit tests for servicediscovery-supported APIs."""
import re
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_servicediscovery
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_servicediscovery
+@mock_aws
def test_create_http_namespace():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_http_namespace(Name="mynamespace")
@@ -36,7 +35,7 @@ def test_create_http_namespace():
assert props["HttpProperties"] == {"HttpName": "mynamespace"}
-@mock_servicediscovery
+@mock_aws
def test_get_http_namespace_minimal():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_http_namespace(Name="mynamespace")
@@ -65,7 +64,7 @@ def test_get_http_namespace_minimal():
assert "Description" not in namespace
-@mock_servicediscovery
+@mock_aws
def test_get_http_namespace():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_http_namespace(
@@ -95,7 +94,7 @@ def test_get_http_namespace():
assert props["HttpProperties"] == {"HttpName": "mynamespace"}
-@mock_servicediscovery
+@mock_aws
def test_delete_namespace():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_http_namespace(Name="mynamespace")
@@ -115,7 +114,7 @@ def test_delete_namespace():
assert client.list_operations()["Operations"] == []
-@mock_servicediscovery
+@mock_aws
def test_delete_unknown_namespace():
client = boto3.client("servicediscovery", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -125,7 +124,7 @@ def test_delete_unknown_namespace():
assert err["Message"] == "unknown"
-@mock_servicediscovery
+@mock_aws
def test_get_unknown_namespace():
client = boto3.client("servicediscovery", region_name="eu-west-1")
with pytest.raises(ClientError) as exc:
@@ -135,7 +134,7 @@ def test_get_unknown_namespace():
assert err["Message"] == "unknown"
-@mock_servicediscovery
+@mock_aws
def test_create_private_dns_namespace_minimal():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_private_dns_namespace(Name="dns_ns", Vpc="vpc_id")
@@ -157,7 +156,7 @@ def test_create_private_dns_namespace_minimal():
assert "SOA" not in props["DnsProperties"]
-@mock_servicediscovery
+@mock_aws
def test_create_private_dns_namespace():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_private_dns_namespace(
@@ -185,7 +184,7 @@ def test_create_private_dns_namespace():
assert props["DnsProperties"]["SOA"] == {"TTL": 123}
-@mock_servicediscovery
+@mock_aws
def test_update_private_dns_namespace():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_private_dns_namespace(
@@ -212,7 +211,7 @@ def test_update_private_dns_namespace():
assert props["DnsProperties"]["SOA"] == {"TTL": 654}
-@mock_servicediscovery
+@mock_aws
def test_create_private_dns_namespace_with_duplicate_vpc():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_private_dns_namespace(Name="dns_ns", Vpc="vpc_id")
@@ -223,7 +222,7 @@ def test_create_private_dns_namespace_with_duplicate_vpc():
assert err["Code"] == "ConflictingDomainExists"
-@mock_servicediscovery
+@mock_aws
def test_create_public_dns_namespace_minimal():
client = boto3.client("servicediscovery", region_name="us-east-2")
client.create_public_dns_namespace(Name="public_dns_ns")
@@ -239,7 +238,7 @@ def test_create_public_dns_namespace_minimal():
assert namespace["Type"] == "DNS_PUBLIC"
-@mock_servicediscovery
+@mock_aws
def test_create_public_dns_namespace():
client = boto3.client("servicediscovery", region_name="us-east-2")
client.create_public_dns_namespace(
@@ -266,7 +265,7 @@ def test_create_public_dns_namespace():
assert dns_props == {"HostedZoneId": "hzi", "SOA": {"TTL": 124}}
-@mock_servicediscovery
+@mock_aws
def test_update_public_dns_namespace():
client = boto3.client("servicediscovery", region_name="us-east-2")
client.create_public_dns_namespace(
diff --git a/tests/test_servicediscovery/test_servicediscovery_operations.py b/tests/test_servicediscovery/test_servicediscovery_operations.py
index 310b2ef39..1eb5b15b8 100644
--- a/tests/test_servicediscovery/test_servicediscovery_operations.py
+++ b/tests/test_servicediscovery/test_servicediscovery_operations.py
@@ -1,17 +1,16 @@
-"""Unit tests for servicediscovery-supported APIs."""
import re
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_servicediscovery
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_servicediscovery
+@mock_aws
def test_list_operations_initial():
client = boto3.client("servicediscovery", region_name="eu-west-1")
resp = client.list_operations()
@@ -19,7 +18,7 @@ def test_list_operations_initial():
assert resp["Operations"] == []
-@mock_servicediscovery
+@mock_aws
def test_list_operations():
client = boto3.client("servicediscovery", region_name="eu-west-2")
@@ -32,7 +31,7 @@ def test_list_operations():
assert resp["Operations"] == [{"Id": op_id, "Status": "SUCCESS"}]
-@mock_servicediscovery
+@mock_aws
def test_get_create_http_namespace_operation():
client = boto3.client("servicediscovery", region_name="eu-west-1")
resp = client.create_http_namespace(Name="mynamespace")
@@ -59,7 +58,7 @@ def test_get_create_http_namespace_operation():
assert targets["NAMESPACE"] in [ns["Id"] for ns in namespaces]
-@mock_servicediscovery
+@mock_aws
def test_get_private_dns_namespace_operation():
client = boto3.client("servicediscovery", region_name="eu-west-1")
resp = client.create_private_dns_namespace(Name="dns_ns", Vpc="vpc_id")
@@ -80,7 +79,7 @@ def test_get_private_dns_namespace_operation():
assert "Targets" in operation
-@mock_servicediscovery
+@mock_aws
def test_get_public_dns_namespace_operation():
client = boto3.client("servicediscovery", region_name="eu-west-1")
resp = client.create_public_dns_namespace(Name="dns_ns")
@@ -101,7 +100,7 @@ def test_get_public_dns_namespace_operation():
assert "Targets" in operation
-@mock_servicediscovery
+@mock_aws
def test_get_update_service_operation():
client = boto3.client("servicediscovery", region_name="eu-west-1")
service_id = client.create_service(
@@ -126,7 +125,7 @@ def test_get_update_service_operation():
assert "Targets" in operation
-@mock_servicediscovery
+@mock_aws
def test_get_unknown_operation():
client = boto3.client("servicediscovery", region_name="eu-west-1")
diff --git a/tests/test_servicediscovery/test_servicediscovery_service.py b/tests/test_servicediscovery/test_servicediscovery_service.py
index 88893161c..0f41d6e5e 100644
--- a/tests/test_servicediscovery/test_servicediscovery_service.py
+++ b/tests/test_servicediscovery/test_servicediscovery_service.py
@@ -1,15 +1,14 @@
-"""Unit tests for servicediscovery-supported APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_servicediscovery
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_servicediscovery
+@mock_aws
def test_create_service_minimal():
client = boto3.client("servicediscovery", region_name="ap-southeast-1")
operation_id = client.create_http_namespace(Name="mynamespace")["OperationId"]
@@ -27,7 +26,7 @@ def test_create_service_minimal():
assert "CreateDate" in resp["Service"]
-@mock_servicediscovery
+@mock_aws
def test_create_service():
client = boto3.client("servicediscovery", region_name="ap-southeast-1")
operation_id = client.create_http_namespace(Name="mynamespace")["OperationId"]
@@ -69,7 +68,7 @@ def test_create_service():
assert resp["Service"]["CreatorRequestId"] == "crid"
-@mock_servicediscovery
+@mock_aws
def test_get_service():
client = boto3.client("servicediscovery", region_name="ap-southeast-1")
@@ -91,7 +90,7 @@ def test_get_service():
assert resp["Service"]["NamespaceId"] == namespace_id
-@mock_servicediscovery
+@mock_aws
def test_get_unknown_service():
client = boto3.client("servicediscovery", region_name="ap-southeast-1")
@@ -102,7 +101,7 @@ def test_get_unknown_service():
assert err["Message"] == "unknown"
-@mock_servicediscovery
+@mock_aws
def test_delete_service():
client = boto3.client("servicediscovery", region_name="eu-west-1")
@@ -123,7 +122,7 @@ def test_delete_service():
assert err["Message"] == service_id
-@mock_servicediscovery
+@mock_aws
def test_update_service_description():
client = boto3.client("servicediscovery", region_name="ap-southeast-1")
operation_id = client.create_http_namespace(Name="mynamespace")["OperationId"]
@@ -164,7 +163,7 @@ def test_update_service_description():
}
-@mock_servicediscovery
+@mock_aws
def test_update_service_others():
client = boto3.client("servicediscovery", region_name="ap-southeast-1")
operation_id = client.create_http_namespace(Name="mynamespace")["OperationId"]
diff --git a/tests/test_servicediscovery/test_servicediscovery_tags.py b/tests/test_servicediscovery/test_servicediscovery_tags.py
index 7c455593b..f135a1f82 100644
--- a/tests/test_servicediscovery/test_servicediscovery_tags.py
+++ b/tests/test_servicediscovery/test_servicediscovery_tags.py
@@ -1,13 +1,12 @@
-"""Unit tests for servicediscovery-supported APIs."""
import boto3
-from moto import mock_servicediscovery
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_servicediscovery
+@mock_aws
def test_create_http_namespace_with_tags():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_http_namespace(
@@ -22,7 +21,7 @@ def test_create_http_namespace_with_tags():
assert resp["Tags"] == [{"Key": "key1", "Value": "val1"}]
-@mock_servicediscovery
+@mock_aws
def test_create_public_dns_namespace_with_tags():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_public_dns_namespace(
@@ -37,7 +36,7 @@ def test_create_public_dns_namespace_with_tags():
assert resp["Tags"] == [{"Key": "key1", "Value": "val1"}]
-@mock_servicediscovery
+@mock_aws
def test_create_private_dns_namespace_with_tags():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_private_dns_namespace(
@@ -52,7 +51,7 @@ def test_create_private_dns_namespace_with_tags():
assert resp["Tags"] == [{"Key": "key1", "Value": "val1"}]
-@mock_servicediscovery
+@mock_aws
def test_create_service_with_tags():
client = boto3.client("servicediscovery", region_name="eu-west-1")
client.create_service(Name="myservice", Tags=[{"Key": "key1", "Value": "val1"}])
@@ -65,7 +64,7 @@ def test_create_service_with_tags():
assert resp["Tags"] == [{"Key": "key1", "Value": "val1"}]
-@mock_servicediscovery
+@mock_aws
def test_tag_resource():
client = boto3.client("servicediscovery", region_name="ap-southeast-1")
client.create_http_namespace(
@@ -84,7 +83,7 @@ def test_tag_resource():
]
-@mock_servicediscovery
+@mock_aws
def test_untag_resource():
client = boto3.client("servicediscovery", region_name="us-east-2")
client.create_http_namespace(Name="mynamespace")
diff --git a/tests/test_servicequotas/test_servicequotas.py b/tests/test_servicequotas/test_servicequotas.py
index 00b84986c..77ae91f44 100644
--- a/tests/test_servicequotas/test_servicequotas.py
+++ b/tests/test_servicequotas/test_servicequotas.py
@@ -1,15 +1,14 @@
-"""Unit tests for servicequotas-supported APIs."""
import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_servicequotas
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_servicequotas
+@mock_aws
def test_list_aws_default_service_quotas():
client = boto3.client("service-quotas", region_name="eu-west-1")
resp = client.list_aws_default_service_quotas(ServiceCode="vpc")
@@ -40,7 +39,7 @@ def test_list_aws_default_service_quotas():
} in resp["Quotas"]
-@mock_servicequotas
+@mock_aws
def test_list_defaults_for_unknown_service():
client = boto3.client("service-quotas", "us-east-1")
@@ -54,7 +53,7 @@ def test_list_defaults_for_unknown_service():
)
-@mock_servicequotas
+@mock_aws
def test_get_service_quota():
client = boto3.client("service-quotas", region_name="us-east-2")
quotas = client.list_aws_default_service_quotas(ServiceCode="vpc")["Quotas"]
@@ -64,7 +63,7 @@ def test_get_service_quota():
assert quota == resp["Quota"]
-@mock_servicequotas
+@mock_aws
def test_get_unknown_service_quota():
client = boto3.client("service-quotas", region_name="us-east-2")
diff --git a/tests/test_ses/__init__.py b/tests/test_ses/__init__.py
index 78e3b825a..208c44bab 100644
--- a/tests/test_ses/__init__.py
+++ b/tests/test_ses/__init__.py
@@ -1,7 +1,7 @@
import os
from functools import wraps
-from moto import mock_ses
+from moto import mock_aws
def ses_aws_verified(func):
@@ -10,7 +10,7 @@ def ses_aws_verified(func):
Can be run against AWS at any time by setting:
MOTO_TEST_ALLOW_AWS_REQUEST=true
- If this environment variable is not set, the function runs in a `mock_ses` context.
+ If this environment variable is not set, the function runs in a `mock_aws` context.
"""
@wraps(func)
@@ -22,7 +22,7 @@ def ses_aws_verified(func):
if allow_aws_request:
resp = func()
else:
- with mock_ses():
+ with mock_aws():
resp = func()
return resp
diff --git a/tests/test_ses/test_server.py b/tests/test_ses/test_server.py
index 0adddcfef..dc4433027 100644
--- a/tests/test_ses/test_server.py
+++ b/tests/test_ses/test_server.py
@@ -1,4 +1,3 @@
-"""Test the different server responses."""
import re
from datetime import datetime
diff --git a/tests/test_ses/test_ses_boto3.py b/tests/test_ses/test_ses_boto3.py
index 4e61f22ba..dfcd8ec6f 100644
--- a/tests/test_ses/test_ses_boto3.py
+++ b/tests/test_ses/test_ses_boto3.py
@@ -6,12 +6,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError, ParamValidationError
-from moto import mock_ses
+from moto import mock_aws
from . import ses_aws_verified
-@mock_ses
+@mock_aws
def test_list_verified_identities():
conn = boto3.client("ses", region_name="us-east-1")
conn.verify_email_identity(EmailAddress="test@example.com")
@@ -40,7 +40,7 @@ def test_list_verified_identities():
)
-@mock_ses
+@mock_aws
def test_identities_are_region_specific():
us_east = boto3.client("ses", region_name="us-east-1")
us_east.verify_email_identity(EmailAddress="test@example.com")
@@ -49,7 +49,7 @@ def test_identities_are_region_specific():
assert not us_west.list_identities()["Identities"]
-@mock_ses
+@mock_aws
def test_verify_email_identity_idempotency():
conn = boto3.client("ses", region_name="us-east-1")
address = "test@example.com"
@@ -61,7 +61,7 @@ def test_verify_email_identity_idempotency():
assert address_list == [address]
-@mock_ses
+@mock_aws
def test_verify_email_address():
conn = boto3.client("ses", region_name="us-east-1")
conn.verify_email_address(EmailAddress="test@example.com")
@@ -70,7 +70,7 @@ def test_verify_email_address():
assert email == "test@example.com"
-@mock_ses
+@mock_aws
def test_delete_identity():
conn = boto3.client("ses", region_name="us-east-1")
conn.verify_email_identity(EmailAddress="test@example.com")
@@ -80,7 +80,7 @@ def test_delete_identity():
assert not conn.list_identities()["Identities"]
-@mock_ses
+@mock_aws
def test_send_email():
conn = boto3.client("ses", region_name="us-east-1")
@@ -112,7 +112,7 @@ def test_send_email():
assert sent_count == 3
-@mock_ses
+@mock_aws
def test_send_email_when_verify_source():
conn = boto3.client("ses", region_name="us-east-1")
@@ -141,7 +141,7 @@ def test_send_email_when_verify_source():
assert sent_count == 2
-@mock_ses
+@mock_aws
def test_send_unverified_email_with_chevrons():
conn = boto3.client("ses", region_name="us-east-1")
@@ -167,7 +167,7 @@ def test_send_unverified_email_with_chevrons():
)
-@mock_ses
+@mock_aws
def test_send_email_invalid_address():
conn = boto3.client("ses", region_name="us-east-1")
conn.verify_domain_identity(Domain="example.com")
@@ -190,7 +190,7 @@ def test_send_email_invalid_address():
assert err["Message"] == "Missing domain"
-@mock_ses
+@mock_aws
def test_send_bulk_templated_email():
conn = boto3.client("ses", region_name="us-east-1")
@@ -286,7 +286,7 @@ def test_send_bulk_templated_email():
assert sent_count == 6
-@mock_ses
+@mock_aws
def test_send_templated_email():
conn = boto3.client("ses", region_name="us-east-1")
@@ -333,7 +333,7 @@ def test_send_templated_email():
assert sent_count == 3
-@mock_ses
+@mock_aws
def test_send_templated_email_invalid_address():
conn = boto3.client("ses", region_name="us-east-1")
conn.verify_domain_identity(Domain="example.com")
@@ -362,7 +362,7 @@ def test_send_templated_email_invalid_address():
assert err["Message"] == "Missing domain"
-@mock_ses
+@mock_aws
def test_send_html_email():
conn = boto3.client("ses", region_name="us-east-1")
@@ -386,7 +386,7 @@ def test_send_html_email():
assert sent_count == 1
-@mock_ses
+@mock_aws
def test_send_raw_email():
conn = boto3.client("ses", region_name="us-east-1")
@@ -405,7 +405,7 @@ def test_send_raw_email():
assert sent_count == 2
-@mock_ses
+@mock_aws
def test_send_raw_email_validate_domain():
conn = boto3.client("ses", region_name="us-east-1")
@@ -424,7 +424,7 @@ def test_send_raw_email_validate_domain():
assert sent_count == 2
-@mock_ses
+@mock_aws
def test_send_raw_email_invalid_address():
conn = boto3.client("ses", region_name="us-east-1")
conn.verify_domain_identity(Domain="example.com")
@@ -458,7 +458,7 @@ def get_raw_email():
return message
-@mock_ses
+@mock_aws
def test_send_raw_email_without_source():
conn = boto3.client("ses", region_name="us-east-1")
@@ -489,7 +489,7 @@ def test_send_raw_email_without_source():
assert sent_count == 2
-@mock_ses
+@mock_aws
def test_send_raw_email_without_source_or_from():
conn = boto3.client("ses", region_name="us-east-1")
@@ -511,7 +511,7 @@ def test_send_raw_email_without_source_or_from():
conn.send_raw_email(**kwargs)
-@mock_ses
+@mock_aws
def test_send_email_notification_with_encoded_sender():
sender = "Foo "
conn = boto3.client("ses", region_name="us-east-1")
@@ -524,7 +524,7 @@ def test_send_email_notification_with_encoded_sender():
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_ses
+@mock_aws
def test_create_configuration_set():
conn = boto3.client("ses", region_name="us-east-1")
conn.create_configuration_set(ConfigurationSet=dict({"Name": "test"}))
@@ -576,7 +576,7 @@ def test_create_configuration_set():
assert ex.value.response["Error"]["Code"] == "EventDestinationAlreadyExists"
-@mock_ses
+@mock_aws
def test_describe_configuration_set():
conn = boto3.client("ses", region_name="us-east-1")
@@ -595,7 +595,7 @@ def test_describe_configuration_set():
assert config_set["ConfigurationSet"]["Name"] == name
-@mock_ses
+@mock_aws
def test_create_receipt_rule_set():
conn = boto3.client("ses", region_name="us-east-1")
result = conn.create_receipt_rule_set(RuleSetName="testRuleSet")
@@ -608,7 +608,7 @@ def test_create_receipt_rule_set():
assert ex.value.response["Error"]["Code"] == "RuleSetNameAlreadyExists"
-@mock_ses
+@mock_aws
def test_create_receipt_rule():
conn = boto3.client("ses", region_name="us-east-1")
rule_set_name = "testRuleSet"
@@ -707,7 +707,7 @@ def test_create_receipt_rule():
assert ex.value.response["Error"]["Code"] == "RuleSetDoesNotExist"
-@mock_ses
+@mock_aws
def test_describe_receipt_rule_set():
conn = boto3.client("ses", region_name="us-east-1")
create_receipt_rule_set_response = conn.create_receipt_rule_set(
@@ -724,7 +724,7 @@ def test_describe_receipt_rule_set():
assert not result["Rules"]
-@mock_ses
+@mock_aws
def test_describe_receipt_rule_set_with_rules():
conn = boto3.client("ses", region_name="us-east-1")
create_receipt_rule_set_response = conn.create_receipt_rule_set(
@@ -773,7 +773,7 @@ def test_describe_receipt_rule_set_with_rules():
assert result["Rules"][0] == receipt_rule
-@mock_ses
+@mock_aws
def test_describe_receipt_rule():
conn = boto3.client("ses", region_name="us-east-1")
rule_set_name = "testRuleSet"
@@ -875,7 +875,7 @@ def test_describe_receipt_rule():
assert error.value.response["Error"]["Code"] == "RuleDoesNotExist"
-@mock_ses
+@mock_aws
def test_update_receipt_rule():
conn = boto3.client("ses", region_name="us-east-1")
rule_set_name = "testRuleSet"
@@ -1054,7 +1054,7 @@ def test_update_receipt_rule():
) in str(error.value)
-@mock_ses
+@mock_aws
def test_update_receipt_rule_actions():
conn = boto3.client("ses", region_name="us-east-1")
rule_set_name = "testRuleSet"
@@ -1195,7 +1195,7 @@ def test_update_receipt_rule_actions():
) in str(error.value)
-@mock_ses
+@mock_aws
def test_create_ses_template():
conn = boto3.client("ses", region_name="us-east-1")
@@ -1240,7 +1240,7 @@ def test_create_ses_template():
assert result["TemplatesMetadata"][0]["Name"] == "MyTemplate"
-@mock_ses
+@mock_aws
def test_render_template():
conn = boto3.client("ses", region_name="us-east-1")
@@ -1338,7 +1338,7 @@ def test_render_template__advanced():
conn.delete_template(TemplateName="MTT")
-@mock_ses
+@mock_aws
def test_update_ses_template():
conn = boto3.client("ses", region_name="us-east-1")
template = {
@@ -1372,7 +1372,7 @@ def test_update_ses_template():
)
-@mock_ses
+@mock_aws
def test_domains_are_case_insensitive():
client = boto3.client("ses", region_name="us-east-1")
duplicate_domains = [
@@ -1388,7 +1388,7 @@ def test_domains_are_case_insensitive():
assert identities[0] == "example.com"
-@mock_ses
+@mock_aws
def test_get_send_statistics():
conn = boto3.client("ses", region_name="us-east-1")
@@ -1429,7 +1429,7 @@ def test_get_send_statistics():
assert stats[0]["DeliveryAttempts"] == 1
-@mock_ses
+@mock_aws
def test_set_identity_mail_from_domain():
conn = boto3.client("ses", region_name="eu-central-1")
@@ -1511,7 +1511,7 @@ def test_set_identity_mail_from_domain():
assert "MailFromDomainStatus" not in actual_attributes
-@mock_ses
+@mock_aws
def test_get_identity_mail_from_domain_attributes():
conn = boto3.client("ses", region_name="eu-central-1")
@@ -1542,7 +1542,7 @@ def test_get_identity_mail_from_domain_attributes():
assert len(attributes["MailFromDomainAttributes"]["lorem.com"]) == 1
-@mock_ses
+@mock_aws
def test_get_identity_verification_attributes():
conn = boto3.client("ses", region_name="eu-central-1")
diff --git a/tests/test_ses/test_ses_sns_boto3.py b/tests/test_ses/test_ses_sns_boto3.py
index 8c5f17f11..6e49758ea 100644
--- a/tests/test_ses/test_ses_sns_boto3.py
+++ b/tests/test_ses/test_ses_sns_boto3.py
@@ -2,12 +2,12 @@ import json
import boto3
-from moto import mock_ses, mock_sns, mock_sqs
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.ses.models import SESFeedback
-@mock_ses
+@mock_aws
def test_enable_disable_ses_sns_communication():
conn = boto3.client("ses", region_name="us-east-1")
conn.set_identity_notification_topic(
@@ -93,44 +93,34 @@ def __test_sns_feedback__(addr, expected_msg, raw_email=False):
assert len(messages) == 0
-@mock_sqs
-@mock_sns
-@mock_ses
+@mock_aws
def test_no_sns_feedback():
__test_sns_feedback__("test", None)
-@mock_sqs
-@mock_sns
-@mock_ses
+@mock_aws
def test_sns_feedback_bounce():
__test_sns_feedback__(SESFeedback.BOUNCE_ADDR, SESFeedback.BOUNCE)
-@mock_sqs
-@mock_sns
-@mock_ses
+@mock_aws
def test_sns_feedback_complaint():
__test_sns_feedback__(SESFeedback.COMPLAINT_ADDR, SESFeedback.COMPLAINT)
-@mock_sqs
-@mock_sns
-@mock_ses
+@mock_aws
def test_sns_feedback_delivery():
__test_sns_feedback__(SESFeedback.SUCCESS_ADDR, SESFeedback.DELIVERY)
-@mock_sqs
-@mock_sns
-@mock_ses
+@mock_aws
def test_sns_feedback_delivery_raw_email():
__test_sns_feedback__(
SESFeedback.SUCCESS_ADDR, SESFeedback.DELIVERY, raw_email=True
)
-@mock_ses
+@mock_aws
def test_get_identity_notification_attributes_default_values():
ses = boto3.client("ses", region_name="us-east-1")
ses.verify_domain_identity(Domain="example.com")
@@ -151,7 +141,7 @@ def test_get_identity_notification_attributes_default_values():
assert "DeliveryTopic" not in resp["test@example.com"]
-@mock_ses
+@mock_aws
def test_set_identity_feedback_forwarding_enabled():
ses = boto3.client("ses", region_name="us-east-1")
ses.verify_domain_identity(Domain="example.com")
diff --git a/tests/test_sesv2/test_server.py b/tests/test_sesv2/test_server.py
index cc869309a..f33437f68 100644
--- a/tests/test_sesv2/test_server.py
+++ b/tests/test_sesv2/test_server.py
@@ -1,5 +1,3 @@
-"""Test different server responses."""
-
import moto.server as server
diff --git a/tests/test_sesv2/test_sesv2.py b/tests/test_sesv2/test_sesv2.py
index 785369667..0a0a37d19 100644
--- a/tests/test_sesv2/test_sesv2.py
+++ b/tests/test_sesv2/test_sesv2.py
@@ -2,7 +2,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ses, mock_sesv2, settings
+from moto import mock_aws, settings
from moto.ses.models import Message, RawMessage, ses_backends
from tests import DEFAULT_ACCOUNT_ID
@@ -12,11 +12,11 @@ from ..test_ses.test_ses_boto3 import get_raw_email
@pytest.fixture(scope="function")
def ses_v1():
"""Use this for API calls which exist in v1 but not in v2"""
- with mock_ses():
+ with mock_aws():
yield boto3.client("ses", region_name="us-east-1")
-@mock_sesv2
+@mock_aws
def test_send_email(ses_v1): # pylint: disable=redefined-outer-name
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -55,7 +55,7 @@ def test_send_email(ses_v1): # pylint: disable=redefined-outer-name
assert msg.body == "test body"
-@mock_sesv2
+@mock_aws
def test_send_html_email(ses_v1): # pylint: disable=redefined-outer-name
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -88,7 +88,7 @@ def test_send_html_email(ses_v1): # pylint: disable=redefined-outer-name
assert msg.body == "Test HTML
"
-@mock_sesv2
+@mock_aws
def test_send_raw_email(ses_v1): # pylint: disable=redefined-outer-name
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -112,7 +112,7 @@ def test_send_raw_email(ses_v1): # pylint: disable=redefined-outer-name
assert int(send_quota["SentLast24Hours"]) == 4
-@mock_sesv2
+@mock_aws
def test_send_raw_email__with_specific_message(
ses_v1,
): # pylint: disable=redefined-outer-name
@@ -143,7 +143,7 @@ def test_send_raw_email__with_specific_message(
assert msg.destinations == ["to@example.com", "foo@example.com"]
-@mock_sesv2
+@mock_aws
def test_send_raw_email__with_to_address_display_name(
ses_v1,
): # pylint: disable=redefined-outer-name
@@ -178,7 +178,7 @@ def test_send_raw_email__with_to_address_display_name(
]
-@mock_sesv2
+@mock_aws
def test_create_contact_list():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -195,7 +195,7 @@ def test_create_contact_list():
assert result["ContactLists"][0]["ContactListName"] == contact_list_name
-@mock_sesv2
+@mock_aws
def test_create_contact_list__with_topics():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -219,7 +219,7 @@ def test_create_contact_list__with_topics():
assert result["ContactLists"][0]["ContactListName"] == contact_list_name
-@mock_sesv2
+@mock_aws
def test_list_contact_lists():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -231,7 +231,7 @@ def test_list_contact_lists():
assert result["ContactLists"] == []
-@mock_sesv2
+@mock_aws
def test_get_contact_list():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -255,7 +255,7 @@ def test_get_contact_list():
assert result["ContactListName"] == contact_list_name
-@mock_sesv2
+@mock_aws
def test_delete_contact_list():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -279,7 +279,7 @@ def test_delete_contact_list():
assert len(result["ContactLists"]) == 0
-@mock_sesv2
+@mock_aws
def test_list_contacts():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -295,7 +295,7 @@ def test_list_contacts():
assert result["Contacts"] == []
-@mock_sesv2
+@mock_aws
def test_create_contact_no_contact_list():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -317,7 +317,7 @@ def test_create_contact_no_contact_list():
)
-@mock_sesv2
+@mock_aws
def test_create_contact():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -340,7 +340,7 @@ def test_create_contact():
assert result["Contacts"][0]["EmailAddress"] == email
-@mock_sesv2
+@mock_aws
def test_get_contact_no_contact_list():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -359,7 +359,7 @@ def test_get_contact_no_contact_list():
)
-@mock_sesv2
+@mock_aws
def test_get_contact():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -381,7 +381,7 @@ def test_get_contact():
assert result["EmailAddress"] == email
-@mock_sesv2
+@mock_aws
def test_get_contact_no_contact():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -399,7 +399,7 @@ def test_get_contact_no_contact():
assert e.value.response["Error"]["Message"] == f"{email} doesn't exist in List."
-@mock_sesv2
+@mock_aws
def test_delete_contact_no_contact_list():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -418,7 +418,7 @@ def test_delete_contact_no_contact_list():
)
-@mock_sesv2
+@mock_aws
def test_delete_contact_no_contact():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
@@ -436,7 +436,7 @@ def test_delete_contact_no_contact():
assert e.value.response["Error"]["Message"] == f"{email} doesn't exist in List."
-@mock_sesv2
+@mock_aws
def test_delete_contact():
# Setup
conn = boto3.client("sesv2", region_name="us-east-1")
diff --git a/tests/test_signer/test_signing_platforms.py b/tests/test_signer/test_signing_platforms.py
index 4cfdac3dd..c13271ce8 100644
--- a/tests/test_signer/test_signing_platforms.py
+++ b/tests/test_signer/test_signing_platforms.py
@@ -1,13 +1,12 @@
-"""Unit tests for signer-supported APIs."""
import boto3
-from moto import mock_signer
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_signer
+@mock_aws
def test_list_signing_platforms():
client = boto3.client("signer", region_name="us-east-2")
resp = client.list_signing_platforms()
diff --git a/tests/test_signer/test_signing_profiles.py b/tests/test_signer/test_signing_profiles.py
index 049d359bf..5f7103c6e 100644
--- a/tests/test_signer/test_signing_profiles.py
+++ b/tests/test_signer/test_signing_profiles.py
@@ -1,13 +1,12 @@
-"""Unit tests for signer-supported APIs."""
import boto3
-from moto import mock_signer
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_signer
+@mock_aws
def test_put_signing_profile():
client = boto3.client("signer", region_name="eu-west-1")
resp = client.put_signing_profile(profileName="prof1", platformId="pid")
@@ -17,7 +16,7 @@ def test_put_signing_profile():
assert "profileVersionArn" in resp
-@mock_signer
+@mock_aws
def test_get_signing_profile():
client = boto3.client("signer", region_name="eu-west-1")
client.put_signing_profile(profileName="prof1", platformId="AWSLambda-SHA384-ECDSA")
@@ -33,7 +32,7 @@ def test_get_signing_profile():
assert resp["signatureValidityPeriod"] == {"type": "MONTHS", "value": 135}
-@mock_signer
+@mock_aws
def test_get_signing_profile__with_args():
client = boto3.client("signer", region_name="eu-west-1")
profile_arn = client.put_signing_profile(
@@ -64,7 +63,7 @@ def test_get_signing_profile__with_args():
assert tag_list == {"k1": "v1", "k3": "v3"}
-@mock_signer
+@mock_aws
def test_cancel_signing_profile():
client = boto3.client("signer", region_name="eu-west-1")
client.put_signing_profile(profileName="prof1", platformId="AWSLambda-SHA384-ECDSA")
diff --git a/tests/test_sns/__init__.py b/tests/test_sns/__init__.py
index 555f0781f..93b079b76 100644
--- a/tests/test_sns/__init__.py
+++ b/tests/test_sns/__init__.py
@@ -5,7 +5,7 @@ from unittest import SkipTest
import boto3
import botocore
-from moto import mock_sns, mock_sts
+from moto import mock_aws
def sns_aws_verified(func):
@@ -14,7 +14,7 @@ def sns_aws_verified(func):
Can be run against AWS at any time by setting:
MOTO_TEST_ALLOW_AWS_REQUEST=true
- If this environment variable is not set, the function runs in a `mock_ses` context.
+ If this environment variable is not set, the function runs in a `mock_aws` context.
"""
@wraps(func)
@@ -43,7 +43,7 @@ def sns_aws_verified(func):
# https://stackoverflow.com/a/75896532/13245310
raise SkipTest("Can't execute SNS tests without Firebase API key")
else:
- with mock_sns(), mock_sts():
+ with mock_aws():
resp = func("mock_api_key")
return resp
diff --git a/tests/test_sns/test_application_boto3.py b/tests/test_sns/test_application_boto3.py
index 04714bb03..38171d0c7 100644
--- a/tests/test_sns/test_application_boto3.py
+++ b/tests/test_sns/test_application_boto3.py
@@ -4,13 +4,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sns
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from . import sns_aws_verified
-@mock_sns
+@mock_aws
def test_create_platform_application():
conn = boto3.client("sns", region_name="us-east-1")
response = conn.create_platform_application(
@@ -27,7 +27,7 @@ def test_create_platform_application():
)
-@mock_sns
+@mock_aws
def test_get_platform_application_attributes():
conn = boto3.client("sns", region_name="us-east-1")
platform_application = conn.create_platform_application(
@@ -48,14 +48,14 @@ def test_get_platform_application_attributes():
}
-@mock_sns
+@mock_aws
def test_get_missing_platform_application_attributes():
conn = boto3.client("sns", region_name="us-east-1")
with pytest.raises(ClientError):
conn.get_platform_application_attributes(PlatformApplicationArn="a-fake-arn")
-@mock_sns
+@mock_aws
def test_set_platform_application_attributes():
conn = boto3.client("sns", region_name="us-east-1")
platform_application = conn.create_platform_application(
@@ -78,7 +78,7 @@ def test_set_platform_application_attributes():
)
-@mock_sns
+@mock_aws
def test_list_platform_applications():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_platform_application(
@@ -93,7 +93,7 @@ def test_list_platform_applications():
assert len(applications) == 2
-@mock_sns
+@mock_aws
def test_delete_platform_application():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_platform_application(
@@ -115,7 +115,7 @@ def test_delete_platform_application():
assert len(applications) == 1
-@mock_sns
+@mock_aws
def test_create_platform_endpoint():
conn = boto3.client("sns", region_name="us-east-1")
platform_application = conn.create_platform_application(
@@ -279,7 +279,7 @@ def test_get_list_endpoints_by_platform_application(api_key=None):
assert err["Message"] == "PlatformApplication does not exist"
-@mock_sns
+@mock_aws
def test_get_endpoint_attributes():
conn = boto3.client("sns", region_name="us-east-1")
platform_application = conn.create_platform_application(
@@ -319,14 +319,14 @@ def test_get_non_existent_endpoint_attributes(
assert error["Message"] == "Endpoint does not exist"
-@mock_sns
+@mock_aws
def test_get_missing_endpoint_attributes():
conn = boto3.client("sns", region_name="us-east-1")
with pytest.raises(ClientError):
conn.get_endpoint_attributes(EndpointArn="a-fake-arn")
-@mock_sns
+@mock_aws
def test_set_endpoint_attributes():
conn = boto3.client("sns", region_name="us-east-1")
platform_application = conn.create_platform_application(
@@ -351,7 +351,7 @@ def test_set_endpoint_attributes():
)
-@mock_sns
+@mock_aws
def test_delete_endpoint():
conn = boto3.client("sns", region_name="us-east-1")
platform_application = conn.create_platform_application(
@@ -378,7 +378,7 @@ def test_delete_endpoint():
assert len(endpoints) == 0
-@mock_sns
+@mock_aws
def test_publish_to_platform_endpoint():
conn = boto3.client("sns", region_name="us-east-1")
platform_application = conn.create_platform_application(
@@ -431,7 +431,7 @@ def test_publish_to_disabled_platform_endpoint(api_key=None):
conn.delete_platform_application(PlatformApplicationArn=application_arn)
-@mock_sns
+@mock_aws
def test_set_sms_attributes():
conn = boto3.client("sns", region_name="us-east-1")
@@ -447,7 +447,7 @@ def test_set_sms_attributes():
assert response["attributes"]["test"] == "test"
-@mock_sns
+@mock_aws
def test_get_sms_attributes_filtered():
conn = boto3.client("sns", region_name="us-east-1")
@@ -462,7 +462,7 @@ def test_get_sms_attributes_filtered():
assert response["attributes"]["DefaultSMSType"] == "Transactional"
-@mock_sns
+@mock_aws
def test_delete_endpoints_of_delete_app():
conn = boto3.client("sns", region_name="us-east-1")
diff --git a/tests/test_sns/test_publish_batch.py b/tests/test_sns/test_publish_batch.py
index ca3792524..a3da85f5e 100644
--- a/tests/test_sns/test_publish_batch.py
+++ b/tests/test_sns/test_publish_batch.py
@@ -4,11 +4,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sns, mock_sqs
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_sns
+@mock_aws
def test_publish_batch_unknown_topic():
client = boto3.client("sns", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
@@ -21,7 +21,7 @@ def test_publish_batch_unknown_topic():
assert err["Message"] == "Topic does not exist"
-@mock_sns
+@mock_aws
def test_publish_batch_too_many_items():
client = boto3.client("sns", region_name="eu-north-1")
topic = client.create_topic(Name="some-topic")
@@ -38,7 +38,7 @@ def test_publish_batch_too_many_items():
assert err["Message"] == "The batch request contains more entries than permissible."
-@mock_sns
+@mock_aws
def test_publish_batch_non_unique_ids():
client = boto3.client("sns", region_name="us-west-2")
topic = client.create_topic(Name="some-topic")
@@ -57,7 +57,7 @@ def test_publish_batch_non_unique_ids():
)
-@mock_sns
+@mock_aws
def test_publish_batch_fifo_without_message_group_id():
client = boto3.client("sns", region_name="us-east-1")
topic = client.create_topic(
@@ -77,7 +77,7 @@ def test_publish_batch_fifo_without_message_group_id():
)
-@mock_sns
+@mock_aws
def test_publish_batch_standard_with_message_group_id():
client = boto3.client("sns", region_name="us-east-1")
topic_arn = client.create_topic(Name="standard_topic")["TopicArn"]
@@ -105,8 +105,7 @@ def test_publish_batch_standard_with_message_group_id():
}
-@mock_sns
-@mock_sqs
+@mock_aws
def test_publish_batch_to_sqs():
client = boto3.client("sns", region_name="us-east-1")
topic_arn = client.create_topic(Name="standard_topic")["TopicArn"]
@@ -146,8 +145,7 @@ def test_publish_batch_to_sqs():
) in messages
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_batch_to_sqs_raw():
client = boto3.client("sns", region_name="us-east-1")
topic_arn = client.create_topic(Name="standard_topic")["TopicArn"]
diff --git a/tests/test_sns/test_publishing_boto3.py b/tests/test_sns/test_publishing_boto3.py
index 0fadf872c..18961b3e2 100644
--- a/tests/test_sns/test_publishing_boto3.py
+++ b/tests/test_sns/test_publishing_boto3.py
@@ -8,7 +8,7 @@ import pytest
from botocore.exceptions import ClientError
from freezegun import freeze_time
-from moto import mock_sns, mock_sqs, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.core.models import responses_mock
from moto.sns import sns_backends
@@ -41,8 +41,7 @@ def to_comparable_dicts(list_entry: list):
return set(list_entry)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_to_sqs():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -76,8 +75,7 @@ def test_publish_to_sqs():
assert acquired_message == expected
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_to_sqs_raw():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(Name="some-topic")
@@ -102,8 +100,7 @@ def test_publish_to_sqs_raw():
assert messages[0].body == message
-@mock_sns
-@mock_sqs
+@mock_aws
def test_publish_to_sqs_fifo():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(
@@ -121,8 +118,7 @@ def test_publish_to_sqs_fifo():
topic.publish(Message="message", MessageGroupId="message_group_id")
-@mock_sns
-@mock_sqs
+@mock_aws
def test_publish_to_sqs_fifo_with_deduplication_id():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(
@@ -161,8 +157,7 @@ def test_publish_to_sqs_fifo_with_deduplication_id():
)
-@mock_sns
-@mock_sqs
+@mock_aws
def test_publish_to_sqs_fifo_raw_with_deduplication_id():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(
@@ -202,8 +197,7 @@ def test_publish_to_sqs_fifo_raw_with_deduplication_id():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_to_sqs_bad():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -265,8 +259,7 @@ def test_publish_to_sqs_bad():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_to_sqs_msg_attr_byte_value():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -306,8 +299,7 @@ def test_publish_to_sqs_msg_attr_byte_value():
assert message.body == "my message"
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_to_sqs_msg_attr_number_type():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(Name="test-topic")
@@ -334,8 +326,7 @@ def test_publish_to_sqs_msg_attr_number_type():
assert message.body == "test message"
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_to_sqs_msg_attr_different_formats():
"""
Verify different Number-formats are processed correctly
@@ -375,7 +366,7 @@ def test_publish_to_sqs_msg_attr_different_formats():
}
-@mock_sns
+@mock_aws
def test_publish_sms():
client = boto3.client("sns", region_name="us-east-1")
@@ -390,7 +381,7 @@ def test_publish_sms():
)
-@mock_sns
+@mock_aws
def test_publish_bad_sms():
client = boto3.client("sns", region_name="us-east-1")
@@ -407,8 +398,7 @@ def test_publish_bad_sms():
assert "must be less than 1600" in client_err.value.response["Error"]["Message"]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_to_sqs_dump_json():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -456,8 +446,7 @@ def test_publish_to_sqs_dump_json():
assert acquired_message == expected
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_to_sqs_in_different_region():
conn = boto3.client("sns", region_name="us-west-1")
conn.create_topic(Name="some-topic")
@@ -493,7 +482,7 @@ def test_publish_to_sqs_in_different_region():
@freeze_time("2013-01-01")
-@mock_sns
+@mock_aws
def test_publish_to_http():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't mock requests in ServerMode")
@@ -529,8 +518,7 @@ def test_publish_to_http():
assert subject == "my subject"
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_subject():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -561,8 +549,7 @@ def test_publish_subject():
raise RuntimeError("Should have raised an InvalidParameter exception")
-@mock_sqs
-@mock_sns
+@mock_aws
def test_publish_null_subject():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -590,7 +577,7 @@ def test_publish_null_subject():
assert "Subject" not in acquired_message
-@mock_sns
+@mock_aws
def test_publish_message_too_long():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(Name="some-topic")
@@ -602,7 +589,7 @@ def test_publish_message_too_long():
topic.publish(Message="".join(["." for i in range(0, 262144)]))
-@mock_sns
+@mock_aws
def test_publish_fifo_needs_group_id():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(
@@ -619,8 +606,7 @@ def test_publish_fifo_needs_group_id():
topic.publish(Message="message", MessageGroupId="message_group_id")
-@mock_sns
-@mock_sqs
+@mock_aws
def test_publish_group_id_to_non_fifo():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(Name="topic")
@@ -635,7 +621,7 @@ def test_publish_group_id_to_non_fifo():
topic.publish(Message="message")
-@mock_sns
+@mock_aws
def test_publish_fifo_needs_deduplication_id():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(
@@ -660,7 +646,7 @@ def test_publish_fifo_needs_deduplication_id():
)
-@mock_sns
+@mock_aws
def test_publish_deduplication_id_to_non_fifo():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(Name="topic")
@@ -704,8 +690,7 @@ def _setup_filter_policy_test(
return topic, queue
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string():
topic, queue = _setup_filter_policy_test({"store": ["example_corp"]})
@@ -725,8 +710,7 @@ def test_filtering_exact_string():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_message_body():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp"]}, filter_policy_scope="MessageBody"
@@ -744,8 +728,7 @@ def test_filtering_exact_string_message_body():
assert message_bodies == [{"store": "example_corp"}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_multiple_message_attributes():
topic, queue = _setup_filter_policy_test({"store": ["example_corp"]})
@@ -769,8 +752,7 @@ def test_filtering_exact_string_multiple_message_attributes():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_multiple_message_attributes_message_body():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp"]}, filter_policy_scope="MessageBody"
@@ -788,8 +770,7 @@ def test_filtering_exact_string_multiple_message_attributes_message_body():
assert message_bodies == [{"store": "example_corp", "event": "order_cancelled"}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_OR_matching():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp", "different_corp"]}
@@ -817,8 +798,7 @@ def test_filtering_exact_string_OR_matching():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_OR_matching_message_body():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp", "different_corp"]}, filter_policy_scope="MessageBody"
@@ -852,8 +832,7 @@ def test_filtering_exact_string_OR_matching_message_body():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_AND_matching_positive():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp"], "event": ["order_cancelled"]}
@@ -879,8 +858,7 @@ def test_filtering_exact_string_AND_matching_positive():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_AND_matching_positive_message_body():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp"], "event": ["order_cancelled"]},
@@ -911,8 +889,7 @@ def test_filtering_exact_string_AND_matching_positive_message_body():
assert message_bodies == [{"store": "example_corp", "event": "order_cancelled"}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_AND_matching_no_match():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp"], "event": ["order_cancelled"]}
@@ -933,8 +910,7 @@ def test_filtering_exact_string_AND_matching_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_AND_matching_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp"], "event": ["order_cancelled"]},
@@ -958,8 +934,7 @@ def test_filtering_exact_string_AND_matching_no_match_message_body():
assert message_bodies == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_no_match():
topic, queue = _setup_filter_policy_test({"store": ["example_corp"]})
@@ -977,8 +952,7 @@ def test_filtering_exact_string_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp"]}, filter_policy_scope="MessageBody"
@@ -996,8 +970,7 @@ def test_filtering_exact_string_no_match_message_body():
assert message_bodies == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_no_attributes_no_match():
topic, queue = _setup_filter_policy_test({"store": ["example_corp"]})
@@ -1010,8 +983,7 @@ def test_filtering_exact_string_no_attributes_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_empty_body_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp"]}, filter_policy_scope="MessageBody"
@@ -1029,8 +1001,7 @@ def test_filtering_exact_string_empty_body_no_match_message_body():
assert message_bodies == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_number_int():
topic, queue = _setup_filter_policy_test({"price": [100]})
@@ -1046,8 +1017,7 @@ def test_filtering_exact_number_int():
assert message_attributes == [{"price": {"Type": "Number", "Value": "100"}}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_number_int_message_body():
topic, queue = _setup_filter_policy_test(
{"price": [100]}, filter_policy_scope="MessageBody"
@@ -1069,8 +1039,7 @@ def test_filtering_exact_number_int_message_body():
assert message_bodies == [{"price": 100}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_number_float():
topic, queue = _setup_filter_policy_test({"price": [100.1]})
@@ -1086,8 +1055,7 @@ def test_filtering_exact_number_float():
assert message_attributes == [{"price": {"Type": "Number", "Value": "100.1"}}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_number_float_message_body():
topic, queue = _setup_filter_policy_test(
{"price": [100.1]}, filter_policy_scope="MessageBody"
@@ -1109,8 +1077,7 @@ def test_filtering_exact_number_float_message_body():
assert message_bodies == [{"price": 100.1}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_number_float_accuracy():
topic, queue = _setup_filter_policy_test({"price": [100.123456789]})
@@ -1128,8 +1095,7 @@ def test_filtering_exact_number_float_accuracy():
assert message_attributes == [{"price": {"Type": "Number", "Value": "100.1234567"}}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_number_float_accuracy_message_body():
topic, queue = _setup_filter_policy_test(
{"price": [100.123456789]}, filter_policy_scope="MessageBody"
@@ -1151,8 +1117,7 @@ def test_filtering_exact_number_float_accuracy_message_body():
assert message_bodies == [{"price": 100.1234567}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_number_no_match():
topic, queue = _setup_filter_policy_test({"price": [100]})
@@ -1168,8 +1133,7 @@ def test_filtering_exact_number_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_number_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{"price": [100]}, filter_policy_scope="MessageBody"
@@ -1187,8 +1151,7 @@ def test_filtering_exact_number_no_match_message_body():
assert message_bodies == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_number_with_string_no_match():
topic, queue = _setup_filter_policy_test({"price": [100]})
@@ -1204,8 +1167,7 @@ def test_filtering_exact_number_with_string_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_number_with_string_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{"price": [100]}, filter_policy_scope="MessageBody"
@@ -1223,8 +1185,7 @@ def test_filtering_exact_number_with_string_no_match_message_body():
assert message_bodies == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_match():
topic, queue = _setup_filter_policy_test(
{"customer_interests": ["basketball", "baseball"]}
@@ -1254,8 +1215,7 @@ def test_filtering_string_array_match():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_match_message_body():
topic, queue = _setup_filter_policy_test(
{"customer_interests": ["basketball", "baseball"]},
@@ -1278,8 +1238,7 @@ def test_filtering_string_array_match_message_body():
assert message_bodies == [{"customer_interests": ["basketball", "rugby"]}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_no_match():
topic, queue = _setup_filter_policy_test({"customer_interests": ["baseball"]})
@@ -1300,8 +1259,7 @@ def test_filtering_string_array_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{"customer_interests": ["baseball"]}, filter_policy_scope="MessageBody"
@@ -1319,8 +1277,7 @@ def test_filtering_string_array_no_match_message_body():
assert message_bodies == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_with_number_match():
topic, queue = _setup_filter_policy_test({"price": [100, 500]})
@@ -1340,8 +1297,7 @@ def test_filtering_string_array_with_number_match():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_with_number_match_message_body():
topic, queue = _setup_filter_policy_test(
{"price": [100, 500]}, filter_policy_scope="MessageBody"
@@ -1363,8 +1319,7 @@ def test_filtering_string_array_with_number_match_message_body():
assert message_bodies == [{"price": [100, 50]}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_with_number_float_accuracy_match():
topic, queue = _setup_filter_policy_test({"price": [100.123456789, 500]})
@@ -1387,8 +1342,7 @@ def test_filtering_string_array_with_number_float_accuracy_match():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_with_number_float_accuracy_match_message_body():
topic, queue = _setup_filter_policy_test(
{"price": [100.123456789, 500]}, filter_policy_scope="MessageBody"
@@ -1410,8 +1364,7 @@ def test_filtering_string_array_with_number_float_accuracy_match_message_body():
assert message_bodies == [{"price": [100.1234567, 50]}]
-@mock_sqs
-@mock_sns
+@mock_aws
# this is the correct behavior from SNS
def test_filtering_string_array_with_number_no_array_match():
topic, queue = _setup_filter_policy_test({"price": [100, 500]})
@@ -1428,8 +1381,7 @@ def test_filtering_string_array_with_number_no_array_match():
assert message_attributes == [{"price": {"Type": "String.Array", "Value": "100"}}]
-@mock_sqs
-@mock_sns
+@mock_aws
# this is the correct behavior from SNS
def test_filtering_string_array_with_number_no_array_match_message_body():
topic, queue = _setup_filter_policy_test(
@@ -1448,8 +1400,7 @@ def test_filtering_string_array_with_number_no_array_match_message_body():
assert message_bodies == [{"price": 100}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_with_number_no_match():
topic, queue = _setup_filter_policy_test({"price": [500]})
@@ -1467,8 +1418,7 @@ def test_filtering_string_array_with_number_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_with_number_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{"price": [500]}, filter_policy_scope="MessageBody"
@@ -1486,8 +1436,7 @@ def test_filtering_string_array_with_number_no_match_message_body():
assert message_bodies == []
-@mock_sqs
-@mock_sns
+@mock_aws
# this is the correct behavior from SNS
def test_filtering_string_array_with_string_no_array_no_match():
topic, queue = _setup_filter_policy_test({"price": [100]})
@@ -1506,8 +1455,7 @@ def test_filtering_string_array_with_string_no_array_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_string_array_with_string_no_array_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{"price": [100]}, filter_policy_scope="MessageBody"
@@ -1525,8 +1473,7 @@ def test_filtering_string_array_with_string_no_array_no_match_message_body():
assert message_bodies == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_attribute_key_exists_match():
topic, queue = _setup_filter_policy_test({"store": [{"exists": True}]})
@@ -1546,8 +1493,7 @@ def test_filtering_attribute_key_exists_match():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_body_key_exists_message_body():
topic, queue = _setup_filter_policy_test(
{"store": [{"exists": True}]}, filter_policy_scope="MessageBody"
@@ -1565,8 +1511,7 @@ def test_filtering_body_key_exists_message_body():
assert message_bodies == [{"store": "example_corp"}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_attribute_key_exists_no_match():
topic, queue = _setup_filter_policy_test({"store": [{"exists": True}]})
@@ -1584,8 +1529,7 @@ def test_filtering_attribute_key_exists_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_body_key_exists_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{"store": [{"exists": True}]}, filter_policy_scope="MessageBody"
@@ -1603,8 +1547,7 @@ def test_filtering_body_key_exists_no_match_message_body():
assert message_bodies == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_attribute_key_not_exists_match():
topic, queue = _setup_filter_policy_test({"store": [{"exists": False}]})
@@ -1624,8 +1567,7 @@ def test_filtering_attribute_key_not_exists_match():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_body_key_not_exists_match_message_body():
topic, queue = _setup_filter_policy_test(
{"store": [{"exists": False}]}, filter_policy_scope="MessageBody"
@@ -1643,8 +1585,7 @@ def test_filtering_body_key_not_exists_match_message_body():
assert message_bodies == [{"event": "order_cancelled"}]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_attribute_key_not_exists_no_match():
topic, queue = _setup_filter_policy_test({"store": [{"exists": False}]})
@@ -1662,8 +1603,7 @@ def test_filtering_attribute_key_not_exists_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_body_key_not_exists_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{"store": [{"exists": False}]}, filter_policy_scope="MessageBody"
@@ -1681,8 +1621,7 @@ def test_filtering_body_key_not_exists_no_match_message_body():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_all_AND_matching_match():
topic, queue = _setup_filter_policy_test(
{
@@ -1723,8 +1662,7 @@ def test_filtering_all_AND_matching_match():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_all_AND_matching_match_message_body():
topic, queue = _setup_filter_policy_test(
{
@@ -1762,8 +1700,7 @@ def test_filtering_all_AND_matching_match_message_body():
]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_all_AND_matching_no_match():
topic, queue = _setup_filter_policy_test(
{
@@ -1795,8 +1732,7 @@ def test_filtering_all_AND_matching_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_all_AND_matching_no_match_message_body():
topic, queue = _setup_filter_policy_test(
{
@@ -1828,8 +1764,7 @@ def test_filtering_all_AND_matching_no_match_message_body():
assert message_bodies == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_prefix():
topic, queue = _setup_filter_policy_test(
{"customer_interests": [{"prefix": "bas"}]}
@@ -1848,8 +1783,7 @@ def test_filtering_prefix():
assert set(message_bodies) == {"match1", "match3"}
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_prefix_message_body():
topic, queue = _setup_filter_policy_test(
{
@@ -1874,8 +1808,7 @@ def test_filtering_prefix_message_body():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but():
topic, queue = _setup_filter_policy_test(
{"customer_interests": [{"anything-but": "basketball"}]}
@@ -1894,8 +1827,7 @@ def test_filtering_anything_but():
assert set(message_bodies) == {"match2", "match3"}
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_message_body():
topic, queue = _setup_filter_policy_test(
{
@@ -1920,8 +1852,7 @@ def test_filtering_anything_but_message_body():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_multiple_values():
topic, queue = _setup_filter_policy_test(
{"customer_interests": [{"anything-but": ["basketball", "rugby"]}]}
@@ -1940,8 +1871,7 @@ def test_filtering_anything_but_multiple_values():
assert set(message_bodies) == {"match3"}
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_multiple_values_message_body():
topic, queue = _setup_filter_policy_test(
{
@@ -1966,8 +1896,7 @@ def test_filtering_anything_but_multiple_values_message_body():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_prefix():
topic, queue = _setup_filter_policy_test(
{"customer_interests": [{"anything-but": {"prefix": "bas"}}]}
@@ -1987,8 +1916,7 @@ def test_filtering_anything_but_prefix():
assert set(message_bodies) == {"match2"}
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_prefix_message_body():
topic, queue = _setup_filter_policy_test(
{
@@ -2013,8 +1941,7 @@ def test_filtering_anything_but_prefix_message_body():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_unknown():
try:
_setup_filter_policy_test(
@@ -2024,8 +1951,7 @@ def test_filtering_anything_but_unknown():
assert err.response["Error"]["Code"] == "InvalidParameter"
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_unknown_message_body_raises():
try:
_setup_filter_policy_test(
@@ -2038,8 +1964,7 @@ def test_filtering_anything_but_unknown_message_body_raises():
assert err.response["Error"]["Code"] == "InvalidParameter"
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_numeric():
topic, queue = _setup_filter_policy_test(
{"customer_interests": [{"anything-but": [100]}]}
@@ -2058,8 +1983,7 @@ def test_filtering_anything_but_numeric():
assert set(message_bodies) == {"match1", "match3"}
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_numeric_message_body():
topic, queue = _setup_filter_policy_test(
{
@@ -2085,8 +2009,7 @@ def test_filtering_anything_but_numeric_message_body():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_numeric_string():
topic, queue = _setup_filter_policy_test(
{"customer_interests": [{"anything-but": ["100"]}]}
@@ -2105,8 +2028,7 @@ def test_filtering_anything_but_numeric_string():
assert set(message_bodies) == {"match1", "match2", "match3"}
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_anything_but_numeric_string_message_body():
topic, queue = _setup_filter_policy_test(
{
@@ -2136,8 +2058,7 @@ def test_filtering_anything_but_numeric_string_message_body():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_numeric_match():
topic, queue = _setup_filter_policy_test(
{"customer_interests": [{"numeric": ["=", 100]}]}
@@ -2156,8 +2077,7 @@ def test_filtering_numeric_match():
assert set(message_bodies) == {"match2"}
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_numeric_match_message_body():
topic, queue = _setup_filter_policy_test(
{
@@ -2182,8 +2102,7 @@ def test_filtering_numeric_match_message_body():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_numeric_range():
topic, queue = _setup_filter_policy_test(
{"customer_interests": [{"numeric": [">", 49, "<=", 100]}]}
@@ -2202,8 +2121,7 @@ def test_filtering_numeric_range():
assert set(message_bodies) == {"match1", "match2"}
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_numeric_range_message_body():
topic, queue = _setup_filter_policy_test(
{
@@ -2228,8 +2146,7 @@ def test_filtering_numeric_range_message_body():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_message_body_invalid_json_no_match():
topic, queue = _setup_filter_policy_test(
{"store": ["example_corp"]}, filter_policy_scope="MessageBody"
@@ -2247,8 +2164,7 @@ def test_filtering_exact_string_message_body_invalid_json_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_message_body_empty_filter_policy_match():
topic, queue = _setup_filter_policy_test({}, filter_policy_scope="MessageBody")
@@ -2268,8 +2184,7 @@ def test_filtering_exact_string_message_body_empty_filter_policy_match():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_message_body_nested():
topic, queue = _setup_filter_policy_test(
{"store": {"name": ["example_corp"]}}, filter_policy_scope="MessageBody"
@@ -2289,8 +2204,7 @@ def test_filtering_exact_string_message_body_nested():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_exact_string_message_body_nested_no_match():
topic, queue = _setup_filter_policy_test(
{"store": {"name": ["example_corp"]}}, filter_policy_scope="MessageBody"
@@ -2308,8 +2222,7 @@ def test_filtering_exact_string_message_body_nested_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_message_body_nested_prefix():
topic, queue = _setup_filter_policy_test(
{"store": {"name": [{"prefix": "example_corp"}]}},
@@ -2330,8 +2243,7 @@ def test_filtering_message_body_nested_prefix():
)
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_message_body_nested_prefix_no_match():
topic, queue = _setup_filter_policy_test(
{"store": {"name": [{"prefix": "example_corp"}]}},
@@ -2350,8 +2262,7 @@ def test_filtering_message_body_nested_prefix_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_message_body_nested_multiple_prefix():
topic, queue = _setup_filter_policy_test(
{
@@ -2388,8 +2299,7 @@ def test_filtering_message_body_nested_multiple_prefix():
assert message_bodies == [payload]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_message_body_nested_multiple_prefix_no_match():
topic, queue = _setup_filter_policy_test(
{
@@ -2426,8 +2336,7 @@ def test_filtering_message_body_nested_multiple_prefix_no_match():
assert message_attributes == []
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_message_body_nested_multiple_records_partial_match():
topic, queue = _setup_filter_policy_test(
{
@@ -2461,8 +2370,7 @@ def test_filtering_message_body_nested_multiple_records_partial_match():
assert message_bodies == [payload]
-@mock_sqs
-@mock_sns
+@mock_aws
def test_filtering_message_body_nested_multiple_records_match():
topic, queue = _setup_filter_policy_test(
{
diff --git a/tests/test_sns/test_server.py b/tests/test_sns/test_server.py
index 11fa05b4b..394bcaa07 100644
--- a/tests/test_sns/test_server.py
+++ b/tests/test_sns/test_server.py
@@ -1,4 +1,3 @@
-"""Test the different server responses."""
import moto.server as server
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
diff --git a/tests/test_sns/test_sns_cloudformation.py b/tests/test_sns/test_sns_cloudformation.py
index c1d6dbd03..092083ce7 100644
--- a/tests/test_sns/test_sns_cloudformation.py
+++ b/tests/test_sns/test_sns_cloudformation.py
@@ -3,11 +3,10 @@ import json
import boto3
import pytest
-from moto import mock_cloudformation, mock_sns
+from moto import mock_aws
-@mock_cloudformation
-@mock_sns
+@mock_aws
def test_sns_topic():
dummy_template = get_template(with_properties=True)
template_json = json.dumps(dummy_template)
@@ -37,8 +36,7 @@ def test_sns_topic():
assert topic_arn_output["OutputValue"] == topic_arn
-@mock_cloudformation
-@mock_sns
+@mock_aws
def test_sns_update_topic():
dummy_template = get_template(with_properties=True)
sns_template_json = json.dumps(dummy_template)
@@ -69,8 +67,7 @@ def test_sns_update_topic():
assert subscription["Endpoint"] == "https://example-updated.com"
-@mock_cloudformation
-@mock_sns
+@mock_aws
@pytest.mark.parametrize("with_properties", [True, False])
def test_sns_update_remove_topic(with_properties):
dummy_template = get_template(with_properties)
@@ -91,8 +88,7 @@ def test_sns_update_remove_topic(with_properties):
assert len(topics) == 0
-@mock_cloudformation
-@mock_sns
+@mock_aws
@pytest.mark.parametrize("with_properties", [True, False])
def test_sns_delete_topic(with_properties):
sns_template_json = json.dumps(get_template(with_properties))
diff --git a/tests/test_sns/test_subscriptions_boto3.py b/tests/test_sns/test_subscriptions_boto3.py
index a63df5f50..1f7b18279 100644
--- a/tests/test_sns/test_subscriptions_boto3.py
+++ b/tests/test_sns/test_subscriptions_boto3.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sns, mock_sqs
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.sns.models import (
DEFAULT_EFFECTIVE_DELIVERY_POLICY,
@@ -12,7 +12,7 @@ from moto.sns.models import (
)
-@mock_sns
+@mock_aws
def test_subscribe_sms():
client = boto3.client("sns", region_name="us-east-1")
client.create_topic(Name="some-topic")
@@ -26,7 +26,7 @@ def test_subscribe_sms():
assert "SubscriptionArn" in resp
-@mock_sns
+@mock_aws
def test_double_subscription():
client = boto3.client("sns", region_name="us-east-1")
client.create_topic(Name="some-topic")
@@ -43,7 +43,7 @@ def test_double_subscription():
assert resp1["SubscriptionArn"] == resp2["SubscriptionArn"]
-@mock_sns
+@mock_aws
def test_subscribe_bad_sms():
client = boto3.client("sns", region_name="us-east-1")
client.create_topic(Name="some-topic")
@@ -79,7 +79,7 @@ def test_subscribe_bad_sms():
)
-@mock_sns
+@mock_aws
def test_creating_subscription():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -104,7 +104,7 @@ def test_creating_subscription():
assert len(subscriptions) == 0
-@mock_sns
+@mock_aws
def test_unsubscribe_from_deleted_topic():
client = boto3.client("sns", region_name="us-east-1")
client.create_topic(Name="some-topic")
@@ -146,7 +146,7 @@ def test_unsubscribe_from_deleted_topic():
client.unsubscribe(SubscriptionArn=subscription_arn)
-@mock_sns
+@mock_aws
def test_getting_subscriptions_by_topic():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="topic1")
@@ -171,7 +171,7 @@ def test_getting_subscriptions_by_topic():
assert topic1_subscriptions[0]["Endpoint"] == "http://example1.com/"
-@mock_sns
+@mock_aws
def test_subscription_paging():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="topic1")
@@ -208,7 +208,7 @@ def test_subscription_paging():
assert "NextToken" not in topic1_subscriptions
-@mock_sns
+@mock_aws
def test_subscribe_attributes():
client = boto3.client("sns", region_name="us-east-1")
client.create_topic(Name="some-topic")
@@ -236,7 +236,7 @@ def test_subscribe_attributes():
)
-@mock_sns
+@mock_aws
def test_creating_subscription_with_attributes():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -311,8 +311,7 @@ def test_creating_subscription_with_attributes():
)
-@mock_sns
-@mock_sqs
+@mock_aws
def test_delete_subscriptions_on_delete_topic():
sqs = boto3.client("sqs", region_name="us-east-1")
conn = boto3.client("sns", region_name="us-east-1")
@@ -333,7 +332,7 @@ def test_delete_subscriptions_on_delete_topic():
assert len(subscriptions) == 0
-@mock_sns
+@mock_aws
def test_set_subscription_attributes():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -436,7 +435,7 @@ def test_set_subscription_attributes():
)
-@mock_sns
+@mock_aws
def test_subscribe_invalid_filter_policy():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -739,7 +738,7 @@ def test_subscribe_invalid_filter_policy():
)
-@mock_sns
+@mock_aws
def test_check_not_opted_out():
conn = boto3.client("sns", region_name="us-east-1")
response = conn.check_if_phone_number_is_opted_out(phoneNumber="+447428545375")
@@ -748,7 +747,7 @@ def test_check_not_opted_out():
assert response["isOptedOut"] is False
-@mock_sns
+@mock_aws
def test_check_opted_out():
# Phone number ends in 99 so is hardcoded in the endpoint to return opted
# out status
@@ -759,7 +758,7 @@ def test_check_opted_out():
assert response["isOptedOut"] is True
-@mock_sns
+@mock_aws
def test_check_opted_out_invalid():
conn = boto3.client("sns", region_name="us-east-1")
@@ -768,7 +767,7 @@ def test_check_opted_out_invalid():
conn.check_if_phone_number_is_opted_out(phoneNumber="+44742LALALA")
-@mock_sns
+@mock_aws
def test_list_opted_out():
conn = boto3.client("sns", region_name="us-east-1")
response = conn.list_phone_numbers_opted_out()
@@ -777,7 +776,7 @@ def test_list_opted_out():
assert len(response["phoneNumbers"]) > 0
-@mock_sns
+@mock_aws
def test_opt_in():
conn = boto3.client("sns", region_name="us-east-1")
response = conn.list_phone_numbers_opted_out()
@@ -791,7 +790,7 @@ def test_opt_in():
assert len(response["phoneNumbers"]) < current_len
-@mock_sns
+@mock_aws
def test_confirm_subscription():
conn = boto3.client("sns", region_name="us-east-1")
response = conn.create_topic(Name="testconfirm")
@@ -808,7 +807,7 @@ def test_confirm_subscription():
)
-@mock_sns
+@mock_aws
def test_get_subscription_attributes_error_not_exists():
# given
client = boto3.client("sns", region_name="us-east-1")
diff --git a/tests/test_sns/test_topics_boto3.py b/tests/test_sns/test_topics_boto3.py
index d5c5ef144..65614cbb8 100644
--- a/tests/test_sns/test_topics_boto3.py
+++ b/tests/test_sns/test_topics_boto3.py
@@ -4,12 +4,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_sns
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.sns.models import DEFAULT_EFFECTIVE_DELIVERY_POLICY, DEFAULT_PAGE_SIZE
-@mock_sns
+@mock_aws
def test_create_and_delete_topic():
conn = boto3.client("sns", region_name="us-east-1")
for topic_name in ("some-topic", "-some-topic-", "_some-topic_", "a" * 256):
@@ -34,7 +34,7 @@ def test_create_and_delete_topic():
assert len(topics) == 0
-@mock_sns
+@mock_aws
def test_delete_non_existent_topic():
conn = boto3.client("sns", region_name="us-east-1")
@@ -44,7 +44,7 @@ def test_delete_non_existent_topic():
)
-@mock_sns
+@mock_aws
def test_create_topic_with_attributes():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(
@@ -57,7 +57,7 @@ def test_create_topic_with_attributes():
assert attributes["DisplayName"] == "test-topic"
-@mock_sns
+@mock_aws
def test_create_topic_with_tags():
conn = boto3.client("sns", region_name="us-east-1")
response = conn.create_topic(
@@ -77,7 +77,7 @@ def test_create_topic_with_tags():
)
-@mock_sns
+@mock_aws
def test_create_topic_should_be_indempodent():
conn = boto3.client("sns", region_name="us-east-1")
topic_arn = conn.create_topic(Name="some-topic")["TopicArn"]
@@ -97,7 +97,7 @@ def test_create_topic_should_be_indempodent():
assert topic_display_name == "should_be_set"
-@mock_sns
+@mock_aws
def test_get_missing_topic():
conn = boto3.client("sns", region_name="us-east-1")
with pytest.raises(ClientError):
@@ -106,7 +106,7 @@ def test_get_missing_topic():
)
-@mock_sns
+@mock_aws
def test_create_topic_must_meet_constraints():
conn = boto3.client("sns", region_name="us-east-1")
common_random_chars = [":", ";", "!", "@", "|", "^", "%"]
@@ -117,7 +117,7 @@ def test_create_topic_must_meet_constraints():
conn.create_topic(Name="no spaces allowed")
-@mock_sns
+@mock_aws
def test_create_topic_should_be_of_certain_length():
conn = boto3.client("sns", region_name="us-east-1")
too_short = ""
@@ -128,7 +128,7 @@ def test_create_topic_should_be_of_certain_length():
conn.create_topic(Name=too_long)
-@mock_sns
+@mock_aws
def test_create_topic_in_multiple_regions():
for region in ["us-west-1", "us-west-2"]:
conn = boto3.client("sns", region_name=region)
@@ -151,7 +151,7 @@ def test_create_topic_in_multiple_regions():
assert err["Type"] == "Sender"
-@mock_sns
+@mock_aws
def test_topic_corresponds_to_region():
for region in ["us-east-1", "us-west-2"]:
conn = boto3.client("sns", region_name=region)
@@ -161,7 +161,7 @@ def test_topic_corresponds_to_region():
assert topic_arn == f"arn:aws:sns:{region}:{ACCOUNT_ID}:some-topic"
-@mock_sns
+@mock_aws
def test_topic_attributes():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
@@ -231,7 +231,7 @@ def test_topic_attributes():
)
-@mock_sns
+@mock_aws
def test_topic_paging():
conn = boto3.client("sns", region_name="us-east-1")
for index in range(DEFAULT_PAGE_SIZE + int(DEFAULT_PAGE_SIZE / 2)):
@@ -251,7 +251,7 @@ def test_topic_paging():
assert len(topics_list) == int(DEFAULT_PAGE_SIZE / 2)
-@mock_sns
+@mock_aws
def test_add_remove_permissions():
client = boto3.client("sns", region_name="us-east-1")
topic_arn = client.create_topic(Name="test-permissions")["TopicArn"]
@@ -349,7 +349,7 @@ def test_add_remove_permissions():
client.remove_permission(TopicArn=topic_arn, Label="non-existing")
-@mock_sns
+@mock_aws
def test_add_permission_errors():
client = boto3.client("sns", region_name="us-east-1")
topic_arn = client.create_topic(Name="test-permissions")["TopicArn"]
@@ -391,7 +391,7 @@ def test_add_permission_errors():
)
-@mock_sns
+@mock_aws
def test_remove_permission_errors():
client = boto3.client("sns", region_name="us-east-1")
topic_arn = client.create_topic(Name="test-permissions")["TopicArn"]
@@ -409,7 +409,7 @@ def test_remove_permission_errors():
assert client_err.value.response["Error"]["Message"] == "Topic does not exist"
-@mock_sns
+@mock_aws
def test_tag_topic():
conn = boto3.client("sns", region_name="us-east-1")
response = conn.create_topic(Name="some-topic-with-tags")
@@ -443,7 +443,7 @@ def test_tag_topic():
)
-@mock_sns
+@mock_aws
def test_untag_topic():
conn = boto3.client("sns", region_name="us-east-1")
response = conn.create_topic(
@@ -467,7 +467,7 @@ def test_untag_topic():
)
-@mock_sns
+@mock_aws
def test_list_tags_for_resource_error():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(
@@ -479,7 +479,7 @@ def test_list_tags_for_resource_error():
assert client_err.value.response["Error"]["Message"] == "Resource does not exist"
-@mock_sns
+@mock_aws
def test_tag_resource_errors():
conn = boto3.client("sns", region_name="us-east-1")
response = conn.create_topic(
@@ -509,7 +509,7 @@ def test_tag_resource_errors():
)
-@mock_sns
+@mock_aws
def test_untag_resource_error():
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(
@@ -521,7 +521,7 @@ def test_untag_resource_error():
assert client_err.value.response["Error"]["Message"] == "Resource does not exist"
-@mock_sns
+@mock_aws
def test_create_fifo_topic():
conn = boto3.client("sns", region_name="us-east-1")
response = conn.create_topic(
@@ -562,7 +562,7 @@ def test_create_fifo_topic():
)
-@mock_sns
+@mock_aws
def test_topic_kms_master_key_id_attribute():
client = boto3.client("sns", region_name="us-west-2")
resp = client.create_topic(Name="test-sns-no-key-attr")
@@ -586,7 +586,7 @@ def test_topic_kms_master_key_id_attribute():
assert resp["Attributes"]["KmsMasterKeyId"] == "key-id"
-@mock_sns
+@mock_aws
def test_topic_fifo_get_attributes():
client = boto3.client("sns", region_name="us-east-1")
resp = client.create_topic(
@@ -610,7 +610,7 @@ def test_topic_fifo_get_attributes():
assert attributes["ContentBasedDeduplication"] == "true"
-@mock_sns
+@mock_aws
def test_topic_get_attributes():
client = boto3.client("sns", region_name="us-east-1")
resp = client.create_topic(Name="test-topic-get-attr")
@@ -621,7 +621,7 @@ def test_topic_get_attributes():
assert "ContentBasedDeduplication" not in attributes
-@mock_sns
+@mock_aws
def test_topic_get_attributes_with_fifo_false():
client = boto3.client("sns", region_name="us-east-1")
resp = client.create_topic(
diff --git a/tests/test_special_cases/test_custom_amis.py b/tests/test_special_cases/test_custom_amis.py
index 41c27d5ae..2980e5ec7 100644
--- a/tests/test_special_cases/test_custom_amis.py
+++ b/tests/test_special_cases/test_custom_amis.py
@@ -11,7 +11,7 @@ from unittest import SkipTest, TestCase, mock
import boto3
import moto
-from moto import mock_ec2, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID
from moto.ec2.models import ec2_backends
@@ -19,7 +19,7 @@ from moto.ec2.models import ec2_backends
# The default AMIs are not loaded for our test case, to speed things up
# But we do need it for this specific test (and others in this file..)
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
+@mock_aws
class TestEC2CustomAMIs(TestCase):
def setup_amis(self):
test_ami_path = Path(__file__).parent / "test_ami.json"
diff --git a/tests/test_sqs/test_server.py b/tests/test_sqs/test_server.py
index 10551b6fb..92730db45 100644
--- a/tests/test_sqs/test_server.py
+++ b/tests/test_sqs/test_server.py
@@ -1,4 +1,3 @@
-"""Test different server responses."""
import re
import threading
import time
diff --git a/tests/test_sqs/test_sqs.py b/tests/test_sqs/test_sqs.py
index 3dc3be847..a28e0428e 100644
--- a/tests/test_sqs/test_sqs.py
+++ b/tests/test_sqs/test_sqs.py
@@ -13,7 +13,7 @@ import pytest
from botocore.exceptions import ClientError
from freezegun import freeze_time
-from moto import mock_sqs, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.sqs.models import (
MAXIMUM_MESSAGE_LENGTH,
@@ -45,7 +45,7 @@ TEST_POLICY = """
MOCK_DEDUPLICATION_TIME_IN_SECONDS = 5
-@mock_sqs
+@mock_aws
def test_create_fifo_queue_fail():
sqs = boto3.client("sqs", region_name="us-east-1")
@@ -57,7 +57,7 @@ def test_create_fifo_queue_fail():
raise RuntimeError("Should have raised InvalidParameterValue Exception")
-@mock_sqs
+@mock_aws
def test_create_queue_with_same_attributes():
sqs = boto3.client("sqs", region_name="us-east-1")
@@ -83,7 +83,7 @@ def test_create_queue_with_same_attributes():
sqs.create_queue(QueueName=q_name, Attributes=attributes)
-@mock_sqs
+@mock_aws
def test_create_queue_with_different_attributes_fail():
sqs = boto3.client("sqs", region_name="us-east-1")
@@ -106,7 +106,7 @@ def test_create_queue_with_different_attributes_fail():
assert new_response["QueueUrl"] == response.get("QueueUrl")
-@mock_sqs
+@mock_aws
def test_create_fifo_queue():
# given
region_name = "us-east-1"
@@ -143,7 +143,7 @@ def test_create_fifo_queue():
assert attributes["VisibilityTimeout"] == "30"
-@mock_sqs
+@mock_aws
def test_create_fifo_queue_with_high_throughput():
# given
sqs = boto3.client("sqs", region_name="us-east-1")
@@ -170,7 +170,7 @@ def test_create_fifo_queue_with_high_throughput():
assert attributes["FifoThroughputLimit"] == "perMessageGroupId"
-@mock_sqs
+@mock_aws
def test_create_queue():
sqs = boto3.resource("sqs", region_name="us-east-1")
@@ -184,7 +184,7 @@ def test_create_queue():
assert queue.attributes.get("VisibilityTimeout") == "30"
-@mock_sqs
+@mock_aws
def test_create_queue_kms():
sqs = boto3.resource("sqs", region_name="us-east-1")
@@ -203,7 +203,7 @@ def test_create_queue_kms():
assert queue.attributes.get("KmsDataKeyReusePeriodSeconds") == "600"
-@mock_sqs
+@mock_aws
def test_create_queue_with_tags():
client = boto3.client("sqs", region_name="us-east-1")
q_name = str(uuid4())[0:6]
@@ -218,7 +218,7 @@ def test_create_queue_with_tags():
}
-@mock_sqs
+@mock_aws
def test_create_queue_with_policy():
client = boto3.client("sqs", region_name="us-east-1")
q_name = str(uuid4())[0:6]
@@ -246,7 +246,7 @@ def test_create_queue_with_policy():
}
-@mock_sqs
+@mock_aws
def test_set_queue_attribute_empty_policy_removes_attr():
client = boto3.client("sqs", region_name="us-east-1")
q_name = str(uuid4())[0:6]
@@ -285,7 +285,7 @@ def test_is_empty_redrive_policy_returns_false_for_valid_policy_format():
assert not Queue._is_empty_redrive_policy(json.dumps({"maxReceiveCount": 5}))
-@mock_sqs
+@mock_aws
def test_set_queue_attribute_empty_redrive_removes_attr():
client = boto3.client("sqs", region_name="us-east-1")
@@ -312,7 +312,7 @@ def test_set_queue_attribute_empty_redrive_removes_attr():
assert "RedrivePolicy" not in response
-@mock_sqs
+@mock_aws
def test_get_queue_url():
client = boto3.client("sqs", region_name="us-east-1")
q_name = str(uuid4())[0:6]
@@ -323,7 +323,7 @@ def test_get_queue_url():
assert q_name in response["QueueUrl"]
-@mock_sqs
+@mock_aws
def test_get_queue_url_error_not_exists():
# given
client = boto3.client("sqs", region_name="us-east-1")
@@ -342,7 +342,7 @@ def test_get_queue_url_error_not_exists():
)
-@mock_sqs
+@mock_aws
def test_get_nonexistent_queue():
sqs = boto3.resource("sqs", region_name="us-east-1")
@@ -356,7 +356,7 @@ def test_get_nonexistent_queue():
)
-@mock_sqs
+@mock_aws
def test_message_send_without_attributes():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -369,7 +369,7 @@ def test_message_send_without_attributes():
assert len(messages) == 1
-@mock_sqs
+@mock_aws
def test_message_send_with_attributes():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -390,7 +390,7 @@ def test_message_send_with_attributes():
assert len(messages) == 1
-@mock_sqs
+@mock_aws
def test_message_retention_period():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -424,7 +424,7 @@ def test_message_retention_period():
assert len(messages) == 0
-@mock_sqs
+@mock_aws
def test_queue_retention_period():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -447,7 +447,7 @@ def test_queue_retention_period():
assert len(messages) == 1
-@mock_sqs
+@mock_aws
def test_message_with_invalid_attributes():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -467,7 +467,7 @@ def test_message_with_invalid_attributes():
)
-@mock_sqs
+@mock_aws
def test_message_with_string_attributes():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -493,7 +493,7 @@ def test_message_with_string_attributes():
assert len(messages) == 1
-@mock_sqs
+@mock_aws
def test_message_with_binary_attribute():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -520,7 +520,7 @@ def test_message_with_binary_attribute():
assert len(messages) == 1
-@mock_sqs
+@mock_aws
def test_message_with_attributes_have_labels():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -541,7 +541,7 @@ def test_message_with_attributes_have_labels():
assert len(messages) == 1
-@mock_sqs
+@mock_aws
def test_message_with_attributes_invalid_datatype():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -565,7 +565,7 @@ def test_message_with_attributes_invalid_datatype():
)
-@mock_sqs
+@mock_aws
def test_send_message_with_message_group_id():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -590,7 +590,7 @@ def test_send_message_with_message_group_id():
assert message_attributes["MessageDeduplicationId"] == "dedupe_id_1"
-@mock_sqs
+@mock_aws
def test_send_message_with_message_group_id_standard_queue():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -606,7 +606,7 @@ def test_send_message_with_message_group_id_standard_queue():
)
-@mock_sqs
+@mock_aws
def test_send_message_with_unicode_characters():
body_one = "Héllo!😀"
@@ -620,7 +620,7 @@ def test_send_message_with_unicode_characters():
assert message_body == body_one
-@mock_sqs
+@mock_aws
def test_set_queue_attributes():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -647,7 +647,7 @@ def _get_common_url(region):
)
-@mock_sqs
+@mock_aws
def test_create_queues_in_multiple_region():
w1 = boto3.client("sqs", region_name="us-west-1")
w1_name = str(uuid4())[0:6]
@@ -668,7 +668,7 @@ def test_create_queues_in_multiple_region():
assert f"{base_url}/{ACCOUNT_ID}/{w2_name}" in w2.list_queues()["QueueUrls"]
-@mock_sqs
+@mock_aws
def test_get_queue_with_prefix():
conn = boto3.client("sqs", region_name="us-west-1")
conn.create_queue(QueueName=str(uuid4())[0:6])
@@ -693,7 +693,7 @@ def test_get_queue_with_prefix():
assert queue[0] == expected_url2
-@mock_sqs
+@mock_aws
def test_delete_queue():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -710,7 +710,7 @@ def test_delete_queue():
assert q_name not in [u[u.rfind("/") + 1 :] for u in all_urls]
-@mock_sqs
+@mock_aws
def test_delete_queue_error_not_exists():
client = boto3.client("sqs", region_name="us-east-1")
@@ -728,7 +728,7 @@ def test_delete_queue_error_not_exists():
)
-@mock_sqs
+@mock_aws
def test_get_queue_attributes():
client = boto3.client("sqs", region_name="us-east-1")
@@ -793,7 +793,7 @@ def test_get_queue_attributes():
assert "Attributes" not in response
-@mock_sqs
+@mock_aws
def test_get_queue_attributes_errors():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(QueueName=str(uuid4())[0:6])
@@ -818,7 +818,7 @@ def test_get_queue_attributes_errors():
assert client_error.value.response["Error"]["Message"] == "Unknown Attribute ."
-@mock_sqs
+@mock_aws
def test_get_queue_attributes_error_not_exists():
# given
client = boto3.client("sqs", region_name="us-east-1")
@@ -839,7 +839,7 @@ def test_get_queue_attributes_error_not_exists():
)
-@mock_sqs
+@mock_aws
def test_set_queue_attribute():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -855,7 +855,7 @@ def test_set_queue_attribute():
assert queue.attributes["VisibilityTimeout"] == "45"
-@mock_sqs
+@mock_aws
def test_send_receive_message_without_attributes():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -885,7 +885,7 @@ def test_send_receive_message_without_attributes():
assert "Attributes" not in message2
-@mock_sqs
+@mock_aws
def test_send_receive_message_with_attributes():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -923,7 +923,7 @@ def test_send_receive_message_with_attributes():
assert message2.get("MD5OfMessageAttributes") == "994258b45346a2cc3f9cbb611aa7af30"
-@mock_sqs
+@mock_aws
def test_send_receive_message_with_attributes_with_labels():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -976,7 +976,7 @@ def test_send_receive_message_with_attributes_with_labels():
assert response.get("MD5OfMessageAttributes") == "9e05cca738e70ff6c6041e82d5e77ef1"
-@mock_sqs
+@mock_aws
def test_receive_message_with_xml_content():
sqs = boto3.client("sqs", region_name="eu-west-2")
queue_url = sqs.create_queue(QueueName=str(uuid4())[0:6])["QueueUrl"]
@@ -1001,7 +1001,7 @@ def test_receive_message_with_xml_content():
assert attr == original_payload
-@mock_sqs
+@mock_aws
def test_change_message_visibility_than_permitted():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cant manipulate time in server mode")
@@ -1036,7 +1036,7 @@ def test_change_message_visibility_than_permitted():
assert ex.response["Error"]["Code"] == "InvalidParameterValue"
-@mock_sqs
+@mock_aws
def test_send_receive_message_timestamps():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -1068,7 +1068,7 @@ def test_send_receive_message_timestamps():
assert False, "aproximate_first_receive_timestamp not an int"
-@mock_sqs
+@mock_aws
@pytest.mark.parametrize(
"attribute_name,expected",
[
@@ -1195,7 +1195,7 @@ def test_send_receive_message_with_attribute_name(attribute_name, expected):
assert expected["SequenceNumber"](message2["Attributes"].get("SequenceNumber"))
-@mock_sqs
+@mock_aws
@pytest.mark.parametrize(
"attribute_name,expected",
[
@@ -1345,7 +1345,7 @@ def test_fifo_send_receive_message_with_attribute_name(attribute_name, expected)
assert expected["SequenceNumber"](message["Attributes"].get("SequenceNumber"))
-@mock_sqs
+@mock_aws
def test_get_queue_attributes_no_param():
"""Test Attributes-key is not returned when no AttributeNames-parameter."""
sqs = boto3.client("sqs", region_name="ap-northeast-3")
@@ -1358,7 +1358,7 @@ def test_get_queue_attributes_no_param():
assert "Attributes" in queue_attrs
-@mock_sqs
+@mock_aws
def test_max_number_of_messages_invalid_param():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -1373,7 +1373,7 @@ def test_max_number_of_messages_invalid_param():
queue.receive_messages(MaxNumberOfMessages=1, WaitTimeSeconds=0)
-@mock_sqs
+@mock_aws
def test_wait_time_seconds_invalid_param():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -1388,7 +1388,7 @@ def test_wait_time_seconds_invalid_param():
queue.receive_messages(WaitTimeSeconds=0)
-@mock_sqs
+@mock_aws
def test_receive_messages_with_wait_seconds_timeout_of_zero():
"""
test that zero messages is returned with a wait_seconds_timeout of zero,
@@ -1403,7 +1403,7 @@ def test_receive_messages_with_wait_seconds_timeout_of_zero():
assert messages == []
-@mock_sqs
+@mock_aws
def test_send_message_with_xml_characters():
sqs = boto3.resource("sqs", region_name="us-east-1")
client = boto3.client("sqs", region_name="us-east-1")
@@ -1418,7 +1418,7 @@ def test_send_message_with_xml_characters():
assert messages[0]["Body"] == body_one
-@mock_sqs
+@mock_aws
def test_send_message_with_delay():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -1438,7 +1438,7 @@ def test_send_message_with_delay():
assert len(messages) == 0
-@mock_sqs
+@mock_aws
def test_send_large_message_fails():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -1453,7 +1453,7 @@ def test_send_large_message_fails():
)
-@mock_sqs
+@mock_aws
def test_message_becomes_inflight_when_received():
sqs = boto3.resource("sqs", region_name="eu-west-1")
queue = sqs.create_queue(
@@ -1481,7 +1481,7 @@ def test_message_becomes_inflight_when_received():
assert queue.attributes["ApproximateNumberOfMessages"] == "1"
-@mock_sqs
+@mock_aws
def test_receive_message_with_explicit_visibility_timeout():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -1503,7 +1503,7 @@ def test_receive_message_with_explicit_visibility_timeout():
assert queue.attributes["ApproximateNumberOfMessages"] == "1"
-@mock_sqs
+@mock_aws
def test_change_message_visibility():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -1543,7 +1543,7 @@ def test_change_message_visibility():
assert queue.attributes["ApproximateNumberOfMessages"] == "0"
-@mock_sqs
+@mock_aws
def test_change_message_visibility_on_unknown_receipt_handle():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -1560,7 +1560,7 @@ def test_change_message_visibility_on_unknown_receipt_handle():
assert err["Message"] == "The input receipt handle is invalid."
-@mock_sqs
+@mock_aws
def test_queue_length():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -1574,7 +1574,7 @@ def test_queue_length():
assert queue.attributes["ApproximateNumberOfMessages"] == "2"
-@mock_sqs
+@mock_aws
def test_delete_batch_operation():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -1596,7 +1596,7 @@ def test_delete_batch_operation():
assert queue.attributes["ApproximateNumberOfMessages"] == "1"
-@mock_sqs
+@mock_aws
def test_change_message_visibility_on_old_message():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -1635,7 +1635,7 @@ def test_change_message_visibility_on_old_message():
assert len(messages) == 0
-@mock_sqs
+@mock_aws
def test_change_message_visibility_on_visible_message():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -1662,7 +1662,7 @@ def test_change_message_visibility_on_visible_message():
assert queue.attributes["ApproximateNumberOfMessages"] == "0"
-@mock_sqs
+@mock_aws
def test_purge_queue_before_delete_message():
client = boto3.client("sqs", region_name="us-east-1")
@@ -1694,7 +1694,7 @@ def test_purge_queue_before_delete_message():
assert receive_resp2["Messages"][0]["Body"] == "second_message"
-@mock_sqs
+@mock_aws
def test_delete_message_after_visibility_timeout():
VISIBILITY_TIMEOUT = 1
sqs = boto3.resource("sqs", region_name="us-east-1")
@@ -1718,7 +1718,7 @@ def test_delete_message_after_visibility_timeout():
assert queue.attributes["ApproximateNumberOfMessages"] == "0"
-@mock_sqs
+@mock_aws
def test_delete_message_errors():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(QueueName=str(uuid4())[0:6])
@@ -1743,7 +1743,7 @@ def test_delete_message_errors():
)
-@mock_sqs
+@mock_aws
def test_delete_message_twice_using_same_receipt_handle():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(QueueName=str(uuid4())[0:6])
@@ -1757,7 +1757,7 @@ def test_delete_message_twice_using_same_receipt_handle():
client.delete_message(QueueUrl=queue_url, ReceiptHandle=receipt_handle)
-@mock_sqs
+@mock_aws
def test_delete_message_using_old_receipt_handle():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(
@@ -1786,7 +1786,7 @@ def test_delete_message_using_old_receipt_handle():
client.delete_message(QueueUrl=queue_url, ReceiptHandle=receipt_2)
-@mock_sqs
+@mock_aws
def test_send_message_batch():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(
@@ -1854,7 +1854,7 @@ def test_send_message_batch():
)
-@mock_sqs
+@mock_aws
def test_delete_message_batch_with_duplicates():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(QueueName=str(uuid4())[0:6])
@@ -1882,7 +1882,7 @@ def test_delete_message_batch_with_duplicates():
assert messages, "message still in the queue"
-@mock_sqs
+@mock_aws
def test_delete_message_batch_with_invalid_receipt_id():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(QueueName=str(uuid4())[0:6])
@@ -1928,7 +1928,7 @@ def test_delete_message_batch_with_invalid_receipt_id():
]
-@mock_sqs
+@mock_aws
def test_message_attributes_in_receive_message():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -1993,7 +1993,7 @@ def test_message_attributes_in_receive_message():
}
-@mock_sqs
+@mock_aws
def test_send_message_batch_errors():
client = boto3.client("sqs", region_name="us-east-1")
@@ -2073,7 +2073,7 @@ def test_send_message_batch_errors():
)
-@mock_sqs
+@mock_aws
def test_send_message_batch_with_empty_list():
client = boto3.client("sqs", region_name="us-east-1")
@@ -2087,7 +2087,7 @@ def test_send_message_batch_with_empty_list():
)
-@mock_sqs
+@mock_aws
def test_batch_change_message_visibility():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cant manipulate time in server mode")
@@ -2140,7 +2140,7 @@ def test_batch_change_message_visibility():
assert len(resp["Messages"]) == 3
-@mock_sqs
+@mock_aws
def test_batch_change_message_visibility_on_old_message():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -2172,7 +2172,7 @@ def test_batch_change_message_visibility_on_old_message():
assert len(resp["Successful"]) == 1
-@mock_sqs
+@mock_aws
def test_permissions():
client = boto3.client("sqs", region_name="us-east-1")
@@ -2238,7 +2238,7 @@ def test_permissions():
}
-@mock_sqs
+@mock_aws
def test_get_queue_attributes_template_response_validation():
client = boto3.client("sqs", region_name="us-east-1")
@@ -2268,7 +2268,7 @@ def test_get_queue_attributes_template_response_validation():
)
-@mock_sqs
+@mock_aws
def test_add_permission_errors():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(QueueName=str(uuid4())[0:6])
@@ -2366,7 +2366,7 @@ def test_add_permission_errors():
)
-@mock_sqs
+@mock_aws
def test_remove_permission_errors():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(QueueName=str(uuid4())[0:6])
@@ -2384,7 +2384,7 @@ def test_remove_permission_errors():
)
-@mock_sqs
+@mock_aws
def test_tags():
client = boto3.client("sqs", region_name="us-east-1")
@@ -2410,7 +2410,7 @@ def test_tags():
assert client.list_queue_tags(QueueUrl=queue_url)["Tags"] == {"test1": "value1"}
-@mock_sqs
+@mock_aws
def test_list_queue_tags_errors():
client = boto3.client("sqs", region_name="us-east-1")
@@ -2426,7 +2426,7 @@ def test_list_queue_tags_errors():
)
-@mock_sqs
+@mock_aws
def test_tag_queue_errors():
client = boto3.client("sqs", region_name="us-east-1")
@@ -2461,7 +2461,7 @@ def test_tag_queue_errors():
)
-@mock_sqs
+@mock_aws
def test_untag_queue_errors():
client = boto3.client("sqs", region_name="us-east-1")
@@ -2483,7 +2483,7 @@ def test_untag_queue_errors():
)
-@mock_sqs
+@mock_aws
def test_create_fifo_queue_with_dlq():
sqs = boto3.client("sqs", region_name="us-east-1")
resp = sqs.create_queue(
@@ -2525,7 +2525,7 @@ def test_create_fifo_queue_with_dlq():
)
-@mock_sqs
+@mock_aws
def test_queue_with_dlq():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cant manipulate time in server mode")
@@ -2591,7 +2591,7 @@ def test_queue_with_dlq():
assert resp["queueUrls"][0] == queue_url2
-@mock_sqs
+@mock_aws
def test_redrive_policy_available():
sqs = boto3.client("sqs", region_name="us-east-1")
@@ -2625,7 +2625,7 @@ def test_redrive_policy_available():
)
-@mock_sqs
+@mock_aws
def test_redrive_policy_non_existent_queue():
sqs = boto3.client("sqs", region_name="us-east-1")
redrive_policy = {
@@ -2640,7 +2640,7 @@ def test_redrive_policy_non_existent_queue():
)
-@mock_sqs
+@mock_aws
def test_redrive_policy_set_attributes():
sqs = boto3.resource("sqs", region_name="us-east-1")
@@ -2661,7 +2661,7 @@ def test_redrive_policy_set_attributes():
assert copy_policy == redrive_policy
-@mock_sqs
+@mock_aws
def test_redrive_policy_set_attributes_with_string_value():
sqs = boto3.resource("sqs", region_name="us-east-1")
@@ -2689,7 +2689,7 @@ def test_redrive_policy_set_attributes_with_string_value():
}
-@mock_sqs
+@mock_aws
def test_receive_messages_with_message_group_id():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -2721,7 +2721,7 @@ def test_receive_messages_with_message_group_id():
assert messages[0].body == "message-3"
-@mock_sqs
+@mock_aws
def test_receive_messages_with_message_group_id_on_requeue():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -2748,7 +2748,7 @@ def test_receive_messages_with_message_group_id_on_requeue():
assert messages[0].message_id == message.message_id
-@mock_sqs
+@mock_aws
def test_receive_messages_with_message_group_id_on_visibility_timeout():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cant manipulate time in server mode")
@@ -2786,7 +2786,7 @@ def test_receive_messages_with_message_group_id_on_visibility_timeout():
assert messages[0].message_id == message.message_id
-@mock_sqs
+@mock_aws
def test_receive_message_for_queue_with_receive_message_wait_time_seconds_set():
sqs = boto3.resource("sqs", region_name="us-east-1")
@@ -2797,7 +2797,7 @@ def test_receive_message_for_queue_with_receive_message_wait_time_seconds_set():
queue.receive_messages()
-@mock_sqs
+@mock_aws
def test_list_queues_limits_to_1000_queues():
if settings.TEST_SERVER_MODE:
# Re-visit once we have a NextToken-implementation for list_queues
@@ -2823,7 +2823,7 @@ def test_list_queues_limits_to_1000_queues():
client.delete_queue(QueueUrl=url)
-@mock_sqs
+@mock_aws
def test_send_message_to_fifo_without_message_group_id():
sqs = boto3.resource("sqs", region_name="eu-west-3")
queue = sqs.create_queue(
@@ -2838,7 +2838,7 @@ def test_send_message_to_fifo_without_message_group_id():
assert err["Message"] == "The request must contain the parameter MessageGroupId."
-@mock_sqs
+@mock_aws
def test_send_messages_to_fifo_without_message_group_id():
sqs = boto3.resource("sqs", region_name="eu-west-3")
queue = sqs.create_queue(
@@ -2853,7 +2853,7 @@ def test_send_messages_to_fifo_without_message_group_id():
assert err["Message"] == "The request must contain the parameter MessageGroupId."
-@mock_sqs
+@mock_aws
def test_maximum_message_size_attribute_default():
sqs = boto3.resource("sqs", region_name="eu-west-3")
queue = sqs.create_queue(QueueName=str(uuid4()))
@@ -2864,7 +2864,7 @@ def test_maximum_message_size_attribute_default():
assert err["Code"] == "InvalidParameterValue"
-@mock_sqs
+@mock_aws
def test_maximum_message_size_attribute_fails_for_invalid_values():
sqs = boto3.resource("sqs", region_name="eu-west-3")
invalid_values = [
@@ -2881,7 +2881,7 @@ def test_maximum_message_size_attribute_fails_for_invalid_values():
assert ex.response["Error"]["Code"] == "InvalidAttributeValue"
-@mock_sqs
+@mock_aws
def test_send_message_fails_when_message_size_greater_than_max_message_size():
sqs = boto3.resource("sqs", region_name="eu-west-3")
message_size_limit = 12345
@@ -2897,7 +2897,7 @@ def test_send_message_fails_when_message_size_greater_than_max_message_size():
assert f"{message_size_limit} bytes" in ex.response["Error"]["Message"]
-@mock_sqs
+@mock_aws
@pytest.mark.parametrize(
"msg_1, msg_2, dedupid_1, dedupid_2, expected_count",
[
@@ -2928,7 +2928,7 @@ def test_fifo_queue_deduplication_with_id(
assert len(messages) == expected_count
-@mock_sqs
+@mock_aws
@pytest.mark.parametrize(
"msg_1, msg_2, expected_count", [("msg1", "msg1", 1), ("msg1", "msg2", 2)]
)
@@ -2950,7 +2950,7 @@ def test_fifo_queue_deduplication_withoutid(msg_1, msg_2, expected_count):
@mock.patch(
"moto.sqs.models.DEDUPLICATION_TIME_IN_SECONDS", MOCK_DEDUPLICATION_TIME_IN_SECONDS
)
-@mock_sqs
+@mock_aws
def test_fifo_queue_send_duplicate_messages_after_deduplication_time_limit():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cant patch env variables in server mode")
@@ -2968,7 +2968,7 @@ def test_fifo_queue_send_duplicate_messages_after_deduplication_time_limit():
assert len(messages) == 2
-@mock_sqs
+@mock_aws
def test_fifo_queue_send_deduplicationid_same_as_sha256_of_old_message():
sqs = boto3.resource("sqs", region_name="us-east-1")
@@ -2991,7 +2991,7 @@ def test_fifo_queue_send_deduplicationid_same_as_sha256_of_old_message():
assert len(messages) == 1
-@mock_sqs
+@mock_aws
def test_fifo_send_message_when_same_group_id_is_in_dlq():
sqs = boto3.resource("sqs", region_name="us-east-1")
@@ -3033,7 +3033,7 @@ def test_fifo_send_message_when_same_group_id_is_in_dlq():
assert len(messages) == 1
-@mock_sqs
+@mock_aws
def test_receive_message_using_name_should_return_name_as_url():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -3051,7 +3051,7 @@ def test_receive_message_using_name_should_return_name_as_url():
assert resp[0].queue_url == name
-@mock_sqs
+@mock_aws
def test_message_attributes_contains_trace_header():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -3083,7 +3083,7 @@ def test_message_attributes_contains_trace_header():
)
-@mock_sqs
+@mock_aws
def test_receive_message_again_preserves_attributes():
sqs = boto3.resource("sqs", region_name="us-east-1")
conn = boto3.client("sqs", region_name="us-east-1")
@@ -3118,7 +3118,7 @@ def test_receive_message_again_preserves_attributes():
assert second_messages[0]["MessageAttributes"].get("Custom2") is not None
-@mock_sqs
+@mock_aws
def test_message_has_windows_return():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=f"{str(uuid4())[0:6]}")
@@ -3131,7 +3131,7 @@ def test_message_has_windows_return():
assert re.match(message, messages[0].body)
-@mock_sqs
+@mock_aws
def test_message_delay_is_more_than_15_minutes():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(
@@ -3194,7 +3194,7 @@ def test_message_delay_is_more_than_15_minutes():
)
-@mock_sqs
+@mock_aws
def test_receive_message_that_becomes_visible_while_long_polling():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName=str(uuid4())[0:6])
@@ -3211,7 +3211,7 @@ def test_receive_message_that_becomes_visible_while_long_polling():
assert end - begin < time_to_wait
-@mock_sqs
+@mock_aws
def test_dedupe_fifo():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -3230,7 +3230,7 @@ def test_dedupe_fifo():
assert int(queue.attributes["ApproximateNumberOfMessages"]) == 1
-@mock_sqs
+@mock_aws
def test_fifo_dedupe_error_no_message_group_id():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -3249,7 +3249,7 @@ def test_fifo_dedupe_error_no_message_group_id():
)
-@mock_sqs
+@mock_aws
def test_fifo_dedupe_error_no_message_dedupe_id():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(
@@ -3269,7 +3269,7 @@ def test_fifo_dedupe_error_no_message_dedupe_id():
)
-@mock_sqs
+@mock_aws
def test_fifo_dedupe_error_no_message_dedupe_id_batch():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(
diff --git a/tests/test_sqs/test_sqs_cloudformation.py b/tests/test_sqs/test_sqs_cloudformation.py
index e1e0e8b19..02b16b9bc 100644
--- a/tests/test_sqs/test_sqs_cloudformation.py
+++ b/tests/test_sqs/test_sqs_cloudformation.py
@@ -5,7 +5,7 @@ from uuid import uuid4
import boto3
-from moto import mock_cloudformation, mock_sqs
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
simple_queue = Template(
@@ -43,8 +43,7 @@ sqs_template_with_tags = """
}"""
-@mock_sqs
-@mock_cloudformation
+@mock_aws
def test_describe_stack_subresources():
res = boto3.resource("cloudformation", region_name="us-east-1")
cf = boto3.client("cloudformation", region_name="us-east-1")
@@ -65,8 +64,7 @@ def test_describe_stack_subresources():
assert f"/{q_name}" in s.physical_resource_id
-@mock_sqs
-@mock_cloudformation
+@mock_aws
def test_list_stack_resources():
cf = boto3.client("cloudformation", region_name="us-east-1")
client = boto3.client("sqs", region_name="us-east-1")
@@ -87,8 +85,7 @@ def test_list_stack_resources():
assert queue["PhysicalResourceId"] == expected_url
-@mock_sqs
-@mock_cloudformation
+@mock_aws
def test_create_from_cloudformation_json_with_tags():
cf = boto3.client("cloudformation", region_name="us-east-1")
client = boto3.client("sqs", region_name="us-east-1")
@@ -106,8 +103,7 @@ def test_create_from_cloudformation_json_with_tags():
assert queue_tags == {"keyname1": "value1", "keyname2": "value2"}
-@mock_cloudformation
-@mock_sqs
+@mock_aws
def test_update_stack():
q_name = str(uuid4())[0:6]
sqs_template = {
@@ -147,8 +143,7 @@ def test_update_stack():
assert attrs["VisibilityTimeout"] == "100"
-@mock_cloudformation
-@mock_sqs
+@mock_aws
def test_update_stack_and_remove_resource():
q_name = str(uuid4())[0:6]
sqs_template = {
@@ -177,8 +172,7 @@ def test_update_stack_and_remove_resource():
assert "QueueUrls" not in client.list_queues(QueueNamePrefix=q_name)
-@mock_cloudformation
-@mock_sqs
+@mock_aws
def test_update_stack_and_add_resource():
sqs_template = {"AWSTemplateFormatVersion": "2010-09-09", "Resources": {}}
sqs_template_json = json.dumps(sqs_template)
@@ -207,8 +201,7 @@ def test_update_stack_and_add_resource():
assert len(client.list_queues(QueueNamePrefix=q_name)["QueueUrls"]) == 1
-@mock_sqs
-@mock_cloudformation
+@mock_aws
def test_create_queue_passing_integer_as_name():
"""
Passing the queue name as an Integer in the CloudFormation template
diff --git a/tests/test_sqs/test_sqs_integration.py b/tests/test_sqs/test_sqs_integration.py
index 84fbd864d..886be8b98 100644
--- a/tests/test_sqs/test_sqs_integration.py
+++ b/tests/test_sqs/test_sqs_integration.py
@@ -1,18 +1,19 @@
import json
import time
import uuid
+from unittest import SkipTest
import boto3
+import pytest
+from botocore.exceptions import ClientError
-from moto import mock_lambda, mock_logs, mock_sqs
+from moto import mock_aws, settings
from tests.markers import requires_docker
from tests.test_awslambda.test_lambda import get_role_name, get_test_zip_file1
from tests.test_awslambda.utilities import get_test_zip_file_print_event
-@mock_logs
-@mock_lambda
-@mock_sqs
+@mock_aws
@requires_docker
def test_invoke_function_from_sqs_queue():
logs_conn = boto3.client("logs", region_name="us-east-1")
@@ -71,9 +72,39 @@ def test_invoke_function_from_sqs_queue():
assert False, "Test Failed"
-@mock_logs
-@mock_lambda
-@mock_sqs
+@mock_aws(config={"lambda": {"use_docker": False}})
+def test_invoke_fake_function_from_sqs_queue():
+ if not settings.TEST_DECORATOR_MODE:
+ raise SkipTest("Can only set Config in DecoratorMode")
+ logs_conn = boto3.client("logs", region_name="us-east-1")
+ sqs = boto3.resource("sqs", region_name="us-east-1")
+ queue_name = str(uuid.uuid4())[0:6]
+ queue = sqs.create_queue(QueueName=queue_name)
+
+ fn_name = str(uuid.uuid4())[0:6]
+ conn = boto3.client("lambda", region_name="us-east-1")
+ func = conn.create_function(
+ FunctionName=fn_name,
+ Runtime="python3.11",
+ Role=get_role_name(),
+ Handler="lambda_function.lambda_handler",
+ Code={"ZipFile": b"n/a"},
+ )
+
+ conn.create_event_source_mapping(
+ EventSourceArn=queue.attributes["QueueArn"], FunctionName=func["FunctionArn"]
+ )
+
+ queue.send_messages(Entries=[{"Id": "1", "MessageBody": "n/a"}])
+
+ # Because the AWSLambda is never invoked, the log group doesn't even exist
+ with pytest.raises(ClientError) as exc:
+ logs_conn.describe_log_streams(logGroupName=f"/aws/lambda/{fn_name}")
+ err = exc.value.response["Error"]
+ assert err["Message"] == "The specified log group does not exist."
+
+
+@mock_aws
@requires_docker
def test_invoke_function_from_sqs_fifo_queue():
"""
diff --git a/tests/test_sqs/test_sqs_multiaccount.py b/tests/test_sqs/test_sqs_multiaccount.py
index a9a74edd8..4dbe81589 100644
--- a/tests/test_sqs/test_sqs_multiaccount.py
+++ b/tests/test_sqs/test_sqs_multiaccount.py
@@ -3,12 +3,11 @@ from uuid import uuid4
import boto3
-from moto import mock_sqs, mock_sts
+from moto import mock_aws
class TestStsAssumeRole(unittest.TestCase):
- @mock_sqs
- @mock_sts
+ @mock_aws
def test_list_queues_in_different_account(self):
sqs = boto3.client("sqs", region_name="us-east-1")
diff --git a/tests/test_ssm/test_ssm_boto3.py b/tests/test_ssm/test_ssm_boto3.py
index 33f2d86c2..a456fb68c 100644
--- a/tests/test_ssm/test_ssm_boto3.py
+++ b/tests/test_ssm/test_ssm_boto3.py
@@ -8,13 +8,13 @@ import botocore.exceptions
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ec2, mock_ssm
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.ssm.models import PARAMETER_HISTORY_MAX_RESULTS, PARAMETER_VERSION_LIMIT
from tests import EXAMPLE_AMI_ID
-@mock_ssm
+@mock_aws
def test_delete_parameter():
client = boto3.client("ssm", region_name="us-east-1")
@@ -31,7 +31,7 @@ def test_delete_parameter():
assert len(response["Parameters"]) == 0
-@mock_ssm
+@mock_aws
def test_delete_nonexistent_parameter():
client = boto3.client("ssm", region_name="us-east-1")
@@ -41,7 +41,7 @@ def test_delete_nonexistent_parameter():
assert ex.value.response["Error"]["Message"] == "Parameter test_noexist not found."
-@mock_ssm
+@mock_aws
def test_delete_parameters():
client = boto3.client("ssm", region_name="us-east-1")
@@ -60,7 +60,7 @@ def test_delete_parameters():
assert len(response["Parameters"]) == 0
-@mock_ssm
+@mock_aws
def test_get_parameters_by_path():
client = boto3.client("ssm", region_name="us-east-1")
@@ -212,7 +212,7 @@ def test_get_parameters_by_path():
@pytest.mark.parametrize("name", ["test", "my-cool-parameter"])
-@mock_ssm
+@mock_aws
def test_put_parameter(name):
client = boto3.client("ssm", region_name="us-east-1")
response = client.put_parameter(
@@ -303,7 +303,7 @@ def test_put_parameter(name):
@pytest.mark.parametrize("name", ["test", "my-cool-parameter"])
-@mock_ssm
+@mock_aws
def test_put_parameter_overwrite_preserves_metadata(name):
test_tag_key = "TestKey"
test_tag_value = "TestValue"
@@ -404,7 +404,7 @@ def test_put_parameter_overwrite_preserves_metadata(name):
]
-@mock_ssm
+@mock_aws
def test_put_parameter_with_invalid_policy():
name = "some_param"
test_description = "A test parameter"
@@ -424,7 +424,7 @@ def test_put_parameter_with_invalid_policy():
assert "Policies" not in param
-@mock_ssm
+@mock_aws
def test_put_parameter_empty_string_value():
client = boto3.client("ssm", region_name="us-east-1")
with pytest.raises(ClientError) as e:
@@ -440,7 +440,7 @@ def test_put_parameter_empty_string_value():
)
-@mock_ssm
+@mock_aws
def test_put_parameter_invalid_names():
client = boto3.client("ssm", region_name="us-east-1")
@@ -499,7 +499,7 @@ def test_put_parameter_invalid_names():
)
-@mock_ssm
+@mock_aws
def test_put_parameter_china():
client = boto3.client("ssm", region_name="cn-north-1")
@@ -510,7 +510,7 @@ def test_put_parameter_china():
assert response["Version"] == 1
-@mock_ssm
+@mock_aws
@pytest.mark.parametrize("bad_data_type", ["not_text", "not_ec2", "something weird"])
def test_put_parameter_invalid_data_type(bad_data_type):
client = boto3.client("ssm", region_name="us-east-1")
@@ -528,7 +528,7 @@ def test_put_parameter_invalid_data_type(bad_data_type):
)
-@mock_ssm
+@mock_aws
def test_put_parameter_invalid_type():
client = boto3.client("ssm", region_name="us-east-1")
bad_type = "str" # correct value is String
@@ -547,7 +547,7 @@ def test_put_parameter_invalid_type():
)
-@mock_ssm
+@mock_aws
def test_put_parameter_no_type():
client = boto3.client("ssm", "us-east-1")
with pytest.raises(ClientError) as e:
@@ -568,7 +568,7 @@ def test_put_parameter_no_type():
assert client.describe_parameters()
-@mock_ssm
+@mock_aws
def test_update_parameter():
# Setup
client = boto3.client("ssm", "us-east-1")
@@ -596,7 +596,7 @@ def test_update_parameter():
assert new_param["Parameter"]["Value"] == updated_value
-@mock_ssm
+@mock_aws
def test_update_parameter_already_exists_error():
# Setup
client = boto3.client("ssm", "us-east-1")
@@ -625,7 +625,7 @@ def test_update_parameter_already_exists_error():
)
-@mock_ssm
+@mock_aws
def test_get_parameter():
client = boto3.client("ssm", region_name="us-east-1")
@@ -645,7 +645,7 @@ def test_get_parameter():
)
-@mock_ssm
+@mock_aws
def test_get_parameter_with_version_and_labels():
client = boto3.client("ssm", region_name="us-east-1")
@@ -709,7 +709,7 @@ def test_get_parameter_with_version_and_labels():
assert ex.value.response["Error"]["Message"] == "Parameter test-3:2 not found."
-@mock_ssm
+@mock_aws
def test_get_parameters_errors():
client = boto3.client("ssm", region_name="us-east-1")
@@ -732,7 +732,7 @@ def test_get_parameters_errors():
)
-@mock_ssm
+@mock_aws
def test_get_nonexistant_parameter():
client = boto3.client("ssm", region_name="us-east-1")
@@ -744,7 +744,7 @@ def test_get_nonexistant_parameter():
assert err.response["Error"]["Message"] == "Parameter test_noexist not found."
-@mock_ssm
+@mock_aws
def test_describe_parameters():
client = boto3.client("ssm", region_name="us-east-1")
@@ -766,7 +766,7 @@ def test_describe_parameters():
assert parameters[0]["AllowedPattern"] == r".*"
-@mock_ssm
+@mock_aws
def test_describe_parameters_paging():
client = boto3.client("ssm", region_name="us-east-1")
@@ -798,7 +798,7 @@ def test_describe_parameters_paging():
assert "NextToken" not in response
-@mock_ssm
+@mock_aws
def test_describe_parameters_filter_names():
client = boto3.client("ssm", region_name="us-east-1")
@@ -820,7 +820,7 @@ def test_describe_parameters_filter_names():
assert "NextToken" not in response
-@mock_ssm
+@mock_aws
def test_describe_parameters_filter_type():
client = boto3.client("ssm", region_name="us-east-1")
@@ -841,7 +841,7 @@ def test_describe_parameters_filter_type():
assert response["NextToken"] == "10"
-@mock_ssm
+@mock_aws
def test_describe_parameters_filter_keyid():
client = boto3.client("ssm", region_name="us-east-1")
@@ -863,7 +863,7 @@ def test_describe_parameters_filter_keyid():
assert "NextToken" not in response
-@mock_ssm
+@mock_aws
def test_describe_parameters_with_parameter_filters_keyid():
client = boto3.client("ssm", region_name="us-east-1")
client.put_parameter(Name="secure-param", Value="secure-value", Type="SecureString")
@@ -904,7 +904,7 @@ def test_describe_parameters_with_parameter_filters_keyid():
assert "NextToken" not in response
-@mock_ssm
+@mock_aws
def test_describe_parameters_with_parameter_filters_name():
client = boto3.client("ssm", region_name="us-east-1")
client.put_parameter(Name="param", Value="value", Type="String")
@@ -968,7 +968,7 @@ def test_describe_parameters_with_parameter_filters_name():
assert "NextToken" not in response
-@mock_ssm
+@mock_aws
def test_describe_parameters_with_parameter_filters_path():
client = boto3.client("ssm", region_name="us-east-1")
client.put_parameter(Name="/foo/name1", Value="value1", Type="String")
@@ -1093,7 +1093,7 @@ def test_describe_parameters_with_parameter_filters_path():
assert "NextToken" not in response
-@mock_ssm
+@mock_aws
def test_describe_parameters_needs_param():
client = boto3.client("ssm", region_name="us-east-1")
with pytest.raises(ClientError) as client_err:
@@ -1197,7 +1197,7 @@ def test_describe_parameters_needs_param():
),
],
)
-@mock_ssm
+@mock_aws
def test_describe_parameters_invalid_parameter_filters(filters, error_msg):
client = boto3.client("ssm", region_name="us-east-1")
@@ -1207,7 +1207,7 @@ def test_describe_parameters_invalid_parameter_filters(filters, error_msg):
@pytest.mark.parametrize("value", ["/###", "//", "test"])
-@mock_ssm
+@mock_aws
def test_describe_parameters_invalid_path(value):
client = boto3.client("ssm", region_name="us-east-1")
@@ -1230,7 +1230,7 @@ def test_describe_parameters_invalid_path(value):
assert "Valid example: /get/parameters2-/by1./path0_." in msg
-@mock_ssm
+@mock_aws
def test_describe_parameters_attributes():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1254,7 +1254,7 @@ def test_describe_parameters_attributes():
assert parameters[1]["Version"] == 1
-@mock_ssm
+@mock_aws
def test_describe_parameters_tags():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1279,7 +1279,7 @@ def test_describe_parameters_tags():
assert {p["Name"] for p in response["Parameters"]} == set(["/spam/eggs"])
-@mock_ssm
+@mock_aws
def test_describe_parameters__multiple_tags():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1331,7 +1331,7 @@ def test_describe_parameters__multiple_tags():
)
-@mock_ssm
+@mock_aws
def test_tags_in_list_tags_from_resource_parameter():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1354,7 +1354,7 @@ def test_tags_in_list_tags_from_resource_parameter():
assert ex.value.response["Error"]["Code"] == "InvalidResourceId"
-@mock_ssm
+@mock_aws
def test_tags_invalid_resource_id():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1363,7 +1363,7 @@ def test_tags_invalid_resource_id():
assert ex.value.response["Error"]["Code"] == "InvalidResourceId"
-@mock_ssm
+@mock_aws
def test_tags_invalid_resource_type():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1372,7 +1372,7 @@ def test_tags_invalid_resource_type():
assert ex.value.response["Error"]["Code"] == "InvalidResourceType"
-@mock_ssm
+@mock_aws
def test_get_parameter_invalid():
client = client = boto3.client("ssm", region_name="us-east-1")
response = client.get_parameters(Names=["invalid"], WithDecryption=False)
@@ -1382,7 +1382,7 @@ def test_get_parameter_invalid():
assert response["InvalidParameters"][0] == "invalid"
-@mock_ssm
+@mock_aws
def test_put_parameter_secure_default_kms():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1405,7 +1405,7 @@ def test_put_parameter_secure_default_kms():
assert response["Parameters"][0]["Type"] == "SecureString"
-@mock_ssm
+@mock_aws
def test_put_parameter_secure_custom_kms():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1432,7 +1432,7 @@ def test_put_parameter_secure_custom_kms():
assert response["Parameters"][0]["Type"] == "SecureString"
-@mock_ssm
+@mock_aws
def test_get_parameter_history():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1461,7 +1461,7 @@ def test_get_parameter_history():
assert len(parameters_response) == 3
-@mock_ssm
+@mock_aws
def test_get_parameter_history_with_secure_string():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1498,7 +1498,7 @@ def test_get_parameter_history_with_secure_string():
assert len(parameters_response) == 3
-@mock_ssm
+@mock_aws
def test_label_parameter_version():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1517,7 +1517,7 @@ def test_label_parameter_version():
assert response["ParameterVersion"] == 1
-@mock_ssm
+@mock_aws
def test_label_parameter_version_with_specific_version():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1536,7 +1536,7 @@ def test_label_parameter_version_with_specific_version():
assert response["ParameterVersion"] == 1
-@mock_ssm
+@mock_aws
def test_label_parameter_version_twice():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1565,7 +1565,7 @@ def test_label_parameter_version_twice():
assert response["Parameters"][0]["Labels"] == test_labels
-@mock_ssm
+@mock_aws
def test_label_parameter_moving_versions():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1607,7 +1607,7 @@ def test_label_parameter_moving_versions():
assert len(parameters_response) == 3
-@mock_ssm
+@mock_aws
def test_label_parameter_moving_versions_complex():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1656,7 +1656,7 @@ def test_label_parameter_moving_versions_complex():
assert len(parameters_response) == 3
-@mock_ssm
+@mock_aws
def test_label_parameter_version_exception_ten_labels_at_once():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1693,7 +1693,7 @@ def test_label_parameter_version_exception_ten_labels_at_once():
)
-@mock_ssm
+@mock_aws
def test_label_parameter_version_exception_ten_labels_over_multiple_calls():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1737,7 +1737,7 @@ def test_label_parameter_version_exception_ten_labels_over_multiple_calls():
)
-@mock_ssm
+@mock_aws
def test_label_parameter_version_invalid_name():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1748,7 +1748,7 @@ def test_label_parameter_version_invalid_name():
assert client_err.value.response["Error"]["Message"] == "Parameter test not found."
-@mock_ssm
+@mock_aws
def test_label_parameter_version_invalid_parameter_version():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1770,7 +1770,7 @@ def test_label_parameter_version_invalid_parameter_version():
)
-@mock_ssm
+@mock_aws
def test_label_parameter_version_invalid_label():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1815,7 +1815,7 @@ def test_label_parameter_version_invalid_label():
)
-@mock_ssm
+@mock_aws
def test_get_parameter_history_with_label():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1850,7 +1850,7 @@ def test_get_parameter_history_with_label():
assert len(parameters_response) == 3
-@mock_ssm
+@mock_aws
def test_get_parameter_history_with_label_non_latest():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1885,7 +1885,7 @@ def test_get_parameter_history_with_label_non_latest():
assert len(parameters_response) == 3
-@mock_ssm
+@mock_aws
def test_get_parameter_history_with_label_latest_assumed():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1918,7 +1918,7 @@ def test_get_parameter_history_with_label_latest_assumed():
assert len(parameters_response) == 3
-@mock_ssm
+@mock_aws
def test_get_parameter_history_missing_parameter():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1930,7 +1930,7 @@ def test_get_parameter_history_missing_parameter():
assert err.response["Error"]["Message"] == "Parameter test_noexist not found."
-@mock_ssm
+@mock_aws
def test_add_remove_list_tags_for_resource():
client = boto3.client("ssm", region_name="us-east-1")
@@ -1966,7 +1966,7 @@ def test_add_remove_list_tags_for_resource():
assert len(response["TagList"]) == 0
-@mock_ssm
+@mock_aws
def test_send_command():
ssm_document = "AWS-RunShellScript"
params = {"commands": ["#!/bin/bash\necho 'hello world'"]}
@@ -2014,7 +2014,7 @@ def test_send_command():
assert cmd["DocumentName"] == ssm_document
-@mock_ssm
+@mock_aws
def test_list_commands():
client = boto3.client("ssm", region_name="us-east-1")
@@ -2058,7 +2058,7 @@ def test_list_commands():
response = client.list_commands(CommandId=str(uuid.uuid4()))
-@mock_ssm
+@mock_aws
def test_get_command_invocation():
client = boto3.client("ssm", region_name="us-east-1")
@@ -2098,8 +2098,7 @@ def test_get_command_invocation():
)
-@mock_ec2
-@mock_ssm
+@mock_aws
def test_get_command_invocations_by_instance_tag():
ec2 = boto3.client("ec2", region_name="us-east-1")
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -2131,7 +2130,7 @@ def test_get_command_invocations_by_instance_tag():
assert resp["Status"] == "Success"
-@mock_ssm
+@mock_aws
def test_parameter_version_limit():
client = boto3.client("ssm", region_name="us-east-1")
parameter_name = "test-param"
@@ -2156,7 +2155,7 @@ def test_parameter_version_limit():
assert parameter_history[latest_version_index]["Value"] == latest_version_value
-@mock_ssm
+@mock_aws
def test_parameter_overwrite_fails_when_limit_reached_and_oldest_version_has_label():
client = boto3.client("ssm", region_name="us-east-1")
parameter_name = "test-param"
@@ -2189,7 +2188,7 @@ def test_parameter_overwrite_fails_when_limit_reached_and_oldest_version_has_lab
)
-@mock_ssm
+@mock_aws
def test_get_parameters_includes_invalid_parameter_when_requesting_invalid_version():
client = boto3.client("ssm", region_name="us-east-1")
parameter_name = "test-param"
@@ -2219,7 +2218,7 @@ def test_get_parameters_includes_invalid_parameter_when_requesting_invalid_versi
assert response["Parameters"][0]["Type"] == "String"
-@mock_ssm
+@mock_aws
def test_get_parameters_includes_invalid_parameter_when_requesting_invalid_label():
client = boto3.client("ssm", region_name="us-east-1")
parameter_name = "test-param"
@@ -2252,7 +2251,7 @@ def test_get_parameters_includes_invalid_parameter_when_requesting_invalid_label
assert len(response["Parameters"]) == 3
-@mock_ssm
+@mock_aws
def test_get_parameters_should_only_return_unique_requests():
client = boto3.client("ssm", region_name="us-east-1")
parameter_name = "test-param"
@@ -2264,7 +2263,7 @@ def test_get_parameters_should_only_return_unique_requests():
assert len(response["Parameters"]) == 1
-@mock_ssm
+@mock_aws
def test_get_parameter_history_should_throw_exception_when_MaxResults_is_too_large():
client = boto3.client("ssm", region_name="us-east-1")
parameter_name = "test-param"
@@ -2289,7 +2288,7 @@ def test_get_parameter_history_should_throw_exception_when_MaxResults_is_too_lar
)
-@mock_ssm
+@mock_aws
def test_get_parameter_history_NextTokenImplementation():
client = boto3.client("ssm", region_name="us-east-1")
parameter_name = "test-param"
@@ -2316,7 +2315,7 @@ def test_get_parameter_history_NextTokenImplementation():
assert len(param_history) == 100
-@mock_ssm
+@mock_aws
def test_get_parameter_history_exception_when_requesting_invalid_parameter():
client = boto3.client("ssm", region_name="us-east-1")
diff --git a/tests/test_ssm/test_ssm_cloudformation.py b/tests/test_ssm/test_ssm_cloudformation.py
index 95d26421a..72fb8dcee 100644
--- a/tests/test_ssm/test_ssm_cloudformation.py
+++ b/tests/test_ssm/test_ssm_cloudformation.py
@@ -2,12 +2,11 @@ import json
import boto3
-from moto import mock_cloudformation, mock_ssm
+from moto import mock_aws
from tests import EXAMPLE_AMI_ID
-@mock_ssm
-@mock_cloudformation
+@mock_aws
def test_get_command_invocations_from_stack():
stack_template = {
"AWSTemplateFormatVersion": "2010-09-09",
diff --git a/tests/test_ssm/test_ssm_default_amis.py b/tests/test_ssm/test_ssm_default_amis.py
index f5e933ba2..0289886f0 100644
--- a/tests/test_ssm/test_ssm_default_amis.py
+++ b/tests/test_ssm/test_ssm_default_amis.py
@@ -1,11 +1,11 @@
import boto3
-from moto import mock_ssm
+from moto import mock_aws
test_ami = "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64"
-@mock_ssm
+@mock_aws
def test_ssm_get_latest_ami_by_path():
client = boto3.client("ssm", region_name="us-west-1")
path = "/aws/service/ami-amazon-linux-latest"
@@ -20,7 +20,7 @@ def test_ssm_get_latest_ami_by_path():
assert all({p["ARN"].startswith("arn:aws:ssm:us-west-1") for p in params})
-@mock_ssm
+@mock_aws
def test_ssm_latest_amis_are_different_in_regions():
client = boto3.client("ssm", region_name="us-west-1")
ami_uswest = client.get_parameter(Name=test_ami)["Parameter"]["Value"]
diff --git a/tests/test_ssm/test_ssm_defaults.py b/tests/test_ssm/test_ssm_defaults.py
index a1eeca440..8f542d416 100644
--- a/tests/test_ssm/test_ssm_defaults.py
+++ b/tests/test_ssm/test_ssm_defaults.py
@@ -1,10 +1,10 @@
import boto3
-from moto import mock_ssm
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_ssm
+@mock_aws
def test_ssm_get_by_path():
client = boto3.client("ssm", region_name="us-west-1")
path = "/aws/service/global-infrastructure/regions"
@@ -21,7 +21,7 @@ def test_ssm_get_by_path():
assert "LastModifiedDate" in pacific
-@mock_ssm
+@mock_aws
def test_global_infrastructure_services():
client = boto3.client("ssm", region_name="us-west-1")
path = "/aws/service/global-infrastructure/services"
@@ -31,7 +31,7 @@ def test_global_infrastructure_services():
)
-@mock_ssm
+@mock_aws
def test_ssm_region_query():
client = boto3.client("ssm", region_name="us-west-1")
param = client.get_parameter(
diff --git a/tests/test_ssm/test_ssm_doc_permissions.py b/tests/test_ssm/test_ssm_doc_permissions.py
index 3d61a64b9..f81b1fd53 100644
--- a/tests/test_ssm/test_ssm_doc_permissions.py
+++ b/tests/test_ssm/test_ssm_doc_permissions.py
@@ -5,12 +5,12 @@ import pytest
import yaml
from botocore.exceptions import ClientError
-from moto import mock_ssm
+from moto import mock_aws
from .test_ssm_docs import _get_yaml_template
-@mock_ssm
+@mock_aws
def test_describe_document_permissions_unknown_document():
client = boto3.client("ssm", region_name="us-east-1")
@@ -37,7 +37,7 @@ def get_client():
return client
-@mock_ssm
+@mock_aws
def test_describe_document_permissions_initial():
client = get_client()
@@ -53,7 +53,7 @@ def test_describe_document_permissions_initial():
[["111111111111"], ["all"], ["All"], ["111111111111", "222222222222"]],
ids=["one_value", "all", "All", "multiple_values"],
)
-@mock_ssm
+@mock_aws
def test_modify_document_permission_add_account_id(ids):
client = get_client()
client.modify_document_permission(
@@ -86,7 +86,7 @@ def test_modify_document_permission_add_account_id(ids):
],
ids=["all", "one_value", "multiple_initials", "multiple_to_remove"],
)
-@mock_ssm
+@mock_aws
def test_modify_document_permission_remove_account_id(initial, to_remove):
client = get_client()
client.modify_document_permission(
@@ -110,7 +110,7 @@ def test_modify_document_permission_remove_account_id(initial, to_remove):
assert res["AccountSharingInfoList"] == expected_account_sharing
-@mock_ssm
+@mock_aws
def test_fail_modify_document_permission_wrong_permission_type():
client = get_client()
with pytest.raises(ClientError) as ex:
@@ -122,7 +122,7 @@ def test_fail_modify_document_permission_wrong_permission_type():
assert re.search(r"Member must satisfy enum value set: \[Share\]", err["Message"])
-@mock_ssm
+@mock_aws
def test_fail_modify_document_permission_wrong_document_version():
client = get_client()
with pytest.raises(ClientError) as ex:
@@ -142,7 +142,7 @@ def test_fail_modify_document_permission_wrong_document_version():
[["alll"], ["1234"], ["1234123412341234"], ["account_id"]],
ids=["all?", "too_short", "too_long", "no-digits"],
)
-@mock_ssm
+@mock_aws
def test_fail_modify_document_permission_add_invalid_account_ids(value):
client = get_client()
with pytest.raises(ClientError) as ex:
@@ -159,7 +159,7 @@ def test_fail_modify_document_permission_add_invalid_account_ids(value):
[["alll"], ["1234"], ["1234123412341234"], ["account_id"]],
ids=["all?", "too_short", "too_long", "no-digits"],
)
-@mock_ssm
+@mock_aws
def test_fail_modify_document_permission_remove_invalid_account_ids(value):
client = get_client()
with pytest.raises(ClientError) as ex:
@@ -171,7 +171,7 @@ def test_fail_modify_document_permission_remove_invalid_account_ids(value):
assert re.search(r"Member must satisfy regular expression pattern:", err["Message"])
-@mock_ssm
+@mock_aws
def test_fail_modify_document_permission_add_all_and_specific():
client = get_client()
with pytest.raises(ClientError) as ex:
@@ -185,7 +185,7 @@ def test_fail_modify_document_permission_add_all_and_specific():
assert err["Message"] == "Accounts can either be all or a group of AWS accounts"
-@mock_ssm
+@mock_aws
def test_fail_modify_document_permission_remove_all_and_specific():
client = get_client()
with pytest.raises(ClientError) as ex:
diff --git a/tests/test_ssm/test_ssm_docs.py b/tests/test_ssm/test_ssm_docs.py
index 8cad210f9..7b7fb9224 100644
--- a/tests/test_ssm/test_ssm_docs.py
+++ b/tests/test_ssm/test_ssm_docs.py
@@ -11,7 +11,7 @@ import pytest
import yaml
from botocore.exceptions import ClientError
-from moto import mock_ssm
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
@@ -125,7 +125,7 @@ def _get_doc_validator(
assert response["DocumentFormat"] == document_format
-@mock_ssm
+@mock_aws
def test_create_document():
template_file = _get_yaml_template()
json_doc = yaml.safe_load(template_file)
@@ -231,7 +231,7 @@ def test_create_document():
assert doc_description["DocumentFormat"] == "YAML"
-@mock_ssm
+@mock_aws
def test_get_document():
template_file = _get_yaml_template()
json_doc = yaml.safe_load(template_file)
@@ -318,7 +318,7 @@ def test_get_document():
_get_doc_validator(response, "NewBase", "2", new_json_doc, "JSON")
-@mock_ssm
+@mock_aws
def test_delete_document():
template_file = _get_yaml_template()
json_doc = yaml.safe_load(template_file)
@@ -462,7 +462,7 @@ def test_delete_document():
assert len(response["DocumentIdentifiers"]) == 0
-@mock_ssm
+@mock_aws
def test_update_document_default_version():
template_file = _get_yaml_template()
json_doc = yaml.safe_load(template_file)
@@ -522,7 +522,7 @@ def test_update_document_default_version():
assert response["Description"]["DefaultVersionName"] == "NewBase"
-@mock_ssm
+@mock_aws
def test_update_document():
template_file = _get_yaml_template()
json_doc = yaml.safe_load(template_file)
@@ -626,7 +626,7 @@ def test_update_document():
assert response["DocumentDescription"]["VersionName"] == "NewBase"
-@mock_ssm
+@mock_aws
def test_describe_document():
template_file = _get_yaml_template()
json_doc = yaml.safe_load(template_file)
@@ -670,7 +670,7 @@ def test_describe_document():
)
-@mock_ssm
+@mock_aws
def test_list_documents():
template_file = _get_yaml_template()
json_doc = yaml.safe_load(template_file)
@@ -761,7 +761,7 @@ def test_list_documents():
assert len(response["DocumentIdentifiers"]) == 1
-@mock_ssm
+@mock_aws
def test_tags_in_list_tags_from_resource_document():
template_file = _get_yaml_template()
json_doc = yaml.safe_load(template_file)
diff --git a/tests/test_ssm/test_ssm_ec2_integration.py b/tests/test_ssm/test_ssm_ec2_integration.py
index 141cf87e7..b49354851 100644
--- a/tests/test_ssm/test_ssm_ec2_integration.py
+++ b/tests/test_ssm/test_ssm_ec2_integration.py
@@ -3,7 +3,7 @@ from unittest import SkipTest, mock
import boto3
-from moto import mock_ec2, mock_ssm, settings
+from moto import mock_aws, settings
test_ami = "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64"
@@ -11,8 +11,7 @@ test_ami = "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_6
# The default AMIs are not loaded for our test case, to speed things up
# But we do need it for this specific test
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
-@mock_ssm
+@mock_aws
def test_ssm_get_latest_ami_by_path():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
diff --git a/tests/test_ssm/test_ssm_ecs_images.py b/tests/test_ssm/test_ssm_ecs_images.py
index 4846b6b96..963323c26 100644
--- a/tests/test_ssm/test_ssm_ecs_images.py
+++ b/tests/test_ssm/test_ssm_ecs_images.py
@@ -3,14 +3,13 @@ from unittest import SkipTest, mock
import boto3
-from moto import mock_ec2, mock_ssm, settings
+from moto import mock_aws, settings
# The default AMIs are not loaded for our test case, to speed things up
# But we do need it for this specific test
@mock.patch.dict(os.environ, {"MOTO_EC2_LOAD_DEFAULT_AMIS": "true"})
-@mock_ec2
-@mock_ssm
+@mock_aws
def test_ssm_get_latest_ami_by_path():
if settings.TEST_SERVER_MODE:
raise SkipTest("Can't set environment variables in ServerMode")
diff --git a/tests/test_ssm/test_ssm_maintenance_windows.py b/tests/test_ssm/test_ssm_maintenance_windows.py
index ebb53bf1f..a3cfe5ecb 100644
--- a/tests/test_ssm/test_ssm_maintenance_windows.py
+++ b/tests/test_ssm/test_ssm_maintenance_windows.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_ssm
+from moto import mock_aws
-@mock_ssm
+@mock_aws
def test_describe_maintenance_window():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -16,7 +16,7 @@ def test_describe_maintenance_window():
assert resp["WindowIdentities"] == []
-@mock_ssm
+@mock_aws
def test_create_maintenance_windows_simple():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -48,7 +48,7 @@ def test_create_maintenance_windows_simple():
assert "StartDate" not in my_window
-@mock_ssm
+@mock_aws
def test_create_maintenance_windows_advanced():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -85,7 +85,7 @@ def test_create_maintenance_windows_advanced():
assert my_window["EndDate"] == "2021-12-31"
-@mock_ssm
+@mock_aws
def test_get_maintenance_windows():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -114,7 +114,7 @@ def test_get_maintenance_windows():
assert "StartDate" not in my_window
-@mock_ssm
+@mock_aws
def test_describe_maintenance_windows():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -136,7 +136,7 @@ def test_describe_maintenance_windows():
assert len(resp["WindowIdentities"]) == 2
-@mock_ssm
+@mock_aws
def test_delete_maintenance_windows():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -154,7 +154,7 @@ def test_delete_maintenance_windows():
assert resp["WindowIdentities"] == []
-@mock_ssm
+@mock_aws
def test_tags():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -213,7 +213,7 @@ def test_tags():
assert tags == [{"Key": "k2", "Value": "v2"}]
-@mock_ssm
+@mock_aws
def test_register_maintenance_window_target():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -244,7 +244,7 @@ def test_register_maintenance_window_target():
assert resp["Targets"][0]["Targets"][0]["Values"] == ["my-instance"]
-@mock_ssm
+@mock_aws
def test_deregister_target_from_maintenance_window():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -275,7 +275,7 @@ def test_deregister_target_from_maintenance_window():
assert len(resp["Targets"]) == 0
-@mock_ssm
+@mock_aws
def test_describe_maintenance_window_with_no_task_or_targets():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -299,7 +299,7 @@ def test_describe_maintenance_window_with_no_task_or_targets():
assert len(resp["Targets"]) == 0
-@mock_ssm
+@mock_aws
def test_register_maintenance_window_task():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -342,7 +342,7 @@ def test_register_maintenance_window_task():
assert resp["Tasks"][0]["MaxErrors"] == "1"
-@mock_ssm
+@mock_aws
def test_deregister_maintenance_window_task():
ssm = boto3.client("ssm", region_name="us-east-1")
diff --git a/tests/test_ssm/test_ssm_patch_baseline.py b/tests/test_ssm/test_ssm_patch_baseline.py
index 692aac84a..7a795fd06 100644
--- a/tests/test_ssm/test_ssm_patch_baseline.py
+++ b/tests/test_ssm/test_ssm_patch_baseline.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_ssm
+from moto import mock_aws
-@mock_ssm
+@mock_aws
def test_create_patch_baseLine():
ssm = boto3.client("ssm", region_name="us-east-1")
@@ -56,7 +56,7 @@ def test_create_patch_baseLine():
assert baseline["BaselineDescription"] == baseline_description
-@mock_ssm
+@mock_aws
def test_delete_patch_baseline():
ssm = boto3.client("ssm", region_name="us-east-1")
diff --git a/tests/test_ssm/test_ssm_secretsmanager.py b/tests/test_ssm/test_ssm_secretsmanager.py
index cee57ef66..4192d1827 100644
--- a/tests/test_ssm/test_ssm_secretsmanager.py
+++ b/tests/test_ssm/test_ssm_secretsmanager.py
@@ -4,13 +4,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_secretsmanager, mock_ssm
+from moto import mock_aws
# https://docs.aws.amazon.com/systems-manager/latest/userguide/integration-ps-secretsmanager.html
-@mock_secretsmanager
-@mock_ssm
+@mock_aws
def test_get_value_from_secrets_manager__by_name():
# given
ssm = boto3.client("ssm", "eu-north-1")
@@ -36,8 +35,7 @@ def test_get_value_from_secrets_manager__by_name():
assert source_result["VersionIdsToStages"] == secret["VersionIdsToStages"]
-@mock_secretsmanager
-@mock_ssm
+@mock_aws
def test_get_value_from_secrets_manager__without_decryption():
# Note that the parameter does not need to exist
ssm = boto3.client("ssm", "eu-north-1")
@@ -50,8 +48,7 @@ def test_get_value_from_secrets_manager__without_decryption():
)
-@mock_secretsmanager
-@mock_ssm
+@mock_aws
def test_get_value_from_secrets_manager__with_decryption_false():
# Note that the parameter does not need to exist
ssm = boto3.client("ssm", "eu-north-1")
@@ -66,8 +63,7 @@ def test_get_value_from_secrets_manager__with_decryption_false():
)
-@mock_secretsmanager
-@mock_ssm
+@mock_aws
def test_get_value_from_secrets_manager__by_id():
# given
ssm = boto3.client("ssm", "eu-north-1")
@@ -97,8 +93,7 @@ def test_get_value_from_secrets_manager__by_id():
assert param["Value"] == "3rd"
-@mock_secretsmanager
-@mock_ssm
+@mock_aws
def test_get_value_from_secrets_manager__by_version():
# given
ssm = boto3.client("ssm", "eu-north-1")
@@ -115,8 +110,7 @@ def test_get_value_from_secrets_manager__by_version():
assert param["Value"] == "1st"
-@mock_secretsmanager
-@mock_ssm
+@mock_aws
def test_get_value_from_secrets_manager__param_does_not_exist():
ssm = boto3.client("ssm", "us-east-1")
with pytest.raises(ClientError) as exc:
diff --git a/tests/test_ssoadmin/test_ssoadmin.py b/tests/test_ssoadmin/test_ssoadmin.py
index e3a134814..61dd48a8f 100644
--- a/tests/test_ssoadmin/test_ssoadmin.py
+++ b/tests/test_ssoadmin/test_ssoadmin.py
@@ -5,7 +5,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ssoadmin
+from moto import mock_aws
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
@@ -15,7 +15,7 @@ DUMMY_PERMISSIONSET_ID = (
DUMMY_INSTANCE_ARN = "arn:aws:sso:::instance/ins-aaaabbbbccccdddd"
-@mock_ssoadmin
+@mock_aws
def test_create_account_assignment():
client = boto3.client("sso-admin", region_name="eu-west-1")
target_id = "222222222222"
@@ -46,7 +46,7 @@ def test_create_account_assignment():
assert status["PrincipalId"] == principal_id
-@mock_ssoadmin
+@mock_aws
def test_delete_account_assignment():
client = boto3.client("sso-admin", region_name="eu-west-1")
target_id = "222222222222"
@@ -97,7 +97,7 @@ def test_delete_account_assignment():
assert resp["AccountAssignments"] == []
-@mock_ssoadmin
+@mock_aws
def test_delete_account_assignment_unknown():
client = boto3.client("sso-admin", region_name="us-east-1")
@@ -121,7 +121,7 @@ def test_delete_account_assignment_unknown():
assert err["Code"] == "ResourceNotFoundException"
-@mock_ssoadmin
+@mock_aws
def test_list_account_assignments():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
@@ -190,7 +190,7 @@ def test_list_account_assignments():
]
-@mock_ssoadmin
+@mock_aws
def test_list_account_assignments_pagination():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
DUMMY_AWS_ACCOUNT_ID = "111111111111"
@@ -250,7 +250,7 @@ def test_list_account_assignments_pagination():
)
-@mock_ssoadmin
+@mock_aws
def test_list_account_assignments_for_principal():
client = boto3.client("sso-admin", region_name="us-west-2")
@@ -333,7 +333,7 @@ def test_list_account_assignments_for_principal():
assert len(response["AccountAssignments"]) == 0
-@mock_ssoadmin
+@mock_aws
def test_list_account_assignments_for_principal_pagination():
client = boto3.client("sso-admin", region_name="us-east-2")
@@ -384,7 +384,7 @@ def test_list_account_assignments_for_principal_pagination():
) == set(["000000000000", "111111111111", "222222222222"])
-@mock_ssoadmin
+@mock_aws
def test_create_permission_set():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
resp = client.create_permission_set(
@@ -404,7 +404,7 @@ def test_create_permission_set():
assert "RelayState" in permission_set
-@mock_ssoadmin
+@mock_aws
def test_update_permission_set():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
resp = client.create_permission_set(
@@ -435,7 +435,7 @@ def test_update_permission_set():
assert permission_set["RelayState"] == "https://console.aws.amazon.com/s3"
-@mock_ssoadmin
+@mock_aws
def test_update_permission_set_unknown():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
@@ -454,7 +454,7 @@ def test_update_permission_set_unknown():
assert err["Code"] == "ResourceNotFoundException"
-@mock_ssoadmin
+@mock_aws
def test_describe_permission_set():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
resp = client.create_permission_set(
@@ -478,7 +478,7 @@ def test_describe_permission_set():
assert "SessionDuration" in permission_set
-@mock_ssoadmin
+@mock_aws
def test_describe_permission_set_unknown():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
@@ -491,7 +491,7 @@ def test_describe_permission_set_unknown():
assert err["Code"] == "ResourceNotFoundException"
-@mock_ssoadmin
+@mock_aws
def test_delete_permission_set():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
resp = client.create_permission_set(
@@ -514,7 +514,7 @@ def test_delete_permission_set():
assert err["Code"] == "ResourceNotFoundException"
-@mock_ssoadmin
+@mock_aws
def test_delete_permission_set_unknown():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
@@ -527,7 +527,7 @@ def test_delete_permission_set_unknown():
assert err["Code"] == "ResourceNotFoundException"
-@mock_ssoadmin
+@mock_aws
def test_list_permission_sets():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
@@ -553,7 +553,7 @@ def test_list_permission_sets():
assert len(permission_sets) == 5
-@mock_ssoadmin
+@mock_aws
def test_list_permission_sets_pagination():
client = boto3.client("sso-admin", region_name="ap-southeast-1")
diff --git a/tests/test_ssoadmin/test_ssoadmin_policies.py b/tests/test_ssoadmin/test_ssoadmin_policies.py
index e7a8ab531..e3fcfd9ee 100644
--- a/tests/test_ssoadmin/test_ssoadmin_policies.py
+++ b/tests/test_ssoadmin/test_ssoadmin_policies.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_ssoadmin
+from moto import mock_aws
from moto.iam.aws_managed_policies import aws_managed_policies_data
# See our Development Tips on writing tests for hints on how to write good tests:
@@ -33,7 +33,7 @@ def create_permissionset(client) -> str:
return response["PermissionSet"]["PermissionSetArn"]
-@mock_ssoadmin
+@mock_aws
def test_put_inline_policy_to_permission_set():
"""
Tests putting and getting an inline policy to a permission set.
@@ -81,7 +81,7 @@ def test_put_inline_policy_to_permission_set():
assert err["Message"] == "Could not find PermissionSet with id ps-hhhhkkkkppppoxyz"
-@mock_ssoadmin
+@mock_aws
def test_get_inline_policy_to_permission_set_no_policy():
client = boto3.client("sso-admin", region_name="us-east-1")
@@ -95,7 +95,7 @@ def test_get_inline_policy_to_permission_set_no_policy():
assert response["InlinePolicy"] == ""
-@mock_ssoadmin
+@mock_aws
def test_delete_inline_policy_to_permissionset():
client = boto3.client("sso-admin", region_name="us-east-1")
@@ -138,7 +138,7 @@ def test_delete_inline_policy_to_permissionset():
assert response["InlinePolicy"] == ""
-@mock_ssoadmin
+@mock_aws
def test_attach_managed_policy_to_permission_set():
client = boto3.client("sso-admin", region_name="us-east-1")
@@ -193,7 +193,7 @@ def test_attach_managed_policy_to_permission_set():
)
-@mock_ssoadmin
+@mock_aws
def test_list_managed_policies_quota_limit(managed_policies):
"""
Tests exceeding the managed policy quota limit.
@@ -231,7 +231,7 @@ def test_list_managed_policies_quota_limit(managed_policies):
)
-@mock_ssoadmin
+@mock_aws
def test_list_managed_policies_in_permission_set(managed_policies):
"""
Tests functionality of listing aws managed policies attached to a permission set.
@@ -288,7 +288,7 @@ def test_list_managed_policies_in_permission_set(managed_policies):
)
-@mock_ssoadmin
+@mock_aws
def test_detach_managed_policy_from_permission_set():
client = boto3.client("sso-admin", region_name="us-east-1")
permission_set_arn = create_permissionset(client)
@@ -330,7 +330,7 @@ def test_detach_managed_policy_from_permission_set():
assert len(response["AttachedManagedPolicies"]) == 0
-@mock_ssoadmin
+@mock_aws
def test_attach_customer_managed_policy_reference_to_permission_set():
client = boto3.client("sso-admin", region_name="us-east-1")
permission_set_arn = create_permissionset(client)
@@ -374,7 +374,7 @@ def test_attach_customer_managed_policy_reference_to_permission_set():
)
-@mock_ssoadmin
+@mock_aws
def test_list_customer_managed_policy_references_in_permission_set():
"""
Tests listing customer managed policies including pagination.
@@ -420,7 +420,7 @@ def test_list_customer_managed_policy_references_in_permission_set():
assert len(set(customer_managed_policy_names)) == 3
-@mock_ssoadmin
+@mock_aws
def test_detach_customer_managed_policy_reference_from_permission_set():
client = boto3.client("sso-admin", region_name="us-east-1")
permission_set_arn = create_permissionset(client)
diff --git a/tests/test_stepfunctions/test_stepfunctions.py b/tests/test_stepfunctions/test_stepfunctions.py
index 49a609dcb..a1cf98358 100644
--- a/tests/test_stepfunctions/test_stepfunctions.py
+++ b/tests/test_stepfunctions/test_stepfunctions.py
@@ -9,7 +9,7 @@ import pytest
from botocore.exceptions import ClientError
from dateutil.tz import tzutc
-from moto import mock_stepfunctions, mock_sts
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
region = "us-east-1"
@@ -22,8 +22,7 @@ simple_definition = (
account_id = None
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_creation_succeeds():
client = boto3.client("stepfunctions", region_name=region)
name = "example_step_function"
@@ -39,7 +38,7 @@ def test_state_machine_creation_succeeds():
)
-@mock_stepfunctions
+@mock_aws
def test_state_machine_creation_fails_with_invalid_names():
client = boto3.client("stepfunctions", region_name=region)
invalid_names = [
@@ -143,7 +142,7 @@ def test_state_machine_creation_fails_with_invalid_names():
)
-@mock_stepfunctions
+@mock_aws
def test_state_machine_creation_requires_valid_role_arn():
client = boto3.client("stepfunctions", region_name=region)
name = "example_step_function"
@@ -156,8 +155,7 @@ def test_state_machine_creation_requires_valid_role_arn():
)
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_update_state_machine():
client = boto3.client("stepfunctions", region_name=region)
@@ -183,7 +181,7 @@ def test_update_state_machine():
assert desc["roleArn"] == updated_role
-@mock_stepfunctions
+@mock_aws
def test_state_machine_list_returns_empty_list_by_default():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -191,8 +189,7 @@ def test_state_machine_list_returns_empty_list_by_default():
assert sm_list["stateMachines"] == []
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_list_returns_created_state_machines():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -219,8 +216,7 @@ def test_state_machine_list_returns_created_state_machines():
assert sm_list["stateMachines"][1]["stateMachineArn"] == machine2["stateMachineArn"]
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_list_pagination():
client = boto3.client("stepfunctions", region_name=region)
for i in range(25):
@@ -243,8 +239,7 @@ def test_state_machine_list_pagination():
assert "24" in page_list[-1]["stateMachines"][-1]["name"]
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_creation_is_idempotent_by_name():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -267,8 +262,7 @@ def test_state_machine_creation_is_idempotent_by_name():
assert len(sm_list["stateMachines"]) == 2
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_creation_can_be_described():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -285,8 +279,7 @@ def test_state_machine_creation_can_be_described():
assert desc["status"] == "ACTIVE"
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_throws_error_when_describing_unknown_machine():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -297,8 +290,7 @@ def test_state_machine_throws_error_when_describing_unknown_machine():
client.describe_state_machine(stateMachineArn=unknown_state_machine)
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_throws_error_when_describing_bad_arn():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -306,8 +298,7 @@ def test_state_machine_throws_error_when_describing_bad_arn():
client.describe_state_machine(stateMachineArn="bad")
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_throws_error_when_describing_machine_in_different_account():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -318,8 +309,7 @@ def test_state_machine_throws_error_when_describing_machine_in_different_account
client.describe_state_machine(stateMachineArn=unknown_state_machine)
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_can_be_deleted():
client = boto3.client("stepfunctions", region_name=region)
sm = client.create_state_machine(
@@ -333,8 +323,7 @@ def test_state_machine_can_be_deleted():
assert len(sm_list["stateMachines"]) == 0
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_can_deleted_nonexisting_machine():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -348,7 +337,7 @@ def test_state_machine_can_deleted_nonexisting_machine():
assert len(sm_list["stateMachines"]) == 0
-@mock_stepfunctions
+@mock_aws
def test_state_machine_tagging_non_existent_resource_fails():
client = boto3.client("stepfunctions", region_name=region)
non_existent_arn = f"arn:aws:states:{region}:{ACCOUNT_ID}:stateMachine:non-existent"
@@ -358,7 +347,7 @@ def test_state_machine_tagging_non_existent_resource_fails():
assert non_existent_arn in ex.value.response["Error"]["Message"]
-@mock_stepfunctions
+@mock_aws
def test_state_machine_untagging_non_existent_resource_fails():
client = boto3.client("stepfunctions", region_name=region)
non_existent_arn = f"arn:aws:states:{region}:{ACCOUNT_ID}:stateMachine:non-existent"
@@ -368,8 +357,7 @@ def test_state_machine_untagging_non_existent_resource_fails():
assert non_existent_arn in ex.value.response["Error"]["Message"]
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_tagging():
client = boto3.client("stepfunctions", region_name=region)
tags = [
@@ -397,8 +385,7 @@ def test_state_machine_tagging():
assert resp["tags"] == tags_expected
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_untagging():
client = boto3.client("stepfunctions", region_name=region)
tags = [
@@ -423,8 +410,7 @@ def test_state_machine_untagging():
assert resp["tags"] == expected_tags
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_list_tags_for_created_machine():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -440,8 +426,7 @@ def test_state_machine_list_tags_for_created_machine():
assert tags[0] == {"key": "tag_key", "value": "tag_value"}
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_list_tags_for_machine_without_tags():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -453,8 +438,7 @@ def test_state_machine_list_tags_for_machine_without_tags():
assert len(tags) == 0
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_list_tags_for_nonexisting_machine():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -466,8 +450,7 @@ def test_state_machine_list_tags_for_nonexisting_machine():
assert len(tags) == 0
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_start_execution():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -485,8 +468,7 @@ def test_state_machine_start_execution():
assert isinstance(execution["startDate"], datetime)
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_start_execution_bad_arn_raises_exception():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -494,8 +476,7 @@ def test_state_machine_start_execution_bad_arn_raises_exception():
client.start_execution(stateMachineArn="bad")
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_start_execution_with_custom_name():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -514,8 +495,7 @@ def test_state_machine_start_execution_with_custom_name():
assert isinstance(execution["startDate"], datetime)
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_start_execution_fails_on_duplicate_execution_name():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -535,8 +515,7 @@ def test_state_machine_start_execution_fails_on_duplicate_execution_name():
)
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_start_execution_with_custom_input():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -557,8 +536,7 @@ def test_state_machine_start_execution_with_custom_input():
assert isinstance(execution["startDate"], datetime)
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_start_execution_with_invalid_input():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -571,8 +549,7 @@ def test_state_machine_start_execution_with_invalid_input():
_ = client.start_execution(stateMachineArn=sm["stateMachineArn"], input="{")
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_list_executions():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -594,7 +571,7 @@ def test_state_machine_list_executions():
assert "stopDate" not in executions["executions"][0]
-@mock_stepfunctions
+@mock_aws
def test_state_machine_list_executions_with_filter():
client = boto3.client("stepfunctions", region_name=region)
sm = client.create_state_machine(
@@ -615,7 +592,7 @@ def test_state_machine_list_executions_with_filter():
assert all(e["status"] == "ABORTED" for e in resp["executions"]) is True
-@mock_stepfunctions
+@mock_aws
def test_state_machine_list_executions_with_pagination():
client = boto3.client("stepfunctions", region_name=region)
sm = client.create_state_machine(
@@ -655,8 +632,7 @@ def test_state_machine_list_executions_with_pagination():
assert ex.value.response["Error"]["Code"] == "InvalidToken"
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_list_executions_when_none_exist():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -669,8 +645,7 @@ def test_state_machine_list_executions_when_none_exist():
assert len(executions["executions"]) == 0
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_describe_execution_with_no_input():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -690,8 +665,7 @@ def test_state_machine_describe_execution_with_no_input():
assert "stopDate" not in description
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_describe_execution_with_custom_input():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -714,8 +688,7 @@ def test_state_machine_describe_execution_with_custom_input():
assert "stopDate" not in description
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_execution_throws_error_when_describing_unknown_execution():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -724,8 +697,7 @@ def test_execution_throws_error_when_describing_unknown_execution():
client.describe_execution(executionArn=unknown_execution)
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_can_be_described_by_execution():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -743,8 +715,7 @@ def test_state_machine_can_be_described_by_execution():
assert desc["stateMachineArn"] == sm["stateMachineArn"]
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_throws_error_when_describing_unknown_execution():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -753,8 +724,7 @@ def test_state_machine_throws_error_when_describing_unknown_execution():
client.describe_state_machine_for_execution(executionArn=unknown_execution)
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_stop_execution():
client = boto3.client("stepfunctions", region_name=region)
#
@@ -775,8 +745,7 @@ def test_state_machine_stop_execution():
assert isinstance(execution["stopDate"], datetime)
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_stop_raises_error_when_unknown_execution():
client = boto3.client("stepfunctions", region_name=region)
client.create_state_machine(
@@ -793,8 +762,7 @@ def test_state_machine_stop_raises_error_when_unknown_execution():
assert "Execution Does Not Exist:" in ex.value.response["Error"]["Message"]
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_get_execution_history_throws_error_with_unknown_execution():
client = boto3.client("stepfunctions", region_name=region)
client.create_state_machine(
@@ -811,8 +779,7 @@ def test_state_machine_get_execution_history_throws_error_with_unknown_execution
assert "Execution Does Not Exist:" in ex.value.response["Error"]["Message"]
-@mock_stepfunctions
-@mock_sts
+@mock_aws
def test_state_machine_get_execution_history_contains_expected_success_events_when_started():
expected_events = [
{
@@ -878,15 +845,14 @@ def test_state_machine_get_execution_history_contains_expected_success_events_wh
@pytest.mark.parametrize(
"test_region", ["us-west-2", "cn-northwest-1", "us-isob-east-1"]
)
-@mock_stepfunctions
+@mock_aws
def test_stepfunction_regions(test_region):
client = boto3.client("stepfunctions", region_name=test_region)
resp = client.list_state_machines()
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
-@mock_stepfunctions
-@mock_sts
+@mock_aws
@mock.patch.dict(os.environ, {"SF_EXECUTION_HISTORY_TYPE": "FAILURE"})
def test_state_machine_get_execution_history_contains_expected_failure_events_when_started():
if os.environ.get("TEST_SERVER_MODE", "false").lower() == "true":
@@ -946,7 +912,7 @@ def test_state_machine_get_execution_history_contains_expected_failure_events_wh
assert exc["status"] == "FAILED"
-@mock_stepfunctions
+@mock_aws
def test_state_machine_name_limits():
# Setup
client = boto3.client("stepfunctions", region_name=region)
@@ -969,7 +935,7 @@ def test_state_machine_name_limits():
)
-@mock_stepfunctions
+@mock_aws
def test_state_machine_execution_name_limits():
# Setup
client = boto3.client("stepfunctions", region_name=region)
diff --git a/tests/test_stepfunctions/test_stepfunctions_cloudformation.py b/tests/test_stepfunctions/test_stepfunctions_cloudformation.py
index b1217066d..a1a69d0fb 100644
--- a/tests/test_stepfunctions/test_stepfunctions_cloudformation.py
+++ b/tests/test_stepfunctions/test_stepfunctions_cloudformation.py
@@ -4,11 +4,10 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_cloudformation, mock_stepfunctions
+from moto import mock_aws
-@mock_stepfunctions
-@mock_cloudformation
+@mock_aws
def test_state_machine_cloudformation():
sf = boto3.client("stepfunctions", region_name="us-east-1")
cf = boto3.resource("cloudformation", region_name="us-east-1")
@@ -64,8 +63,7 @@ def test_state_machine_cloudformation():
assert "Does Not Exist" in ex.value.response["Error"]["Message"]
-@mock_stepfunctions
-@mock_cloudformation
+@mock_aws
def test_state_machine_cloudformation_update_with_replacement():
sf = boto3.client("stepfunctions", region_name="us-east-1")
cf = boto3.resource("cloudformation", region_name="us-east-1")
@@ -143,8 +141,7 @@ def test_state_machine_cloudformation_update_with_replacement():
assert "State Machine Does Not Exist" in ex.value.response["Error"]["Message"]
-@mock_stepfunctions
-@mock_cloudformation
+@mock_aws
def test_state_machine_cloudformation_update_with_no_interruption():
sf = boto3.client("stepfunctions", region_name="us-east-1")
cf = boto3.resource("cloudformation", region_name="us-east-1")
diff --git a/tests/test_sts/test_server.py b/tests/test_sts/test_server.py
index 1e9604e16..52e0421d6 100644
--- a/tests/test_sts/test_server.py
+++ b/tests/test_sts/test_server.py
@@ -1,4 +1,3 @@
-"""Test the different server responses."""
import moto.server as server
diff --git a/tests/test_sts/test_sts.py b/tests/test_sts/test_sts.py
index e08aa017c..ec2f6c401 100644
--- a/tests/test_sts/test_sts.py
+++ b/tests/test_sts/test_sts.py
@@ -9,13 +9,13 @@ import pytest
from botocore.client import ClientError
from freezegun import freeze_time
-from moto import mock_iam, mock_sts, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from moto.sts.responses import MAX_FEDERATION_TOKEN_POLICY_LENGTH
@freeze_time("2012-01-01 12:00:00")
-@mock_sts
+@mock_aws
def test_get_session_token_boto3():
client = boto3.client("sts", region_name="us-east-1")
creds = client.get_session_token(DurationSeconds=903)["Credentials"]
@@ -36,7 +36,7 @@ def test_get_session_token_boto3():
@freeze_time("2012-01-01 12:00:00")
-@mock_sts
+@mock_aws
def test_get_federation_token_boto3():
client = boto3.client("sts", region_name="us-east-1")
token_name = "Bob"
@@ -65,8 +65,7 @@ def test_get_federation_token_boto3():
@freeze_time("2012-01-01 12:00:00")
-@mock_sts
-@mock_iam
+@mock_aws
def test_assume_role():
client = boto3.client("sts", region_name="us-east-1")
iam_client = boto3.client("iam", region_name="us-east-1")
@@ -131,7 +130,7 @@ def test_assume_role():
@freeze_time("2012-01-01 12:00:00")
-@mock_sts
+@mock_aws
def test_assume_role_with_saml():
client = boto3.client("sts", region_name="us-east-1")
role_name = "test-role"
@@ -229,7 +228,7 @@ def test_assume_role_with_saml():
@freeze_time("2012-01-01 12:00:00")
-@mock_sts
+@mock_aws
def test_assume_role_with_saml_should_not_rely_on_attribute_order():
client = boto3.client("sts", region_name="us-east-1")
role_name = "test-role"
@@ -315,7 +314,7 @@ def test_assume_role_with_saml_should_not_rely_on_attribute_order():
@freeze_time("2012-01-01 12:00:00")
-@mock_sts
+@mock_aws
def test_assume_role_with_saml_should_respect_xml_namespaces():
client = boto3.client("sts", region_name="us-east-1")
role_name = "test-role"
@@ -401,7 +400,7 @@ def test_assume_role_with_saml_should_respect_xml_namespaces():
@freeze_time("2012-01-01 12:00:00")
-@mock_sts
+@mock_aws
def test_assume_role_with_saml_when_xml_tag_contains_xmlns_attributes():
"""Test assume role with saml when xml tag contains xmlns attributes.
@@ -498,7 +497,7 @@ def test_assume_role_with_saml_when_xml_tag_contains_xmlns_attributes():
@freeze_time("2012-01-01 12:00:00")
-@mock_sts
+@mock_aws
def test_assume_role_with_saml_when_saml_attribute_not_provided():
"""Test session duration when saml attribute are not provided.
@@ -583,7 +582,7 @@ def test_assume_role_with_saml_when_saml_attribute_not_provided():
@freeze_time("2012-01-01 12:00:00")
-@mock_sts
+@mock_aws
def test_assume_role_with_web_identity_boto3():
client = boto3.client("sts", region_name="us-east-1")
@@ -631,7 +630,7 @@ def test_assume_role_with_web_identity_boto3():
assert "session-name" in user["AssumedRoleId"]
-@mock_sts
+@mock_aws
def test_get_caller_identity_with_default_credentials():
identity = boto3.client("sts", region_name="us-east-1").get_caller_identity()
@@ -640,8 +639,7 @@ def test_get_caller_identity_with_default_credentials():
assert identity["Account"] == str(ACCOUNT_ID)
-@mock_sts
-@mock_iam
+@mock_aws
def test_get_caller_identity_with_iam_user_credentials():
iam_client = boto3.client("iam", region_name="us-east-1")
iam_user_name = "new-user"
@@ -660,8 +658,7 @@ def test_get_caller_identity_with_iam_user_credentials():
assert identity["Account"] == str(ACCOUNT_ID)
-@mock_sts
-@mock_iam
+@mock_aws
def test_get_caller_identity_with_assumed_role_credentials():
iam_client = boto3.client("iam", region_name="us-east-1")
sts_client = boto3.client("sts", region_name="us-east-1")
@@ -696,7 +693,7 @@ def test_get_caller_identity_with_assumed_role_credentials():
assert identity["Account"] == str(ACCOUNT_ID)
-@mock_sts
+@mock_aws
def test_federation_token_with_too_long_policy():
"""Test federation token with policy longer than 2048 character fails."""
cli = boto3.client("sts", region_name="us-east-1")
@@ -726,7 +723,7 @@ def test_federation_token_with_too_long_policy():
@patch.dict("os.environ", {"MOTO_ENABLE_ISO_REGIONS": "true"})
@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1", "us-isob-east-1"])
-@mock_sts
+@mock_aws
def test_sts_regions(region):
client = boto3.client("sts", region_name=region)
resp = client.get_caller_identity()
diff --git a/tests/test_sts/test_sts_integration.py b/tests/test_sts/test_sts_integration.py
index 141cd526d..8fe1d7084 100644
--- a/tests/test_sts/test_sts_integration.py
+++ b/tests/test_sts/test_sts_integration.py
@@ -3,13 +3,11 @@ from base64 import b64encode
import boto3
-from moto import mock_dynamodb, mock_iam, mock_sts
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
-@mock_sts
-@mock_iam
-@mock_dynamodb
+@mock_aws
class TestStsAssumeRole(unittest.TestCase):
def setUp(self) -> None:
self.account_b = "111111111111"
diff --git a/tests/test_support/test_server.py b/tests/test_support/test_server.py
index 409f8b8cb..8941a17fd 100644
--- a/tests/test_support/test_server.py
+++ b/tests/test_support/test_server.py
@@ -1,4 +1,3 @@
-"""Test the different server responses for support."""
import moto.server as server
diff --git a/tests/test_support/test_support.py b/tests/test_support/test_support.py
index 91549228e..99fb865d4 100644
--- a/tests/test_support/test_support.py
+++ b/tests/test_support/test_support.py
@@ -1,10 +1,10 @@
import boto3
import pytest
-from moto import mock_support
+from moto import mock_aws
-@mock_support
+@mock_aws
def test_describe_trusted_advisor_checks_returns_amount_of_checks():
"""Test that trusted advisor returns 104 checks."""
client = boto3.client("support", "us-east-1")
@@ -12,7 +12,7 @@ def test_describe_trusted_advisor_checks_returns_amount_of_checks():
assert len(response["checks"]) == 104
-@mock_support
+@mock_aws
def test_describe_trusted_advisor_checks_returns_an_expected_id():
"""Test that a random check id is returned."""
client = boto3.client("support", "us-east-1")
@@ -24,7 +24,7 @@ def test_describe_trusted_advisor_checks_returns_an_expected_id():
assert "zXCkfM1nI3" in check_ids
-@mock_support
+@mock_aws
def test_describe_trusted_advisor_checks_returns_an_expected_check_name():
"""Test that a random check name is returned."""
client = boto3.client("support", "us-east-1")
@@ -36,7 +36,7 @@ def test_describe_trusted_advisor_checks_returns_an_expected_check_name():
assert "Unassociated Elastic IP Addresses" in check_names
-@mock_support
+@mock_aws
def test_refresh_trusted_advisor_check_returns_expected_check():
"""Test refresh of a trusted advisor check returns check id in response."""
client = boto3.client("support", "us-east-1")
@@ -45,7 +45,7 @@ def test_refresh_trusted_advisor_check_returns_expected_check():
assert response["status"]["checkId"] == check_name
-@mock_support
+@mock_aws
def test_refresh_trusted_advisor_check_returns_an_expected_status():
"""Test refresh of a trusted advisor check returns an expected status."""
client = boto3.client("support", "us-east-1")
@@ -63,7 +63,7 @@ def test_refresh_trusted_advisor_check_returns_an_expected_status():
["none", "enqueued", "processing", "success", "abandoned"],
],
)
-@mock_support
+@mock_aws
def test_refresh_trusted_advisor_check_cycles_to_new_status_on_each_call(
possible_statuses,
):
@@ -79,7 +79,7 @@ def test_refresh_trusted_advisor_check_cycles_to_new_status_on_each_call(
assert actual_statuses == possible_statuses
-@mock_support
+@mock_aws
def test_refresh_trusted_advisor_check_cycles_to_new_status_on_with_two_checks():
"""Test next expected status is returned when additional checks are made."""
client = boto3.client("support", "us-east-1")
@@ -108,7 +108,7 @@ def test_refresh_trusted_advisor_check_cycles_to_new_status_on_with_two_checks()
)
-@mock_support
+@mock_aws
def test_refresh_trusted_advisor_check_cycle_continues_on_full_cycle():
"""Test that after cycling through all statuses, check continues cycle."""
client = boto3.client("support", "us-east-1")
@@ -129,7 +129,7 @@ def test_refresh_trusted_advisor_check_cycle_continues_on_full_cycle():
assert expected_none_response["status"]["status"] == "none"
-@mock_support
+@mock_aws
def test_support_case_is_closed():
"""Test that on closing a case, the correct response is returned."""
client = boto3.client("support", "us-east-1")
@@ -164,7 +164,7 @@ def test_support_case_is_closed():
assert expected_final_case == "resolved"
-@mock_support
+@mock_aws
def test_support_case_created():
"""Test support request creation response contains case ID."""
client = boto3.client("support", "us-east-1")
@@ -193,7 +193,7 @@ def test_support_case_created():
("language", "test_language"),
],
)
-@mock_support
+@mock_aws
def test_support_created_case_can_be_described(key, value):
"""Test support request creation can be described."""
@@ -238,7 +238,7 @@ def test_support_created_case_can_be_described(key, value):
("language", "test_language"),
],
)
-@mock_support
+@mock_aws
def test_support_created_case_can_be_described_without_next_token(key, value):
"""Test support request creation can be described without next token."""
@@ -282,7 +282,7 @@ def test_support_created_case_can_be_described_without_next_token(key, value):
("language", "test_language"),
],
)
-@mock_support
+@mock_aws
def test_support_created_case_can_be_described_without_max_results(key, value):
"""Test support request creation can be described without max_results."""
@@ -326,7 +326,7 @@ def test_support_created_case_can_be_described_without_max_results(key, value):
("language", "test_language"),
],
)
-@mock_support
+@mock_aws
def test_support_created_case_can_be_described_without_max_results_or_next_token(
key, value
):
@@ -361,7 +361,7 @@ def test_support_created_case_can_be_described_without_max_results_or_next_token
assert actual_case_id == value
-@mock_support
+@mock_aws
def test_support_created_case_can_be_described_without_params():
"""Test support request creation without params can be described."""
@@ -386,7 +386,7 @@ def test_support_created_case_can_be_described_without_params():
assert len(describe_cases_response["cases"]) == 1
-@mock_support
+@mock_aws
def test_support_created_case_cc_email_correct():
"""Test a support request can be described with correct cc email."""
@@ -421,7 +421,7 @@ def test_support_created_case_cc_email_correct():
assert actual_case_id == "test_email_cc"
-@mock_support
+@mock_aws
def test_support_case_include_resolved_defaults_to_false():
"""Test support request description doesn't include resolved cases."""
client = boto3.client("support", "us-east-1")
@@ -455,7 +455,7 @@ def test_support_case_include_resolved_defaults_to_false():
assert case_id_list not in actual
-@mock_support
+@mock_aws
def test_support_case_include_communications_defaults_to_true():
"""Test support request description includes communications cases."""
client = boto3.client("support", "us-east-1")
@@ -488,7 +488,7 @@ def test_support_case_include_communications_defaults_to_true():
assert "recentCommunications" in actual
-@mock_support
+@mock_aws
def test_multiple_support_created_cases_can_be_described():
"""Test creation of multiple support requests descriptions."""
client = boto3.client("support", "us-east-1")
@@ -536,7 +536,7 @@ def test_multiple_support_created_cases_can_be_described():
assert actual_case_id_2 == case_id_list[1]
-@mock_support
+@mock_aws
def test_support_created_case_can_be_described_and_contains_communications_when_set_to_true():
"""Test support request description when includeResolvedCases=True.
@@ -572,7 +572,7 @@ def test_support_created_case_can_be_described_and_contains_communications_when_
assert "recentCommunications" in actual_recent_comm
-@mock_support
+@mock_aws
def test_support_created_case_can_be_described_and_does_not_contain_communications_when_false():
"""Test support request creation when includeCommunications=False."""
@@ -606,7 +606,7 @@ def test_support_created_case_can_be_described_and_does_not_contain_communicatio
assert "recentCommunications" not in actual_recent_comm
-@mock_support
+@mock_aws
def test_support_created_case_can_be_described_and_contains_resolved_cases_when_true():
"""Test support request creation when includeResolvedCases=true."""
client = boto3.client("support", "us-east-1")
@@ -641,7 +641,7 @@ def test_support_created_case_can_be_described_and_contains_resolved_cases_when_
assert actual == case_id_list
-@mock_support
+@mock_aws
def test_support_created_case_can_be_described_and_does_not_contain_resolved_cases_when_false():
"""Test support request when includeResolvedCases=false."""
client = boto3.client("support", "us-east-1")
@@ -676,7 +676,7 @@ def test_support_created_case_can_be_described_and_does_not_contain_resolved_cas
assert case_id_list not in actual
-@mock_support
+@mock_aws
def test_support_created_case_can_be_described_and_can_cycle_case_severities():
"""Test support request creation cycles case severities."""
client = boto3.client("support", "us-east-1")
diff --git a/tests/test_swf/responses/test_activity_tasks.py b/tests/test_swf/responses/test_activity_tasks.py
index afb941d4f..1d18c6532 100644
--- a/tests/test_swf/responses/test_activity_tasks.py
+++ b/tests/test_swf/responses/test_activity_tasks.py
@@ -5,14 +5,14 @@ import pytest
from botocore.exceptions import ClientError
from freezegun import freeze_time
-from moto import mock_swf, settings
+from moto import mock_aws, settings
from ..utils import SCHEDULE_ACTIVITY_TASK_DECISION, setup_workflow_boto3
# PollForActivityTask endpoint
-@mock_swf
+@mock_aws
def test_poll_for_activity_task_when_one_boto3():
client = setup_workflow_boto3()
decision_token = client.poll_for_decision_task(
@@ -41,7 +41,7 @@ def test_poll_for_activity_task_when_one_boto3():
@pytest.mark.parametrize("task_name", ["activity-task-list", "non-existent-queue"])
-@mock_swf
+@mock_aws
def test_poll_for_activity_task_when_none_boto3(task_name):
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -58,7 +58,7 @@ def test_poll_for_activity_task_when_none_boto3(task_name):
@pytest.mark.parametrize(
"task_name,cnt", [("activity-task-list", 1), ("non-existent", 0)]
)
-@mock_swf
+@mock_aws
def test_count_pending_activity_tasks_boto3(task_name, cnt):
client = setup_workflow_boto3()
decision_token = client.poll_for_decision_task(
@@ -78,7 +78,7 @@ def test_count_pending_activity_tasks_boto3(task_name, cnt):
# RespondActivityTaskCompleted endpoint
-@mock_swf
+@mock_aws
def test_respond_activity_task_completed_boto3():
client = setup_workflow_boto3()
decision_token = client.poll_for_decision_task(
@@ -107,7 +107,7 @@ def test_respond_activity_task_completed_boto3():
}
-@mock_swf
+@mock_aws
def test_respond_activity_task_completed_on_closed_workflow_execution_boto3():
client = setup_workflow_boto3()
decision_token = client.poll_for_decision_task(
@@ -131,7 +131,7 @@ def test_respond_activity_task_completed_on_closed_workflow_execution_boto3():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_respond_activity_task_completed_with_task_already_completed_boto3():
client = setup_workflow_boto3()
decision_token = client.poll_for_decision_task(
@@ -158,7 +158,7 @@ def test_respond_activity_task_completed_with_task_already_completed_boto3():
# RespondActivityTaskFailed endpoint
-@mock_swf
+@mock_aws
def test_respond_activity_task_failed_boto3():
client = setup_workflow_boto3()
decision_token = client.poll_for_decision_task(
@@ -188,7 +188,7 @@ def test_respond_activity_task_failed_boto3():
}
-@mock_swf
+@mock_aws
def test_respond_activity_task_completed_with_wrong_token_boto3():
# NB: we just test ONE failure case for RespondActivityTaskFailed
# because the safeguards are shared with RespondActivityTaskCompleted, so
@@ -214,7 +214,7 @@ def test_respond_activity_task_completed_with_wrong_token_boto3():
# RecordActivityTaskHeartbeat endpoint
-@mock_swf
+@mock_aws
def test_record_activity_task_heartbeat_boto3():
client = setup_workflow_boto3()
decision_token = client.poll_for_decision_task(
@@ -231,7 +231,7 @@ def test_record_activity_task_heartbeat_boto3():
assert resp["cancelRequested"] is False
-@mock_swf
+@mock_aws
def test_record_activity_task_heartbeat_with_wrong_token_boto3():
client = setup_workflow_boto3()
decision_token = client.poll_for_decision_task(
@@ -251,7 +251,7 @@ def test_record_activity_task_heartbeat_with_wrong_token_boto3():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_record_activity_task_heartbeat_sets_details_in_case_of_timeout_boto3():
if settings.TEST_SERVER_MODE:
raise SkipTest("Unable to manipulate time in ServerMode")
diff --git a/tests/test_swf/responses/test_activity_types.py b/tests/test_swf/responses/test_activity_types.py
index d723bd227..e97deeec9 100644
--- a/tests/test_swf/responses/test_activity_types.py
+++ b/tests/test_swf/responses/test_activity_types.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_swf
+from moto import mock_aws
# RegisterActivityType endpoint
-@mock_swf
+@mock_aws
def test_register_activity_type_boto3():
client = boto3.client("swf", region_name="us-west-2")
client.register_domain(
@@ -25,7 +25,7 @@ def test_register_activity_type_boto3():
assert actype["activityType"]["version"] == "v1.0"
-@mock_swf
+@mock_aws
def test_register_already_existing_activity_type_boto3():
client = boto3.client("swf", region_name="us-west-2")
client.register_domain(
@@ -50,7 +50,7 @@ def test_register_already_existing_activity_type_boto3():
# ListActivityTypes endpoint
-@mock_swf
+@mock_aws
def test_list_activity_types_boto3():
client = boto3.client("swf", region_name="us-west-2")
client.register_domain(
@@ -75,7 +75,7 @@ def test_list_activity_types_boto3():
assert names == ["a-test-activity", "b-test-activity", "c-test-activity"]
-@mock_swf
+@mock_aws
def test_list_activity_types_reverse_order_boto3():
client = boto3.client("swf", region_name="us-west-2")
client.register_domain(
@@ -102,7 +102,7 @@ def test_list_activity_types_reverse_order_boto3():
# DeprecateActivityType endpoint
-@mock_swf
+@mock_aws
def test_deprecate_activity_type_boto3():
client = boto3.client("swf", region_name="us-west-2")
client.register_domain(
@@ -124,7 +124,7 @@ def test_deprecate_activity_type_boto3():
assert actype["activityType"]["version"] == "v1.0"
-@mock_swf
+@mock_aws
def test_deprecate_already_deprecated_activity_type_boto3():
client = boto3.client("swf", region_name="us-west-2")
client.register_domain(
@@ -149,7 +149,7 @@ def test_deprecate_already_deprecated_activity_type_boto3():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_deprecate_non_existent_activity_type_boto3():
client = boto3.client("swf", region_name="us-west-2")
client.register_domain(
@@ -169,7 +169,7 @@ def test_deprecate_non_existent_activity_type_boto3():
# DeprecateActivityType endpoint
-@mock_swf
+@mock_aws
def test_undeprecate_activity_type():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -191,7 +191,7 @@ def test_undeprecate_activity_type():
assert resp["typeInfo"]["status"] == "REGISTERED"
-@mock_swf
+@mock_aws
def test_undeprecate_already_undeprecated_activity_type():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -214,7 +214,7 @@ def test_undeprecate_already_undeprecated_activity_type():
)
-@mock_swf
+@mock_aws
def test_undeprecate_never_deprecated_activity_type():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -231,7 +231,7 @@ def test_undeprecate_never_deprecated_activity_type():
)
-@mock_swf
+@mock_aws
def test_undeprecate_non_existent_activity_type():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -246,7 +246,7 @@ def test_undeprecate_non_existent_activity_type():
# DescribeActivityType endpoint
-@mock_swf
+@mock_aws
def test_describe_activity_type_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -270,7 +270,7 @@ def test_describe_activity_type_boto3():
assert infos["status"] == "REGISTERED"
-@mock_swf
+@mock_aws
def test_describe_non_existent_activity_type_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
diff --git a/tests/test_swf/responses/test_decision_tasks.py b/tests/test_swf/responses/test_decision_tasks.py
index 9e688ef36..b282c15be 100644
--- a/tests/test_swf/responses/test_decision_tasks.py
+++ b/tests/test_swf/responses/test_decision_tasks.py
@@ -7,14 +7,14 @@ from botocore.exceptions import ClientError
from dateutil.parser import parse as dtparse
from freezegun import freeze_time
-from moto import mock_swf, settings
+from moto import mock_aws, settings
from ..utils import setup_workflow_boto3
# PollForDecisionTask endpoint
-@mock_swf
+@mock_aws
def test_poll_for_decision_task_when_one_boto3():
client = setup_workflow_boto3()
@@ -40,7 +40,7 @@ def test_poll_for_decision_task_when_one_boto3():
)
-@mock_swf
+@mock_aws
def test_poll_for_decision_task_previous_started_event_id_boto3():
client = setup_workflow_boto3()
@@ -70,7 +70,7 @@ def test_poll_for_decision_task_previous_started_event_id_boto3():
assert resp["previousStartedEventId"] == 3
-@mock_swf
+@mock_aws
def test_poll_for_decision_task_ensure_single_started_task():
client = setup_workflow_boto3()
@@ -137,7 +137,7 @@ def test_poll_for_decision_task_ensure_single_started_task():
]
-@mock_swf
+@mock_aws
def test_poll_for_decision_task_exclude_completed_executions():
client = setup_workflow_boto3()
@@ -157,7 +157,7 @@ def test_poll_for_decision_task_exclude_completed_executions():
assert "taskToken" not in resp
-@mock_swf
+@mock_aws
def test_poll_for_decision_task_when_none_boto3():
client = setup_workflow_boto3()
@@ -172,7 +172,7 @@ def test_poll_for_decision_task_when_none_boto3():
assert resp["startedEventId"] == 0
-@mock_swf
+@mock_aws
def test_poll_for_decision_task_on_non_existent_queue_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -182,7 +182,7 @@ def test_poll_for_decision_task_on_non_existent_queue_boto3():
assert resp["startedEventId"] == 0
-@mock_swf
+@mock_aws
def test_poll_for_decision_task_with_reverse_order_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -199,7 +199,7 @@ def test_poll_for_decision_task_with_reverse_order_boto3():
# CountPendingDecisionTasks endpoint
-@mock_swf
+@mock_aws
def test_count_pending_decision_tasks_boto3():
client = setup_workflow_boto3()
client.poll_for_decision_task(domain="test-domain", taskList={"name": "queue"})
@@ -210,7 +210,7 @@ def test_count_pending_decision_tasks_boto3():
assert resp["truncated"] is False
-@mock_swf
+@mock_aws
def test_count_pending_decision_tasks_on_non_existent_task_list_boto3():
client = setup_workflow_boto3()
resp = client.count_pending_decision_tasks(
@@ -220,7 +220,7 @@ def test_count_pending_decision_tasks_on_non_existent_task_list_boto3():
assert resp["truncated"] is False
-@mock_swf
+@mock_aws
def test_count_pending_decision_tasks_after_decision_completes_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -238,7 +238,7 @@ def test_count_pending_decision_tasks_after_decision_completes_boto3():
# RespondDecisionTaskCompleted endpoint
-@mock_swf
+@mock_aws
def test_respond_decision_task_completed_with_no_decision_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -275,7 +275,7 @@ def test_respond_decision_task_completed_with_no_decision_boto3():
assert resp["latestExecutionContext"] == "free-form context"
-@mock_swf
+@mock_aws
def test_respond_decision_task_completed_with_wrong_token_boto3():
client = setup_workflow_boto3()
client.poll_for_decision_task(domain="test-domain", taskList={"name": "queue"})
@@ -286,7 +286,7 @@ def test_respond_decision_task_completed_with_wrong_token_boto3():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_respond_decision_task_completed_on_close_workflow_execution_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -305,7 +305,7 @@ def test_respond_decision_task_completed_on_close_workflow_execution_boto3():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_respond_decision_task_completed_with_task_already_completed_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -323,7 +323,7 @@ def test_respond_decision_task_completed_with_task_already_completed_boto3():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_respond_decision_task_completed_with_complete_workflow_execution_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -357,7 +357,7 @@ def test_respond_decision_task_completed_with_complete_workflow_execution_boto3(
)
-@mock_swf
+@mock_aws
def test_respond_decision_task_completed_with_close_decision_not_last_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -381,7 +381,7 @@ def test_respond_decision_task_completed_with_close_decision_not_last_boto3():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_respond_decision_task_completed_with_invalid_decision_type_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -406,7 +406,7 @@ def test_respond_decision_task_completed_with_invalid_decision_type_boto3():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_respond_decision_task_completed_with_missing_attributes_totally_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -432,7 +432,7 @@ def test_respond_decision_task_completed_with_missing_attributes_totally_boto3()
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_respond_decision_task_completed_with_fail_workflow_execution_boto3():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -468,7 +468,7 @@ def test_respond_decision_task_completed_with_fail_workflow_execution_boto3():
assert attrs["details"] == "foo"
-@mock_swf
+@mock_aws
@freeze_time("2015-01-01 12:00:00 UTC")
def test_respond_decision_task_completed_with_schedule_activity_task_boto3():
client = setup_workflow_boto3()
@@ -522,7 +522,7 @@ def test_respond_decision_task_completed_with_schedule_activity_task_boto3():
assert ts == dtparse("2015-01-01 12:00:00 UTC")
-@mock_swf
+@mock_aws
def test_record_marker_decision():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -556,7 +556,7 @@ def test_record_marker_decision():
}
-@mock_swf
+@mock_aws
def test_start_and_fire_timer_decision():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
@@ -601,7 +601,7 @@ def test_start_and_fire_timer_decision():
}
-@mock_swf
+@mock_aws
def test_cancel_workflow_decision():
client = setup_workflow_boto3()
resp = client.poll_for_decision_task(
diff --git a/tests/test_swf/responses/test_domains.py b/tests/test_swf/responses/test_domains.py
index a6d08ceb8..838577a99 100644
--- a/tests/test_swf/responses/test_domains.py
+++ b/tests/test_swf/responses/test_domains.py
@@ -2,12 +2,12 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_swf
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
# RegisterDomain endpoint
-@mock_swf
+@mock_aws
def test_register_domain_boto3():
client = boto3.client("swf", region_name="us-west-1")
client.register_domain(
@@ -26,7 +26,7 @@ def test_register_domain_boto3():
assert domain["arn"] == f"arn:aws:swf:us-west-1:{ACCOUNT_ID}:/domain/test-domain"
-@mock_swf
+@mock_aws
def test_register_already_existing_domain_boto3():
client = boto3.client("swf", region_name="us-west-1")
client.register_domain(
@@ -47,7 +47,7 @@ def test_register_already_existing_domain_boto3():
# ListDomains endpoint
-@mock_swf
+@mock_aws
def test_list_domains_order_boto3():
client = boto3.client("swf", region_name="us-west-1")
client.register_domain(
@@ -67,7 +67,7 @@ def test_list_domains_order_boto3():
assert names == ["a-test-domain", "b-test-domain", "c-test-domain"]
-@mock_swf
+@mock_aws
def test_list_domains_reverse_order_boto3():
client = boto3.client("swf", region_name="us-west-1")
client.register_domain(
@@ -90,7 +90,7 @@ def test_list_domains_reverse_order_boto3():
# DeprecateDomain endpoint
-@mock_swf
+@mock_aws
def test_deprecate_domain_boto3():
client = boto3.client("swf", region_name="us-west-1")
client.register_domain(
@@ -108,7 +108,7 @@ def test_deprecate_domain_boto3():
assert domain["name"] == "test-domain"
-@mock_swf
+@mock_aws
def test_deprecate_already_deprecated_domain_boto3():
client = boto3.client("swf", region_name="us-west-1")
client.register_domain(
@@ -123,7 +123,7 @@ def test_deprecate_already_deprecated_domain_boto3():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_deprecate_non_existent_domain_boto3():
client = boto3.client("swf", region_name="us-west-1")
@@ -135,7 +135,7 @@ def test_deprecate_non_existent_domain_boto3():
# UndeprecateDomain endpoint
-@mock_swf
+@mock_aws
def test_undeprecate_domain():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -149,7 +149,7 @@ def test_undeprecate_domain():
assert resp["domainInfo"]["status"] == "REGISTERED"
-@mock_swf
+@mock_aws
def test_undeprecate_already_undeprecated_domain():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -162,7 +162,7 @@ def test_undeprecate_already_undeprecated_domain():
client.undeprecate_domain(name="test-domain")
-@mock_swf
+@mock_aws
def test_undeprecate_never_deprecated_domain():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -173,7 +173,7 @@ def test_undeprecate_never_deprecated_domain():
client.undeprecate_domain(name="test-domain")
-@mock_swf
+@mock_aws
def test_undeprecate_non_existent_domain():
client = boto3.client("swf", region_name="us-east-1")
@@ -182,7 +182,7 @@ def test_undeprecate_non_existent_domain():
# DescribeDomain endpoint
-@mock_swf
+@mock_aws
def test_describe_domain_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -198,7 +198,7 @@ def test_describe_domain_boto3():
assert domain["domainInfo"]["status"] == "REGISTERED"
-@mock_swf
+@mock_aws
def test_describe_non_existent_domain_boto3():
client = boto3.client("swf", region_name="us-west-1")
diff --git a/tests/test_swf/responses/test_timeouts.py b/tests/test_swf/responses/test_timeouts.py
index 490eb2c17..7af878b02 100644
--- a/tests/test_swf/responses/test_timeouts.py
+++ b/tests/test_swf/responses/test_timeouts.py
@@ -4,14 +4,14 @@ from unittest import SkipTest
from dateutil.parser import parse as dtparse
from freezegun import freeze_time
-from moto import mock_swf, settings
+from moto import mock_aws, settings
from ..utils import SCHEDULE_ACTIVITY_TASK_DECISION, setup_workflow_boto3
# Activity Task Heartbeat timeout
# Default value in workflow helpers: 5 mins
-@mock_swf
+@mock_aws
def test_activity_task_heartbeat_timeout_boto3():
if settings.TEST_SERVER_MODE:
raise SkipTest("Unable to manipulate time in ServerMode")
@@ -54,7 +54,7 @@ def test_activity_task_heartbeat_timeout_boto3():
# Decision Task Start to Close timeout
# Default value in workflow helpers: 5 mins
-@mock_swf
+@mock_aws
def test_decision_task_start_to_close_timeout_boto3():
if settings.TEST_SERVER_MODE:
raise SkipTest("Unable to manipulate time in ServerMode")
@@ -105,7 +105,7 @@ def test_decision_task_start_to_close_timeout_boto3():
# Workflow Execution Start to Close timeout
# Default value in workflow helpers: 2 hours
-@mock_swf
+@mock_aws
def test_workflow_execution_start_to_close_timeout_boto3():
if settings.TEST_SERVER_MODE:
raise SkipTest("Unable to manipulate time in ServerMode")
diff --git a/tests/test_swf/responses/test_workflow_executions.py b/tests/test_swf/responses/test_workflow_executions.py
index d17276b55..d5c36aa65 100644
--- a/tests/test_swf/responses/test_workflow_executions.py
+++ b/tests/test_swf/responses/test_workflow_executions.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_swf
+from moto import mock_aws
from moto.core.utils import unix_time, utcnow
@@ -31,7 +31,7 @@ def setup_swf_environment_boto3():
# StartWorkflowExecution endpoint
-@mock_swf
+@mock_aws
def test_start_workflow_execution_boto3():
client = setup_swf_environment_boto3()
@@ -43,7 +43,7 @@ def test_start_workflow_execution_boto3():
assert "runId" in wf
-@mock_swf
+@mock_aws
def test_signal_workflow_execution_boto3():
client = setup_swf_environment_boto3()
hsh = client.start_workflow_execution(
@@ -68,7 +68,7 @@ def test_signal_workflow_execution_boto3():
assert wfe["openCounts"]["openDecisionTasks"] == 2
-@mock_swf
+@mock_aws
def test_signal_workflow_execution_without_runId():
conn = setup_swf_environment_boto3()
hsh = conn.start_workflow_execution(
@@ -93,7 +93,7 @@ def test_signal_workflow_execution_without_runId():
assert "WorkflowExecutionSignaled" in types
-@mock_swf
+@mock_aws
def test_start_already_started_workflow_execution_boto3():
client = setup_swf_environment_boto3()
client.start_workflow_execution(
@@ -113,7 +113,7 @@ def test_start_already_started_workflow_execution_boto3():
assert ex.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
-@mock_swf
+@mock_aws
def test_start_workflow_execution_on_deprecated_type_boto3():
client = setup_swf_environment_boto3()
client.deprecate_workflow_type(
@@ -134,7 +134,7 @@ def test_start_workflow_execution_on_deprecated_type_boto3():
# DescribeWorkflowExecution endpoint
-@mock_swf
+@mock_aws
def test_describe_workflow_execution_boto3():
client = setup_swf_environment_boto3()
hsh = client.start_workflow_execution(
@@ -151,7 +151,7 @@ def test_describe_workflow_execution_boto3():
assert wfe["executionInfo"]["executionStatus"] == "OPEN"
-@mock_swf
+@mock_aws
def test_describe_non_existent_workflow_execution_boto3():
client = setup_swf_environment_boto3()
@@ -168,7 +168,7 @@ def test_describe_non_existent_workflow_execution_boto3():
# GetWorkflowExecutionHistory endpoint
-@mock_swf
+@mock_aws
def test_get_workflow_execution_history_boto3():
client = setup_swf_environment_boto3()
hsh = client.start_workflow_execution(
@@ -185,7 +185,7 @@ def test_get_workflow_execution_history_boto3():
assert types == ["WorkflowExecutionStarted", "DecisionTaskScheduled"]
-@mock_swf
+@mock_aws
def test_get_workflow_execution_history_with_reverse_order_boto3():
client = setup_swf_environment_boto3()
hsh = client.start_workflow_execution(
@@ -204,7 +204,7 @@ def test_get_workflow_execution_history_with_reverse_order_boto3():
assert types == ["DecisionTaskScheduled", "WorkflowExecutionStarted"]
-@mock_swf
+@mock_aws
def test_get_workflow_execution_history_on_non_existent_workflow_execution_boto3():
client = setup_swf_environment_boto3()
@@ -221,7 +221,7 @@ def test_get_workflow_execution_history_on_non_existent_workflow_execution_boto3
# ListOpenWorkflowExecutions endpoint
-@mock_swf
+@mock_aws
def test_list_open_workflow_executions_boto3():
client = setup_swf_environment_boto3()
# One open workflow execution
@@ -263,7 +263,7 @@ def test_list_open_workflow_executions_boto3():
# ListClosedWorkflowExecutions endpoint
-@mock_swf
+@mock_aws
def test_list_closed_workflow_executions_boto3():
client = setup_swf_environment_boto3()
# Leave one workflow execution open to make sure it isn't displayed
@@ -305,7 +305,7 @@ def test_list_closed_workflow_executions_boto3():
# TerminateWorkflowExecution endpoint
-@mock_swf
+@mock_aws
def test_terminate_workflow_execution_boto3():
client = setup_swf_environment_boto3()
run_id = client.start_workflow_execution(
@@ -333,7 +333,7 @@ def test_terminate_workflow_execution_boto3():
assert attrs["cause"] == "OPERATOR_INITIATED"
-@mock_swf
+@mock_aws
def test_terminate_workflow_execution_with_wrong_workflow_or_run_id_boto3():
client = setup_swf_environment_boto3()
run_id = client.start_workflow_execution(
diff --git a/tests/test_swf/responses/test_workflow_types.py b/tests/test_swf/responses/test_workflow_types.py
index 6e055956f..7c38f913d 100644
--- a/tests/test_swf/responses/test_workflow_types.py
+++ b/tests/test_swf/responses/test_workflow_types.py
@@ -2,11 +2,11 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_swf
+from moto import mock_aws
# RegisterWorkflowType endpoint
-@mock_swf
+@mock_aws
def test_register_workflow_type_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -24,7 +24,7 @@ def test_register_workflow_type_boto3():
assert actype["workflowType"]["version"] == "v1.0"
-@mock_swf
+@mock_aws
def test_register_already_existing_workflow_type_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -45,7 +45,7 @@ def test_register_already_existing_workflow_type_boto3():
# ListWorkflowTypes endpoint
-@mock_swf
+@mock_aws
def test_list_workflow_types_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -72,7 +72,7 @@ def test_list_workflow_types_boto3():
# ListWorkflowTypes endpoint
-@mock_swf
+@mock_aws
def test_list_workflow_types_reverse_order_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -99,7 +99,7 @@ def test_list_workflow_types_reverse_order_boto3():
# DeprecateWorkflowType endpoint
-@mock_swf
+@mock_aws
def test_deprecate_workflow_type_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -120,7 +120,7 @@ def test_deprecate_workflow_type_boto3():
assert actype["workflowType"]["version"] == "v1.0"
-@mock_swf
+@mock_aws
def test_deprecate_already_deprecated_workflow_type_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -144,7 +144,7 @@ def test_deprecate_already_deprecated_workflow_type_boto3():
)
-@mock_swf
+@mock_aws
def test_deprecate_non_existent_workflow_type_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -163,7 +163,7 @@ def test_deprecate_non_existent_workflow_type_boto3():
# UndeprecateWorkflowType endpoint
-@mock_swf
+@mock_aws
def test_undeprecate_workflow_type():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -185,7 +185,7 @@ def test_undeprecate_workflow_type():
assert resp["typeInfo"]["status"] == "REGISTERED"
-@mock_swf
+@mock_aws
def test_undeprecate_already_undeprecated_workflow_type():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -208,7 +208,7 @@ def test_undeprecate_already_undeprecated_workflow_type():
)
-@mock_swf
+@mock_aws
def test_undeprecate_never_deprecated_workflow_type():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -225,7 +225,7 @@ def test_undeprecate_never_deprecated_workflow_type():
)
-@mock_swf
+@mock_aws
def test_undeprecate_non_existent_workflow_type():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
@@ -240,7 +240,7 @@ def test_undeprecate_non_existent_workflow_type():
# DescribeWorkflowType endpoint
-@mock_swf
+@mock_aws
def test_describe_workflow_type_full_boto3():
# boto3 required as boto doesn't support all of the arguments
client = boto3.client("swf", region_name="us-east-1")
@@ -275,7 +275,7 @@ def test_describe_workflow_type_full_boto3():
assert resp["configuration"]["defaultLambdaRole"] == "arn:bar"
-@mock_swf
+@mock_aws
def test_describe_non_existent_workflow_type_boto3():
client = boto3.client("swf", region_name="us-east-1")
client.register_domain(
diff --git a/tests/test_textract/test_server.py b/tests/test_textract/test_server.py
index d84f4a0b1..0bf2ffc25 100644
--- a/tests/test_textract/test_server.py
+++ b/tests/test_textract/test_server.py
@@ -1,11 +1,10 @@
-"""Test different server responses."""
import json
import moto.server as server
-from moto import mock_textract
+from moto import mock_aws
-@mock_textract
+@mock_aws
def test_textract_start_text_detection():
backend = server.create_backend_app("textract")
test_client = backend.test_client()
@@ -23,7 +22,7 @@ def test_textract_start_text_detection():
assert isinstance(data["JobId"], str)
-@mock_textract
+@mock_aws
def test_detect_document_text():
backend = server.create_backend_app("textract")
test_client = backend.test_client()
@@ -39,7 +38,7 @@ def test_detect_document_text():
assert isinstance(data["Blocks"], list)
-@mock_textract
+@mock_aws
def test_textract_start_text_detection_without_document_location():
backend = server.create_backend_app("textract")
test_client = backend.test_client()
@@ -55,7 +54,7 @@ def test_textract_start_text_detection_without_document_location():
)
-@mock_textract
+@mock_aws
def test_textract_get_text_detection():
backend = server.create_backend_app("textract")
test_client = backend.test_client()
@@ -80,7 +79,7 @@ def test_textract_get_text_detection():
assert data["JobStatus"] == "SUCCEEDED"
-@mock_textract
+@mock_aws
def test_textract_get_text_detection_without_job_id():
backend = server.create_backend_app("textract")
test_client = backend.test_client()
diff --git a/tests/test_textract/test_textract.py b/tests/test_textract/test_textract.py
index 818d9580a..e8a24bb15 100644
--- a/tests/test_textract/test_textract.py
+++ b/tests/test_textract/test_textract.py
@@ -1,4 +1,3 @@
-"""Unit tests for textract-supported APIs."""
from random import randint
from unittest import SkipTest
@@ -6,14 +5,14 @@ import boto3
import pytest
from botocore.exceptions import ClientError, ParamValidationError
-from moto import mock_textract, settings
+from moto import mock_aws, settings
from moto.textract.models import TextractBackend
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
-@mock_textract
+@mock_aws
def test_get_document_text_detection():
if settings.TEST_SERVER_MODE:
raise SkipTest("Cannot set textract backend values in server mode")
@@ -54,7 +53,7 @@ def test_get_document_text_detection():
assert resp["DocumentMetadata"]["Pages"] == TextractBackend.PAGES
-@mock_textract
+@mock_aws
def test_start_document_text_detection():
client = boto3.client("textract", region_name="us-east-1")
resp = client.start_document_text_detection(
@@ -64,7 +63,7 @@ def test_start_document_text_detection():
assert "JobId" in resp
-@mock_textract
+@mock_aws
def test_get_document_text_detection_without_job_id():
client = boto3.client("textract", region_name="us-east-1")
with pytest.raises(ClientError) as e:
@@ -73,7 +72,7 @@ def test_get_document_text_detection_without_job_id():
assert e.value.response["Error"]["Code"] == "InvalidJobIdException"
-@mock_textract
+@mock_aws
def test_get_document_text_detection_without_document_location():
client = boto3.client("textract", region_name="us-east-1")
with pytest.raises(ParamValidationError) as e:
@@ -86,7 +85,7 @@ def test_get_document_text_detection_without_document_location():
)
-@mock_textract
+@mock_aws
def test_detect_document_text():
client = boto3.client("textract", region_name="us-east-1")
result = client.detect_document_text(
diff --git a/tests/test_timestreamwrite/__init__.py b/tests/test_timestreamwrite/__init__.py
index 94cbaf92e..211bde487 100644
--- a/tests/test_timestreamwrite/__init__.py
+++ b/tests/test_timestreamwrite/__init__.py
@@ -1,7 +1,7 @@
import os
from functools import wraps
-from moto import mock_s3, mock_sts, mock_timestreamwrite
+from moto import mock_aws
def timestreamwrite_aws_verified(func):
@@ -10,7 +10,7 @@ def timestreamwrite_aws_verified(func):
Can be run against AWS at any time by setting:
MOTO_TEST_ALLOW_AWS_REQUEST=true
- If this environment variable is not set, the function runs in a `mock_timestreamwrite`, `mock_s3` and `mock_sts` context.
+ If this environment variable is not set, the function runs in a `mock_aws` context.
"""
@@ -23,7 +23,7 @@ def timestreamwrite_aws_verified(func):
if allow_aws_request:
return func()
else:
- with mock_timestreamwrite(), mock_s3(), mock_sts():
+ with mock_aws():
return func()
return pagination_wrapper
diff --git a/tests/test_timestreamwrite/test_server.py b/tests/test_timestreamwrite/test_server.py
index f2ceb65d6..44101e5e7 100644
--- a/tests/test_timestreamwrite/test_server.py
+++ b/tests/test_timestreamwrite/test_server.py
@@ -1,10 +1,10 @@
import json
import moto.server as server
-from moto import mock_timestreamwrite
+from moto import mock_aws
-@mock_timestreamwrite
+@mock_aws
def test_timestreamwrite_list():
backend = server.create_backend_app("timestream-write")
test_client = backend.test_client()
diff --git a/tests/test_timestreamwrite/test_timestreamwrite_database.py b/tests/test_timestreamwrite/test_timestreamwrite_database.py
index 9596fd065..a600f6dca 100644
--- a/tests/test_timestreamwrite/test_timestreamwrite_database.py
+++ b/tests/test_timestreamwrite/test_timestreamwrite_database.py
@@ -4,7 +4,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_timestreamwrite
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from . import timestreamwrite_aws_verified
@@ -37,7 +37,7 @@ def test_create_database_simple():
ts.delete_database(DatabaseName=db_name)
-@mock_timestreamwrite
+@mock_aws
def test_create_database_advanced():
ts = boto3.client("timestream-write", region_name="us-east-1")
resp = ts.create_database(
@@ -55,7 +55,7 @@ def test_create_database_advanced():
assert database["KmsKeyId"] == "mykey"
-@mock_timestreamwrite
+@mock_aws
def test_describe_database():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="mydatabase", KmsKeyId="mykey")
@@ -81,7 +81,7 @@ def test_describe_unknown_database():
assert err["Message"] == "The database unknown does not exist."
-@mock_timestreamwrite
+@mock_aws
def test_list_databases():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="db_with", KmsKeyId="mykey")
@@ -109,7 +109,7 @@ def test_list_databases():
} in databases
-@mock_timestreamwrite
+@mock_aws
def test_delete_database():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="db_1", KmsKeyId="mykey")
@@ -125,7 +125,7 @@ def test_delete_database():
assert [db["DatabaseName"] for db in databases] == ["db_1", "db_3"]
-@mock_timestreamwrite
+@mock_aws
def test_update_database():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="mydatabase", KmsKeyId="mykey")
diff --git a/tests/test_timestreamwrite/test_timestreamwrite_table.py b/tests/test_timestreamwrite/test_timestreamwrite_table.py
index 201177adf..c94beab9b 100644
--- a/tests/test_timestreamwrite/test_timestreamwrite_table.py
+++ b/tests/test_timestreamwrite/test_timestreamwrite_table.py
@@ -5,7 +5,7 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_timestreamwrite, settings
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from . import timestreamwrite_aws_verified
@@ -122,7 +122,7 @@ def test_create_table_without_retention_properties():
ts.delete_database(DatabaseName=db_name)
-@mock_timestreamwrite
+@mock_aws
def test_describe_table():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="mydatabase")
@@ -167,7 +167,7 @@ def test_describe_unknown_database():
ts.delete_database(DatabaseName=db_name)
-@mock_timestreamwrite
+@mock_aws
def test_create_multiple_tables():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="mydatabase")
@@ -199,7 +199,7 @@ def test_create_multiple_tables():
assert {t["TableStatus"] for t in tables} == {"ACTIVE"}
-@mock_timestreamwrite
+@mock_aws
def test_delete_table():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="mydatabase")
@@ -224,7 +224,7 @@ def test_delete_table():
assert {t["TableName"] for t in tables} == {"mytable_0", "mytable_2"}
-@mock_timestreamwrite
+@mock_aws
def test_update_table():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="mydatabase")
@@ -257,7 +257,7 @@ def test_update_table():
}
-@mock_timestreamwrite
+@mock_aws
def test_update_table__with_magnetic_store_write_properties():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="mydatabase")
@@ -289,7 +289,7 @@ def test_update_table__with_magnetic_store_write_properties():
}
-@mock_timestreamwrite
+@mock_aws
def test_write_records():
# The query-feature is not available at the moment,
# so there's no way for us to verify writing records is successful
diff --git a/tests/test_timestreamwrite/test_timestreamwrite_tagging.py b/tests/test_timestreamwrite/test_timestreamwrite_tagging.py
index a2def7986..f4f9c510c 100644
--- a/tests/test_timestreamwrite/test_timestreamwrite_tagging.py
+++ b/tests/test_timestreamwrite/test_timestreamwrite_tagging.py
@@ -3,12 +3,12 @@ from uuid import uuid4
import boto3
import pytest
-from moto import mock_timestreamwrite
+from moto import mock_aws
from . import timestreamwrite_aws_verified
-@mock_timestreamwrite
+@mock_aws
def test_list_tagging_for_table_without_tags():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="mydatabase")
@@ -27,7 +27,7 @@ def test_list_tagging_for_table_without_tags():
assert resp["Tags"] == []
-@mock_timestreamwrite
+@mock_aws
def test_list_tagging_for_table_with_tags():
ts = boto3.client("timestream-write", region_name="us-east-1")
ts.create_database(DatabaseName="mydatabase")
@@ -47,7 +47,7 @@ def test_list_tagging_for_table_with_tags():
assert resp["Tags"] == [{"Key": "k1", "Value": "v1"}]
-@mock_timestreamwrite
+@mock_aws
def test_list_tagging_for_database_without_tags():
ts = boto3.client("timestream-write", region_name="us-east-1")
db_arn = ts.create_database(DatabaseName="mydatabase")["Database"]["Arn"]
@@ -56,7 +56,7 @@ def test_list_tagging_for_database_without_tags():
assert resp["Tags"] == []
-@mock_timestreamwrite
+@mock_aws
def test_list_tagging_for_database_with_tags():
ts = boto3.client("timestream-write", region_name="us-east-1")
db_arn = ts.create_database(
diff --git a/tests/test_transcribe/test_transcribe_boto3.py b/tests/test_transcribe/test_transcribe_boto3.py
index 6d62288a7..0a72d8293 100644
--- a/tests/test_transcribe/test_transcribe_boto3.py
+++ b/tests/test_transcribe/test_transcribe_boto3.py
@@ -1,11 +1,10 @@
-# -*- coding: utf-8 -*-
import boto3
import pytest
-from moto import mock_transcribe
+from moto import mock_aws
-@mock_transcribe
+@mock_aws
def test_run_medical_transcription_job_minimal_params():
region_name = "us-east-1"
@@ -73,7 +72,7 @@ def test_run_medical_transcription_job_minimal_params():
client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name)
-@mock_transcribe
+@mock_aws
def test_run_medical_transcription_job_all_params():
region_name = "us-east-1"
@@ -175,7 +174,7 @@ def test_run_medical_transcription_job_all_params():
}
-@mock_transcribe
+@mock_aws
def test_run_transcription_job_all_params():
region_name = "us-east-1"
@@ -287,7 +286,7 @@ def test_run_transcription_job_all_params():
}
-@mock_transcribe
+@mock_aws
def test_run_transcription_job_minimal_params():
region_name = "us-east-1"
@@ -357,7 +356,7 @@ def test_run_transcription_job_minimal_params():
client.get_transcription_job(TranscriptionJobName=job_name)
-@mock_transcribe
+@mock_aws
def test_run_transcription_job_s3output_params():
region_name = "us-east-1"
@@ -437,7 +436,7 @@ def test_run_transcription_job_s3output_params():
)
-@mock_transcribe
+@mock_aws
def test_run_transcription_job_identify_languages_params():
region_name = "us-east-1"
@@ -507,7 +506,7 @@ def test_run_transcription_job_identify_languages_params():
assert transcription_job["IdentifiedLanguageScore"] == 0.999645948
-@mock_transcribe
+@mock_aws
def test_get_nonexistent_medical_transcription_job():
region_name = "us-east-1"
client = boto3.client("transcribe", region_name=region_name)
@@ -518,7 +517,7 @@ def test_get_nonexistent_medical_transcription_job():
)
-@mock_transcribe
+@mock_aws
def test_get_nonexistent_transcription_job():
region_name = "us-east-1"
client = boto3.client("transcribe", region_name=region_name)
@@ -527,7 +526,7 @@ def test_get_nonexistent_transcription_job():
client.get_transcription_job(TranscriptionJobName="NonexistentJobName")
-@mock_transcribe
+@mock_aws
def test_run_medical_transcription_job_with_existing_job_name():
region_name = "us-east-1"
@@ -549,7 +548,7 @@ def test_run_medical_transcription_job_with_existing_job_name():
client.start_medical_transcription_job(**args)
-@mock_transcribe
+@mock_aws
def test_run_transcription_job_with_existing_job_name():
region_name = "us-east-1"
@@ -568,7 +567,7 @@ def test_run_transcription_job_with_existing_job_name():
client.start_transcription_job(**args)
-@mock_transcribe
+@mock_aws
def test_run_medical_transcription_job_nonexistent_vocabulary():
region_name = "us-east-1"
@@ -588,7 +587,7 @@ def test_run_medical_transcription_job_nonexistent_vocabulary():
client.start_medical_transcription_job(**args)
-@mock_transcribe
+@mock_aws
def test_run_transcription_job_nonexistent_vocabulary():
region_name = "us-east-1"
@@ -606,7 +605,7 @@ def test_run_transcription_job_nonexistent_vocabulary():
client.start_transcription_job(**args)
-@mock_transcribe
+@mock_aws
def test_list_medical_transcription_jobs():
region_name = "us-east-1"
@@ -698,7 +697,7 @@ def test_list_medical_transcription_jobs():
assert "NextToken" not in response
-@mock_transcribe
+@mock_aws
def test_list_transcription_jobs():
region_name = "us-east-1"
@@ -782,7 +781,7 @@ def test_list_transcription_jobs():
assert "NextToken" not in response
-@mock_transcribe
+@mock_aws
def test_create_medical_vocabulary():
region_name = "us-east-1"
@@ -817,7 +816,7 @@ def test_create_medical_vocabulary():
client.get_medical_vocabulary(VocabularyName=vocabulary_name)
-@mock_transcribe
+@mock_aws
def test_create_vocabulary():
region_name = "us-east-1"
@@ -872,7 +871,7 @@ def test_create_vocabulary():
assert resp["VocabularyState"] == "READY"
-@mock_transcribe
+@mock_aws
def test_list_vocabularies():
region_name = "us-east-1"
@@ -955,7 +954,7 @@ def test_list_vocabularies():
assert len(response["Vocabularies"]) == 14
-@mock_transcribe
+@mock_aws
def test_list_medical_vocabularies():
region_name = "us-east-1"
@@ -1041,7 +1040,7 @@ def test_list_medical_vocabularies():
assert len(response["Vocabularies"]) == 14
-@mock_transcribe
+@mock_aws
def test_get_nonexistent_medical_vocabulary():
region_name = "us-east-1"
client = boto3.client("transcribe", region_name=region_name)
@@ -1050,7 +1049,7 @@ def test_get_nonexistent_medical_vocabulary():
client.get_medical_vocabulary(VocabularyName="NonexistentVocabularyName")
-@mock_transcribe
+@mock_aws
def test_get_nonexistent_vocabulary():
region_name = "us-east-1"
client = boto3.client("transcribe", region_name=region_name)
@@ -1059,7 +1058,7 @@ def test_get_nonexistent_vocabulary():
client.get_vocabulary(VocabularyName="NonexistentVocabularyName")
-@mock_transcribe
+@mock_aws
def test_create_medical_vocabulary_with_existing_vocabulary_name():
region_name = "us-east-1"
@@ -1078,7 +1077,7 @@ def test_create_medical_vocabulary_with_existing_vocabulary_name():
client.create_medical_vocabulary(**args)
-@mock_transcribe
+@mock_aws
def test_create_vocabulary_with_existing_vocabulary_name():
region_name = "us-east-1"
@@ -1097,7 +1096,7 @@ def test_create_vocabulary_with_existing_vocabulary_name():
client.create_vocabulary(**args)
-@mock_transcribe
+@mock_aws
def test_create_vocabulary_with_bad_request():
region_name = "us-east-1"
diff --git a/tests/test_utilities/test_tagging_service.py b/tests/test_utilities/test_tagging_service.py
index b86ff2419..520376ae1 100644
--- a/tests/test_utilities/test_tagging_service.py
+++ b/tests/test_utilities/test_tagging_service.py
@@ -1,4 +1,3 @@
-"""Unit tests for the TaggingService class."""
from moto.utilities.tagging_service import TaggingService
diff --git a/tests/test_utilities/test_threaded_server.py b/tests/test_utilities/test_threaded_server.py
index ffefa440d..a33060740 100644
--- a/tests/test_utilities/test_threaded_server.py
+++ b/tests/test_utilities/test_threaded_server.py
@@ -4,7 +4,7 @@ from unittest import SkipTest
import boto3
import requests
-from moto import mock_s3, settings
+from moto import mock_aws, settings
from moto.server import ThreadedMotoServer
@@ -20,26 +20,14 @@ class TestThreadedMotoServer(unittest.TestCase):
self.server.stop()
def test_server_is_reachable(self):
- s3_client = boto3.client(
- "s3",
- endpoint_url="http://127.0.0.1:5000",
- aws_access_key_id="ak",
- aws_secret_access_key="sk",
- region_name="us-east-1",
- )
+ s3_client = boto3.client("s3", endpoint_url="http://127.0.0.1:5000")
s3_client.create_bucket(Bucket="test")
buckets = s3_client.list_buckets()["Buckets"]
assert len(buckets) == 1
assert [b["Name"] for b in buckets] == ["test"]
def test_server_can_handle_multiple_services(self):
- s3_client = boto3.client(
- "s3",
- endpoint_url="http://127.0.0.1:5000",
- aws_access_key_id="ak",
- aws_secret_access_key="sk",
- region_name="us-east-1",
- )
+ s3_client = boto3.client("s3", endpoint_url="http://127.0.0.1:5000")
dynamodb_client = boto3.client(
"dynamodb",
endpoint_url="http://127.0.0.1:5000",
@@ -58,15 +46,9 @@ class TestThreadedMotoServer(unittest.TestCase):
assert dynamodb_client.list_tables()["TableNames"] == ["table1"]
- @mock_s3
+ @mock_aws
def test_load_data_from_inmemory_client(self):
- server_client = boto3.client(
- "s3",
- endpoint_url="http://127.0.0.1:5000",
- aws_access_key_id="ak",
- aws_secret_access_key="sk",
- region_name="us-east-1",
- )
+ server_client = boto3.client("s3", endpoint_url="http://127.0.0.1:5000")
server_client.create_bucket(Bucket="test")
in_mem_client = boto3.client("s3")
diff --git a/tests/test_wafv2/test_server.py b/tests/test_wafv2/test_server.py
index 314818220..11f1efcc6 100644
--- a/tests/test_wafv2/test_server.py
+++ b/tests/test_wafv2/test_server.py
@@ -1,5 +1,9 @@
+import unittest
+
+import pytest
+
import moto.server as server
-from moto import mock_wafv2
+from moto import mock_aws, settings
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .test_helper_functions import CREATE_WEB_ACL_BODY, LIST_WEB_ACL_BODY
@@ -16,7 +20,13 @@ LIST_WEB_ACL_HEADERS = {
}
-@mock_wafv2
+@pytest.fixture(scope="function", autouse=True)
+def skip_in_server_mode():
+ if settings.TEST_SERVER_MODE:
+ raise unittest.SkipTest("No point testing this in ServerMode")
+
+
+@mock_aws
def test_create_web_acl():
backend = server.create_backend_app("wafv2")
test_client = backend.test_client()
@@ -58,7 +68,7 @@ def test_create_web_acl():
)
-@mock_wafv2
+@mock_aws
def test_list_web_ac_ls():
backend = server.create_backend_app("wafv2")
test_client = backend.test_client()
diff --git a/tests/test_wafv2/test_wafv2.py b/tests/test_wafv2/test_wafv2.py
index 9890ff19a..019eb430f 100644
--- a/tests/test_wafv2/test_wafv2.py
+++ b/tests/test_wafv2/test_wafv2.py
@@ -2,13 +2,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_wafv2
+from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from .test_helper_functions import CREATE_WEB_ACL_BODY, LIST_WEB_ACL_BODY
-@mock_wafv2
+@mock_aws
def test_create_web_acl():
conn = boto3.client("wafv2", region_name="us-east-1")
@@ -35,7 +35,7 @@ def test_create_web_acl():
)
-@mock_wafv2
+@mock_aws
def test_create_web_acl_with_all_arguments():
client = boto3.client("wafv2", region_name="us-east-2")
web_acl_id = client.create_web_acl(
@@ -95,7 +95,7 @@ def test_create_web_acl_with_all_arguments():
assert len(wacl["Rules"]) == 2
-@mock_wafv2
+@mock_aws
def test_get_web_acl():
conn = boto3.client("wafv2", region_name="us-east-1")
body = CREATE_WEB_ACL_BODY("John", "REGIONAL")
@@ -105,7 +105,7 @@ def test_get_web_acl():
assert wacl["Id"] == web_acl_id
-@mock_wafv2
+@mock_aws
def test_list_web_acl():
conn = boto3.client("wafv2", region_name="us-east-1")
conn.create_web_acl(**CREATE_WEB_ACL_BODY("Daphne", "REGIONAL"))
@@ -123,7 +123,7 @@ def test_list_web_acl():
assert web_acls[0]["Name"] == "Penelope"
-@mock_wafv2
+@mock_aws
def test_delete_web_acl():
conn = boto3.client("wafv2", region_name="us-east-1")
wacl_id = conn.create_web_acl(**CREATE_WEB_ACL_BODY("Daphne", "REGIONAL"))[
@@ -144,7 +144,7 @@ def test_delete_web_acl():
)
-@mock_wafv2
+@mock_aws
def test_update_web_acl():
conn = boto3.client("wafv2", region_name="us-east-1")
wacl_id = conn.create_web_acl(**CREATE_WEB_ACL_BODY("Daphne", "REGIONAL"))[
diff --git a/tests/test_wafv2/test_wafv2_integration.py b/tests/test_wafv2/test_wafv2_integration.py
index 875feadb2..bf536b594 100644
--- a/tests/test_wafv2/test_wafv2_integration.py
+++ b/tests/test_wafv2/test_wafv2_integration.py
@@ -2,13 +2,13 @@ import boto3
import pytest
from botocore.exceptions import ClientError
-from moto import mock_apigateway, mock_wafv2
+from moto import mock_aws
from tests.test_apigateway.test_apigateway_stage import create_method_integration
from .test_helper_functions import CREATE_WEB_ACL_BODY
-@mock_wafv2
+@mock_aws
def test_associate_with_unknown_resource():
conn = boto3.client("wafv2", region_name="us-east-1")
wacl_arn = conn.create_web_acl(**CREATE_WEB_ACL_BODY("John", "REGIONAL"))[
@@ -34,8 +34,7 @@ def test_associate_with_unknown_resource():
)
-@mock_apigateway
-@mock_wafv2
+@mock_aws
def test_associate_with_apigateway_stage():
conn = boto3.client("wafv2", region_name="us-east-1")
wacl_arn = conn.create_web_acl(**CREATE_WEB_ACL_BODY("John", "REGIONAL"))[
@@ -56,8 +55,7 @@ def test_associate_with_apigateway_stage():
assert "webAclArn" not in stage
-@mock_apigateway
-@mock_wafv2
+@mock_aws
def test_get_web_acl_for_resource():
conn = boto3.client("wafv2", region_name="us-east-1")
wacl_arn = conn.create_web_acl(**CREATE_WEB_ACL_BODY("John", "REGIONAL"))[
@@ -78,7 +76,7 @@ def test_get_web_acl_for_resource():
assert resp["WebACL"]["ARN"] == wacl_arn
-@mock_wafv2
+@mock_aws
def test_disassociate_unknown_resource():
conn = boto3.client("wafv2", region_name="us-east-1")
# Nothing happens
diff --git a/tests/test_wafv2/test_wafv2_rules.py b/tests/test_wafv2/test_wafv2_rules.py
index 3acc50442..43e764d78 100644
--- a/tests/test_wafv2/test_wafv2_rules.py
+++ b/tests/test_wafv2/test_wafv2_rules.py
@@ -1,9 +1,9 @@
import boto3
-from moto import mock_wafv2
+from moto import mock_aws
-@mock_wafv2
+@mock_aws
def test_list_rule_groups():
client = boto3.client("wafv2", region_name="us-east-2")
resp = client.list_rule_groups(Scope="CLOUDFRONT")
diff --git a/tests/test_wafv2/test_wafv2_tags.py b/tests/test_wafv2/test_wafv2_tags.py
index 7abce87ef..50ac16e69 100644
--- a/tests/test_wafv2/test_wafv2_tags.py
+++ b/tests/test_wafv2/test_wafv2_tags.py
@@ -1,11 +1,11 @@
import boto3
-from moto import mock_wafv2
+from moto import mock_aws
from .test_helper_functions import CREATE_WEB_ACL_BODY
-@mock_wafv2
+@mock_aws
def test_list_tags_for_resource__none_supplied():
conn = boto3.client("wafv2", region_name="us-east-1")
arn = conn.create_web_acl(**CREATE_WEB_ACL_BODY("John", "REGIONAL"))["Summary"][
@@ -16,7 +16,7 @@ def test_list_tags_for_resource__none_supplied():
assert tag_info["TagList"] == []
-@mock_wafv2
+@mock_aws
def test_list_tags_for_resource():
conn = boto3.client("wafv2", region_name="us-east-1")
arn = conn.create_web_acl(
@@ -35,7 +35,7 @@ def test_list_tags_for_resource():
assert tag_info["TagList"] == [{"Key": "k1", "Value": "v1"}]
-@mock_wafv2
+@mock_aws
def test_tag_resource():
conn = boto3.client("wafv2", region_name="us-east-1")
arn = conn.create_web_acl(
@@ -64,7 +64,7 @@ def test_tag_resource():
]
-@mock_wafv2
+@mock_aws
def test_untag_resource():
conn = boto3.client("wafv2", region_name="us-east-1")
arn = conn.create_web_acl(
diff --git a/tests/test_xray/test_xray_boto3.py b/tests/test_xray/test_xray_boto3.py
index d04fe8649..887f86b97 100644
--- a/tests/test_xray/test_xray_boto3.py
+++ b/tests/test_xray/test_xray_boto3.py
@@ -3,10 +3,10 @@ import json
import boto3
-from moto import mock_xray
+from moto import mock_aws
-@mock_xray
+@mock_aws
def test_put_telemetry():
client = boto3.client("xray", region_name="us-east-1")
@@ -34,7 +34,7 @@ def test_put_telemetry():
)
-@mock_xray
+@mock_aws
def test_put_trace_segments():
client = boto3.client("xray", region_name="us-east-1")
@@ -53,7 +53,7 @@ def test_put_trace_segments():
)
-@mock_xray
+@mock_aws
def test_trace_summary():
client = boto3.client("xray", region_name="us-east-1")
@@ -85,7 +85,7 @@ def test_trace_summary():
)
-@mock_xray
+@mock_aws
def test_batch_get_trace():
client = boto3.client("xray", region_name="us-east-1")
@@ -123,7 +123,7 @@ def test_batch_get_trace():
# Following are not implemented, just testing it returns what boto expects
-@mock_xray
+@mock_aws
def test_batch_get_service_graph():
client = boto3.client("xray", region_name="us-east-1")
@@ -132,7 +132,7 @@ def test_batch_get_service_graph():
)
-@mock_xray
+@mock_aws
def test_batch_get_trace_graph():
client = boto3.client("xray", region_name="us-east-1")
diff --git a/tests/test_xray/test_xray_client.py b/tests/test_xray/test_xray_client.py
index 2bc529d89..e11da411f 100644
--- a/tests/test_xray/test_xray_client.py
+++ b/tests/test_xray/test_xray_client.py
@@ -9,8 +9,9 @@ import botocore.client
import botocore.endpoint
import requests # noqa # pylint: disable=all
-from moto import XRaySegment, mock_dynamodb, mock_xray_client
+from moto import mock_aws
from moto.utilities.distutils_version import LooseVersion
+from moto.xray import XRaySegment, mock_xray_client
from moto.xray.mock_client import MockEmitter
original_make_api_call = botocore.client.BaseClient._make_api_call
@@ -37,8 +38,7 @@ def check_coverage_status():
raise SkipTest("Can't run this test with Coverage 5.x")
-@mock_xray_client
-@mock_dynamodb
+@mock_aws
def test_xray_dynamo_request_id():
check_coverage_status()
@@ -71,7 +71,7 @@ def test_xray_dynamo_request_id_with_context_mgr():
with mock_xray_client():
assert isinstance(xray_core.xray_recorder._emitter, MockEmitter)
- with mock_dynamodb():
+ with mock_aws():
# Could be ran in any order, so we need to tell sdk that its been unpatched
xray_core_patcher._PATCHED_MODULES = set()
xray_core.patch_all()