Cleanup some incorrect date formats.

This commit is contained in:
Steve Pulec 2014-11-29 23:34:40 -05:00
parent f0d576a790
commit 1a015d0e39
9 changed files with 24 additions and 24 deletions

View File

@ -80,8 +80,8 @@ class convert_flask_to_httpretty_response(object):
return response, status, headers return response, status, headers
def iso_8601_datetime(datetime): def iso_8601_datetime_with_milliseconds(datetime):
return datetime.strftime("%Y-%m-%dT%H:%M:%SZ") return datetime.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + 'Z'
def rfc_1123_datetime(datetime): def rfc_1123_datetime(datetime):

View File

@ -9,7 +9,7 @@ import codecs
import six import six
from moto.core import BaseBackend from moto.core import BaseBackend
from moto.core.utils import iso_8601_datetime, rfc_1123_datetime from moto.core.utils import iso_8601_datetime_with_milliseconds, rfc_1123_datetime
from .exceptions import BucketAlreadyExists, MissingBucket from .exceptions import BucketAlreadyExists, MissingBucket
from .utils import clean_key_name, _VersionedKeyStore from .utils import clean_key_name, _VersionedKeyStore
@ -71,7 +71,7 @@ class FakeKey(object):
@property @property
def last_modified_ISO8601(self): def last_modified_ISO8601(self):
return iso_8601_datetime(self.last_modified) return iso_8601_datetime_with_milliseconds(self.last_modified)
@property @property
def last_modified_RFC1123(self): def last_modified_RFC1123(self):

View File

@ -9,7 +9,7 @@ import six
from moto.compat import OrderedDict from moto.compat import OrderedDict
from moto.core import BaseBackend from moto.core import BaseBackend
from moto.core.utils import iso_8601_datetime from moto.core.utils import iso_8601_datetime_with_milliseconds
from moto.sqs import sqs_backends from moto.sqs import sqs_backends
from .utils import make_arn_for_topic, make_arn_for_subscription from .utils import make_arn_for_topic, make_arn_for_subscription
@ -69,7 +69,7 @@ class Subscription(object):
"TopicArn": self.topic.arn, "TopicArn": self.topic.arn,
"Subject": "my subject", "Subject": "my subject",
"Message": message, "Message": message,
"Timestamp": iso_8601_datetime(datetime.datetime.now()), "Timestamp": iso_8601_datetime_with_milliseconds(datetime.datetime.now()),
"SignatureVersion": "1", "SignatureVersion": "1",
"Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=", "Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
"SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem", "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",

View File

@ -1,7 +1,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import datetime import datetime
from moto.core import BaseBackend from moto.core import BaseBackend
from moto.core.utils import iso_8601_datetime from moto.core.utils import iso_8601_datetime_with_milliseconds
class Token(object): class Token(object):
@ -13,7 +13,7 @@ class Token(object):
@property @property
def expiration_ISO8601(self): def expiration_ISO8601(self):
return iso_8601_datetime(self.expiration) return iso_8601_datetime_with_milliseconds(self.expiration)
class AssumedRole(object): class AssumedRole(object):
@ -27,7 +27,7 @@ class AssumedRole(object):
@property @property
def expiration_ISO8601(self): def expiration_ISO8601(self):
return iso_8601_datetime(self.expiration) return iso_8601_datetime_with_milliseconds(self.expiration)
class STSBackend(BaseBackend): class STSBackend(BaseBackend):

View File

