Fixing broken tests #2126

- KMS
- S3
- CloudFormation (Thanks kgutwin!)
This commit is contained in:
Mike Grima 2019-03-25 13:19:01 -07:00
parent 64152f4cda
commit 921b5a3227
5 changed files with 10 additions and 8 deletions

View File

@ -85,9 +85,9 @@ class FakeStack(BaseModel):
def _parse_template(self):
yaml.add_multi_constructor('', yaml_tag_constructor)
try:
self.template_dict = yaml.load(self.template)
self.template_dict = yaml.load(self.template, Loader=yaml.Loader)
except yaml.parser.ParserError:
self.template_dict = json.loads(self.template)
self.template_dict = json.loads(self.template, Loader=yaml.Loader)
@property
def stack_parameters(self):

View File

@ -448,8 +448,8 @@ def test_short_form_func_in_yaml_teamplate():
KeySplit: !Split [A, B]
KeySub: !Sub A
"""
yaml.add_multi_constructor('', yaml_tag_constructor)
template_dict = yaml.load(template)
yaml.add_multi_constructor('', yaml_tag_constructor, Loader=yaml.Loader)
template_dict = yaml.load(template, Loader=yaml.Loader)
key_and_expects = [
['KeyRef', {'Ref': 'foo'}],
['KeyB64', {'Fn::Base64': 'valueToEncode'}],

View File

@ -8,8 +8,8 @@ import sure # noqa
from moto import mock_kms, mock_kms_deprecated
from nose.tools import assert_raises
from freezegun import freeze_time
from datetime import datetime, timedelta
from dateutil.tz import tzlocal
from datetime import datetime
from dateutil.tz import tzutc
@mock_kms_deprecated
@ -660,7 +660,7 @@ def test_schedule_key_deletion():
KeyId=key['KeyMetadata']['KeyId']
)
assert response['KeyId'] == key['KeyMetadata']['KeyId']
assert response['DeletionDate'] == datetime(2015, 1, 31, 12, 0, tzinfo=tzlocal())
assert response['DeletionDate'] == datetime(2015, 1, 31, 12, 0, tzinfo=tzutc())
else:
# Can't manipulate time in server mode
response = client.schedule_key_deletion(
@ -685,7 +685,7 @@ def test_schedule_key_deletion_custom():
PendingWindowInDays=7
)
assert response['KeyId'] == key['KeyMetadata']['KeyId']
assert response['DeletionDate'] == datetime(2015, 1, 8, 12, 0, tzinfo=tzlocal())
assert response['DeletionDate'] == datetime(2015, 1, 8, 12, 0, tzinfo=tzutc())
else:
# Can't manipulate time in server mode
response = client.schedule_key_deletion(

View File

@ -15,6 +15,7 @@ class AuthenticatedClient(FlaskClient):
def open(self, *args, **kwargs):
kwargs['headers'] = kwargs.get('headers', {})
kwargs['headers']['Authorization'] = "Any authorization header"
kwargs['content_length'] = 0 # Fixes content-length complaints.
return super(AuthenticatedClient, self).open(*args, **kwargs)

View File

@ -13,6 +13,7 @@ class AuthenticatedClient(FlaskClient):
def open(self, *args, **kwargs):
kwargs['headers'] = kwargs.get('headers', {})
kwargs['headers']['Authorization'] = "Any authorization header"
kwargs['content_length'] = 0 # Fixes content-length complaints.
return super(AuthenticatedClient, self).open(*args, **kwargs)