Testing new version of decorator.

This commit is contained in:
Steve Pulec 2017-02-15 22:35:45 -05:00
parent d3df810065
commit fde721bed7
123 changed files with 2740 additions and 1114 deletions

View File

@ -4,6 +4,10 @@ Moto Changelog
Latest
------
BACKWARDS INCOMPATIBLE
* The normal @mock_<service> decorators will no longer work with boto. It is suggested that you upgrade to boto3 or use the standalone-server mode. If you would still like to use boto, you must use the @mock_<service>_deprecated decorators which will be removed in a future release.
* The @mock_s3bucket_path decorator is now deprecated. Use the @mock_s3 decorator instead.
0.4.31
------

View File

@ -263,7 +263,3 @@ boto3.resource(
```console
$ pip install moto
```
## Thanks
A huge thanks to [Gabriel Falcão](https://github.com/gabrielfalcao) and his [HTTPretty](https://github.com/gabrielfalcao/HTTPretty) library. Moto would not exist without it.

View File

@ -6,33 +6,32 @@ __title__ = 'moto'
__version__ = '0.4.31'
from .apigateway import mock_apigateway # flake8: noqa
from .autoscaling import mock_autoscaling # flake8: noqa
from .autoscaling import mock_autoscaling, mock_autoscaling_deprecated # flake8: noqa
from .awslambda import mock_lambda # flake8: noqa
from .cloudformation import mock_cloudformation # flake8: noqa
from .cloudwatch import mock_cloudwatch # flake8: noqa
from .datapipeline import mock_datapipeline # flake8: noqa
from .dynamodb import mock_dynamodb # flake8: noqa
from .dynamodb2 import mock_dynamodb2 # flake8: noqa
from .ec2 import mock_ec2 # flake8: noqa
from .cloudformation import mock_cloudformation, mock_cloudformation_deprecated # flake8: noqa
from .cloudwatch import mock_cloudwatch, mock_cloudwatch_deprecated # flake8: noqa
from .datapipeline import mock_datapipeline, mock_datapipeline_deprecated # flake8: noqa
from .dynamodb import mock_dynamodb, mock_dynamodb_deprecated # flake8: noqa
from .dynamodb2 import mock_dynamodb2, mock_dynamodb2_deprecated # flake8: noqa
from .ec2 import mock_ec2, mock_ec2_deprecated # flake8: noqa
from .ecs import mock_ecs # flake8: noqa
from .elb import mock_elb # flake8: noqa
from .emr import mock_emr # flake8: noqa
from .glacier import mock_glacier # flake8: noqa
from .elb import mock_elb, mock_elb_deprecated # flake8: noqa
from .emr import mock_emr, mock_emr_deprecated # flake8: noqa
from .glacier import mock_glacier, mock_glacier_deprecated # flake8: noqa
from .opsworks import mock_opsworks # flake8: noqa
from .iam import mock_iam # flake8: noqa
from .kinesis import mock_kinesis # flake8: noqa
from .kms import mock_kms # flake8: noqa
from .rds import mock_rds # flake8: noqa
from .rds2 import mock_rds2 # flake8: noqa
from .redshift import mock_redshift # flake8: noqa
from .s3 import mock_s3 # flake8: noqa
from .s3bucket_path import mock_s3bucket_path # flake8: noqa
from .ses import mock_ses # flake8: noqa
from .sns import mock_sns # flake8: noqa
from .sqs import mock_sqs # flake8: noqa
from .sts import mock_sts # flake8: noqa
from .route53 import mock_route53 # flake8: noqa
from .swf import mock_swf # flake8: noqa
from .iam import mock_iam, mock_iam_deprecated # flake8: noqa
from .kinesis import mock_kinesis, mock_kinesis_deprecated # flake8: noqa
from .kms import mock_kms, mock_kms_deprecated # flake8: noqa
from .rds import mock_rds, mock_rds_deprecated # flake8: noqa
from .rds2 import mock_rds2, mock_rds2_deprecated # flake8: noqa
from .redshift import mock_redshift, mock_redshift_deprecated # flake8: noqa
from .s3 import mock_s3, mock_s3_deprecated # flake8: noqa
from .ses import mock_ses, mock_ses_deprecated # flake8: noqa
from .sns import mock_sns, mock_sns_deprecated # flake8: noqa
from .sqs import mock_sqs, mock_sqs_deprecated # flake8: noqa
from .sts import mock_sts, mock_sts_deprecated # flake8: noqa
from .route53 import mock_route53, mock_route53_deprecated # flake8: noqa
from .swf import mock_swf, mock_swf_deprecated # flake8: noqa
try:

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import apigateway_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
apigateway_backend = apigateway_backends['us-east-1']
mock_apigateway = base_decorator(apigateway_backends)
mock_apigateway_deprecated = deprecated_base_decorator(apigateway_backends)

View File

@ -1,9 +1,10 @@
from __future__ import absolute_import
from __future__ import unicode_literals
import datetime
import httpretty
import requests
from moto.packages.responses import responses
from moto.core import BaseBackend
from moto.core.utils import iso_8601_datetime_with_milliseconds
from .utils import create_id
@ -315,8 +316,12 @@ class RestAPI(object):
return resource
# TODO deal with no matching resource
def resource_callback(self, request, full_url, headers):
path_after_stage_name = '/'.join(request.path.split("/")[2:])
def resource_callback(self, request, full_url=None, headers=None):
if not headers:
headers = request.headers
path = request.path if hasattr(request, 'path') else request.path_url
path_after_stage_name = '/'.join(path.split("/")[2:])
if not path_after_stage_name:
path_after_stage_name = '/'
@ -325,11 +330,8 @@ class RestAPI(object):
return status_code, headers, response
def update_integration_mocks(self, stage_name):
httpretty.enable()
stage_url = STAGE_URL.format(api_id=self.id, region_name=self.region_name, stage_name=stage_name)
for method in httpretty.httpretty.METHODS:
httpretty.register_uri(method, stage_url, body=self.resource_callback)
responses.add_callback(responses.GET, stage_url, callback=self.resource_callback)
def create_stage(self, name, deployment_id,variables=None,description='',cacheClusterEnabled=None,cacheClusterSize=None):
if variables is None:

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import autoscaling_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
autoscaling_backend = autoscaling_backends['us-east-1']
mock_autoscaling = base_decorator(autoscaling_backends)
mock_autoscaling_deprecated = deprecated_base_decorator(autoscaling_backends)

View File

@ -1,7 +1,7 @@
from __future__ import unicode_literals
from .models import lambda_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
lambda_backend = lambda_backends['us-east-1']
mock_lambda = base_decorator(lambda_backends)
mock_lambda_deprecated = deprecated_base_decorator(lambda_backends)

View File

@ -38,11 +38,13 @@ class LambdaResponse(BaseResponse):
def _invoke(self, request, full_url, headers):
lambda_backend = self.get_lambda_backend(full_url)
function_name = request.path.split('/')[-2]
path = request.path if hasattr(request, 'path') else request.path_url
function_name = path.split('/')[-2]
if lambda_backend.has_function(function_name):
fn = lambda_backend.get_function(function_name)
payload = fn.invoke(request, headers)
headers['Content-Length'] = str(len(payload))
return 202, headers, payload
else:
return 404, headers, "{}"
@ -68,7 +70,8 @@ class LambdaResponse(BaseResponse):
def _delete_function(self, request, full_url, headers):
lambda_backend = self.get_lambda_backend(full_url)
function_name = request.path.split('/')[-1]
path = request.path if hasattr(request, 'path') else request.path_url
function_name = path.split('/')[-1]
if lambda_backend.has_function(function_name):
lambda_backend.delete_function(function_name)
@ -79,7 +82,8 @@ class LambdaResponse(BaseResponse):
def _get_function(self, request, full_url, headers):
lambda_backend = self.get_lambda_backend(full_url)
function_name = request.path.split('/')[-1]
path = request.path if hasattr(request, 'path') else request.path_url
function_name = path.split('/')[-1]
if lambda_backend.has_function(function_name):
fn = lambda_backend.get_function(function_name)

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import cloudformation_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
cloudformation_backend = cloudformation_backends['us-east-1']
mock_cloudformation = base_decorator(cloudformation_backends)
mock_cloudformation_deprecated = deprecated_base_decorator(cloudformation_backends)

View File

@ -1,5 +1,6 @@
from .models import cloudwatch_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
cloudwatch_backend = cloudwatch_backends['us-east-1']
mock_cloudwatch = base_decorator(cloudwatch_backends)
mock_cloudwatch_deprecated = deprecated_base_decorator(cloudwatch_backends)

View File

@ -1,22 +1,23 @@
from __future__ import unicode_literals
from __future__ import absolute_import
import functools
import inspect
import re
from httpretty import HTTPretty
from moto.packages.responses import responses
from moto.packages.httpretty import HTTPretty
from .responses import metadata_response
from .utils import convert_regex_to_flask_path
from .utils import convert_regex_to_flask_path, convert_flask_to_responses_response
class MockAWS(object):
class BaseMockAWS(object):
nested_count = 0
def __init__(self, backends):
self.backends = backends
if self.__class__.nested_count == 0:
HTTPretty.reset()
self.reset()
def __call__(self, func, reset=True):
if inspect.isclass(func):
@ -35,24 +36,7 @@ class MockAWS(object):
for backend in self.backends.values():
backend.reset()
if not HTTPretty.is_enabled():
HTTPretty.enable()
for method in HTTPretty.METHODS:
backend = list(self.backends.values())[0]
for key, value in backend.urls.items():
HTTPretty.register_uri(
method=method,
uri=re.compile(key),
body=value,
)
# Mock out localhost instance metadata
HTTPretty.register_uri(
method=method,
uri=re.compile('http://169.254.169.254/latest/meta-data/.*'),
body=metadata_response
)
self.enable_patching()
def stop(self):
self.__class__.nested_count -= 1
@ -60,9 +44,7 @@ class MockAWS(object):
if self.__class__.nested_count < 0:
raise RuntimeError('Called stop() before start().')
if self.__class__.nested_count == 0:
HTTPretty.disable()
HTTPretty.reset()
self.disable_patching()
def decorate_callable(self, func, reset):
def wrapper(*args, **kwargs):
@ -97,6 +79,73 @@ class MockAWS(object):
return klass
class HttprettyMockAWS(BaseMockAWS):
def reset(self):
HTTPretty.reset()
def enable_patching(self):
if not HTTPretty.is_enabled():
HTTPretty.enable()
for method in HTTPretty.METHODS:
backend = list(self.backends.values())[0]
for key, value in backend.urls.items():
HTTPretty.register_uri(
method=method,
uri=re.compile(key),
body=value,
)
# Mock out localhost instance metadata
HTTPretty.register_uri(
method=method,
uri=re.compile('http://169.254.169.254/latest/meta-data/.*'),
body=metadata_response
)
def disable_patching(self):
if self.__class__.nested_count == 0:
HTTPretty.disable()
HTTPretty.reset()
RESPONSES_METHODS = [responses.GET, responses.DELETE, responses.HEAD,
responses.OPTIONS, responses.PATCH, responses.POST, responses.PUT]
class ResponsesMockAWS(BaseMockAWS):
def reset(self):
responses.reset()
def enable_patching(self):
responses.start()
for method in RESPONSES_METHODS:
backend = list(self.backends.values())[0]
for key, value in backend.urls.items():
responses.add_callback(
method=method,
url=re.compile(key),
callback=convert_flask_to_responses_response(value),
)
# Mock out localhost instance metadata
responses.add_callback(
method=method,
url=re.compile('http://169.254.169.254/latest/meta-data/.*'),
callback=convert_flask_to_responses_response(metadata_response),
)
for pattern in responses.mock._urls:
pattern['stream'] = True
def disable_patching(self):
if self.__class__.nested_count == 0:
try:
responses.stop()
except AttributeError:
pass
responses.reset()
MockAWS = ResponsesMockAWS
class Model(type):
def __new__(self, clsname, bases, namespace):
cls = super(Model, self).__new__(self, clsname, bases, namespace)
@ -187,6 +236,12 @@ class BaseBackend(object):
else:
return MockAWS({'global': self})
def deprecated_decorator(self, func=None):
if func:
return HttprettyMockAWS({'global': self})(func)
else:
return HttprettyMockAWS({'global': self})
class base_decorator(object):
mock_backend = MockAWS
@ -199,3 +254,7 @@ class base_decorator(object):
return self.mock_backend(self.backends)(func)
else:
return self.mock_backend(self.backends)
class deprecated_base_decorator(base_decorator):
mock_backend = HttprettyMockAWS

View File

@ -138,7 +138,7 @@ class BaseResponse(_TemplateEnvironmentMixin):
flat = flatten_json_request_body('', decoded, input_spec)
for key, value in flat.items():
querystring[key] = [value]
else:
elif self.body:
querystring.update(parse_qs(self.body, keep_blank_values=True))
if not querystring:
querystring.update(headers)
@ -152,6 +152,8 @@ class BaseResponse(_TemplateEnvironmentMixin):
self.region = self.get_region_from_url(full_url)
self.headers = request.headers
if 'host' not in self.headers:
self.headers['host'] = urlparse(full_url).netloc
self.response_headers = headers
def get_region_from_url(self, full_url):
@ -189,6 +191,9 @@ class BaseResponse(_TemplateEnvironmentMixin):
body, new_headers = response
status = new_headers.get('status', 200)
headers.update(new_headers)
# Cast status to string
if "status" in headers:
headers['status'] = str(headers['status'])
return status, headers, body
raise NotImplementedError("The {0} action has not been implemented".format(action))
@ -327,6 +332,7 @@ def metadata_response(request, full_url, headers):
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html
"""
parsed_url = urlparse(full_url)
tomorrow = datetime.datetime.utcnow() + datetime.timedelta(days=1)
credentials = dict(

View File

@ -103,6 +103,28 @@ class convert_flask_to_httpretty_response(object):
return response, status, headers
class convert_flask_to_responses_response(object):
def __init__(self, callback):
self.callback = callback
@property
def __name__(self):
# For instance methods, use class and method names. Otherwise
# use module and method name
if inspect.ismethod(self.callback):
outer = self.callback.__self__.__class__.__name__
else:
outer = self.callback.__module__
return "{0}.{1}".format(outer, self.callback.__name__)
def __call__(self, request, *args, **kwargs):
result = self.callback(request, request.url, request.headers)
# result is a status, headers, response tuple
status, headers, response = result
return status, headers, response
def iso_8601_datetime_with_milliseconds(datetime):
return datetime.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + 'Z'

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import datapipeline_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
datapipeline_backend = datapipeline_backends['us-east-1']
mock_datapipeline = base_decorator(datapipeline_backends)
mock_datapipeline_deprecated = deprecated_base_decorator(datapipeline_backends)

View File

@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .models import dynamodb_backend
mock_dynamodb = dynamodb_backend.decorator
mock_dynamodb_deprecated = dynamodb_backend.deprecated_decorator

View File

@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .models import dynamodb_backend2
mock_dynamodb2 = dynamodb_backend2.decorator
mock_dynamodb2_deprecated = dynamodb_backend2.deprecated_decorator

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import ec2_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
ec2_backend = ec2_backends['us-east-1']
mock_ec2 = base_decorator(ec2_backends)
mock_ec2_deprecated = deprecated_base_decorator(ec2_backends)

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import ecs_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
ecs_backend = ecs_backends['us-east-1']
mock_ecs = base_decorator(ecs_backends)
mock_ecs_deprecated = deprecated_base_decorator(ecs_backends)

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import elb_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
elb_backend = elb_backends['us-east-1']
mock_elb = base_decorator(elb_backends)
mock_elb_deprecated = deprecated_base_decorator(elb_backends)

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import emr_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
emr_backend = emr_backends['us-east-1']
mock_emr = base_decorator(emr_backends)
mock_emr_deprecated = deprecated_base_decorator(emr_backends)

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import glacier_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
glacier_backend = glacier_backends['us-east-1']
mock_glacier = base_decorator(glacier_backends)
mock_glacier_deprecated = deprecated_base_decorator(glacier_backends)

View File

@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .models import iam_backend
mock_iam = iam_backend.decorator
mock_iam_deprecated = iam_backend.deprecated_decorator

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import kinesis_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
kinesis_backend = kinesis_backends['us-east-1']
mock_kinesis = base_decorator(kinesis_backends)
mock_kinesis_deprecated = deprecated_base_decorator(kinesis_backends)

View File

@ -19,7 +19,10 @@ class KinesisResponse(BaseResponse):
@property
def is_firehose(self):
host = self.headers.get('host') or self.headers['Host']
try:
host = self.headers.get('host') or self.headers['Host']
except KeyError:
import pdb;pdb.set_trace()
return host.startswith('firehose')
def create_stream(self):

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import kms_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
kms_backend = kms_backends['us-east-1']
mock_kms = base_decorator(kms_backends)
mock_kms_deprecated = deprecated_base_decorator(kms_backends)

View File

@ -1,6 +1,6 @@
from __future__ import unicode_literals
from .models import opsworks_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
opsworks_backend = opsworks_backends['us-east-1']
mock_opsworks = base_decorator(opsworks_backends)

View File

@ -4,7 +4,7 @@ from .responses import OpsWorksResponse
# AWS OpsWorks has a single endpoint: opsworks.us-east-1.amazonaws.com
# and only supports HTTPS requests.
url_bases = [
"opsworks.us-east-1.amazonaws.com"
"https?://opsworks.us-east-1.amazonaws.com"
]
url_paths = {

View File

View File

@ -0,0 +1,60 @@
# #!/usr/bin/env python
# -*- coding: utf-8 -*-
# <HTTPretty - HTTP client mock for Python>
# Copyright (C) <2011-2013> Gabriel Falcão <gabriel@nacaolivre.org>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
__version__ = version = '0.8.10'
from .core import httpretty, httprettified, EmptyRequestHeaders
from .errors import HTTPrettyError, UnmockedError
from .core import URIInfo
HTTPretty = httpretty
activate = httprettified
enable = httpretty.enable
register_uri = httpretty.register_uri
disable = httpretty.disable
is_enabled = httpretty.is_enabled
reset = httpretty.reset
Response = httpretty.Response
GET = httpretty.GET
PUT = httpretty.PUT
POST = httpretty.POST
DELETE = httpretty.DELETE
HEAD = httpretty.HEAD
PATCH = httpretty.PATCH
OPTIONS = httpretty.OPTIONS
CONNECT = httpretty.CONNECT
def last_request():
"""returns the last request"""
return httpretty.last_request
def has_request():
"""returns a boolean indicating whether any request has been made"""
return not isinstance(httpretty.last_request.headers, EmptyRequestHeaders)

View File

@ -0,0 +1,100 @@
# #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# <HTTPretty - HTTP client mock for Python>
# Copyright (C) <2011-2013> Gabriel Falcão <gabriel@nacaolivre.org>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
import sys
import types
PY3 = sys.version_info[0] == 3
if PY3: # pragma: no cover
text_type = str
byte_type = bytes
import io
StringIO = io.BytesIO
basestring = (str, bytes)
class BaseClass(object):
def __repr__(self):
return self.__str__()
else: # pragma: no cover
text_type = unicode
byte_type = str
import StringIO
StringIO = StringIO.StringIO
basestring = basestring
class BaseClass(object):
def __repr__(self):
ret = self.__str__()
if PY3: # pragma: no cover
return ret
else:
return ret.encode('utf-8')
try: # pragma: no cover
from urllib.parse import urlsplit, urlunsplit, parse_qs, quote, quote_plus, unquote
unquote_utf8 = unquote
except ImportError: # pragma: no cover
from urlparse import urlsplit, urlunsplit, parse_qs, unquote
from urllib import quote, quote_plus
def unquote_utf8(qs):
if isinstance(qs, text_type):
qs = qs.encode('utf-8')
s = unquote(qs)
if isinstance(s, byte_type):
return s.decode("utf-8")
else:
return s
try: # pragma: no cover
from http.server import BaseHTTPRequestHandler
except ImportError: # pragma: no cover
from BaseHTTPServer import BaseHTTPRequestHandler
ClassTypes = (type,)
if not PY3: # pragma: no cover
ClassTypes = (type, types.ClassType)
__all__ = [
'PY3',
'StringIO',
'text_type',
'byte_type',
'BaseClass',
'BaseHTTPRequestHandler',
'quote',
'quote_plus',
'urlunsplit',
'urlsplit',
'parse_qs',
'ClassTypes',
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
# #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# <HTTPretty - HTTP client mock for Python>
# Copyright (C) <2011-2013> Gabriel Falcão <gabriel@nacaolivre.org>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
class HTTPrettyError(Exception):
pass
class UnmockedError(HTTPrettyError):
def __init__(self):
super(UnmockedError, self).__init__(
'No mocking was registered, and real connections are '
'not allowed (httpretty.allow_net_connect = False).'
)

View File

@ -0,0 +1,155 @@
# #!/usr/bin/env python
# -*- coding: utf-8 -*-
# <HTTPretty - HTTP client mock for Python>
# Copyright (C) <2011-2013> Gabriel Falcão <gabriel@nacaolivre.org>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
import re
from .compat import BaseClass
from .utils import decode_utf8
STATUSES = {
100: "Continue",
101: "Switching Protocols",
102: "Processing",
200: "OK",
201: "Created",
202: "Accepted",
203: "Non-Authoritative Information",
204: "No Content",
205: "Reset Content",
206: "Partial Content",
207: "Multi-Status",
208: "Already Reported",
226: "IM Used",
300: "Multiple Choices",
301: "Moved Permanently",
302: "Found",
303: "See Other",
304: "Not Modified",
305: "Use Proxy",
306: "Switch Proxy",
307: "Temporary Redirect",
308: "Permanent Redirect",
400: "Bad Request",
401: "Unauthorized",
402: "Payment Required",
403: "Forbidden",
404: "Not Found",
405: "Method Not Allowed",
406: "Not Acceptable",
407: "Proxy Authentication Required",
408: "Request a Timeout",
409: "Conflict",
410: "Gone",
411: "Length Required",
412: "Precondition Failed",
413: "Request Entity Too Large",
414: "Request-URI Too Long",
415: "Unsupported Media Type",
416: "Requested Range Not Satisfiable",
417: "Expectation Failed",
418: "I'm a teapot",
420: "Enhance Your Calm",
422: "Unprocessable Entity",
423: "Locked",
424: "Failed Dependency",
424: "Method Failure",
425: "Unordered Collection",
426: "Upgrade Required",
428: "Precondition Required",
429: "Too Many Requests",
431: "Request Header Fields Too Large",
444: "No Response",
449: "Retry With",
450: "Blocked by Windows Parental Controls",
451: "Unavailable For Legal Reasons",
451: "Redirect",
494: "Request Header Too Large",
495: "Cert Error",
496: "No Cert",
497: "HTTP to HTTPS",
499: "Client Closed Request",
500: "Internal Server Error",
501: "Not Implemented",
502: "Bad Gateway",
503: "Service Unavailable",
504: "Gateway Timeout",
505: "HTTP Version Not Supported",
506: "Variant Also Negotiates",
507: "Insufficient Storage",
508: "Loop Detected",
509: "Bandwidth Limit Exceeded",
510: "Not Extended",
511: "Network Authentication Required",
598: "Network read timeout error",
599: "Network connect timeout error",
}
class HttpBaseClass(BaseClass):
GET = 'GET'
PUT = 'PUT'
POST = 'POST'
DELETE = 'DELETE'
HEAD = 'HEAD'
PATCH = 'PATCH'
OPTIONS = 'OPTIONS'
CONNECT = 'CONNECT'
METHODS = (GET, PUT, POST, DELETE, HEAD, PATCH, OPTIONS, CONNECT)
def parse_requestline(s):
"""
http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5
>>> parse_requestline('GET / HTTP/1.0')
('GET', '/', '1.0')
>>> parse_requestline('post /testurl htTP/1.1')
('POST', '/testurl', '1.1')
>>> parse_requestline('Im not a RequestLine')
Traceback (most recent call last):
...
ValueError: Not a Request-Line
"""
methods = '|'.join(HttpBaseClass.METHODS)
m = re.match(r'(' + methods + ')\s+(.*)\s+HTTP/(1.[0|1])', s, re.I)
if m:
return m.group(1).upper(), m.group(2), m.group(3)
else:
raise ValueError('Not a Request-Line')
def last_requestline(sent_data):
"""
Find the last line in sent_data that can be parsed with parse_requestline
"""
for line in reversed(sent_data):
try:
parse_requestline(decode_utf8(line))
except ValueError:
pass
else:
return line

View File

@ -0,0 +1,48 @@
# #!/usr/bin/env python
# -*- coding: utf-8 -*-
# <HTTPretty - HTTP client mock for Python>
# Copyright (C) <2011-2013> Gabriel Falcão <gabriel@nacaolivre.org>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
from .compat import (
byte_type, text_type
)
def utf8(s):
if isinstance(s, text_type):
s = s.encode('utf-8')
elif s is None:
return byte_type()
return byte_type(s)
def decode_utf8(s):
if isinstance(s, byte_type):
s = s.decode("utf-8")
elif s is None:
return text_type()
return text_type(s)

@ -0,0 +1 @@
Subproject commit 8d500447e3d5c2b96ace2eb7ab0f60158e921ed8

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import rds_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
rds_backend = rds_backends['us-east-1']
mock_rds = base_decorator(rds_backends)
mock_rds_deprecated = deprecated_base_decorator(rds_backends)

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import rds2_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, deprecated_base_decorator
rds2_backend = rds2_backends['us-west-1']
mock_rds2 = base_decorator(rds2_backends)
mock_rds2_deprecated = deprecated_base_decorator(rds2_backends)

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import redshift_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
redshift_backend = redshift_backends['us-east-1']
mock_redshift = base_decorator(redshift_backends)
mock_redshift_deprecated = deprecated_base_decorator(redshift_backends)

View File

@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .models import route53_backend
mock_route53 = route53_backend.decorator
mock_route53_deprecated = route53_backend.deprecated_decorator

View File

@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .models import s3_backend
mock_s3 = s3_backend.decorator
mock_s3_deprecated = s3_backend.deprecated_decorator

View File

@ -25,7 +25,7 @@ class FakeKey(object):
self.value = value
self.last_modified = datetime.datetime.utcnow()
self.acl = get_canned_acl('private')
self._storage_class = storage
self._storage_class = storage if storage else "STANDARD"
self._metadata = {}
self._expiry = None
self._etag = etag
@ -92,6 +92,7 @@ class FakeKey(object):
r = {
'etag': self.etag,
'last-modified': self.last_modified_RFC1123,
'content-length': str(len(self.value)),
}
if self._storage_class != 'STANDARD':
r['x-amz-storage-class'] = self._storage_class
@ -100,7 +101,7 @@ class FakeKey(object):
r['x-amz-restore'] = rhdr.format(self.expiry_date)
if self._is_versioned:
r['x-amz-version-id'] = self._version_id
r['x-amz-version-id'] = str(self._version_id)
return r

View File

@ -49,6 +49,8 @@ class ResponseObject(_TemplateEnvironmentMixin):
def subdomain_based_buckets(self, request):
host = request.headers.get('host', request.headers.get('Host'))
if not host:
host = urlparse(request.url).netloc
if not host or host.startswith("localhost"):
# For localhost, default to path-based buckets
@ -130,6 +132,8 @@ class ResponseObject(_TemplateEnvironmentMixin):
else:
# Flask server
body = request.data
if body is None:
body = ''
body = body.decode('utf-8')
if method == 'HEAD':
@ -334,7 +338,8 @@ class ResponseObject(_TemplateEnvironmentMixin):
return 409, headers, template.render(bucket=removed_bucket)
def _bucket_response_post(self, request, body, bucket_name, headers):
if self.is_delete_keys(request, request.path, bucket_name):
path = request.path if hasattr(request, 'path') else request.path_url
if self.is_delete_keys(request, path, bucket_name):
return self._bucket_response_delete_keys(request, body, bucket_name, headers)
# POST to bucket-url should create file from form
@ -344,7 +349,7 @@ class ResponseObject(_TemplateEnvironmentMixin):
else:
# HTTPretty, build new form object
form = {}
for kv in request.body.decode('utf-8').split('&'):
for kv in body.decode('utf-8').split('&'):
k, v = kv.split('=')
form[k] = v
@ -428,9 +433,13 @@ class ResponseObject(_TemplateEnvironmentMixin):
if hasattr(request, 'body'):
# Boto
body = request.body
if hasattr(body, 'read'):
body = body.read()
else:
# Flask server
body = request.data
if body is None:
body = b''
if method == 'GET':
return self._key_response_get(bucket_name, query, key_name, headers)
@ -546,7 +555,7 @@ class ResponseObject(_TemplateEnvironmentMixin):
if key:
headers.update(key.metadata)
headers.update(key.response_dict)
return 200, headers, key.value
return 200, headers, ""
else:
return 404, headers, ""

View File

@ -1,4 +1 @@
from __future__ import unicode_literals
from moto import mock_s3
mock_s3bucket_path = mock_s3

View File

@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .models import ses_backend
mock_ses = ses_backend.decorator
mock_ses_deprecated = ses_backend.deprecated_decorator

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import sns_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
sns_backend = sns_backends['us-east-1']
mock_sns = base_decorator(sns_backends)
mock_sns_deprecated = deprecated_base_decorator(sns_backends)

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import sqs_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
sqs_backend = sqs_backends['us-east-1']
mock_sqs = base_decorator(sqs_backends)
mock_sqs_deprecated = deprecated_base_decorator(sqs_backends)

View File

@ -122,6 +122,7 @@ class SQSResponse(BaseResponse):
queue = self.sqs_backend.delete_queue(queue_name)
if not queue:
return "A queue with name {0} does not exist".format(queue_name), dict(status=404)
template = self.response_template(DELETE_QUEUE_RESPONSE)
return template.render(queue=queue)

View File

@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .models import sts_backend
mock_sts = sts_backend.decorator
mock_sts_deprecated = sts_backend.deprecated_decorator

View File

@ -1,6 +1,7 @@
from __future__ import unicode_literals
from .models import swf_backends
from ..core.models import MockAWS, base_decorator
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
swf_backend = swf_backends['us-east-1']
mock_swf = base_decorator(swf_backends)
mock_swf_deprecated = deprecated_base_decorator(swf_backends)

View File

@ -5,7 +5,6 @@ from setuptools import setup, find_packages
install_requires = [
"Jinja2>=2.8",
"boto>=2.36.0",
"httpretty==0.8.10",
"requests",
"xmltodict",
"six",

View File

@ -1 +1,8 @@
from __future__ import unicode_literals
import logging
# Disable extra logging for tests
logging.getLogger('boto').setLevel(logging.CRITICAL)
logging.getLogger('boto3').setLevel(logging.CRITICAL)
logging.getLogger('botocore').setLevel(logging.CRITICAL)
logging.getLogger('nose').setLevel(logging.CRITICAL)

View File

@ -5,11 +5,11 @@ from datetime import datetime
from dateutil.tz import tzutc
import boto3
from freezegun import freeze_time
import httpretty
import requests
import sure # noqa
from botocore.exceptions import ClientError
from moto.packages.responses import responses
from moto import mock_apigateway
@ -883,11 +883,10 @@ def test_deployment():
stage['description'].should.equal('_new_description_')
@httpretty.activate
@mock_apigateway
def test_http_proxying_integration():
httpretty.register_uri(
httpretty.GET, "http://httpbin.org/robots.txt", body='a fake response'
responses.add(
responses.GET, "http://httpbin.org/robots.txt", body='a fake response'
)
region_name = 'us-west-2'

View File

@ -8,12 +8,12 @@ from boto.ec2.autoscale import Tag
import boto.ec2.elb
import sure # noqa
from moto import mock_autoscaling, mock_ec2, mock_elb
from moto import mock_autoscaling, mock_ec2_deprecated, mock_elb_deprecated, mock_autoscaling_deprecated
from tests.helpers import requires_boto_gte
@mock_autoscaling
@mock_elb
@mock_autoscaling_deprecated
@mock_elb_deprecated
def test_create_autoscaling_group():
elb_conn = boto.ec2.elb.connect_to_region('us-east-1')
elb_conn.create_load_balancer('test_lb', zones=[], listeners=[(80, 8080, 'http')])
@ -73,7 +73,7 @@ def test_create_autoscaling_group():
tag.propagate_at_launch.should.equal(True)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_autoscaling_groups_defaults():
""" Test with the minimum inputs and check that all of the proper defaults
are assigned for the other attributes """
@ -112,7 +112,7 @@ def test_create_autoscaling_groups_defaults():
list(group.tags).should.equal([])
@mock_autoscaling
@mock_autoscaling_deprecated
def test_autoscaling_group_describe_filter():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -138,7 +138,7 @@ def test_autoscaling_group_describe_filter():
conn.get_all_groups().should.have.length_of(3)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_autoscaling_update():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -169,7 +169,7 @@ def test_autoscaling_update():
group.vpc_zone_identifier.should.equal('subnet-5678efgh')
@mock_autoscaling
@mock_autoscaling_deprecated
def test_autoscaling_tags_update():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -211,7 +211,7 @@ def test_autoscaling_tags_update():
group.tags.should.have.length_of(2)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_autoscaling_group_delete():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -235,8 +235,8 @@ def test_autoscaling_group_delete():
conn.get_all_groups().should.have.length_of(0)
@mock_ec2
@mock_autoscaling
@mock_ec2_deprecated
@mock_autoscaling_deprecated
def test_autoscaling_group_describe_instances():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -269,7 +269,7 @@ def test_autoscaling_group_describe_instances():
@requires_boto_gte("2.8")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_set_desired_capacity_up():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -304,7 +304,7 @@ def test_set_desired_capacity_up():
@requires_boto_gte("2.8")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_set_desired_capacity_down():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -339,7 +339,7 @@ def test_set_desired_capacity_down():
@requires_boto_gte("2.8")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_set_desired_capacity_the_same():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -372,8 +372,8 @@ def test_set_desired_capacity_the_same():
instances = list(conn.get_all_autoscaling_instances())
instances.should.have.length_of(2)
@mock_autoscaling
@mock_elb
@mock_autoscaling_deprecated
@mock_elb_deprecated
def test_autoscaling_group_with_elb():
elb_conn = boto.connect_elb()
zones = ['us-east-1a', 'us-east-1b']

View File

@ -5,11 +5,11 @@ from boto.ec2.blockdevicemapping import BlockDeviceType, BlockDeviceMapping
import sure # noqa
from moto import mock_autoscaling
from moto import mock_autoscaling_deprecated
from tests.helpers import requires_boto_gte
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -38,7 +38,7 @@ def test_create_launch_configuration():
@requires_boto_gte("2.27.0")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_with_block_device_mappings():
block_device_mapping = BlockDeviceMapping()
@ -101,7 +101,7 @@ def test_create_launch_configuration_with_block_device_mappings():
@requires_boto_gte("2.12")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_for_2_12():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -116,7 +116,7 @@ def test_create_launch_configuration_for_2_12():
@requires_boto_gte("2.25.0")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_using_ip_association():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -131,7 +131,7 @@ def test_create_launch_configuration_using_ip_association():
@requires_boto_gte("2.25.0")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_using_ip_association_should_default_to_false():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -144,7 +144,7 @@ def test_create_launch_configuration_using_ip_association_should_default_to_fals
launch_config.associate_public_ip_address.should.equal(False)
@mock_autoscaling
@mock_autoscaling_deprecated
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 """
@ -171,7 +171,7 @@ def test_create_launch_configuration_defaults():
@requires_boto_gte("2.12")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_defaults_for_2_12():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -184,7 +184,7 @@ def test_create_launch_configuration_defaults_for_2_12():
launch_config.ebs_optimized.should.equal(False)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_launch_configuration_describe_filter():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -202,7 +202,7 @@ def test_launch_configuration_describe_filter():
conn.get_all_launch_configurations().should.have.length_of(3)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_launch_configuration_delete():
conn = boto.connect_autoscale()
config = LaunchConfiguration(

View File

@ -5,7 +5,7 @@ from boto.ec2.autoscale.group import AutoScalingGroup
from boto.ec2.autoscale.policy import ScalingPolicy
import sure # noqa
from moto import mock_autoscaling
from moto import mock_autoscaling_deprecated
def setup_autoscale_group():
@ -27,7 +27,7 @@ def setup_autoscale_group():
return group
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_policy():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -48,7 +48,7 @@ def test_create_policy():
policy.cooldown.should.equal(60)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_policy_default_values():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -67,7 +67,7 @@ def test_create_policy_default_values():
policy.cooldown.should.equal(300)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_update_policy():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -94,7 +94,7 @@ def test_update_policy():
policy.scaling_adjustment.should.equal(2)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_delete_policy():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -112,7 +112,7 @@ def test_delete_policy():
conn.get_all_policies().should.have.length_of(0)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_execute_policy_exact_capacity():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -130,7 +130,7 @@ def test_execute_policy_exact_capacity():
instances.should.have.length_of(3)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_execute_policy_positive_change_in_capacity():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -148,7 +148,7 @@ def test_execute_policy_positive_change_in_capacity():
instances.should.have.length_of(5)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_execute_policy_percent_change_in_capacity():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -166,7 +166,7 @@ def test_execute_policy_percent_change_in_capacity():
instances.should.have.length_of(3)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_execute_policy_small_percent_change_in_capacity():
""" http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/as-scale-based-on-demand.html
If PercentChangeInCapacity returns a value between 0 and 1,

View File

@ -12,7 +12,7 @@ import sure # noqa
import tests.backport_assert_raises # noqa
from nose.tools import assert_raises
from moto import mock_cloudformation, mock_s3
from moto import mock_cloudformation_deprecated, mock_s3_deprecated
from moto.cloudformation import cloudformation_backends
dummy_template = {
@ -46,7 +46,7 @@ dummy_template_json2 = json.dumps(dummy_template2)
dummy_template_json3 = json.dumps(dummy_template3)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_create_stack():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -69,7 +69,7 @@ def test_create_stack():
})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_creating_stacks_across_regions():
west1_conn = boto.cloudformation.connect_to_region("us-west-1")
west1_conn.create_stack("test_stack", template_body=dummy_template_json)
@ -81,7 +81,7 @@ def test_creating_stacks_across_regions():
list(west2_conn.describe_stacks()).should.have.length_of(1)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_create_stack_with_notification_arn():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -94,8 +94,8 @@ def test_create_stack_with_notification_arn():
[n.value for n in stack.notification_arns].should.contain('arn:aws:sns:us-east-1:123456789012:fake-queue')
@mock_cloudformation
@mock_s3
@mock_cloudformation_deprecated
@mock_s3_deprecated
def test_create_stack_from_s3_url():
s3_conn = boto.s3.connect_to_region('us-west-1')
bucket = s3_conn.create_bucket("foobar")
@ -123,7 +123,7 @@ def test_create_stack_from_s3_url():
})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_describe_stack_by_name():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -135,7 +135,7 @@ def test_describe_stack_by_name():
stack.stack_name.should.equal('test_stack')
@mock_cloudformation
@mock_cloudformation_deprecated
def test_describe_stack_by_stack_id():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -149,7 +149,7 @@ def test_describe_stack_by_stack_id():
stack_by_id.stack_name.should.equal("test_stack")
@mock_cloudformation
@mock_cloudformation_deprecated
def test_describe_deleted_stack():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -166,7 +166,7 @@ def test_describe_deleted_stack():
stack_by_id.stack_status.should.equal("DELETE_COMPLETE")
@mock_cloudformation
@mock_cloudformation_deprecated
def test_get_template_by_name():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -188,7 +188,7 @@ def test_get_template_by_name():
})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_list_stacks():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -205,7 +205,7 @@ def test_list_stacks():
stacks[0].template_description.should.equal("Stack 1")
@mock_cloudformation
@mock_cloudformation_deprecated
def test_delete_stack_by_name():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -218,7 +218,7 @@ def test_delete_stack_by_name():
conn.list_stacks().should.have.length_of(0)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_delete_stack_by_id():
conn = boto.connect_cloudformation()
stack_id = conn.create_stack(
@ -235,7 +235,7 @@ def test_delete_stack_by_id():
conn.describe_stacks(stack_id).should.have.length_of(1)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_delete_stack_with_resource_missing_delete_attr():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -248,14 +248,14 @@ def test_delete_stack_with_resource_missing_delete_attr():
conn.list_stacks().should.have.length_of(0)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_bad_describe_stack():
conn = boto.connect_cloudformation()
with assert_raises(BotoServerError):
conn.describe_stacks("bad_stack")
@mock_cloudformation()
@mock_cloudformation_deprecated()
def test_cloudformation_params():
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -279,7 +279,7 @@ def test_cloudformation_params():
param.value.should.equal('testing123')
@mock_cloudformation
@mock_cloudformation_deprecated
def test_stack_tags():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -292,7 +292,7 @@ def test_stack_tags():
dict(stack.tags).should.equal({"foo": "bar", "baz": "bleh"})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_update_stack():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -316,7 +316,7 @@ def test_update_stack():
})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_update_stack():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -339,7 +339,7 @@ def test_update_stack():
})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_update_stack_when_rolled_back():
conn = boto.connect_cloudformation()
stack_id = conn.create_stack("test_stack", template_body=dummy_template_json)
@ -355,7 +355,7 @@ def test_update_stack_when_rolled_back():
ex.reason.should.equal('Bad Request')
ex.status.should.equal(400)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_describe_stack_events_shows_create_update_and_delete():
conn = boto.connect_cloudformation()
stack_id = conn.create_stack("test_stack", template_body=dummy_template_json)

View File

@ -5,7 +5,7 @@ import boto
import boto.s3
import boto.s3.key
from botocore.exceptions import ClientError
from moto import mock_cloudformation, mock_s3
from moto import mock_cloudformation, mock_s3_deprecated
import json
import sure # noqa
@ -118,7 +118,7 @@ def test_create_stack_with_role_arn():
@mock_cloudformation
@mock_s3
@mock_s3_deprecated
def test_create_stack_from_s3_url():
s3_conn = boto.s3.connect_to_region('us-west-1')
bucket = s3_conn.create_bucket("foobar")

View File

@ -18,20 +18,26 @@ import boto3
import sure # noqa
from moto import (
mock_autoscaling,
mock_autoscaling_deprecated,
mock_cloudformation,
mock_datapipeline,
mock_cloudformation_deprecated,
mock_datapipeline_deprecated,
mock_ec2,
mock_ec2_deprecated,
mock_elb,
mock_iam,
mock_elb_deprecated,
mock_iam_deprecated,
mock_kms,
mock_lambda,
mock_rds,
mock_rds_deprecated,
mock_rds2,
mock_rds2_deprecated,
mock_redshift,
mock_route53,
mock_sns,
mock_redshift_deprecated,
mock_route53_deprecated,
mock_sns_deprecated,
mock_sqs,
mock_sqs_deprecated,
)
from .fixtures import (
@ -49,7 +55,7 @@ from .fixtures import (
)
@mock_cloudformation()
@mock_cloudformation_deprecated()
def test_stack_sqs_integration():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -79,7 +85,7 @@ def test_stack_sqs_integration():
queue.physical_resource_id.should.equal("my-queue")
@mock_cloudformation()
@mock_cloudformation_deprecated()
def test_stack_list_resources():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -110,8 +116,8 @@ def test_stack_list_resources():
queue.physical_resource_id.should.equal("my-queue")
@mock_cloudformation()
@mock_sqs()
@mock_cloudformation_deprecated()
@mock_sqs_deprecated()
def test_update_stack():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -148,8 +154,8 @@ def test_update_stack():
queues[0].get_attributes('VisibilityTimeout')['VisibilityTimeout'].should.equal('100')
@mock_cloudformation()
@mock_sqs()
@mock_cloudformation_deprecated()
@mock_sqs_deprecated()
def test_update_stack_and_remove_resource():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -184,8 +190,8 @@ def test_update_stack_and_remove_resource():
queues.should.have.length_of(0)
@mock_cloudformation()
@mock_sqs()
@mock_cloudformation_deprecated()
@mock_sqs_deprecated()
def test_update_stack_and_add_resource():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -223,8 +229,8 @@ def test_update_stack_and_add_resource():
queues.should.have.length_of(1)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_stack_ec2_integration():
ec2_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -257,9 +263,9 @@ def test_stack_ec2_integration():
instance.physical_resource_id.should.equal(ec2_instance.id)
@mock_ec2()
@mock_elb()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_elb_deprecated()
@mock_cloudformation_deprecated()
def test_stack_elb_integration_with_attached_ec2_instances():
elb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -307,8 +313,8 @@ def test_stack_elb_integration_with_attached_ec2_instances():
list(load_balancer.availability_zones).should.equal(['us-east-1'])
@mock_elb()
@mock_cloudformation()
@mock_elb_deprecated()
@mock_cloudformation_deprecated()
def test_stack_elb_integration_with_health_check():
elb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -355,8 +361,8 @@ def test_stack_elb_integration_with_health_check():
health_check.unhealthy_threshold.should.equal(2)
@mock_elb()
@mock_cloudformation()
@mock_elb_deprecated()
@mock_cloudformation_deprecated()
def test_stack_elb_integration_with_update():
elb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -399,9 +405,9 @@ def test_stack_elb_integration_with_update():
load_balancer.availability_zones[0].should.equal('us-west-1b')
@mock_ec2()
@mock_redshift()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_redshift_deprecated()
@mock_cloudformation_deprecated()
def test_redshift_stack():
redshift_template_json = json.dumps(redshift.template)
@ -443,8 +449,8 @@ def test_redshift_stack():
group.rules[0].grants[0].cidr_ip.should.equal("10.0.0.1/16")
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_stack_security_groups():
security_group_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -519,9 +525,9 @@ def test_stack_security_groups():
rule2.grants[0].group_id.should.equal(other_group.id)
@mock_autoscaling()
@mock_elb()
@mock_cloudformation()
@mock_autoscaling_deprecated()
@mock_elb_deprecated()
@mock_cloudformation_deprecated()
def test_autoscaling_group_with_elb():
web_setup_template = {
@ -601,8 +607,8 @@ def test_autoscaling_group_with_elb():
elb_resource.physical_resource_id.should.contain("my-elb")
@mock_autoscaling()
@mock_cloudformation()
@mock_autoscaling_deprecated()
@mock_cloudformation_deprecated()
def test_autoscaling_group_update():
asg_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -650,8 +656,8 @@ def test_autoscaling_group_update():
asg.max_size.should.equal(3)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_vpc_single_instance_in_subnet():
template_json = json.dumps(vpc_single_instance_in_subnet.template)
@ -695,8 +701,8 @@ def test_vpc_single_instance_in_subnet():
eip_resource = [resource for resource in resources if resource.resource_type == 'AWS::EC2::EIP'][0]
eip_resource.physical_resource_id.should.equal(eip.allocation_id)
@mock_cloudformation()
@mock_ec2()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
@mock_rds2()
def test_rds_db_parameter_groups():
ec2_conn = boto.ec2.connect_to_region("us-west-1")
@ -734,9 +740,9 @@ def test_rds_db_parameter_groups():
@mock_cloudformation()
@mock_ec2()
@mock_rds()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
@mock_rds_deprecated()
def test_rds_mysql_with_read_replica():
ec2_conn = boto.ec2.connect_to_region("us-west-1")
ec2_conn.create_security_group('application', 'Our Application Group')
@ -776,9 +782,9 @@ def test_rds_mysql_with_read_replica():
security_group.ec2_groups[0].name.should.equal("application")
@mock_cloudformation()
@mock_ec2()
@mock_rds()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
@mock_rds_deprecated()
def test_rds_mysql_with_read_replica_in_vpc():
template_json = json.dumps(rds_mysql_with_read_replica.template)
conn = boto.cloudformation.connect_to_region("eu-central-1")
@ -804,9 +810,9 @@ def test_rds_mysql_with_read_replica_in_vpc():
subnet_group.description.should.equal("my db subnet group")
@mock_autoscaling()
@mock_iam()
@mock_cloudformation()
@mock_autoscaling_deprecated()
@mock_iam_deprecated()
@mock_cloudformation_deprecated()
def test_iam_roles():
iam_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -923,8 +929,8 @@ def test_iam_roles():
role_resource.physical_resource_id.should.equal(role.role_id)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_single_instance_with_ebs_volume():
template_json = json.dumps(single_instance_with_ebs_volume.template)
@ -951,7 +957,7 @@ def test_single_instance_with_ebs_volume():
ebs_volumes[0].physical_resource_id.should.equal(volume.id)
@mock_cloudformation()
@mock_cloudformation_deprecated()
def test_create_template_without_required_param():
template_json = json.dumps(single_instance_with_ebs_volume.template)
conn = boto.cloudformation.connect_to_region("us-west-1")
@ -961,8 +967,8 @@ def test_create_template_without_required_param():
).should.throw(BotoServerError)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_classic_eip():
template_json = json.dumps(ec2_classic_eip.template)
@ -977,8 +983,8 @@ def test_classic_eip():
cfn_eip.physical_resource_id.should.equal(eip.public_ip)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_vpc_eip():
template_json = json.dumps(vpc_eip.template)
@ -993,8 +999,8 @@ def test_vpc_eip():
cfn_eip.physical_resource_id.should.equal(eip.allocation_id)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_fn_join():
template_json = json.dumps(fn_join.template)
@ -1008,8 +1014,8 @@ def test_fn_join():
fn_join_output.value.should.equal('test eip:{0}'.format(eip.public_ip))
@mock_cloudformation()
@mock_sqs()
@mock_cloudformation_deprecated()
@mock_sqs_deprecated()
def test_conditional_resources():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1054,8 +1060,8 @@ def test_conditional_resources():
list(sqs_conn.get_all_queues()).should.have.length_of(1)
@mock_cloudformation()
@mock_ec2()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
def test_conditional_if_handling():
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1110,8 +1116,8 @@ def test_conditional_if_handling():
ec2_instance.image_id.should.equal("ami-00000000")
@mock_cloudformation()
@mock_ec2()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
def test_cloudformation_mapping():
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1155,8 +1161,8 @@ def test_cloudformation_mapping():
ec2_instance.image_id.should.equal("ami-c9c7978c")
@mock_cloudformation()
@mock_route53()
@mock_cloudformation_deprecated()
@mock_route53_deprecated()
def test_route53_roundrobin():
route53_conn = boto.connect_route53()
@ -1198,9 +1204,9 @@ def test_route53_roundrobin():
output.value.should.equal('arn:aws:route53:::hostedzone/{0}'.format(zone_id))
@mock_cloudformation()
@mock_ec2()
@mock_route53()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
@mock_route53_deprecated()
def test_route53_ec2_instance_with_public_ip():
route53_conn = boto.connect_route53()
ec2_conn = boto.ec2.connect_to_region("us-west-1")
@ -1233,8 +1239,8 @@ def test_route53_ec2_instance_with_public_ip():
record_set1.resource_records[0].should.equal("10.0.0.25")
@mock_cloudformation()
@mock_route53()
@mock_cloudformation_deprecated()
@mock_route53_deprecated()
def test_route53_associate_health_check():
route53_conn = boto.connect_route53()
@ -1270,8 +1276,8 @@ def test_route53_associate_health_check():
record_set.health_check.should.equal(health_check_id)
@mock_cloudformation()
@mock_route53()
@mock_cloudformation_deprecated()
@mock_route53_deprecated()
def test_route53_with_update():
route53_conn = boto.connect_route53()
@ -1314,8 +1320,8 @@ def test_route53_with_update():
record_set.resource_records.should.equal(["my_other.example.com"])
@mock_cloudformation()
@mock_sns()
@mock_cloudformation_deprecated()
@mock_sns_deprecated()
def test_sns_topic():
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1367,8 +1373,8 @@ def test_sns_topic():
topic_arn_output.value.should.equal(topic_arn)
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_vpc_gateway_attachment_creation_should_attach_itself_to_vpc():
template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1415,8 +1421,8 @@ def test_vpc_gateway_attachment_creation_should_attach_itself_to_vpc():
igws.should.have.length_of(1)
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_vpc_peering_creation():
vpc_conn = boto.vpc.connect_to_region("us-west-1")
vpc_source = vpc_conn.create_vpc("10.0.0.0/16")
@ -1445,8 +1451,8 @@ def test_vpc_peering_creation():
peering_connections.should.have.length_of(1)
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_multiple_security_group_ingress_separate_from_security_group_by_id():
template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1507,8 +1513,8 @@ def test_multiple_security_group_ingress_separate_from_security_group_by_id():
security_group1.rules[0].to_port.should.equal('8080')
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_security_group_ingress_separate_from_security_group_by_id():
ec2_conn = boto.ec2.connect_to_region("us-west-1")
ec2_conn.create_security_group("test-security-group1", "test security group")
@ -1558,8 +1564,8 @@ def test_security_group_ingress_separate_from_security_group_by_id():
security_group1.rules[0].to_port.should.equal('8080')
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_security_group_ingress_separate_from_security_group_by_id_using_vpc():
vpc_conn = boto.vpc.connect_to_region("us-west-1")
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -1624,8 +1630,8 @@ def test_security_group_ingress_separate_from_security_group_by_id_using_vpc():
security_group1.rules[0].to_port.should.equal('8080')
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_security_group_with_update():
vpc_conn = boto.vpc.connect_to_region("us-west-1")
vpc1 = vpc_conn.create_vpc("10.0.0.0/16")
@ -1669,8 +1675,8 @@ def test_security_group_with_update():
security_group.vpc_id.should.equal(vpc2.id)
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_subnets_should_be_created_with_availability_zone():
vpc_conn = boto.vpc.connect_to_region('us-west-1')
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -1698,8 +1704,8 @@ def test_subnets_should_be_created_with_availability_zone():
subnet.availability_zone.should.equal('us-west-1b')
@mock_cloudformation
@mock_datapipeline
@mock_cloudformation_deprecated
@mock_datapipeline_deprecated
def test_datapipeline():
dp_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1796,11 +1802,10 @@ def lambda_handler(event, context):
return _process_lamda(pfunc)
@mock_cloudformation
@mock_cloudformation_deprecated
@mock_lambda
def test_lambda_function():
# switch this to python as backend lambda only supports python execution.
conn = boto3.client('lambda', 'us-east-1')
template = {
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
@ -1827,6 +1832,7 @@ def test_lambda_function():
template_body=template_json,
)
conn = boto3.client('lambda', 'us-east-1')
result = conn.list_functions()
result['Functions'].should.have.length_of(1)
result['Functions'][0]['Description'].should.equal('Test function')

View File

@ -2,7 +2,7 @@ import boto
from boto.ec2.cloudwatch.alarm import MetricAlarm
import sure # noqa
from moto import mock_cloudwatch
from moto import mock_cloudwatch_deprecated
def alarm_fixture(name="tester", action=None):
action = action or ['arn:alarm']
@ -23,7 +23,7 @@ def alarm_fixture(name="tester", action=None):
unit='Seconds',
)
@mock_cloudwatch
@mock_cloudwatch_deprecated
def test_create_alarm():
conn = boto.connect_cloudwatch()
@ -49,7 +49,7 @@ def test_create_alarm():
alarm.unit.should.equal('Seconds')
@mock_cloudwatch
@mock_cloudwatch_deprecated
def test_delete_alarm():
conn = boto.connect_cloudwatch()
@ -68,7 +68,7 @@ def test_delete_alarm():
alarms.should.have.length_of(0)
@mock_cloudwatch
@mock_cloudwatch_deprecated
def test_put_metric_data():
conn = boto.connect_cloudwatch()
@ -87,7 +87,7 @@ def test_put_metric_data():
dict(metric.dimensions).should.equal({'InstanceId': ['i-0123456,i-0123457']})
@mock_cloudwatch
@mock_cloudwatch_deprecated
def test_describe_alarms():
conn = boto.connect_cloudwatch()
@ -114,7 +114,7 @@ def test_describe_alarms():
alarms = conn.describe_alarms()
alarms.should.have.length_of(0)
@mock_cloudwatch
@mock_cloudwatch_deprecated
def test_describe_state_value_unimplemented():
conn = boto.connect_cloudwatch()

View File

@ -7,19 +7,19 @@ import unittest
import tests.backport_assert_raises # noqa
from nose.tools import assert_raises
from moto import mock_ec2, mock_s3
from moto import mock_ec2_deprecated, mock_s3_deprecated
'''
Test the different ways that the decorator can be used
'''
@mock_ec2
@mock_ec2_deprecated
def test_basic_connect():
boto.connect_ec2()
@mock_ec2
@mock_ec2_deprecated
def test_basic_decorator():
conn = boto.connect_ec2('the_key', 'the_secret')
list(conn.get_all_instances()).should.equal([])
@ -30,7 +30,7 @@ def test_context_manager():
with assert_raises(EC2ResponseError):
conn.get_all_instances()
with mock_ec2():
with mock_ec2_deprecated():
conn = boto.connect_ec2('the_key', 'the_secret')
list(conn.get_all_instances()).should.equal([])
@ -44,7 +44,7 @@ def test_decorator_start_and_stop():
with assert_raises(EC2ResponseError):
conn.get_all_instances()
mock = mock_ec2()
mock = mock_ec2_deprecated()
mock.start()
conn = boto.connect_ec2('the_key', 'the_secret')
list(conn.get_all_instances()).should.equal([])
@ -54,7 +54,7 @@ def test_decorator_start_and_stop():
conn.get_all_instances()
@mock_ec2
@mock_ec2_deprecated
def test_decorater_wrapped_gets_set():
"""
Moto decorator's __wrapped__ should get set to the tests function
@ -62,7 +62,7 @@ def test_decorater_wrapped_gets_set():
test_decorater_wrapped_gets_set.__wrapped__.__name__.should.equal('test_decorater_wrapped_gets_set')
@mock_ec2
@mock_ec2_deprecated
class Tester(object):
def test_the_class(self):
conn = boto.connect_ec2()
@ -73,7 +73,7 @@ class Tester(object):
list(conn.get_all_instances()).should.have.length_of(0)
@mock_s3
@mock_s3_deprecated
class TesterWithSetup(unittest.TestCase):
def setUp(self):
self.conn = boto.connect_s3()

View File

@ -5,12 +5,12 @@ from boto.sqs.connection import SQSConnection
from boto.sqs.message import Message
from boto.ec2 import EC2Connection
from moto import mock_sqs, mock_ec2
from moto import mock_sqs_deprecated, mock_ec2_deprecated
class TestNestedDecorators(unittest.TestCase):
@mock_sqs
@mock_sqs_deprecated
def setup_sqs_queue(self):
conn = SQSConnection()
q = conn.create_queue('some-queue')
@ -21,7 +21,7 @@ class TestNestedDecorators(unittest.TestCase):
self.assertEqual(q.count(), 1)
@mock_ec2
@mock_ec2_deprecated
def test_nested(self):
self.setup_sqs_queue()

View File

@ -3,7 +3,7 @@ from __future__ import unicode_literals
import boto.datapipeline
import sure # noqa
from moto import mock_datapipeline
from moto import mock_datapipeline_deprecated
from moto.datapipeline.utils import remove_capitalization_of_dict_keys
@ -13,7 +13,7 @@ def get_value_from_fields(key, fields):
return field['stringValue']
@mock_datapipeline
@mock_datapipeline_deprecated
def test_create_pipeline():
conn = boto.datapipeline.connect_to_region("us-west-2")
@ -78,7 +78,7 @@ PIPELINE_OBJECTS = [
]
@mock_datapipeline
@mock_datapipeline_deprecated
def test_creating_pipeline_definition():
conn = boto.datapipeline.connect_to_region("us-west-2")
res = conn.create_pipeline("mypipeline", "some-unique-id")
@ -97,7 +97,7 @@ def test_creating_pipeline_definition():
}])
@mock_datapipeline
@mock_datapipeline_deprecated
def test_describing_pipeline_objects():
conn = boto.datapipeline.connect_to_region("us-west-2")
res = conn.create_pipeline("mypipeline", "some-unique-id")
@ -116,7 +116,7 @@ def test_describing_pipeline_objects():
}])
@mock_datapipeline
@mock_datapipeline_deprecated
def test_activate_pipeline():
conn = boto.datapipeline.connect_to_region("us-west-2")
@ -133,7 +133,7 @@ def test_activate_pipeline():
get_value_from_fields('@pipelineState', fields).should.equal("SCHEDULED")
@mock_datapipeline
@mock_datapipeline_deprecated
def test_listing_pipelines():
conn = boto.datapipeline.connect_to_region("us-west-2")
res1 = conn.create_pipeline("mypipeline1", "some-unique-id1")

