summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Washenberger <mark.washenberger@rackspace.com>2011-03-17 14:04:31 -0400
committerMark Washenberger <mark.washenberger@rackspace.com>2011-03-17 14:04:31 -0400
commit66c237a4d321887830e5282781870525abf00365 (patch)
treef104f537f5e2db224c1fd35e6d01bb431973cb85
parent3ee835c60d2b43086b1e324501025d1f0221da27 (diff)
teach glance image server get to handle timestamps
-rw-r--r--nova/image/glance.py2
-rw-r--r--nova/tests/image/test_glance.py30
2 files changed, 30 insertions, 2 deletions
diff --git a/nova/image/glance.py b/nova/image/glance.py
index 7706a42e4..f725fe176 100644
--- a/nova/image/glance.py
+++ b/nova/image/glance.py
@@ -108,7 +108,7 @@ class GlanceImageService(service.BaseImageService):
raise exception.NotFound
for chunk in image_chunks:
data.write(chunk)
- return metadata
+ return self._convert_timestamps_to_datetimes(metadata)
def create(self, context, metadata, data=None):
"""
diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py
index 16fe0e7c0..1e6c45219 100644
--- a/nova/tests/image/test_glance.py
+++ b/nova/tests/image/test_glance.py
@@ -14,7 +14,17 @@ class StubGlanceClient(object):
def get_images_detailed(self):
return self.images.itervalues()
-class TestGlance(unittest.TestCase):
+ def get_image(self, id):
+ return self.images[id], []
+
+
+class NullWriter(object):
+
+ def write(self, *arg, **kwargs):
+ pass
+
+
+class TestGlanceImageServiceDatetimes(unittest.TestCase):
def setUp(self):
self.client = StubGlanceClient(None)
@@ -87,3 +97,21 @@ class TestGlance(unittest.TestCase):
self.assertEqual(i1['updated_at'], now)
self.assertEqual(i1['deleted_at'], None)
self.assertEqual(i2['deleted_at'], now)
+
+ def test_get_handles_timestamps(self):
+ now = dt.datetime.utcnow()
+ self.client.images = {'abcd': {
+ 'id': 'abcd',
+ 'name': 'nifty image',
+ 'created_at': now.isoformat(),
+ 'updated_at': now.isoformat(),
+ 'deleted_at': now.isoformat(),
+ }}
+ actual = self.service.get({}, 'abcd', NullWriter())
+ for attr in ('created_at', 'updated_at', 'deleted_at'):
+ self.assertEqual(actual[attr], now)
+
+ def test_get_handles_deleted_at_none(self):
+ self.client.images = {'abcd': {'deleted_at': None}}
+ actual = self.service.get({}, 'abcd', NullWriter())
+ self.assertEqual(actual['deleted_at'], None)