summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorSoren Hansen <soren@linux2go.dk>2011-11-10 10:41:37 +0100
committerSoren Hansen <soren@linux2go.dk>2011-11-10 13:35:40 +0100
commit6c0fd03fc3e4f30ca6d1e7d55e83d7a325fae447 (patch)
tree1ca2ca21df54fe1ebbc25edd12685865001d4e9d /nova/tests
parent26d2bad187ba8fab4f5e4b2f76b86f3e8762caa8 (diff)
downloadnova-6c0fd03fc3e4f30ca6d1e7d55e83d7a325fae447.tar.gz
nova-6c0fd03fc3e4f30ca6d1e7d55e83d7a325fae447.tar.xz
nova-6c0fd03fc3e4f30ca6d1e7d55e83d7a325fae447.zip
Extend fake image service to let it hold image data
Make the fake image service able to store image data in memory. This is handy for unit testing, but probably not very useful otherwise (images are pretty big, so holding them in memory is not a very good idea). Change-Id: I2d07baf24cab544e19521b9486feee3272d0407e
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_image.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/nova/tests/test_image.py b/nova/tests/test_image.py
index 9eeefe0e5..0cb138956 100644
--- a/nova/tests/test_image.py
+++ b/nova/tests/test_image.py
@@ -16,6 +16,7 @@
# under the License.
import datetime
+import StringIO
from nova import context
from nova import exception
@@ -128,6 +129,16 @@ class _ImageTestCase(test.TestCase):
index = self.image_service.index(self.context)
self.assertEquals(len(index), 0)
+ def test_create_then_get(self):
+ blob = 'some data'
+ s1 = StringIO.StringIO(blob)
+ self.image_service.create(self.context,
+ {'id': '32', 'foo': 'bar'},
+ data=s1)
+ s2 = StringIO.StringIO()
+ self.image_service.get(self.context, '32', data=s2)
+ self.assertEquals(s2.getvalue(), blob, 'Did not get blob back intact')
+
class FakeImageTestCase(_ImageTestCase):
def setUp(self):