Replace static v2 Image model with warlock model

* Add warlock v0.1.0 as a dependency
* Generate a pythonic, self-validating Image model using warlock
* Add raw method to Schema model
* Related to bp glance-client-v2

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a04
This commit is contained in:
Brian Waldon
2012-07-14 01:11:22 +00:00
parent b6cef9d145
commit c398af18b0
6 changed files with 37 additions and 23 deletions
+5 -10
View File
@@ -15,6 +15,8 @@
import unittest
import warlock
from glanceclient.v2 import images
from tests import utils
@@ -49,22 +51,15 @@ fixtures = {
}
class TestImage(unittest.TestCase):
def test_image_minimum(self):
raw_image = {
'id': '8a5b2424-9751-498b-925f-66f62747c501',
'name': 'image-7',
}
image = images.Image(**raw_image)
self.assertEqual(image.id, '8a5b2424-9751-498b-925f-66f62747c501')
self.assertEqual(image.name, 'image-7')
fake_schema = {'name': 'image', 'properties': {'id': {}, 'name': {}}}
FakeModel = warlock.model_factory(fake_schema)
class TestController(unittest.TestCase):
def setUp(self):
super(TestController, self).setUp()
self.api = utils.FakeAPI(fixtures)
self.controller = images.Controller(self.api)
self.controller = images.Controller(self.api, FakeModel)
def test_list_images(self):
images = self.controller.list()