View File

@ -7,13 +7,13 @@ import requests
import tests.backport_assert_raises
from nose.tools import assert_raises
from moto import mock_dynamodb
from moto import mock_dynamodb, mock_dynamodb_deprecated
from moto.dynamodb import dynamodb_backend
from boto.exception import DynamoDBResponseError
@mock_dynamodb
@mock_dynamodb_deprecated
def test_list_tables():
name = 'TestTable'
dynamodb_backend.create_table(name, hash_key_attr="name", hash_key_type="S")
@ -21,7 +21,7 @@ def test_list_tables():
assert conn.list_tables() == ['TestTable']
@mock_dynamodb
@mock_dynamodb_deprecated
def test_list_tables_layer_1():
dynamodb_backend.create_table("test_1", hash_key_attr="name", hash_key_type="S")
dynamodb_backend.create_table("test_2", hash_key_attr="name", hash_key_type="S")
@ -35,7 +35,7 @@ def test_list_tables_layer_1():
res.should.equal(expected)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_describe_missing_table():
conn = boto.connect_dynamodb('the_key', 'the_secret')
with assert_raises(DynamoDBResponseError):
@ -49,7 +49,7 @@ def test_sts_handler():
res.text.should.contain("SecretAccessKey")
@mock_dynamodb
@mock_dynamodb_deprecated
def test_dynamodb_with_connect_to_region():
# this will work if connected with boto.connect_dynamodb()
dynamodb = boto.dynamodb.connect_to_region('us-west-2')

