Removed extra dependency as per suggestion, although it fixes the issue much better IMO, we should be safe sticking with using the format from python's isoformat()

This commit is contained in:
Brian Lamar 2011-03-28 13:18:47 -04:00
parent 23bed216db
commit 56b4dd3929
2 changed files with 3 additions and 28 deletions

View File

@ -20,8 +20,6 @@ from __future__ import absolute_import
import datetime
import iso8601
from glance.common import exception as glance_exception
from nova import exception
@ -232,4 +230,5 @@ def _parse_glance_iso8601_timestamp(timestamp):
"""
Parse a subset of iso8601 timestamps into datetime objects
"""
return iso8601.parse_date(timestamp).replace(tzinfo=None)
ISO_FMT = "%Y-%m-%dT%H:%M:%S.%f"
return datetime.datetime.strptime(timestamp, ISO_FMT)

View File

@ -55,9 +55,8 @@ class NullWriter(object):
class BaseGlanceTest(unittest.TestCase):
NOW_GLANCE_FORMAT = "2010-10-11T10:30:22"
NOW_GLANCE_FORMAT = "2010-10-11T10:30:22.000000"
NOW_DATETIME = datetime.datetime(2010, 10, 11, 10, 30, 22)
NOW_ISO_FORMAT = "2010-10-11T10:30:22.000000"
def setUp(self):
# FIXME(sirp): we can probably use stubs library here rather than
@ -145,33 +144,17 @@ class TestGetterDateTimeNoneTests(BaseGlanceTest):
image_meta = self.service.show(self.context, 'image1')
self.assertDateTimesFilled(image_meta)
def test_show_makes_datetimes_iso(self):
self.client.images = self._make_iso_fixtures()
image_meta = self.service.show(self.context, 'image1')
self.assertDateTimesFilled(image_meta)
def test_detail_makes_datetimes(self):
self.client.images = self._make_datetime_fixtures()
image_meta = self.service.detail(self.context)[0]
self.assertDateTimesFilled(image_meta)
def test_detail_makes_datetimes_iso(self):
self.client.images = self._make_iso_fixtures()
image_meta = self.service.detail(self.context)[0]
self.assertDateTimesFilled(image_meta)
def test_get_makes_datetimes(self):
self.client.images = self._make_datetime_fixtures()
writer = NullWriter()
image_meta = self.service.get(self.context, 'image1', writer)
self.assertDateTimesFilled(image_meta)
def test_get_makes_datetimes_iso(self):
self.client.images = self._make_iso_fixtures()
writer = NullWriter()
image_meta = self.service.get(self.context, 'image1', writer)
self.assertDateTimesFilled(image_meta)
def _make_datetime_fixtures(self):
fixtures = {'image1': {'name': 'image1', 'is_public': True,
'created_at': self.NOW_GLANCE_FORMAT,
@ -179,13 +162,6 @@ class TestGetterDateTimeNoneTests(BaseGlanceTest):
'deleted_at': self.NOW_GLANCE_FORMAT}}
return fixtures
def _make_iso_fixtures(self):
fixtures = {'image1': {'name': 'image1', 'is_public': True,
'created_at': self.NOW_ISO_FORMAT,
'updated_at': self.NOW_ISO_FORMAT,
'deleted_at': self.NOW_ISO_FORMAT}}
return fixtures
def _make_none_datetime_fixtures(self):
fixtures = {'image1': {'name': 'image1', 'is_public': True,
'updated_at': None,