summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Washenberger <mark.washenberger@rackspace.com>2011-03-16 17:56:40 -0400
committerMark Washenberger <mark.washenberger@rackspace.com>2011-03-16 17:56:40 -0400
commitcc2d4728d32d016ef803d0def456cac6e315e8fa (patch)
tree730830be188aa486537c0100f9510dc5cafb18de
parent3459cfb89bd90605e54fd1fb28b8b38089f3e236 (diff)
get started testing
-rw-r--r--nova/image/glance.py6
-rw-r--r--nova/tests/image/__init__.py0
-rw-r--r--nova/tests/image/test_glance.py18
3 files changed, 22 insertions, 2 deletions
diff --git a/nova/image/glance.py b/nova/image/glance.py
index 15fca69b8..3b448db4b 100644
--- a/nova/image/glance.py
+++ b/nova/image/glance.py
@@ -37,8 +37,10 @@ GlanceClient = utils.import_class('glance.client.Client')
class GlanceImageService(service.BaseImageService):
"""Provides storage and retrieval of disk image objects within Glance."""
- def __init__(self):
- self.client = GlanceClient(FLAGS.glance_host, FLAGS.glance_port)
+ def __init__(self, client=None):
+ if client is None:
+ self.client = GlanceClient(FLAGS.glance_host, FLAGS.glance_port)
+ self.client = client
def index(self, context):
"""
diff --git a/nova/tests/image/__init__.py b/nova/tests/image/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/nova/tests/image/__init__.py
diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py
new file mode 100644
index 000000000..b568f593d
--- /dev/null
+++ b/nova/tests/image/test_glance.py
@@ -0,0 +1,18 @@
+import unittest
+
+from nova.image import glance
+
+class StubGlanceClient(object):
+
+ def __init__(self, images):
+ self._images = images
+
+ def get_image_meta(id):
+ return self._images[id]
+
+class TestGlance(unittest.TestCase):
+
+ def test(self):
+ images = {'xyz': "image"}
+ client = StubGlanceClient(images)
+ service = glance.GlanceImageService(client)