View File

@ -4,7 +4,7 @@ import boto
import sure # noqa
from freezegun import freeze_time
from moto import mock_dynamodb
from moto import mock_dynamodb_deprecated
from boto.dynamodb import condition
from boto.dynamodb.exceptions import DynamoDBKeyNotFoundError, DynamoDBValidationError
@ -29,7 +29,7 @@ def create_table(conn):
@freeze_time("2012-01-14")
@mock_dynamodb
@mock_dynamodb_deprecated
def test_create_table():
conn = boto.connect_dynamodb()
create_table(conn)
@ -60,7 +60,7 @@ def test_create_table():
conn.describe_table('messages').should.equal(expected)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_table():
conn = boto.connect_dynamodb()
create_table(conn)
@ -72,7 +72,7 @@ def test_delete_table():
conn.layer1.delete_table.when.called_with('messages').should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_update_table_throughput():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -86,7 +86,7 @@ def test_update_table_throughput():
table.write_units.should.equal(6)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_item_add_and_describe_and_update():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -133,7 +133,7 @@ def test_item_add_and_describe_and_update():
})
@mock_dynamodb
@mock_dynamodb_deprecated
def test_item_put_without_table():
conn = boto.connect_dynamodb()
@ -146,7 +146,7 @@ def test_item_put_without_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_get_missing_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -158,7 +158,7 @@ def test_get_missing_item():
table.has_item("foobar", "more").should.equal(False)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_get_item_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -171,7 +171,7 @@ def test_get_item_with_undeclared_table():
).should.throw(DynamoDBKeyNotFoundError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_get_item_without_range_key():
conn = boto.connect_dynamodb()
message_table_schema = conn.create_schema(
@ -195,7 +195,7 @@ def test_get_item_without_range_key():
table.get_item.when.called_with(hash_key=hash_key).should.throw(DynamoDBValidationError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -223,7 +223,7 @@ def test_delete_item():
item.delete.when.called_with().should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item_with_attribute_response():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -260,7 +260,7 @@ def test_delete_item_with_attribute_response():
item.delete.when.called_with().should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -273,7 +273,7 @@ def test_delete_item_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_query():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -323,7 +323,7 @@ def test_query():
results.response['Items'].should.have.length_of(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_query_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -339,7 +339,7 @@ def test_query_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -402,7 +402,7 @@ def test_scan():
results.response['Items'].should.have.length_of(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -419,7 +419,7 @@ def test_scan_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan_after_has_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -430,7 +430,7 @@ def test_scan_after_has_item():
list(table.scan()).should.equal([])
@mock_dynamodb
@mock_dynamodb_deprecated
def test_write_batch():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -474,7 +474,7 @@ def test_write_batch():
table.item_count.should.equal(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_batch_read():
conn = boto.connect_dynamodb()
table = create_table(conn)

View File

@ -4,7 +4,7 @@ import boto
import sure # noqa
from freezegun import freeze_time
from moto import mock_dynamodb
from moto import mock_dynamodb_deprecated
from boto.dynamodb import condition
from boto.dynamodb.exceptions import DynamoDBKeyNotFoundError
@ -27,7 +27,7 @@ def create_table(conn):
@freeze_time("2012-01-14")
@mock_dynamodb
@mock_dynamodb_deprecated
def test_create_table():
conn = boto.connect_dynamodb()
create_table(conn)
@ -54,7 +54,7 @@ def test_create_table():
conn.describe_table('messages').should.equal(expected)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_table():
conn = boto.connect_dynamodb()
create_table(conn)
@ -66,7 +66,7 @@ def test_delete_table():
conn.layer1.delete_table.when.called_with('messages').should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_update_table_throughput():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -80,7 +80,7 @@ def test_update_table_throughput():
table.write_units.should.equal(6)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_item_add_and_describe_and_update():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -120,7 +120,7 @@ def test_item_add_and_describe_and_update():
})
@mock_dynamodb
@mock_dynamodb_deprecated
def test_item_put_without_table():
conn = boto.connect_dynamodb()
@ -132,7 +132,7 @@ def test_item_put_without_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_get_missing_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -142,7 +142,7 @@ def test_get_missing_item():
).should.throw(DynamoDBKeyNotFoundError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_get_item_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -154,7 +154,7 @@ def test_get_item_with_undeclared_table():
).should.throw(DynamoDBKeyNotFoundError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -181,7 +181,7 @@ def test_delete_item():
item.delete.when.called_with().should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item_with_attribute_response():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -216,7 +216,7 @@ def test_delete_item_with_attribute_response():
item.delete.when.called_with().should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -228,7 +228,7 @@ def test_delete_item_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_query():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -248,7 +248,7 @@ def test_query():
results.response['Items'].should.have.length_of(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_query_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -258,7 +258,7 @@ def test_query_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -318,7 +318,7 @@ def test_scan():
results.response['Items'].should.have.length_of(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -335,7 +335,7 @@ def test_scan_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan_after_has_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -346,7 +346,7 @@ def test_scan_after_has_item():
list(table.scan()).should.equal([])
@mock_dynamodb
@mock_dynamodb_deprecated
def test_write_batch():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -388,7 +388,7 @@ def test_write_batch():
table.item_count.should.equal(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_batch_read():
conn = boto.connect_dynamodb()
table = create_table(conn)

View File

@ -4,7 +4,7 @@ import six
import boto
import sure # noqa
import requests
from moto import mock_dynamodb2
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
from moto.dynamodb2 import dynamodb_backend2
from boto.exception import JSONResponseError
from tests.helpers import requires_boto_gte
@ -16,7 +16,7 @@ except ImportError:
print("This boto version is not supported")
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_list_tables():
name = 'TestTable'
#{'schema': }
@ -32,7 +32,7 @@ def test_list_tables():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_list_tables_layer_1():
dynamodb_backend2.create_table("test_1",schema=[
{u'KeyType': u'HASH', u'AttributeName': u'name'}
@ -55,7 +55,7 @@ def test_list_tables_layer_1():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_describe_missing_table():
conn = boto.dynamodb2.connect_to_region(
'us-west-2',

View File

@ -7,7 +7,7 @@ import boto3
from boto3.dynamodb.conditions import Key
import sure # noqa
from freezegun import freeze_time
from moto import mock_dynamodb2
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
from boto.exception import JSONResponseError
from tests.helpers import requires_boto_gte
try:
@ -61,7 +61,7 @@ def iterate_results(res):
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
@freeze_time("2012-01-14")
def test_create_table():
table = create_table()
@ -90,7 +90,7 @@ def test_create_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
@freeze_time("2012-01-14")
def test_create_table_with_local_index():
table = create_table_with_local_indexes()
@ -132,7 +132,7 @@ def test_create_table_with_local_index():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
table = create_table()
@ -144,7 +144,7 @@ def test_delete_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_table_throughput():
table = create_table()
table.throughput["read"].should.equal(10)
@ -169,7 +169,7 @@ def test_update_table_throughput():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_add_and_describe_and_update():
table = create_table()
ok = table.put_item(data={
@ -212,7 +212,7 @@ def test_item_add_and_describe_and_update():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_partial_save():
table = create_table()
@ -242,7 +242,7 @@ def test_item_partial_save():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_put_without_table():
table = Table('undeclared-table')
item_data = {
@ -256,7 +256,7 @@ def test_item_put_without_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_missing_item():
table = create_table()
@ -267,14 +267,14 @@ def test_get_missing_item():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_item_with_undeclared_table():
table = Table('undeclared-table')
table.get_item.when.called_with(test_hash=3241526475).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_item_without_range_key():
table = Table.create('messages', schema=[
HashKey('test_hash'),
@ -291,7 +291,7 @@ def test_get_item_without_range_key():
@requires_boto_gte("2.30.0")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item():
table = create_table()
item_data = {
@ -313,7 +313,7 @@ def test_delete_item():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item_with_undeclared_table():
table = Table("undeclared-table")
item_data = {
@ -327,7 +327,7 @@ def test_delete_item_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query():
table = create_table()
@ -384,7 +384,7 @@ def test_query():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_undeclared_table():
table = Table('undeclared')
results = table.query(
@ -396,7 +396,7 @@ def test_query_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan():
table = create_table()
item_data = {
@ -451,7 +451,7 @@ def test_scan():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
conn.scan.when.called_with(
@ -468,7 +468,7 @@ def test_scan_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_write_batch():
table = create_table()
with table.batch_write() as batch:
@ -498,7 +498,7 @@ def test_write_batch():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_batch_read():
table = create_table()
item_data = {
@ -542,14 +542,14 @@ def test_batch_read():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_key_fields():
table = create_table()
kf = table.get_key_fields()
kf.should.equal(['forum_name', 'subject'])
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_create_with_global_indexes():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -594,7 +594,7 @@ def test_create_with_global_indexes():
])
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_global_indexes():
table = Table.create('messages', schema=[
HashKey('subject'),
@ -638,7 +638,7 @@ def test_query_with_global_indexes():
list(results).should.have.length_of(0)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_local_indexes():
table = create_table_with_local_indexes()
item_data = {
@ -658,7 +658,7 @@ def test_query_with_local_indexes():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_eq():
table = create_table_with_local_indexes()
item_data = [
@ -691,7 +691,7 @@ def test_query_filter_eq():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_lt():
table = create_table_with_local_indexes()
item_data = [
@ -726,7 +726,7 @@ def test_query_filter_lt():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_gt():
table = create_table_with_local_indexes()
item_data = [
@ -760,7 +760,7 @@ def test_query_filter_gt():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_lte():
table = create_table_with_local_indexes()
item_data = [
@ -794,7 +794,7 @@ def test_query_filter_lte():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_gte():
table = create_table_with_local_indexes()
item_data = [
@ -827,7 +827,7 @@ def test_query_filter_gte():
list(results).should.have.length_of(2)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_reverse_query():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -851,7 +851,7 @@ def test_reverse_query():
[r['created_at'] for r in results].should.equal(expected)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_lookup():
from decimal import Decimal
table = Table.create('messages', schema=[
@ -871,7 +871,7 @@ def test_lookup():
message.get('test_range').should.equal(Decimal(range_key))
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_failed_overwrite():
table = Table.create('messages', schema=[
HashKey('id'),
@ -900,7 +900,7 @@ def test_failed_overwrite():
dict(returned_item).should.equal(data4)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_conflicting_writes():
table = Table.create('messages', schema=[
HashKey('id'),

View File

@ -6,7 +6,7 @@ from boto3.dynamodb.conditions import Key
import sure # noqa
from freezegun import freeze_time
from boto.exception import JSONResponseError
from moto import mock_dynamodb2
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
from tests.helpers import requires_boto_gte
import botocore
try:
@ -29,7 +29,7 @@ def create_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
@freeze_time("2012-01-14")
def test_create_table():
create_table()
@ -62,7 +62,7 @@ def test_create_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_table():
create_table()
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -75,7 +75,7 @@ def test_delete_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_table_throughput():
table = create_table()
table.throughput["read"].should.equal(10)
@ -91,7 +91,7 @@ def test_update_table_throughput():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_add_and_describe_and_update():
table = create_table()
@ -125,7 +125,7 @@ def test_item_add_and_describe_and_update():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_partial_save():
table = create_table()
@ -152,7 +152,7 @@ def test_item_partial_save():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_put_without_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -167,7 +167,7 @@ def test_item_put_without_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_item_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -178,7 +178,7 @@ def test_get_item_with_undeclared_table():
@requires_boto_gte("2.30.0")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item():
table = create_table()
@ -202,7 +202,7 @@ def test_delete_item():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -213,7 +213,7 @@ def test_delete_item_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query():
table = create_table()
@ -233,7 +233,7 @@ def test_query():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -244,7 +244,7 @@ def test_query_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan():
table = create_table()
@ -295,7 +295,7 @@ def test_scan():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -313,7 +313,7 @@ def test_scan_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_write_batch():
table = create_table()
@ -344,7 +344,7 @@ def test_write_batch():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_batch_read():
table = create_table()
@ -385,7 +385,7 @@ def test_batch_read():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_key_fields():
table = create_table()
kf = table.get_key_fields()
@ -393,14 +393,14 @@ def test_get_key_fields():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_missing_item():
table = create_table()
table.get_item.when.called_with(forum_name='missing').should.throw(ItemNotFound)
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_special_item():
table = Table.create('messages', schema=[
HashKey('date-joined')
@ -418,7 +418,7 @@ def test_get_special_item():
dict(returned_item).should.equal(data)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_item_remove():
conn = boto.dynamodb2.connect_to_region("us-west-2")
table = Table.create('messages', schema=[
@ -444,7 +444,7 @@ def test_update_item_remove():
})
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_item_set():
conn = boto.dynamodb2.connect_to_region("us-west-2")
table = Table.create('messages', schema=[
@ -471,7 +471,7 @@ def test_update_item_set():
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_failed_overwrite():
table = Table.create('messages', schema=[
HashKey('id'),
@ -499,7 +499,7 @@ def test_failed_overwrite():
dict(returned_item).should.equal(data4)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_conflicting_writes():
table = Table.create('messages', schema=[
HashKey('id'),

View File

@ -9,11 +9,11 @@ from boto.exception import EC2ResponseError, JSONResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_emr_deprecated
from tests.helpers import requires_boto_gte
@mock_ec2
@mock_emr_deprecated
def test_ami_create_and_delete():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -69,7 +69,7 @@ def test_ami_create_and_delete():
@requires_boto_gte("2.14.0")
@mock_ec2
@mock_emr_deprecated
def test_ami_copy():
conn = boto.ec2.connect_to_region("us-west-1")
reservation = conn.run_instances('ami-1234abcd')
@ -119,7 +119,7 @@ def test_ami_copy():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_emr_deprecated
def test_ami_tagging():
conn = boto.connect_vpc('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -145,7 +145,7 @@ def test_ami_tagging():
image.tags["a key"].should.equal("some value")
@mock_ec2
@mock_emr_deprecated
def test_ami_create_from_missing_instance():
conn = boto.connect_ec2('the_key', 'the_secret')
args = ["i-abcdefg", "test-ami", "this is a test ami"]
@ -157,7 +157,7 @@ def test_ami_create_from_missing_instance():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_emr_deprecated
def test_ami_pulls_attributes_from_instance():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -169,7 +169,7 @@ def test_ami_pulls_attributes_from_instance():
image.kernel_id.should.equal('test-kernel')
@mock_ec2
@mock_emr_deprecated
def test_ami_filters():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -220,7 +220,7 @@ def test_ami_filters():
set([ami.id for ami in amis_by_nonpublic]).should.equal(set([imageA.id]))
@mock_ec2
@mock_emr_deprecated
def test_ami_filtering_via_tag():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -243,7 +243,7 @@ def test_ami_filtering_via_tag():
set([ami.id for ami in amis_by_tagB]).should.equal(set([imageB.id]))
@mock_ec2
@mock_emr_deprecated
def test_getting_missing_ami():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -254,7 +254,7 @@ def test_getting_missing_ami():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_emr_deprecated
def test_getting_malformed_ami():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -265,7 +265,7 @@ def test_getting_malformed_ami():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_emr_deprecated
def test_ami_attribute_group_permissions():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -318,7 +318,7 @@ def test_ami_attribute_group_permissions():
conn.modify_image_attribute.when.called_with(**REMOVE_GROUP_ARGS).should_not.throw(EC2ResponseError)
@mock_ec2
@mock_emr_deprecated
def test_ami_attribute_user_permissions():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -383,7 +383,7 @@ def test_ami_attribute_user_permissions():
conn.modify_image_attribute.when.called_with(**REMOVE_USERS_ARGS).should_not.throw(EC2ResponseError)
@mock_ec2
@mock_emr_deprecated
def test_ami_attribute_user_and_group_permissions():
"""
Boto supports adding/removing both users and groups at the same time.
@ -435,7 +435,7 @@ def test_ami_attribute_user_and_group_permissions():
image.is_public.should.equal(False)
@mock_ec2
@mock_emr_deprecated
def test_ami_attribute_error_cases():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')

View File

@ -4,10 +4,10 @@ import boto.ec2
import boto3
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_describe_regions():
conn = boto.connect_ec2('the_key', 'the_secret')
regions = conn.get_all_regions()
@ -16,7 +16,7 @@ def test_describe_regions():
region.endpoint.should.contain(region.name)
@mock_ec2
@mock_ec2_deprecated
def test_availability_zones():
conn = boto.connect_ec2('the_key', 'the_secret')
regions = conn.get_all_regions()

View File

@ -5,10 +5,10 @@ from nose.tools import assert_raises
from nose.tools import assert_false
from boto.exception import EC2ResponseError
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_create_customer_gateways():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -19,7 +19,7 @@ def test_create_customer_gateways():
customer_gateway.bgp_asn.should.equal(65534)
customer_gateway.ip_address.should.equal('205.251.242.54')
@mock_ec2
@mock_ec2_deprecated
def test_describe_customer_gateways():
conn = boto.connect_vpc('the_key', 'the_secret')
customer_gateway = conn.create_customer_gateway('ipsec.1', '205.251.242.54', 65534)
@ -27,7 +27,7 @@ def test_describe_customer_gateways():
cgws.should.have.length_of(1)
cgws[0].id.should.match(customer_gateway.id)
@mock_ec2
@mock_ec2_deprecated
def test_delete_customer_gateways():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -39,7 +39,7 @@ def test_delete_customer_gateways():
cgws = conn.get_all_customer_gateways()
cgws.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_delete_customer_gateways_bad_id():
conn = boto.connect_vpc('the_key', 'the_secret')
with assert_raises(EC2ResponseError) as cm:

View File

@ -9,13 +9,13 @@ from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
SAMPLE_DOMAIN_NAME = u'example.com'
SAMPLE_NAME_SERVERS = [u'10.0.0.6', u'10.0.0.7']
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_associate():
""" associate dhcp option """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -26,7 +26,7 @@ def test_dhcp_options_associate():
rval.should.be.equal(True)
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_associate_invalid_dhcp_id():
""" associate dhcp option bad dhcp options id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -39,7 +39,7 @@ def test_dhcp_options_associate_invalid_dhcp_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_associate_invalid_vpc_id():
""" associate dhcp option invalid vpc id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -52,7 +52,7 @@ def test_dhcp_options_associate_invalid_vpc_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_delete_with_vpc():
"""Test deletion of dhcp options with vpc"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -78,7 +78,7 @@ def test_dhcp_options_delete_with_vpc():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_create_dhcp_options():
"""Create most basic dhcp option"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -89,7 +89,7 @@ def test_create_dhcp_options():
dhcp_option.options[u'domain-name-servers'][1].should.be.equal(SAMPLE_NAME_SERVERS[1])
@mock_ec2
@mock_ec2_deprecated
def test_create_dhcp_options_invalid_options():
"""Create invalid dhcp options"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -108,7 +108,7 @@ def test_create_dhcp_options_invalid_options():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_describe_dhcp_options():
"""Test dhcp options lookup by id"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -121,7 +121,7 @@ def test_describe_dhcp_options():
dhcp_options.should.be.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_describe_dhcp_options_invalid_id():
"""get error on invalid dhcp_option_id lookup"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -133,7 +133,7 @@ def test_describe_dhcp_options_invalid_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_delete_dhcp_options():
"""delete dhcp option"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -151,7 +151,7 @@ def test_delete_dhcp_options():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_delete_dhcp_options_invalid_id():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -164,7 +164,7 @@ def test_delete_dhcp_options_invalid_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_delete_dhcp_options_malformed_id():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -177,7 +177,7 @@ def test_delete_dhcp_options_malformed_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_tagging():
conn = boto.connect_vpc('the_key', 'the_secret')
dhcp_option = conn.create_dhcp_options()
@ -194,7 +194,7 @@ def test_dhcp_tagging():
dhcp_option.tags["a key"].should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_get_by_tag():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -230,7 +230,7 @@ def test_dhcp_options_get_by_tag():
dhcp_options_sets.should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_get_by_id():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -308,7 +308,7 @@ def test_dhcp_options_get_by_key_filter():
dhcp_options_sets.should.have.length_of(3)
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_get_by_invalid_filter():
conn = boto.connect_vpc('the_key', 'the_secret')

View File

@ -8,10 +8,10 @@ import boto
from boto.exception import EC2ResponseError, JSONResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_create_and_delete_volume():
conn = boto.connect_ec2('the_key', 'the_secret')
volume = conn.create_volume(80, "us-east-1a")
@ -43,7 +43,7 @@ def test_create_and_delete_volume():
@mock_ec2
@mock_ec2_deprecated
def test_create_encrypted_volume_dryrun():
conn = boto.connect_ec2('the_key', 'the_secret')
with assert_raises(JSONResponseError) as ex:
@ -53,7 +53,7 @@ def test_create_encrypted_volume_dryrun():
ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the CreateVolume operation: Request would have succeeded, but DryRun flag is set')
@mock_ec2
@mock_ec2_deprecated
def test_create_encrypted_volume():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.create_volume(80, "us-east-1a", encrypted=True)
@ -68,7 +68,7 @@ def test_create_encrypted_volume():
all_volumes[0].encrypted.should.be(True)
@mock_ec2
@mock_ec2_deprecated
def test_filter_volume_by_id():
conn = boto.connect_ec2('the_key', 'the_secret')
volume1 = conn.create_volume(80, "us-east-1a")
@ -82,7 +82,7 @@ def test_filter_volume_by_id():
vol2.should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_volume_filters():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -155,7 +155,7 @@ def test_volume_filters():
)
@mock_ec2
@mock_ec2_deprecated
def test_volume_attach_and_detach():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -209,7 +209,7 @@ def test_volume_attach_and_detach():
cm3.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_create_snapshot():
conn = boto.connect_ec2('the_key', 'the_secret')
volume = conn.create_volume(80, "us-east-1a")
@ -245,7 +245,7 @@ def test_create_snapshot():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_create_encrypted_snapshot():
conn = boto.connect_ec2('the_key', 'the_secret')
volume = conn.create_volume(80, "us-east-1a", encrypted=True)
@ -260,7 +260,7 @@ def test_create_encrypted_snapshot():
snapshots[0].encrypted.should.be(True)
@mock_ec2
@mock_ec2_deprecated
def test_filter_snapshot_by_id():
conn = boto.connect_ec2('the_key', 'the_secret')
volume1 = conn.create_volume(36, "us-east-1a")
@ -281,7 +281,7 @@ def test_filter_snapshot_by_id():
s.region.name.should.equal(conn.region.name)
@mock_ec2
@mock_ec2_deprecated
def test_snapshot_filters():
conn = boto.connect_ec2('the_key', 'the_secret')
volume1 = conn.create_volume(20, "us-east-1a", encrypted=False)
@ -322,7 +322,7 @@ def test_snapshot_filters():
set([snap.id for snap in snapshots_by_encrypted]).should.equal(set([snapshot3.id]))
@mock_ec2
@mock_ec2_deprecated
def test_snapshot_attribute():
import copy
@ -418,7 +418,7 @@ def test_snapshot_attribute():
user_ids=['user']).should.throw(NotImplementedError)
@mock_ec2
@mock_ec2_deprecated
def test_create_volume_from_snapshot():
conn = boto.connect_ec2('the_key', 'the_secret')
volume = conn.create_volume(80, "us-east-1a")
@ -439,7 +439,7 @@ def test_create_volume_from_snapshot():
new_volume.snapshot_id.should.equal(snapshot.id)
@mock_ec2
@mock_ec2_deprecated
def test_create_volume_from_encrypted_snapshot():
conn = boto.connect_ec2('the_key', 'the_secret')
volume = conn.create_volume(80, "us-east-1a", encrypted=True)
@ -454,7 +454,7 @@ def test_create_volume_from_encrypted_snapshot():
new_volume.encrypted.should.be(True)
@mock_ec2
@mock_ec2_deprecated
def test_modify_attribute_blockDeviceMapping():
"""
Reproduces the missing feature explained at [0], where we want to mock a
@ -481,7 +481,7 @@ def test_modify_attribute_blockDeviceMapping():
instance.block_device_mapping['/dev/sda1'].delete_on_termination.should.be(True)
@mock_ec2
@mock_ec2_deprecated
def test_volume_tag_escaping():
conn = boto.connect_ec2('the_key', 'the_secret')
vol = conn.create_volume(10, 'us-east-1a')

View File

@ -10,12 +10,12 @@ import six
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
import logging
@mock_ec2
@mock_ec2_deprecated
def test_eip_allocate_classic():
"""Allocate/release Classic EIP"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -42,7 +42,7 @@ def test_eip_allocate_classic():
standard.should_not.be.within(conn.get_all_addresses())
@mock_ec2
@mock_ec2_deprecated
def test_eip_allocate_vpc():
"""Allocate/release VPC EIP"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -60,7 +60,7 @@ def test_eip_allocate_vpc():
vpc.release()
@mock_ec2
@mock_ec2_deprecated
def test_eip_allocate_invalid_domain():
"""Allocate EIP invalid domain"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -72,7 +72,7 @@ def test_eip_allocate_invalid_domain():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_associate_classic():
"""Associate/Disassociate EIP to classic instance"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -114,7 +114,7 @@ def test_eip_associate_classic():
instance.terminate()
@mock_ec2
@mock_ec2_deprecated
def test_eip_associate_vpc():
"""Associate/Disassociate EIP to VPC instance"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -176,7 +176,7 @@ def test_eip_boto3_vpc_association():
instance.public_dns_name.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_associate_network_interface():
"""Associate/Disassociate EIP to NIC"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -204,7 +204,7 @@ def test_eip_associate_network_interface():
eip.release()
eip = None
@mock_ec2
@mock_ec2_deprecated
def test_eip_reassociate():
"""reassociate EIP"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -233,7 +233,7 @@ def test_eip_reassociate():
instance1.terminate()
instance2.terminate()
@mock_ec2
@mock_ec2_deprecated
def test_eip_reassociate_nic():
"""reassociate EIP"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -261,7 +261,7 @@ def test_eip_reassociate_nic():
eip.release()
eip = None
@mock_ec2
@mock_ec2_deprecated
def test_eip_associate_invalid_args():
"""Associate EIP, invalid args """
conn = boto.connect_ec2('the_key', 'the_secret')
@ -280,7 +280,7 @@ def test_eip_associate_invalid_args():
instance.terminate()
@mock_ec2
@mock_ec2_deprecated
def test_eip_disassociate_bogus_association():
"""Disassociate bogus EIP"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -291,7 +291,7 @@ def test_eip_disassociate_bogus_association():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_release_bogus_eip():
"""Release bogus EIP"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -303,7 +303,7 @@ def test_eip_release_bogus_eip():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_disassociate_arg_error():
"""Invalid arguments disassociate address"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -315,7 +315,7 @@ def test_eip_disassociate_arg_error():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_release_arg_error():
"""Invalid arguments release address"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -327,7 +327,7 @@ def test_eip_release_arg_error():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_describe():
"""Listing of allocated Elastic IP Addresses."""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -363,7 +363,7 @@ def test_eip_describe():
len(conn.get_all_addresses()).should.be.equal(0)
@mock_ec2
@mock_ec2_deprecated
def test_eip_describe_none():
"""Error when search for bogus IP"""
conn = boto.connect_ec2('the_key', 'the_secret')

View File

@ -10,13 +10,13 @@ import boto.ec2
from boto.exception import EC2ResponseError, JSONResponseError
import sure # noqa
from moto import mock_ec2, mock_cloudformation
from moto import mock_ec2, mock_cloudformation_deprecated, mock_ec2_deprecated
from tests.helpers import requires_boto_gte
from tests.test_cloudformation.fixtures import vpc_eni
import json
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -54,7 +54,7 @@ def test_elastic_network_interfaces():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces_subnet_validation():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -65,7 +65,7 @@ def test_elastic_network_interfaces_subnet_validation():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces_with_private_ip():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -83,7 +83,7 @@ def test_elastic_network_interfaces_with_private_ip():
eni.private_ip_addresses[0].private_ip_address.should.equal(private_ip)
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces_with_groups():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -101,7 +101,7 @@ def test_elastic_network_interfaces_with_groups():
@requires_boto_gte("2.12.0")
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces_modify_attribute():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -133,7 +133,7 @@ def test_elastic_network_interfaces_modify_attribute():
eni.groups[0].id.should.equal(security_group2.id)
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces_filtering():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -281,8 +281,8 @@ def test_elastic_network_interfaces_get_by_subnet_id():
enis.should.have.length_of(0)
@mock_ec2
@mock_cloudformation
@mock_ec2_deprecated
@mock_cloudformation_deprecated
def test_elastic_network_interfaces_cloudformation():
template = vpc_eni.template
template_json = json.dumps(template)

View File

@ -7,10 +7,10 @@ import boto
from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_console_output():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -20,7 +20,7 @@ def test_console_output():
output.output.should_not.equal(None)
@mock_ec2
@mock_ec2_deprecated
def test_console_output_without_instance():
conn = boto.connect_ec2('the_key', 'the_secret')

View File

@ -12,7 +12,7 @@ from boto.exception import EC2ResponseError, JSONResponseError
from freezegun import freeze_time
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
from tests.helpers import requires_boto_gte
@ -23,7 +23,7 @@ def add_servers(ami_id, count):
conn.run_instances(ami_id)
@mock_ec2
@mock_ec2_deprecated
def test_add_servers():
add_servers('ami-1234abcd', 2)
@ -37,7 +37,7 @@ def test_add_servers():
@freeze_time("2014-01-01 05:00:00")
@mock_ec2
@mock_ec2_deprecated
def test_instance_launch_and_terminate():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -87,14 +87,14 @@ def test_instance_launch_and_terminate():
instance.state.should.equal('terminated')
@mock_ec2
@mock_ec2_deprecated
def test_terminate_empty_instances():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.terminate_instances.when.called_with([]).should.throw(EC2ResponseError)
@freeze_time("2014-01-01 05:00:00")
@mock_ec2
@mock_ec2_deprecated
def test_instance_attach_volume():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -123,7 +123,7 @@ def test_instance_attach_volume():
v.status.should.equal('in-use')
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_by_id():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=2)
@ -150,7 +150,7 @@ def test_get_instances_by_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_state():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -178,7 +178,7 @@ def test_get_instances_filtering_by_state():
conn.get_all_instances.when.called_with(filters={'not-implemented-filter': 'foobar'}).should.throw(NotImplementedError)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_instance_id():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -197,7 +197,7 @@ def test_get_instances_filtering_by_instance_id():
reservations.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_instance_type():
conn = boto.connect_ec2()
reservation1 = conn.run_instances('ami-1234abcd', instance_type='m1.small')
@ -238,7 +238,7 @@ def test_get_instances_filtering_by_instance_type():
#bogus instance-type should return none
reservations.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_reason_code():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -257,7 +257,7 @@ def test_get_instances_filtering_by_reason_code():
reservations[0].instances[0].id.should.equal(instance3.id)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_source_dest_check():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=2)
@ -274,7 +274,7 @@ def test_get_instances_filtering_by_source_dest_check():
source_dest_check_true[0].instances[0].id.should.equal(instance2.id)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_vpc_id():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -298,7 +298,7 @@ def test_get_instances_filtering_by_vpc_id():
reservations2[0].instances[0].id.should.equal(instance2.id)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_architecture():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=1)
@ -309,7 +309,7 @@ def test_get_instances_filtering_by_architecture():
reservations[0].instances.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_tag():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -351,7 +351,7 @@ def test_get_instances_filtering_by_tag():
reservations[0].instances[1].id.should.equal(instance3.id)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_tag_value():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -388,7 +388,7 @@ def test_get_instances_filtering_by_tag_value():
reservations[0].instances[0].id.should.equal(instance1.id)
reservations[0].instances[1].id.should.equal(instance3.id)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_tag_name():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -418,7 +418,7 @@ def test_get_instances_filtering_by_tag_name():
reservations[0].instances[1].id.should.equal(instance2.id)
reservations[0].instances[2].id.should.equal(instance3.id)
@mock_ec2
@mock_ec2_deprecated
def test_instance_start_and_stop():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', min_count=2)
@ -448,7 +448,7 @@ def test_instance_start_and_stop():
started_instances[0].state.should.equal('pending')
@mock_ec2
@mock_ec2_deprecated
def test_instance_reboot():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -464,7 +464,7 @@ def test_instance_reboot():
instance.state.should.equal('pending')
@mock_ec2
@mock_ec2_deprecated
def test_instance_attribute_instance_type():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -482,7 +482,7 @@ def test_instance_attribute_instance_type():
instance_attribute.should.be.a(InstanceAttribute)
instance_attribute.get('instanceType').should.equal("m1.small")
@mock_ec2
@mock_ec2_deprecated
def test_modify_instance_attribute_security_groups():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -506,7 +506,7 @@ def test_modify_instance_attribute_security_groups():
any(g.id == sg_id2 for g in group_list).should.be.ok
@mock_ec2
@mock_ec2_deprecated
def test_instance_attribute_user_data():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -525,7 +525,7 @@ def test_instance_attribute_user_data():
instance_attribute.get("userData").should.equal("this is my user data")
@mock_ec2
@mock_ec2_deprecated
def test_instance_attribute_source_dest_check():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -566,7 +566,7 @@ def test_instance_attribute_source_dest_check():
instance_attribute.get("sourceDestCheck").should.equal(True)
@mock_ec2
@mock_ec2_deprecated
def test_user_data_with_run_instance():
user_data = b"some user data"
conn = boto.connect_ec2('the_key', 'the_secret')
@ -580,7 +580,7 @@ def test_user_data_with_run_instance():
decoded_user_data.should.equal(b"some user data")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_security_group_name():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -600,7 +600,7 @@ def test_run_instance_with_security_group_name():
instance.groups[0].name.should.equal("group1")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_security_group_id():
conn = boto.connect_ec2('the_key', 'the_secret')
group = conn.create_security_group('group1', "some description")
@ -612,7 +612,7 @@ def test_run_instance_with_security_group_id():
instance.groups[0].name.should.equal("group1")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_instance_type():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', instance_type="t1.micro")
@ -621,7 +621,7 @@ def test_run_instance_with_instance_type():
instance.instance_type.should.equal("t1.micro")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_default_placement():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -630,7 +630,7 @@ def test_run_instance_with_default_placement():
instance.placement.should.equal("us-east-1a")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_placement():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', placement="us-east-1b")
@ -639,7 +639,7 @@ def test_run_instance_with_placement():
instance.placement.should.equal("us-east-1b")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_subnet():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -653,7 +653,7 @@ def test_run_instance_with_subnet():
all_enis.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_nic_autocreated():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -686,7 +686,7 @@ def test_run_instance_with_nic_autocreated():
eni.private_ip_addresses[0].private_ip_address.should.equal(private_ip)
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_nic_preexisting():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -724,7 +724,7 @@ def test_run_instance_with_nic_preexisting():
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_instance_with_nic_attach_detach():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -790,7 +790,7 @@ def test_instance_with_nic_attach_detach():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_ec2_classic_has_public_ip_address():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', key_name="keypair_name")
@ -802,7 +802,7 @@ def test_ec2_classic_has_public_ip_address():
instance.private_dns_name.should.contain(instance.private_ip_address)
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_keypair():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', key_name="keypair_name")
@ -811,14 +811,14 @@ def test_run_instance_with_keypair():
instance.key_name.should.equal("keypair_name")
@mock_ec2
@mock_ec2_deprecated
def test_describe_instance_status_no_instances():
conn = boto.connect_ec2('the_key', 'the_secret')
all_status = conn.get_all_instance_status()
len(all_status).should.equal(0)
@mock_ec2
@mock_ec2_deprecated
def test_describe_instance_status_with_instances():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.run_instances('ami-1234abcd', key_name="keypair_name")
@ -829,7 +829,7 @@ def test_describe_instance_status_with_instances():
all_status[0].system_status.status.should.equal('ok')
@mock_ec2
@mock_ec2_deprecated
def test_describe_instance_status_with_instance_filter():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -852,7 +852,7 @@ def test_describe_instance_status_with_instance_filter():
cm.exception.request_id.should_not.be.none
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_describe_instance_status_with_non_running_instances():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -877,7 +877,7 @@ def test_describe_instance_status_with_non_running_instances():
status3 = next((s for s in all_status if s.id == instance3.id), None)
status3.state_name.should.equal('running')
@mock_ec2
@mock_ec2_deprecated
def test_get_instance_by_security_group():
conn = boto.connect_ec2('the_key', 'the_secret')

View File

@ -10,14 +10,14 @@ from boto.exception import EC2ResponseError, JSONResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
VPC_CIDR="10.0.0.0/16"
BAD_VPC="vpc-deadbeef"
BAD_IGW="igw-deadbeef"
@mock_ec2
@mock_ec2_deprecated
def test_igw_create():
""" internet gateway create """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -37,7 +37,7 @@ def test_igw_create():
igw = conn.get_all_internet_gateways()[0]
igw.attachments.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_igw_attach():
""" internet gateway attach """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -55,7 +55,7 @@ def test_igw_attach():
igw = conn.get_all_internet_gateways()[0]
igw.attachments[0].vpc_id.should.be.equal(vpc.id)
@mock_ec2
@mock_ec2_deprecated
def test_igw_attach_bad_vpc():
""" internet gateway fail to attach w/ bad vpc """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -67,7 +67,7 @@ def test_igw_attach_bad_vpc():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_attach_twice():
""" internet gateway fail to attach twice """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -82,7 +82,7 @@ def test_igw_attach_twice():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_detach():
""" internet gateway detach"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -100,7 +100,7 @@ def test_igw_detach():
igw = conn.get_all_internet_gateways()[0]
igw.attachments.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_igw_detach_wrong_vpc():
""" internet gateway fail to detach w/ wrong vpc """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -115,7 +115,7 @@ def test_igw_detach_wrong_vpc():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_detach_invalid_vpc():
""" internet gateway fail to detach w/ invalid vpc """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -129,7 +129,7 @@ def test_igw_detach_invalid_vpc():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_detach_unattached():
""" internet gateway fail to detach unattached """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -142,7 +142,7 @@ def test_igw_detach_unattached():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_delete():
""" internet gateway delete"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -160,7 +160,7 @@ def test_igw_delete():
conn.delete_internet_gateway(igw.id)
conn.get_all_internet_gateways().should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_igw_delete_attached():
""" internet gateway fail to delete attached """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -174,7 +174,7 @@ def test_igw_delete_attached():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_desribe():
""" internet gateway fetch by id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -182,7 +182,7 @@ def test_igw_desribe():
igw_by_search = conn.get_all_internet_gateways([igw.id])[0]
igw.id.should.equal(igw_by_search.id)
@mock_ec2
@mock_ec2_deprecated
def test_igw_desribe_bad_id():
""" internet gateway fail to fetch by bad id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -193,7 +193,7 @@ def test_igw_desribe_bad_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_filter_by_vpc_id():
""" internet gateway filter by vpc id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -208,7 +208,7 @@ def test_igw_filter_by_vpc_id():
result[0].id.should.equal(igw1.id)
@mock_ec2
@mock_ec2_deprecated
def test_igw_filter_by_tags():
""" internet gateway filter by vpc id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -222,7 +222,7 @@ def test_igw_filter_by_tags():
result[0].id.should.equal(igw1.id)
@mock_ec2
@mock_ec2_deprecated
def test_igw_filter_by_internet_gateway_id():
""" internet gateway filter by internet gateway id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -235,7 +235,7 @@ def test_igw_filter_by_internet_gateway_id():
result[0].id.should.equal(igw1.id)
@mock_ec2
@mock_ec2_deprecated
def test_igw_filter_by_attachment_state():
""" internet gateway filter by attachment state """
conn = boto.connect_vpc('the_key', 'the_secret')

View File

@ -8,16 +8,16 @@ import six
import sure # noqa
from boto.exception import EC2ResponseError, JSONResponseError
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_empty():
conn = boto.connect_ec2('the_key', 'the_secret')
assert len(conn.get_all_key_pairs()) == 0
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_invalid_id():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -28,7 +28,7 @@ def test_key_pairs_invalid_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_create():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -45,7 +45,7 @@ def test_key_pairs_create():
assert kps[0].name == 'foo'
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_create_two():
conn = boto.connect_ec2('the_key', 'the_secret')
kp = conn.create_key_pair('foo')
@ -60,7 +60,7 @@ def test_key_pairs_create_two():
kps[0].name.should.equal('foo')
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_create_exist():
conn = boto.connect_ec2('the_key', 'the_secret')
kp = conn.create_key_pair('foo')
@ -74,7 +74,7 @@ def test_key_pairs_create_exist():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_delete_no_exist():
conn = boto.connect_ec2('the_key', 'the_secret')
assert len(conn.get_all_key_pairs()) == 0
@ -82,7 +82,7 @@ def test_key_pairs_delete_no_exist():
r.should.be.ok
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_delete_exist():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.create_key_pair('foo')
@ -98,7 +98,7 @@ def test_key_pairs_delete_exist():
assert len(conn.get_all_key_pairs()) == 0
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_import():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -115,7 +115,7 @@ def test_key_pairs_import():
assert kps[0].name == 'foo'
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_import_exist():
conn = boto.connect_ec2('the_key', 'the_secret')
kp = conn.import_key_pair('foo', b'content')

View File

@ -2,10 +2,10 @@ from __future__ import unicode_literals
import boto
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_default_network_acl_created_with_vpc():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -13,7 +13,7 @@ def test_default_network_acl_created_with_vpc():
all_network_acls.should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_network_acls():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -22,7 +22,7 @@ def test_network_acls():
all_network_acls.should.have.length_of(3)
@mock_ec2
@mock_ec2_deprecated
def test_new_subnet_associates_with_default_network_acl():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.get_all_vpcs()[0]
@ -36,7 +36,7 @@ def test_new_subnet_associates_with_default_network_acl():
[a.subnet_id for a in acl.associations].should.contain(subnet.id)
@mock_ec2
@mock_ec2_deprecated
def test_network_acl_entries():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -62,7 +62,7 @@ def test_network_acl_entries():
entries[0].rule_action.should.equal('ALLOW')
@mock_ec2
@mock_ec2_deprecated
def test_associate_new_network_acl_with_subnet():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -81,7 +81,7 @@ def test_associate_new_network_acl_with_subnet():
test_network_acl.associations[0].subnet_id.should.equal(subnet.id)
@mock_ec2
@mock_ec2_deprecated
def test_delete_network_acl():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -101,7 +101,7 @@ def test_delete_network_acl():
any(acl.id == network_acl.id for acl in updated_network_acls).shouldnt.be.ok
@mock_ec2
@mock_ec2_deprecated
def test_network_acl_tagging():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")

View File

@ -3,7 +3,7 @@ import boto.ec2
import boto.ec2.autoscale
import boto.ec2.elb
import sure
from moto import mock_ec2, mock_autoscaling, mock_elb
from moto import mock_ec2_deprecated, mock_autoscaling_deprecated, mock_elb_deprecated
def add_servers_to_region(ami_id, count, region):
@ -12,7 +12,7 @@ def add_servers_to_region(ami_id, count, region):
conn.run_instances(ami_id)
@mock_ec2
@mock_ec2_deprecated
def test_add_servers_to_a_single_region():
region = 'ap-northeast-1'
add_servers_to_region('ami-1234abcd', 1, region)
@ -27,7 +27,7 @@ def test_add_servers_to_a_single_region():
reservations[1].instances[0].image_id.should.equal('ami-5678efgh')
@mock_ec2
@mock_ec2_deprecated
def test_add_servers_to_multiple_regions():
region1 = 'us-east-1'
region2 = 'ap-northeast-1'
@ -46,8 +46,8 @@ def test_add_servers_to_multiple_regions():
ap_reservations[0].instances[0].image_id.should.equal('ami-5678efgh')
@mock_autoscaling
@mock_elb
@mock_autoscaling_deprecated
@mock_elb_deprecated
def test_create_autoscaling_group():
elb_conn = boto.ec2.elb.connect_to_region('us-east-1')
elb_conn.create_load_balancer('us_test_lb', zones=[], listeners=[(80, 8080, 'http')])

View File

@ -8,11 +8,11 @@ import boto3
from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
from tests.helpers import requires_boto_gte
@mock_ec2
@mock_ec2_deprecated
def test_route_tables_defaults():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -37,7 +37,7 @@ def test_route_tables_defaults():
all_route_tables.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_route_tables_additional():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -77,7 +77,7 @@ def test_route_tables_additional():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_route_tables_filters_standard():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -115,7 +115,7 @@ def test_route_tables_filters_standard():
conn.get_all_route_tables.when.called_with(filters={'not-implemented-filter': 'foobar'}).should.throw(NotImplementedError)
@mock_ec2
@mock_ec2_deprecated
def test_route_tables_filters_associations():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -152,7 +152,7 @@ def test_route_tables_filters_associations():
association1_route_tables[0].associations.should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_route_table_associations():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -219,7 +219,7 @@ def test_route_table_associations():
@requires_boto_gte("2.16.0")
@mock_ec2
@mock_ec2_deprecated
def test_route_table_replace_route_table_association():
"""
Note: Boto has deprecated replace_route_table_assocation (which returns status)
@ -289,7 +289,7 @@ def test_route_table_replace_route_table_association():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_route_table_get_by_tag():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -326,7 +326,7 @@ def test_route_table_get_by_tag_boto3():
route_tables[0].tags[0].should.equal({'Key': 'Name', 'Value': 'TestRouteTable'})
@mock_ec2
@mock_ec2_deprecated
def test_routes_additional():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -364,7 +364,7 @@ def test_routes_additional():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_routes_replace():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -412,7 +412,7 @@ def test_routes_replace():
@requires_boto_gte("2.19.0")
@mock_ec2
@mock_ec2_deprecated
def test_routes_not_supported():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -431,7 +431,7 @@ def test_routes_not_supported():
@requires_boto_gte("2.34.0")
@mock_ec2
@mock_ec2_deprecated
def test_routes_vpc_peering_connection():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -458,7 +458,7 @@ def test_routes_vpc_peering_connection():
@requires_boto_gte("2.34.0")
@mock_ec2
@mock_ec2_deprecated
def test_routes_vpn_gateway():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -480,7 +480,7 @@ def test_routes_vpn_gateway():
new_route.vpc_peering_connection_id.should.be.none
@mock_ec2
@mock_ec2_deprecated
def test_network_acl_tagging():
conn = boto.connect_vpc('the_key', 'the secret')

View File

@ -12,10 +12,10 @@ from botocore.exceptions import ClientError
from boto.exception import EC2ResponseError, JSONResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_create_and_describe_security_group():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -43,7 +43,7 @@ def test_create_and_describe_security_group():
set(group_names).should.equal(set(["default", "test security group"]))
@mock_ec2
@mock_ec2_deprecated
def test_create_security_group_without_description_raises_error():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -54,7 +54,7 @@ def test_create_security_group_without_description_raises_error():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_default_security_group():
conn = boto.ec2.connect_to_region('us-east-1')
groups = conn.get_all_security_groups()
@ -62,7 +62,7 @@ def test_default_security_group():
groups[0].name.should.equal("default")
@mock_ec2
@mock_ec2_deprecated
def test_create_and_describe_vpc_security_group():
conn = boto.connect_ec2('the_key', 'the_secret')
vpc_id = 'vpc-5300000c'
@ -88,7 +88,7 @@ def test_create_and_describe_vpc_security_group():
all_groups[0].name.should.equal('test security group')
@mock_ec2
@mock_ec2_deprecated
def test_create_two_security_groups_with_same_name_in_different_vpc():
conn = boto.connect_ec2('the_key', 'the_secret')
vpc_id = 'vpc-5300000c'
@ -105,7 +105,7 @@ def test_create_two_security_groups_with_same_name_in_different_vpc():
set(group_names).should.equal(set(["default", "test security group"]))
@mock_ec2
@mock_ec2_deprecated
def test_deleting_security_groups():
conn = boto.connect_ec2('the_key', 'the_secret')
security_group1 = conn.create_security_group('test1', 'test1')
@ -135,7 +135,7 @@ def test_deleting_security_groups():
conn.get_all_security_groups().should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_delete_security_group_in_vpc():
conn = boto.connect_ec2('the_key', 'the_secret')
vpc_id = "vpc-12345"
@ -145,7 +145,7 @@ def test_delete_security_group_in_vpc():
conn.delete_security_group(group_id=security_group1.id)
@mock_ec2
@mock_ec2_deprecated
def test_authorize_ip_range_and_revoke():
conn = boto.connect_ec2('the_key', 'the_secret')
security_group = conn.create_security_group('test', 'test')
@ -216,7 +216,7 @@ def test_authorize_ip_range_and_revoke():
egress_security_group.rules_egress.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_authorize_other_group_and_revoke():
conn = boto.connect_ec2('the_key', 'the_secret')
security_group = conn.create_security_group('test', 'test')
@ -269,7 +269,7 @@ def test_authorize_other_group_egress_and_revoke():
sg01.ip_permissions_egress.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_authorize_group_in_vpc():
conn = boto.connect_ec2('the_key', 'the_secret')
vpc_id = "vpc-12345"
@ -295,7 +295,7 @@ def test_authorize_group_in_vpc():
security_group.rules.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_get_all_security_groups():
conn = boto.connect_ec2()
sg1 = conn.create_security_group(name='test1', description='test1', vpc_id='vpc-mjm05d27')
@ -321,7 +321,7 @@ def test_get_all_security_groups():
resp.should.have.length_of(4)
@mock_ec2
@mock_ec2_deprecated
def test_authorize_bad_cidr_throws_invalid_parameter_value():
conn = boto.connect_ec2('the_key', 'the_secret')
security_group = conn.create_security_group('test', 'test')
@ -332,7 +332,7 @@ def test_authorize_bad_cidr_throws_invalid_parameter_value():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_security_group_tagging():
conn = boto.connect_vpc()
vpc = conn.create_vpc("10.0.0.0/16")
@ -356,7 +356,7 @@ def test_security_group_tagging():
group.tags["Test"].should.equal("Tag")
@mock_ec2
@mock_ec2_deprecated
def test_security_group_tag_filtering():
conn = boto.connect_ec2()
sg = conn.create_security_group("test-sg", "Test SG")
@ -366,7 +366,7 @@ def test_security_group_tag_filtering():
groups.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_authorize_all_protocols_with_no_port_specification():
conn = boto.connect_ec2()
sg = conn.create_security_group('test', 'test')
@ -379,7 +379,7 @@ def test_authorize_all_protocols_with_no_port_specification():
sg.rules[0].to_port.should.equal(None)
@mock_ec2
@mock_ec2_deprecated
def test_sec_group_rule_limit():
ec2_conn = boto.connect_ec2()
sg = ec2_conn.create_security_group('test', 'test')
@ -441,7 +441,7 @@ def test_sec_group_rule_limit():
cm.exception.error_code.should.equal('RulesPerSecurityGroupLimitExceeded')
@mock_ec2
@mock_ec2_deprecated
def test_sec_group_rule_limit_vpc():
ec2_conn = boto.connect_ec2()
vpc_conn = boto.connect_vpc()
@ -611,7 +611,7 @@ def test_authorize_and_revoke_in_bulk():
for ip_permission in expected_ip_permissions:
sg01.ip_permissions_egress.shouldnt.contain(ip_permission)
@mock_ec2
@mock_ec2_deprecated
def test_get_all_security_groups_filter_with_same_vpc_id():
conn = boto.connect_ec2('the_key', 'the_secret')
vpc_id = 'vpc-5300000c'

View File

@ -7,12 +7,13 @@ import boto3
import sure # noqa
from boto.exception import JSONResponseError
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
from moto.backends import get_model
from moto.core.utils import iso_8601_datetime_with_milliseconds
@mock_ec2
@mock_ec2_deprecated
def test_request_spot_instances():
conn = boto3.client('ec2', 'us-east-1')
vpc = conn.create_vpc(CidrBlock="10.0.0.0/8")['Vpc']
@ -73,7 +74,7 @@ def test_request_spot_instances():
request.launch_specification.subnet_id.should.equal(subnet_id)
@mock_ec2
@mock_ec2_deprecated
def test_request_spot_instances_default_arguments():
"""
Test that moto set the correct default arguments
@ -106,7 +107,7 @@ def test_request_spot_instances_default_arguments():
request.launch_specification.subnet_id.should.equal(None)
@mock_ec2
@mock_ec2_deprecated
def test_cancel_spot_instance_request():
conn = boto.connect_ec2()
@ -130,7 +131,7 @@ def test_cancel_spot_instance_request():
requests.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_request_spot_instances_fulfilled():
"""
Test that moto correctly fullfills a spot instance request
@ -156,7 +157,7 @@ def test_request_spot_instances_fulfilled():
request.state.should.equal("active")
@mock_ec2
@mock_ec2_deprecated
def test_tag_spot_instance_request():
"""
Test that moto correctly tags a spot instance request
@ -177,7 +178,7 @@ def test_tag_spot_instance_request():
tag_dict.should.equal({'tag1': 'value1', 'tag2': 'value2'})
@mock_ec2
@mock_ec2_deprecated
def test_get_all_spot_instance_requests_filtering():
"""
Test that moto correctly filters spot instance requests
@ -211,7 +212,7 @@ def test_get_all_spot_instance_requests_filtering():
requests.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_request_spot_instances_setting_instance_id():
conn = boto.ec2.connect_to_region("us-east-1")
request = conn.request_spot_instances(

View File

@ -11,10 +11,10 @@ from botocore.exceptions import ParamValidationError
import json
import sure # noqa
from moto import mock_cloudformation, mock_ec2
from moto import mock_cloudformation_deprecated, mock_ec2, mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_subnets():
ec2 = boto.connect_ec2('the_key', 'the_secret')
conn = boto.connect_vpc('the_key', 'the_secret')
@ -36,7 +36,7 @@ def test_subnets():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_subnet_create_vpc_validation():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -47,7 +47,7 @@ def test_subnet_create_vpc_validation():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_subnet_tagging():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -65,7 +65,7 @@ def test_subnet_tagging():
subnet.tags["a key"].should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_subnet_should_have_proper_availability_zone_set():
conn = boto.vpc.connect_to_region('us-west-1')
vpcA = conn.create_vpc("10.0.0.0/16")
@ -87,7 +87,7 @@ def test_default_subnet():
subnet.map_public_ip_on_launch.shouldnt.be.ok
@mock_ec2
@mock_ec2_deprecated
def test_non_default_subnet():
vpc_cli = boto.vpc.connect_to_region('us-west-1')
@ -150,7 +150,7 @@ def test_modify_subnet_attribute_validation():
client.modify_subnet_attribute(SubnetId=subnet.id, MapPublicIpOnLaunch={'Value': 'invalid'})
@mock_ec2
@mock_ec2_deprecated
def test_get_subnets_filtering():
ec2 = boto.ec2.connect_to_region('us-west-1')
conn = boto.vpc.connect_to_region('us-west-1')
@ -205,8 +205,8 @@ def test_get_subnets_filtering():
conn.get_all_subnets.when.called_with(filters={'not-implemented-filter': 'foobar'}).should.throw(NotImplementedError)
@mock_ec2
@mock_cloudformation
@mock_ec2_deprecated
@mock_cloudformation_deprecated
def test_subnet_tags_through_cloudformation():
vpc_conn = boto.vpc.connect_to_region('us-west-1')
vpc = vpc_conn.create_vpc("10.0.0.0/16")

View File

@ -8,11 +8,11 @@ from boto.exception import EC2ResponseError, JSONResponseError
from boto.ec2.instance import Reservation
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
from nose.tools import assert_raises
@mock_ec2
@mock_ec2_deprecated
def test_add_tag():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -32,7 +32,7 @@ def test_add_tag():
existing_instance.tags["a key"].should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_remove_tag():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -59,7 +59,7 @@ def test_remove_tag():
instance.remove_tag("a key", "some value")
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -73,7 +73,7 @@ def test_get_all_tags():
tag.value.should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags_with_special_characters():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -87,7 +87,7 @@ def test_get_all_tags_with_special_characters():
tag.value.should.equal("some<> value")
@mock_ec2
@mock_ec2_deprecated
def test_create_tags():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -108,7 +108,7 @@ def test_create_tags():
set([tag_dict[key] for key in tag_dict]).should.equal(set([tag.value for tag in tags]))
@mock_ec2
@mock_ec2_deprecated
def test_tag_limit_exceeded():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -137,7 +137,7 @@ def test_tag_limit_exceeded():
tag.value.should.equal("a value")
@mock_ec2
@mock_ec2_deprecated
def test_invalid_parameter_tag_null():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -150,7 +150,7 @@ def test_invalid_parameter_tag_null():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_invalid_id():
conn = boto.connect_ec2('the_key', 'the_secret')
with assert_raises(EC2ResponseError) as cm:
@ -166,7 +166,7 @@ def test_invalid_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags_resource_id_filter():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -193,7 +193,7 @@ def test_get_all_tags_resource_id_filter():
tag.value.should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags_resource_type_filter():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -220,7 +220,7 @@ def test_get_all_tags_resource_type_filter():
tag.value.should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags_key_filter():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -239,7 +239,7 @@ def test_get_all_tags_key_filter():
tag.value.should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags_value_filter():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -283,7 +283,7 @@ def test_get_all_tags_value_filter():
tags.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_retrieved_instances_must_contain_their_tags():
tag_key = 'Tag name'
tag_value = 'Tag value'
@ -314,7 +314,7 @@ def test_retrieved_instances_must_contain_their_tags():
retrieved_tags[tag_key].should.equal(tag_value)
@mock_ec2
@mock_ec2_deprecated
def test_retrieved_volumes_must_contain_their_tags():
tag_key = 'Tag name'
tag_value = 'Tag value'
@ -337,7 +337,7 @@ def test_retrieved_volumes_must_contain_their_tags():
retrieved_tags[tag_key].should.equal(tag_value)
@mock_ec2
@mock_ec2_deprecated
def test_retrieved_snapshots_must_contain_their_tags():
tag_key = 'Tag name'
tag_value = 'Tag value'
@ -359,7 +359,7 @@ def test_retrieved_snapshots_must_contain_their_tags():
retrieved_tags[tag_key].should.equal(tag_value)
@mock_ec2
@mock_ec2_deprecated
def test_filter_instances_by_wildcard_tags():
conn = boto.connect_ec2(aws_access_key_id='the_key', aws_secret_access_key='the_secret')
reservation = conn.run_instances('ami-1234abcd')

View File

@ -2,10 +2,10 @@ from __future__ import unicode_literals
import boto
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_virtual_private_gateways():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -16,7 +16,7 @@ def test_virtual_private_gateways():
vpn_gateway.state.should.equal('available')
vpn_gateway.availability_zone.should.equal('us-east-1a')
@mock_ec2
@mock_ec2_deprecated
def test_describe_vpn_gateway():
conn = boto.connect_vpc('the_key', 'the_secret')
vpn_gateway = conn.create_vpn_gateway('ipsec.1', 'us-east-1a')
@ -32,7 +32,7 @@ def test_describe_vpn_gateway():
vpn_gateway.availability_zone.should.equal('us-east-1a')
@mock_ec2
@mock_ec2_deprecated
def test_vpn_gateway_vpc_attachment():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -50,7 +50,7 @@ def test_vpn_gateway_vpc_attachment():
attachments[0].state.should.equal('attached')
@mock_ec2
@mock_ec2_deprecated
def test_delete_vpn_gateway():
conn = boto.connect_vpc('the_key', 'the_secret')
vpn_gateway = conn.create_vpn_gateway('ipsec.1', 'us-east-1a')
@ -60,7 +60,7 @@ def test_delete_vpn_gateway():
vgws.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_vpn_gateway_tagging():
conn = boto.connect_vpc('the_key', 'the_secret')
vpn_gateway = conn.create_vpn_gateway('ipsec.1', 'us-east-1a')
@ -76,7 +76,7 @@ def test_vpn_gateway_tagging():
vpn_gateway.tags["a key"].should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_detach_vpn_gateway():
conn = boto.connect_vpc('the_key', 'the_secret')

View File

@ -7,12 +7,12 @@ import boto
from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
from tests.helpers import requires_boto_gte
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_peering_connections():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -25,7 +25,7 @@ def test_vpc_peering_connections():
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_peering_connections_get_all():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc_pcx = test_vpc_peering_connections()
@ -37,7 +37,7 @@ def test_vpc_peering_connections_get_all():
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_peering_connections_accept():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc_pcx = test_vpc_peering_connections()
@ -57,7 +57,7 @@ def test_vpc_peering_connections_accept():
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_peering_connections_reject():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc_pcx = test_vpc_peering_connections()
@ -77,7 +77,7 @@ def test_vpc_peering_connections_reject():
@requires_boto_gte("2.32.1")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_peering_connections_delete():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc_pcx = test_vpc_peering_connections()

View File

@ -8,13 +8,13 @@ import boto
from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
SAMPLE_DOMAIN_NAME = u'example.com'
SAMPLE_NAME_SERVERS = [u'10.0.0.6', u'10.0.0.7']
@mock_ec2
@mock_ec2_deprecated
def test_vpcs():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -35,7 +35,7 @@ def test_vpcs():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_vpc_defaults():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -50,7 +50,7 @@ def test_vpc_defaults():
conn.get_all_route_tables().should.have.length_of(1)
conn.get_all_security_groups(filters={'vpc-id': [vpc.id]}).should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_isdefault_filter():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -59,7 +59,7 @@ def test_vpc_isdefault_filter():
conn.get_all_vpcs(filters={'isDefault': 'true'}).should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_multiple_vpcs_default_filter():
conn = boto.connect_vpc('the_key', 'the_secret')
conn.create_vpc("10.8.0.0/16")
@ -71,7 +71,7 @@ def test_multiple_vpcs_default_filter():
vpc[0].cidr_block.should.equal('172.31.0.0/16')
@mock_ec2
@mock_ec2_deprecated
def test_vpc_state_available_filter():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -80,7 +80,7 @@ def test_vpc_state_available_filter():
vpc.delete()
conn.get_all_vpcs(filters={'state': 'available'}).should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_tagging():
conn = boto.connect_vpc()
vpc = conn.create_vpc("10.0.0.0/16")
@ -96,7 +96,7 @@ def test_vpc_tagging():
vpc.tags["a key"].should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_id():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -110,7 +110,7 @@ def test_vpc_get_by_id():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_cidr_block():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -124,7 +124,7 @@ def test_vpc_get_by_cidr_block():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_dhcp_options_id():
conn = boto.connect_vpc()
dhcp_options = conn.create_dhcp_options(SAMPLE_DOMAIN_NAME, SAMPLE_NAME_SERVERS)
@ -142,7 +142,7 @@ def test_vpc_get_by_dhcp_options_id():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_tag():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -160,7 +160,7 @@ def test_vpc_get_by_tag():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_tag_key_superset():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -180,7 +180,7 @@ def test_vpc_get_by_tag_key_superset():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_tag_key_subset():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -200,7 +200,7 @@ def test_vpc_get_by_tag_key_subset():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_tag_value_superset():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -220,7 +220,7 @@ def test_vpc_get_by_tag_value_superset():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_tag_value_subset():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -339,7 +339,7 @@ def test_vpc_modify_enable_dns_hostnames():
attr = response.get('EnableDnsHostnames')
attr.get('Value').should.be.ok
@mock_ec2
@mock_ec2_deprecated
def test_vpc_associate_dhcp_options():
conn = boto.connect_vpc()
dhcp_options = conn.create_dhcp_options(SAMPLE_DOMAIN_NAME, SAMPLE_NAME_SERVERS)

View File

@ -4,10 +4,10 @@ from nose.tools import assert_raises
import sure # noqa
from boto.exception import EC2ResponseError
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_create_vpn_connections():
conn = boto.connect_vpc('the_key', 'the_secret')
vpn_connection = conn.create_vpn_connection('ipsec.1', 'vgw-0123abcd', 'cgw-0123abcd')
@ -15,7 +15,7 @@ def test_create_vpn_connections():
vpn_connection.id.should.match(r'vpn-\w+')
vpn_connection.type.should.equal('ipsec.1')
@mock_ec2
@mock_ec2_deprecated
def test_delete_vpn_connections():
conn = boto.connect_vpc('the_key', 'the_secret')
vpn_connection = conn.create_vpn_connection('ipsec.1', 'vgw-0123abcd', 'cgw-0123abcd')
@ -25,13 +25,13 @@ def test_delete_vpn_connections():
list_of_vpn_connections = conn.get_all_vpn_connections()
list_of_vpn_connections.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_delete_vpn_connections_bad_id():
conn = boto.connect_vpc('the_key', 'the_secret')
with assert_raises(EC2ResponseError):
conn.delete_vpn_connection('vpn-0123abcd')
@mock_ec2
@mock_ec2_deprecated
def test_describe_vpn_connections():
conn = boto.connect_vpc('the_key', 'the_secret')
list_of_vpn_connections = conn.get_all_vpn_connections()

View File

@ -18,9 +18,9 @@ from boto.ec2.elb.policies import (
from boto.exception import BotoServerError
import sure # noqa
from moto import mock_elb, mock_ec2
from moto import mock_elb, mock_ec2, mock_elb_deprecated, mock_ec2_deprecated
@mock_elb
@mock_elb_deprecated
def test_create_load_balancer():
conn = boto.connect_elb()
@ -43,13 +43,13 @@ def test_create_load_balancer():
listener2.protocol.should.equal("TCP")
@mock_elb
@mock_elb_deprecated
def test_getting_missing_elb():
conn = boto.connect_elb()
conn.get_all_load_balancers.when.called_with(load_balancer_names='aaa').should.throw(BotoServerError)
@mock_elb
@mock_elb_deprecated
def test_create_elb_in_multiple_region():
zones = ['us-east-1a', 'us-east-1b']
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -63,7 +63,7 @@ def test_create_elb_in_multiple_region():
list(west1_conn.get_all_load_balancers()).should.have.length_of(1)
list(west2_conn.get_all_load_balancers()).should.have.length_of(1)
@mock_elb
@mock_elb_deprecated
def test_create_load_balancer_with_certificate():
conn = boto.connect_elb()
@ -99,7 +99,7 @@ def test_create_and_delete_boto3_support():
)
list(client.describe_load_balancers()['LoadBalancerDescriptions']).should.have.length_of(0)
@mock_elb
@mock_elb_deprecated
def test_add_listener():
conn = boto.connect_elb()
zones = ['us-east-1a', 'us-east-1b']
@ -119,7 +119,7 @@ def test_add_listener():
listener2.protocol.should.equal("TCP")
@mock_elb
@mock_elb_deprecated
def test_delete_listener():
conn = boto.connect_elb()
@ -161,7 +161,7 @@ def test_create_and_delete_listener_boto3_support():
balancer['ListenerDescriptions'][1]['Listener']['InstancePort'].should.equal(8443)
@mock_elb
@mock_elb_deprecated
def test_set_sslcertificate():
conn = boto.connect_elb()
@ -178,7 +178,7 @@ def test_set_sslcertificate():
listener1.ssl_certificate_id.should.equal("arn:certificate")
@mock_elb
@mock_elb_deprecated
def test_get_load_balancers_by_name():
conn = boto.connect_elb()
@ -193,7 +193,7 @@ def test_get_load_balancers_by_name():
conn.get_all_load_balancers(load_balancer_names=['my-lb1', 'my-lb2']).should.have.length_of(2)
@mock_elb
@mock_elb_deprecated
def test_delete_load_balancer():
conn = boto.connect_elb()
@ -209,7 +209,7 @@ def test_delete_load_balancer():
balancers.should.have.length_of(0)
@mock_elb
@mock_elb_deprecated
def test_create_health_check():
conn = boto.connect_elb()
@ -262,8 +262,8 @@ def test_create_health_check_boto3():
balancer['HealthCheck']['UnhealthyThreshold'].should.equal(5)
@mock_ec2
@mock_elb
@mock_ec2_deprecated
@mock_elb_deprecated
def test_register_instances():
ec2_conn = boto.connect_ec2()
reservation = ec2_conn.run_instances('ami-1234abcd', 2)
@ -307,8 +307,8 @@ def test_register_instances_boto3():
set(instance_ids).should.equal(set([instance_id1, instance_id2]))
@mock_ec2
@mock_elb
@mock_ec2_deprecated
@mock_elb_deprecated
def test_deregister_instances():
ec2_conn = boto.connect_ec2()
reservation = ec2_conn.run_instances('ami-1234abcd', 2)
@ -365,7 +365,7 @@ def test_deregister_instances_boto3():
balancer['Instances'][0]['InstanceId'].should.equal(instance_id2)
@mock_elb
@mock_elb_deprecated
def test_default_attributes():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -378,7 +378,7 @@ def test_default_attributes():
attributes.connecting_settings.idle_timeout.should.equal(60)
@mock_elb
@mock_elb_deprecated
def test_cross_zone_load_balancing_attribute():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -393,7 +393,7 @@ def test_cross_zone_load_balancing_attribute():
attributes.cross_zone_load_balancing.enabled.should.be.false
@mock_elb
@mock_elb_deprecated
def test_connection_draining_attribute():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -419,7 +419,7 @@ def test_connection_draining_attribute():
attributes.connection_draining.enabled.should.be.false
@mock_elb
@mock_elb_deprecated
def test_access_log_attribute():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -444,7 +444,7 @@ def test_access_log_attribute():
attributes.access_log.enabled.should.be.false
@mock_elb
@mock_elb_deprecated
def test_connection_settings_attribute():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -462,7 +462,7 @@ def test_connection_settings_attribute():
attributes = lb.get_attributes(force=True)
attributes.connecting_settings.idle_timeout.should.equal(60)
@mock_elb
@mock_elb_deprecated
def test_create_lb_cookie_stickiness_policy():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -482,7 +482,7 @@ def test_create_lb_cookie_stickiness_policy():
int(cookie_expiration_period_response_str).should.equal(cookie_expiration_period)
lb.policies.lb_cookie_stickiness_policies[0].policy_name.should.equal(policy_name)
@mock_elb
@mock_elb_deprecated
def test_create_lb_cookie_stickiness_policy_no_expiry():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -495,7 +495,7 @@ def test_create_lb_cookie_stickiness_policy_no_expiry():
lb.policies.lb_cookie_stickiness_policies[0].cookie_expiration_period.should.be.none
lb.policies.lb_cookie_stickiness_policies[0].policy_name.should.equal(policy_name)
@mock_elb
@mock_elb_deprecated
def test_create_app_cookie_stickiness_policy():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -509,7 +509,7 @@ def test_create_app_cookie_stickiness_policy():
lb.policies.app_cookie_stickiness_policies[0].cookie_name.should.equal(cookie_name)
lb.policies.app_cookie_stickiness_policies[0].policy_name.should.equal(policy_name)
@mock_elb
@mock_elb_deprecated
def test_create_lb_policy():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -521,7 +521,7 @@ def test_create_lb_policy():
lb = conn.get_all_load_balancers()[0]
lb.policies.other_policies[0].policy_name.should.equal(policy_name)
@mock_elb
@mock_elb_deprecated
def test_set_policies_of_listener():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -543,7 +543,7 @@ def test_set_policies_of_listener():
# by contrast to a backend, a listener stores only policy name strings
listener.policy_names[0].should.equal(policy_name)
@mock_elb
@mock_elb_deprecated
def test_set_policies_of_backend_server():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -562,8 +562,8 @@ def test_set_policies_of_backend_server():
# by contrast to a listener, a backend stores OtherPolicy objects
backend.policies[0].policy_name.should.equal(policy_name)
@mock_ec2
@mock_elb
@mock_ec2_deprecated
@mock_elb_deprecated
def test_describe_instance_health():
ec2_conn = boto.connect_ec2()
reservation = ec2_conn.run_instances('ami-1234abcd', 2)
@ -765,7 +765,7 @@ def test_subnets():
lb.should.have.key('VPCId').which.should.equal(vpc.id)
@mock_elb
@mock_elb_deprecated
def test_create_load_balancer_duplicate():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]

View File

@ -11,7 +11,7 @@ from boto.emr.step import StreamingStep
import six
import sure # noqa
from moto import mock_emr
from moto import mock_emr_deprecated
from tests.helpers import requires_boto_gte
@ -35,7 +35,7 @@ input_instance_groups = [
]
@mock_emr
@mock_emr_deprecated
def test_describe_cluster():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -106,7 +106,7 @@ def test_describe_cluster():
cluster.visibletoallusers.should.equal('true')
@mock_emr
@mock_emr_deprecated
def test_describe_jobflows():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -158,7 +158,7 @@ def test_describe_jobflows():
resp.should.have.length_of(200)
@mock_emr
@mock_emr_deprecated
def test_describe_jobflow():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -241,7 +241,7 @@ def test_describe_jobflow():
jf.visibletoallusers.should.equal('true')
@mock_emr
@mock_emr_deprecated
def test_list_clusters():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -309,7 +309,7 @@ def test_list_clusters():
resp.clusters.should.have.length_of(30)
@mock_emr
@mock_emr_deprecated
def test_run_jobflow():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -326,7 +326,7 @@ def test_run_jobflow():
job_flow.steps.should.have.length_of(0)
@mock_emr
@mock_emr_deprecated
def test_run_jobflow_in_multiple_regions():
regions = {}
for region in ['us-east-1', 'eu-west-1']:
@ -343,7 +343,7 @@ def test_run_jobflow_in_multiple_regions():
@requires_boto_gte("2.8")
@mock_emr
@mock_emr_deprecated
def test_run_jobflow_with_new_params():
# Test that run_jobflow works with newer params
conn = boto.connect_emr()
@ -351,7 +351,7 @@ def test_run_jobflow_with_new_params():
@requires_boto_gte("2.8")
@mock_emr
@mock_emr_deprecated
def test_run_jobflow_with_visible_to_all_users():
conn = boto.connect_emr()
for expected in (True, False):
@ -364,7 +364,7 @@ def test_run_jobflow_with_visible_to_all_users():
@requires_boto_gte("2.8")
@mock_emr
@mock_emr_deprecated
def test_run_jobflow_with_instance_groups():
input_groups = dict((g.name, g) for g in input_instance_groups)
conn = boto.connect_emr()
@ -384,7 +384,7 @@ def test_run_jobflow_with_instance_groups():
@requires_boto_gte("2.8")
@mock_emr
@mock_emr_deprecated
def test_set_termination_protection():
conn = boto.connect_emr()
job_id = conn.run_jobflow(**run_jobflow_args)
@ -401,7 +401,7 @@ def test_set_termination_protection():
@requires_boto_gte("2.8")
@mock_emr
@mock_emr_deprecated
def test_set_visible_to_all_users():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -419,7 +419,7 @@ def test_set_visible_to_all_users():
job_flow.visibletoallusers.should.equal('false')
@mock_emr
@mock_emr_deprecated
def test_terminate_jobflow():
conn = boto.connect_emr()
job_id = conn.run_jobflow(**run_jobflow_args)
@ -433,7 +433,7 @@ def test_terminate_jobflow():
# testing multiple end points for each feature
@mock_emr
@mock_emr_deprecated
def test_bootstrap_actions():
bootstrap_actions = [
BootstrapAction(
@ -466,7 +466,7 @@ def test_bootstrap_actions():
list(arg.value for arg in x.args).should.equal(y.args())
@mock_emr
@mock_emr_deprecated
def test_instance_groups():
input_groups = dict((g.name, g) for g in input_instance_groups)
@ -536,7 +536,7 @@ def test_instance_groups():
int(igs['task-2'].instancerunningcount).should.equal(3)
@mock_emr
@mock_emr_deprecated
def test_steps():
input_steps = [
StreamingStep(
@ -633,7 +633,7 @@ def test_steps():
test_list_steps_with_states()
@mock_emr
@mock_emr_deprecated
def test_tags():
input_tags = {"tag1": "val1", "tag2": "val2"}

View File

@ -4,10 +4,10 @@ from tempfile import NamedTemporaryFile
import boto.glacier
import sure # noqa
from moto import mock_glacier
from moto import mock_glacier_deprecated
@mock_glacier
@mock_glacier_deprecated
def test_create_and_delete_archive():
the_file = NamedTemporaryFile(delete=False)
the_file.write(b"some stuff")

View File

@ -5,10 +5,10 @@ import json
from boto.glacier.layer1 import Layer1
import sure # noqa
from moto import mock_glacier
from moto import mock_glacier_deprecated
@mock_glacier
@mock_glacier_deprecated
def test_init_glacier_job():
conn = Layer1(region_name="us-west-2")
vault_name = "my_vault"
@ -23,7 +23,7 @@ def test_init_glacier_job():
job_response['Location'].should.equal("//vaults/my_vault/jobs/{0}".format(job_id))
@mock_glacier
@mock_glacier_deprecated
def test_describe_job():
conn = Layer1(region_name="us-west-2")
vault_name = "my_vault"
@ -56,7 +56,7 @@ def test_describe_job():
})
@mock_glacier
@mock_glacier_deprecated
def test_list_glacier_jobs():
conn = Layer1(region_name="us-west-2")
vault_name = "my_vault"
@ -77,7 +77,7 @@ def test_list_glacier_jobs():
len(jobs['JobList']).should.equal(2)
@mock_glacier
@mock_glacier_deprecated
def test_get_job_output():
conn = Layer1(region_name="us-west-2")
vault_name = "my_vault"

View File

@ -3,10 +3,10 @@ from __future__ import unicode_literals
import boto.glacier
import sure # noqa
from moto import mock_glacier
from moto import mock_glacier_deprecated
@mock_glacier
@mock_glacier_deprecated
def test_create_vault():
conn = boto.glacier.connect_to_region("us-west-2")
@ -17,7 +17,7 @@ def test_create_vault():
vaults[0].name.should.equal("my_vault")
@mock_glacier
@mock_glacier_deprecated
def test_delete_vault():
conn = boto.glacier.connect_to_region("us-west-2")

View File

@ -6,7 +6,7 @@ import boto3
import sure # noqa
from boto.exception import BotoServerError
from botocore.exceptions import ClientError
from moto import mock_iam
from moto import mock_iam, mock_iam_deprecated
from moto.iam.models import aws_managed_policies
from nose.tools import assert_raises, assert_equals, assert_not_equals
from nose.tools import raises
@ -14,7 +14,7 @@ from nose.tools import raises
from tests.helpers import requires_boto_gte
@mock_iam()
@mock_iam_deprecated()
def test_get_all_server_certs():
conn = boto.connect_iam()
@ -26,7 +26,7 @@ def test_get_all_server_certs():
cert1.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
@mock_iam()
@mock_iam_deprecated()
def test_get_server_cert_doesnt_exist():
conn = boto.connect_iam()
@ -34,7 +34,7 @@ def test_get_server_cert_doesnt_exist():
conn.get_server_certificate("NonExistant")
@mock_iam()
@mock_iam_deprecated()
def test_get_server_cert():
conn = boto.connect_iam()
@ -44,7 +44,7 @@ def test_get_server_cert():
cert.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
@mock_iam()
@mock_iam_deprecated()
def test_upload_server_cert():
conn = boto.connect_iam()
@ -54,7 +54,7 @@ def test_upload_server_cert():
cert.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
@mock_iam()
@mock_iam_deprecated()
@raises(BotoServerError)
def test_get_role__should_throw__when_role_does_not_exist():
conn = boto.connect_iam()
@ -62,7 +62,7 @@ def test_get_role__should_throw__when_role_does_not_exist():
conn.get_role('unexisting_role')
@mock_iam()
@mock_iam_deprecated()
@raises(BotoServerError)
def test_get_instance_profile__should_throw__when_instance_profile_does_not_exist():
conn = boto.connect_iam()
@ -70,7 +70,7 @@ def test_get_instance_profile__should_throw__when_instance_profile_does_not_exis
conn.get_instance_profile('unexisting_instance_profile')
@mock_iam()
@mock_iam_deprecated()
def test_create_role_and_instance_profile():
conn = boto.connect_iam()
conn.create_instance_profile("my-profile", path="my-path")
@ -91,7 +91,7 @@ def test_create_role_and_instance_profile():
conn.list_roles().roles[0].role_name.should.equal('my-role')
@mock_iam()
@mock_iam_deprecated()
def test_remove_role_from_instance_profile():
conn = boto.connect_iam()
conn.create_instance_profile("my-profile", path="my-path")
@ -108,7 +108,7 @@ def test_remove_role_from_instance_profile():
dict(profile.roles).should.be.empty
@mock_iam()
@mock_iam_deprecated()
def test_list_instance_profiles():
conn = boto.connect_iam()
conn.create_instance_profile("my-profile", path="my-path")
@ -123,7 +123,7 @@ def test_list_instance_profiles():
profiles[0].roles.role_name.should.equal("my-role")
@mock_iam()
@mock_iam_deprecated()
def test_list_instance_profiles_for_role():
conn = boto.connect_iam()
@ -153,7 +153,7 @@ def test_list_instance_profiles_for_role():
len(profile_list).should.equal(0)
@mock_iam()
@mock_iam_deprecated()
def test_list_role_policies():
conn = boto.connect_iam()
conn.create_role("my-role")
@ -162,7 +162,7 @@ def test_list_role_policies():
role.policy_names[0].should.equal("test policy")
@mock_iam()
@mock_iam_deprecated()
def test_put_role_policy():
conn = boto.connect_iam()
conn.create_role("my-role", assume_role_policy_document="some policy", path="my-path")
@ -171,7 +171,7 @@ def test_put_role_policy():
policy.should.equal("test policy")
@mock_iam()
@mock_iam_deprecated()
def test_update_assume_role_policy():
conn = boto.connect_iam()
role = conn.create_role("my-role")
@ -180,7 +180,7 @@ def test_update_assume_role_policy():
role.assume_role_policy_document.should.equal("my-policy")
@mock_iam()
@mock_iam_deprecated()
def test_create_user():
conn = boto.connect_iam()
conn.create_user('my-user')
@ -188,7 +188,7 @@ def test_create_user():
conn.create_user('my-user')
@mock_iam()
@mock_iam_deprecated()
def test_get_user():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -210,7 +210,7 @@ def test_list_users():
user['Arn'].should.equal('arn:aws:iam::123456789012:user/my-user')
@mock_iam()
@mock_iam_deprecated()
def test_create_login_profile():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -221,7 +221,7 @@ def test_create_login_profile():
conn.create_login_profile('my-user', 'my-pass')
@mock_iam()
@mock_iam_deprecated()
def test_delete_login_profile():
conn = boto.connect_iam()
conn.create_user('my-user')
@ -231,7 +231,7 @@ def test_delete_login_profile():
conn.delete_login_profile('my-user')
@mock_iam()
@mock_iam_deprecated()
def test_create_access_key():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -240,7 +240,7 @@ def test_create_access_key():
conn.create_access_key('my-user')
@mock_iam()
@mock_iam_deprecated()
def test_get_all_access_keys():
conn = boto.connect_iam()
conn.create_user('my-user')
@ -257,7 +257,7 @@ def test_get_all_access_keys():
)
@mock_iam()
@mock_iam_deprecated()
def test_delete_access_key():
conn = boto.connect_iam()
conn.create_user('my-user')
@ -265,7 +265,7 @@ def test_delete_access_key():
conn.delete_access_key(access_key_id, 'my-user')
@mock_iam()
@mock_iam_deprecated()
def test_delete_user():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -274,7 +274,7 @@ def test_delete_user():
conn.delete_user('my-user')
@mock_iam()
@mock_iam_deprecated()
def test_generate_credential_report():
conn = boto.connect_iam()
result = conn.generate_credential_report()
@ -283,7 +283,7 @@ def test_generate_credential_report():
result['generate_credential_report_response']['generate_credential_report_result']['state'].should.equal('COMPLETE')
@mock_iam()
@mock_iam_deprecated()
def test_get_credential_report():
conn = boto.connect_iam()
conn.create_user('my-user')
@ -298,7 +298,7 @@ def test_get_credential_report():
@requires_boto_gte('2.39')
@mock_iam()
@mock_iam_deprecated()
def test_managed_policy():
conn = boto.connect_iam()

View File

@ -4,10 +4,10 @@ import sure # noqa
from nose.tools import assert_raises
from boto.exception import BotoServerError
from moto import mock_iam
from moto import mock_iam, mock_iam_deprecated
@mock_iam()
@mock_iam_deprecated()
def test_create_group():
conn = boto.connect_iam()
conn.create_group('my-group')
@ -15,7 +15,7 @@ def test_create_group():
conn.create_group('my-group')
@mock_iam()
@mock_iam_deprecated()
def test_get_group():
conn = boto.connect_iam()
conn.create_group('my-group')
@ -24,7 +24,7 @@ def test_get_group():
conn.get_group('not-group')
@mock_iam()
@mock_iam_deprecated()
def test_get_all_groups():
conn = boto.connect_iam()
conn.create_group('my-group1')
@ -33,7 +33,7 @@ def test_get_all_groups():
groups.should.have.length_of(2)
@mock_iam()
@mock_iam_deprecated()
def test_add_user_to_group():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -45,7 +45,7 @@ def test_add_user_to_group():
conn.add_user_to_group('my-group', 'my-user')
@mock_iam()
@mock_iam_deprecated()
def test_remove_user_from_group():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -58,7 +58,7 @@ def test_remove_user_from_group():
conn.remove_user_from_group('my-group', 'my-user')
@mock_iam()
@mock_iam_deprecated()
def test_get_groups_for_user():
conn = boto.connect_iam()
conn.create_group('my-group1')

View File

@ -4,10 +4,10 @@ import boto.kinesis
from boto.kinesis.exceptions import ResourceNotFoundException, InvalidArgumentException
import sure # noqa
from moto import mock_kinesis
from moto import mock_kinesis_deprecated
@mock_kinesis
@mock_kinesis_deprecated
def test_create_cluster():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -25,13 +25,13 @@ def test_create_cluster():
shards.should.have.length_of(2)
@mock_kinesis
@mock_kinesis_deprecated
def test_describe_non_existant_stream():
conn = boto.kinesis.connect_to_region("us-east-1")
conn.describe_stream.when.called_with("not-a-stream").should.throw(ResourceNotFoundException)
@mock_kinesis
@mock_kinesis_deprecated
def test_list_and_delete_stream():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -48,7 +48,7 @@ def test_list_and_delete_stream():
conn.delete_stream.when.called_with("not-a-stream").should.throw(ResourceNotFoundException)
@mock_kinesis
@mock_kinesis_deprecated
def test_basic_shard_iterator():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -66,7 +66,7 @@ def test_basic_shard_iterator():
response['Records'].should.equal([])
@mock_kinesis
@mock_kinesis_deprecated
def test_get_invalid_shard_iterator():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -76,7 +76,7 @@ def test_get_invalid_shard_iterator():
conn.get_shard_iterator.when.called_with(stream_name, "123", 'TRIM_HORIZON').should.throw(ResourceNotFoundException)
@mock_kinesis
@mock_kinesis_deprecated
def test_put_records():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -107,7 +107,7 @@ def test_put_records():
record["SequenceNumber"].should.equal("1")
@mock_kinesis
@mock_kinesis_deprecated
def test_get_records_limit():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -136,7 +136,7 @@ def test_get_records_limit():
response['Records'].should.have.length_of(2)
@mock_kinesis
@mock_kinesis_deprecated
def test_get_records_at_sequence_number():
# AT_SEQUENCE_NUMBER - Start reading exactly from the position denoted by a specific sequence number.
conn = boto.kinesis.connect_to_region("us-west-2")
@ -167,7 +167,7 @@ def test_get_records_at_sequence_number():
response['Records'][0]['Data'].should.equal('2')
@mock_kinesis
@mock_kinesis_deprecated
def test_get_records_after_sequence_number():
# AFTER_SEQUENCE_NUMBER - Start reading right after the position denoted by a specific sequence number.
conn = boto.kinesis.connect_to_region("us-west-2")
@ -197,7 +197,7 @@ def test_get_records_after_sequence_number():
response['Records'][0]['Data'].should.equal('3')
@mock_kinesis
@mock_kinesis_deprecated
def test_get_records_latest():
# LATEST - Start reading just after the most recent record in the shard, so that you always read the most recent data in the shard.
conn = boto.kinesis.connect_to_region("us-west-2")
@ -232,7 +232,7 @@ def test_get_records_latest():
response['Records'][0]['Data'].should.equal('last_record')
@mock_kinesis
@mock_kinesis_deprecated
def test_invalid_shard_iterator_type():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = "my_stream"
@ -244,7 +244,7 @@ def test_invalid_shard_iterator_type():
stream_name, shard_id, 'invalid-type').should.throw(InvalidArgumentException)
@mock_kinesis
@mock_kinesis_deprecated
def test_add_tags():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = "my_stream"
@ -257,7 +257,7 @@ def test_add_tags():
conn.add_tags_to_stream(stream_name, {'tag2':'val4'})
@mock_kinesis
@mock_kinesis_deprecated
def test_list_tags():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = "my_stream"
@ -278,7 +278,7 @@ def test_list_tags():
tags.get('tag2').should.equal('val4')
@mock_kinesis
@mock_kinesis_deprecated
def test_remove_tags():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = "my_stream"
@ -300,7 +300,7 @@ def test_remove_tags():
tags.get('tag2').should.equal(None)
@mock_kinesis
@mock_kinesis_deprecated
def test_split_shard():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = 'my_stream'
@ -341,7 +341,7 @@ def test_split_shard():
sum([shard['SequenceNumberRange']['EndingSequenceNumber'] for shard in shards]).should.equal(99)
@mock_kinesis
@mock_kinesis_deprecated
def test_merge_shards():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = 'my_stream'

View File

@ -5,10 +5,10 @@ import boto.kms
from boto.exception import JSONResponseError
from boto.kms.exceptions import AlreadyExistsException, NotFoundException
import sure # noqa
from moto import mock_kms
from moto import mock_kms_deprecated
from nose.tools import assert_raises
@mock_kms
@mock_kms_deprecated
def test_create_key():
conn = boto.kms.connect_to_region("us-west-2")
@ -19,7 +19,7 @@ def test_create_key():
key['KeyMetadata']['Enabled'].should.equal(True)
@mock_kms
@mock_kms_deprecated
def test_describe_key():
conn = boto.kms.connect_to_region("us-west-2")
key = conn.create_key(policy="my policy", description="my key", key_usage='ENCRYPT_DECRYPT')
@ -30,7 +30,7 @@ def test_describe_key():
key['KeyMetadata']['KeyUsage'].should.equal("ENCRYPT_DECRYPT")
@mock_kms
@mock_kms_deprecated
def test_describe_key_via_alias():
conn = boto.kms.connect_to_region("us-west-2")
key = conn.create_key(policy="my policy", description="my key", key_usage='ENCRYPT_DECRYPT')
@ -42,7 +42,7 @@ def test_describe_key_via_alias():
alias_key['KeyMetadata']['Arn'].should.equal(key['KeyMetadata']['Arn'])
@mock_kms
@mock_kms_deprecated
def test_describe_key_via_alias_not_found():
conn = boto.kms.connect_to_region("us-west-2")
key = conn.create_key(policy="my policy", description="my key", key_usage='ENCRYPT_DECRYPT')
@ -51,7 +51,7 @@ def test_describe_key_via_alias_not_found():
conn.describe_key.when.called_with('alias/not-found-alias').should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_describe_key_via_arn():
conn = boto.kms.connect_to_region("us-west-2")
key = conn.create_key(policy="my policy", description="my key", key_usage='ENCRYPT_DECRYPT')
@ -63,13 +63,13 @@ def test_describe_key_via_arn():
the_key['KeyMetadata']['KeyId'].should.equal(key['KeyMetadata']['KeyId'])
@mock_kms
@mock_kms_deprecated
def test_describe_missing_key():
conn = boto.kms.connect_to_region("us-west-2")
conn.describe_key.when.called_with("not-a-key").should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_list_keys():
conn = boto.kms.connect_to_region("us-west-2")
@ -80,7 +80,7 @@ def test_list_keys():
keys['Keys'].should.have.length_of(2)
@mock_kms
@mock_kms_deprecated
def test_enable_key_rotation():
conn = boto.kms.connect_to_region("us-west-2")
@ -91,7 +91,7 @@ def test_enable_key_rotation():
conn.get_key_rotation_status(key_id)['KeyRotationEnabled'].should.equal(True)
@mock_kms
@mock_kms_deprecated
def test_enable_key_rotation_via_arn():
conn = boto.kms.connect_to_region("us-west-2")
@ -104,13 +104,13 @@ def test_enable_key_rotation_via_arn():
@mock_kms
@mock_kms_deprecated
def test_enable_key_rotation_with_missing_key():
conn = boto.kms.connect_to_region("us-west-2")
conn.enable_key_rotation.when.called_with("not-a-key").should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_enable_key_rotation_with_alias_name_should_fail():
conn = boto.kms.connect_to_region("us-west-2")
key = conn.create_key(policy="my policy", description="my key", key_usage='ENCRYPT_DECRYPT')
@ -122,7 +122,7 @@ def test_enable_key_rotation_with_alias_name_should_fail():
conn.enable_key_rotation.when.called_with('alias/my-alias').should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_disable_key_rotation():
conn = boto.kms.connect_to_region("us-west-2")
@ -136,7 +136,7 @@ def test_disable_key_rotation():
conn.get_key_rotation_status(key_id)['KeyRotationEnabled'].should.equal(False)
@mock_kms
@mock_kms_deprecated
def test_encrypt():
"""
test_encrypt
@ -147,26 +147,26 @@ def test_encrypt():
response['CiphertextBlob'].should.equal(b'ZW5jcnlwdG1l')
@mock_kms
@mock_kms_deprecated
def test_decrypt():
conn = boto.kms.connect_to_region('us-west-2')
response = conn.decrypt('ZW5jcnlwdG1l'.encode('utf-8'))
response['Plaintext'].should.equal(b'encryptme')
@mock_kms
@mock_kms_deprecated
def test_disable_key_rotation_with_missing_key():
conn = boto.kms.connect_to_region("us-west-2")
conn.disable_key_rotation.when.called_with("not-a-key").should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_get_key_rotation_status_with_missing_key():
conn = boto.kms.connect_to_region("us-west-2")
conn.get_key_rotation_status.when.called_with("not-a-key").should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_get_key_rotation_status():
conn = boto.kms.connect_to_region("us-west-2")
@ -176,7 +176,7 @@ def test_get_key_rotation_status():
conn.get_key_rotation_status(key_id)['KeyRotationEnabled'].should.equal(False)
@mock_kms
@mock_kms_deprecated
def test_create_key_defaults_key_rotation():
conn = boto.kms.connect_to_region("us-west-2")
@ -186,7 +186,7 @@ def test_create_key_defaults_key_rotation():
conn.get_key_rotation_status(key_id)['KeyRotationEnabled'].should.equal(False)
@mock_kms
@mock_kms_deprecated
def test_get_key_policy():
conn = boto.kms.connect_to_region('us-west-2')
@ -196,7 +196,7 @@ def test_get_key_policy():
policy = conn.get_key_policy(key_id, 'default')
policy['Policy'].should.equal('my policy')
@mock_kms
@mock_kms_deprecated
def test_get_key_policy_via_arn():
conn = boto.kms.connect_to_region('us-west-2')
@ -205,7 +205,7 @@ def test_get_key_policy_via_arn():
policy['Policy'].should.equal('my policy')
@mock_kms
@mock_kms_deprecated
def test_put_key_policy():
conn = boto.kms.connect_to_region('us-west-2')
@ -217,7 +217,7 @@ def test_put_key_policy():
policy['Policy'].should.equal('new policy')
@mock_kms
@mock_kms_deprecated
def test_put_key_policy_via_arn():
conn = boto.kms.connect_to_region('us-west-2')
@ -229,7 +229,7 @@ def test_put_key_policy_via_arn():
policy['Policy'].should.equal('new policy')
@mock_kms
@mock_kms_deprecated
def test_put_key_policy_via_alias_should_not_update():
conn = boto.kms.connect_to_region('us-west-2')
@ -242,7 +242,7 @@ def test_put_key_policy_via_alias_should_not_update():
policy['Policy'].should.equal('my policy')
@mock_kms
@mock_kms_deprecated
def test_put_key_policy():
conn = boto.kms.connect_to_region('us-west-2')
@ -253,7 +253,7 @@ def test_put_key_policy():
policy['Policy'].should.equal('new policy')
@mock_kms
@mock_kms_deprecated
def test_list_key_policies():
conn = boto.kms.connect_to_region('us-west-2')
@ -264,7 +264,7 @@ def test_list_key_policies():
policies['PolicyNames'].should.equal(['default'])
@mock_kms
@mock_kms_deprecated
def test__create_alias__returns_none_if_correct():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -275,7 +275,7 @@ def test__create_alias__returns_none_if_correct():
resp.should.be.none
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_reserved_alias():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -300,7 +300,7 @@ def test__create_alias__raises_if_reserved_alias():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__create_alias__can_create_multiple_aliases_for_same_key_id():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -311,7 +311,7 @@ def test__create_alias__can_create_multiple_aliases_for_same_key_id():
kms.create_alias('alias/my-alias5', key_id).should.be.none
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_wrong_prefix():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -328,7 +328,7 @@ def test__create_alias__raises_if_wrong_prefix():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_duplicate():
region = 'us-west-2'
kms = boto.kms.connect_to_region(region)
@ -354,7 +354,7 @@ def test__create_alias__raises_if_duplicate():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_alias_has_restricted_characters():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -378,7 +378,7 @@ def test__create_alias__raises_if_alias_has_restricted_characters():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_alias_has_colon_character():
# For some reason, colons are not accepted for an alias, even though they are accepted by regex ^[a-zA-Z0-9:/_-]+$
kms = boto.connect_kms()
@ -401,7 +401,7 @@ def test__create_alias__raises_if_alias_has_colon_character():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__create_alias__accepted_characters():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -416,7 +416,7 @@ def test__create_alias__accepted_characters():
kms.create_alias(alias_name, key_id)
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_target_key_id_is_existing_alias():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -437,7 +437,7 @@ def test__create_alias__raises_if_target_key_id_is_existing_alias():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__delete_alias():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -454,7 +454,7 @@ def test__delete_alias():
kms.create_alias(alias, key_id)
@mock_kms
@mock_kms_deprecated
def test__delete_alias__raises_if_wrong_prefix():
kms = boto.connect_kms()
@ -470,7 +470,7 @@ def test__delete_alias__raises_if_wrong_prefix():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__delete_alias__raises_if_alias_is_not_found():
region = 'us-west-2'
kms = boto.kms.connect_to_region(region)
@ -490,7 +490,7 @@ def test__delete_alias__raises_if_alias_is_not_found():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__list_aliases():
region = "eu-west-1"
kms = boto.kms.connect_to_region(region)
@ -532,7 +532,7 @@ def test__list_aliases():
len(aliases).should.equal(7)
@mock_kms
@mock_kms_deprecated
def test__assert_valid_key_id():
from moto.kms.responses import _assert_valid_key_id
import uuid
@ -541,7 +541,7 @@ def test__assert_valid_key_id():
_assert_valid_key_id.when.called_with(str(uuid.uuid4())).should_not.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test__assert_default_policy():
from moto.kms.responses import _assert_default_policy

View File

@ -66,7 +66,7 @@ def test_describe_layers():
rv1 = client.describe_layers(StackId=stack_id)
rv2 = client.describe_layers(LayerIds=[layer_id])
rv1.should.equal(rv2)
rv1['Layers'].should.equal(rv2['Layers'])
rv1['Layers'][0]['Name'].should.equal("TestLayer")

Some files were not shown because too many files have changed in this diff Show More