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
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user