@ -6,7 +6,7 @@ import sure # noqa
from moto import mock_ec2 from moto import mock_ec2
from moto.backends import get_model from moto.backends import get_model
from moto.core.utils import iso_8601_datetime from moto.core.utils import iso_8601_datetime_with_milliseconds
@mock_ec2 @mock_ec2
@ -16,8 +16,8 @@ def test_request_spot_instances():
conn.create_security_group('group1', 'description') conn.create_security_group('group1', 'description')
conn.create_security_group('group2', 'description') conn.create_security_group('group2', 'description')
start = iso_8601_datetime(datetime.datetime(2013, 1, 1)) start = iso_8601_datetime_with_milliseconds(datetime.datetime(2013, 1, 1))
end = iso_8601_datetime(datetime.datetime(2013, 1, 2)) end = iso_8601_datetime_with_milliseconds(datetime.datetime(2013, 1, 2))
request = conn.request_spot_instances( request = conn.request_spot_instances(
price=0.5, image_id='ami-abcd1234', count=1, type='one-time', price=0.5, image_id='ami-abcd1234', count=1, type='one-time',
@ -145,7 +145,7 @@ def test_tag_spot_instance_request():
request = requests[0] request = requests[0]
tag_dict = dict(request.tags) tag_dict = dict(request.tags)
tag_dict.should.equal({'tag1' : 'value1', 'tag2' : 'value2'}) tag_dict.should.equal({'tag1': 'value1', 'tag2': 'value2'})
@mock_ec2 @mock_ec2
@ -161,7 +161,7 @@ def test_get_all_spot_instance_requests_filtering():
request2 = conn.request_spot_instances( request2 = conn.request_spot_instances(
price=0.5, image_id='ami-abcd1234', price=0.5, image_id='ami-abcd1234',
) )
request3 = conn.request_spot_instances( conn.request_spot_instances(
price=0.5, image_id='ami-abcd1234', price=0.5, image_id='ami-abcd1234',
) )
request1[0].add_tag('tag1', 'value1') request1[0].add_tag('tag1', 'value1')
@ -169,16 +169,16 @@ def test_get_all_spot_instance_requests_filtering():
request2[0].add_tag('tag1', 'value1') request2[0].add_tag('tag1', 'value1')
request2[0].add_tag('tag2', 'wrong') request2[0].add_tag('tag2', 'wrong')
requests = conn.get_all_spot_instance_requests(filters={'state' : 'active'}) requests = conn.get_all_spot_instance_requests(filters={'state': 'active'})
requests.should.have.length_of(0) requests.should.have.length_of(0)
requests = conn.get_all_spot_instance_requests(filters={'state' : 'open'}) requests = conn.get_all_spot_instance_requests(filters={'state': 'open'})
requests.should.have.length_of(3) requests.should.have.length_of(3)
requests = conn.get_all_spot_instance_requests(filters={'tag:tag1' : 'value1'}) requests = conn.get_all_spot_instance_requests(filters={'tag:tag1': 'value1'})
requests.should.have.length_of(2) requests.should.have.length_of(2)
requests = conn.get_all_spot_instance_requests(filters={'tag:tag1' : 'value1', 'tag:tag2' : 'value2'}) requests = conn.get_all_spot_instance_requests(filters={'tag:tag1': 'value1', 'tag:tag2': 'value2'})
requests.should.have.length_of(1) requests.should.have.length_of(1)

View File

@ -273,7 +273,7 @@ def test_last_modified():
key.set_contents_from_string("some value") key.set_contents_from_string("some value")
rs = bucket.get_all_keys() rs = bucket.get_all_keys()
rs[0].last_modified.should.equal('2012-01-01T12:00:00Z') rs[0].last_modified.should.equal('2012-01-01T12:00:00.000Z')
bucket.get_key("the-key").last_modified.should.equal('Sun, 01 Jan 2012 12:00:00 GMT') bucket.get_key("the-key").last_modified.should.equal('Sun, 01 Jan 2012 12:00:00 GMT')

View File

@ -133,7 +133,7 @@ def test_last_modified():
key.set_contents_from_string("some value") key.set_contents_from_string("some value")
rs = bucket.get_all_keys() rs = bucket.get_all_keys()
rs[0].last_modified.should.equal('2012-01-01T12:00:00Z') rs[0].last_modified.should.equal('2012-01-01T12:00:00.000Z')
bucket.get_key("the-key").last_modified.should.equal('Sun, 01 Jan 2012 12:00:00 GMT') bucket.get_key("the-key").last_modified.should.equal('Sun, 01 Jan 2012 12:00:00 GMT')

View File

@ -75,7 +75,7 @@ def test_publish_to_http():
"TopicArn": ["arn:aws:sns:us-east-1:123456789012:some-topic"], "TopicArn": ["arn:aws:sns:us-east-1:123456789012:some-topic"],
"Subject": ["my subject"], "Subject": ["my subject"],
"Message": ["my message"], "Message": ["my message"],
"Timestamp": ["2013-01-01T00:00:00Z"], "Timestamp": ["2013-01-01T00:00:00.000Z"],
"SignatureVersion": ["1"], "SignatureVersion": ["1"],
"Signature": ["EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc="], "Signature": ["EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc="],
"SigningCertURL": ["https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem"], "SigningCertURL": ["https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem"],

View File

@ -14,7 +14,7 @@ def test_get_session_token():
conn = boto.connect_sts() conn = boto.connect_sts()
token = conn.get_session_token(duration=123) token = conn.get_session_token(duration=123)
token.expiration.should.equal('2012-01-01T12:02:03Z') token.expiration.should.equal('2012-01-01T12:02:03.000Z')
token.session_token.should.equal("AQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/LTo6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4IgRmpRV3zrkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15fjrBs2+cTQtpZ3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE") token.session_token.should.equal("AQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/LTo6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4IgRmpRV3zrkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15fjrBs2+cTQtpZ3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE")
token.access_key.should.equal("AKIAIOSFODNN7EXAMPLE") token.access_key.should.equal("AKIAIOSFODNN7EXAMPLE")
token.secret_key.should.equal("wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY") token.secret_key.should.equal("wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY")
@ -26,7 +26,7 @@ def test_get_federation_token():
conn = boto.connect_sts() conn = boto.connect_sts()
token = conn.get_federation_token(duration=123, name="Bob") token = conn.get_federation_token(duration=123, name="Bob")
token.credentials.expiration.should.equal('2012-01-01T12:02:03Z') token.credentials.expiration.should.equal('2012-01-01T12:02:03.000Z')
token.credentials.session_token.should.equal("AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQWLWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI/qkPpKPi/kMcGdQrmGdeehM4IC1NtBmUpp2wUE8phUZampKsburEDy0KPkyQDYwT7WZ0wq5VSXDvp75YU9HFvlRd8Tx6q6fE8YQcHNVXAkiY9q6d+xo0rKwT38xVqr7ZD0u0iPPkUL64lIZbqBAz+scqKmlzm8FDrypNC9Yjc8fPOLn9FX9KSYvKTr4rvx3iSIlTJabIQwj2ICCR/oLxBA==") token.credentials.session_token.should.equal("AQoDYXdzEPT//////////wEXAMPLEtc764bNrC9SAPBSM22wDOk4x4HIZ8j4FZTwdQWLWsKWHGBuFqwAeMicRXmxfpSPfIeoIYRqTflfKD8YUuwthAx7mSEI/qkPpKPi/kMcGdQrmGdeehM4IC1NtBmUpp2wUE8phUZampKsburEDy0KPkyQDYwT7WZ0wq5VSXDvp75YU9HFvlRd8Tx6q6fE8YQcHNVXAkiY9q6d+xo0rKwT38xVqr7ZD0u0iPPkUL64lIZbqBAz+scqKmlzm8FDrypNC9Yjc8fPOLn9FX9KSYvKTr4rvx3iSIlTJabIQwj2ICCR/oLxBA==")
token.credentials.access_key.should.equal("AKIAIOSFODNN7EXAMPLE") token.credentials.access_key.should.equal("AKIAIOSFODNN7EXAMPLE")
token.credentials.secret_key.should.equal("wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY") token.credentials.secret_key.should.equal("wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY")
@ -57,7 +57,7 @@ def test_assume_role():
role = conn.assume_role(s3_role, "session-name", policy, duration_seconds=123) role = conn.assume_role(s3_role, "session-name", policy, duration_seconds=123)
credentials = role.credentials credentials = role.credentials
credentials.expiration.should.equal('2012-01-01T12:02:03Z') credentials.expiration.should.equal('2012-01-01T12:02:03.000Z')
credentials.session_token.should.equal("BQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/LTo6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4IgRmpRV3zrkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15fjrBs2+cTQtpZ3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE") credentials.session_token.should.equal("BQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/LTo6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4IgRmpRV3zrkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15fjrBs2+cTQtpZ3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE")
credentials.access_key.should.equal("AKIAIOSFODNN7EXAMPLE") credentials.access_key.should.equal("AKIAIOSFODNN7EXAMPLE")
credentials.secret_key.should.equal("aJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY") credentials.secret_key.should.equal("aJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY")