summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Waldon <bcwaldon@gmail.com>2012-07-14 01:11:22 +0000
committerBrian Waldon <bcwaldon@gmail.com>2012-07-13 18:38:41 -0700
commitc398af18b0b8fb5fb075be22563812e179290b2a (patch)
treebd5d428318e6e1e64a5289d581e7286786e52a0a /tests
parentb6cef9d145f870dd717843751f0c5d68867e07d5 (diff)
downloadpython-glanceclient-c398af18b0b8fb5fb075be22563812e179290b2a.tar.gz
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
Diffstat (limited to 'tests')
-rw-r--r--tests/v2/test_images.py15
-rw-r--r--tests/v2/test_schemas.py5
2 files changed, 10 insertions, 10 deletions
diff --git a/tests/v2/test_images.py b/tests/v2/test_images.py
index f6f1292..471c9ee 100644
--- a/tests/v2/test_images.py
+++ b/tests/v2/test_images.py
@@ -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()
diff --git a/tests/v2/test_schemas.py b/tests/v2/test_schemas.py
index 6e64c29..b11b480 100644
--- a/tests/v2/test_schemas.py
+++ b/tests/v2/test_schemas.py
@@ -67,6 +67,11 @@ class TestSchema(unittest.TestCase):
self.assertEqual(schema.name, 'Country')
self.assertEqual([p.name for p in schema.properties], ['size'])
+ def test_raw(self):
+ raw_schema = {'name': 'Country', 'properties': {}}
+ schema = schemas.Schema(raw_schema)
+ self.assertEqual(schema.raw(), raw_schema)
+
class TestController(unittest.TestCase):
def setUp(self):