summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Prince <dan.prince@rackspace.com>2011-06-03 11:34:49 -0400
committerDan Prince <dan.prince@rackspace.com>2011-06-03 11:34:49 -0400
commiteadabab8b70bdc4789615844e2263cbed7aa283c (patch)
tree7ba7501f095fffe17322bacac4c578c0dfd951d9
parent118ad787703f44c9f7ff8e3ea87cf1b396ea6187 (diff)
downloadnova-eadabab8b70bdc4789615844e2263cbed7aa283c.tar.gz
nova-eadabab8b70bdc4789615844e2263cbed7aa283c.tar.xz
nova-eadabab8b70bdc4789615844e2263cbed7aa283c.zip
Added a test case for XML serialization.
-rw-r--r--nova/tests/api/openstack/fakes.py3
-rw-r--r--nova/tests/api/openstack/test_images.py33
2 files changed, 35 insertions, 1 deletions
diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py
index e9b46f933..601c1e9e4 100644
--- a/nova/tests/api/openstack/fakes.py
+++ b/nova/tests/api/openstack/fakes.py
@@ -143,7 +143,8 @@ def stub_out_networking(stubs):
def stub_out_compute_api_snapshot(stubs):
def snapshot(self, context, instance_id, name):
- return dict(id='123')
+ return dict(id='123', status='ACTIVE',
+ properties=dict(instance_id='123'))
stubs.Set(nova.compute.API, 'snapshot', snapshot)
diff --git a/nova/tests/api/openstack/test_images.py b/nova/tests/api/openstack/test_images.py
index 961c271ca..ae7025146 100644
--- a/nova/tests/api/openstack/test_images.py
+++ b/nova/tests/api/openstack/test_images.py
@@ -902,6 +902,39 @@ class ImageControllerWithGlanceServiceTest(test.TestCase):
response = req.get_response(fakes.wsgi_app())
self.assertEqual(200, response.status_int)
+ def test_create_image_v1_1_xml_serialization(self):
+
+ body = dict(image=dict(serverRef='123', name='Backup 1'))
+ req = webob.Request.blank('/v1.1/images')
+ req.method = 'POST'
+ req.body = json.dumps(body)
+ req.headers["content-type"] = "application/json"
+ req.headers["accept"] = "application/xml"
+ response = req.get_response(fakes.wsgi_app())
+ self.assertEqual(200, response.status_int)
+ resp_xml = minidom.parseString(response.body.replace(" ", ""))
+ expected_href = "http://localhost/v1.1/images/123"
+ expected_image = minidom.parseString("""
+ <image
+ created="None"
+ id="123"
+ name="None"
+ serverRef="http://localhost/v1.1/servers/123"
+ status="ACTIVE"
+ updated="None"
+ xmlns="http://docs.openstack.org/compute/api/v1.1">
+ <links>
+ <link href="%(expected_href)s" rel="self"/>
+ <link href="%(expected_href)s" rel="bookmark"
+ type="application/json" />
+ <link href="%(expected_href)s" rel="bookmark"
+ type="application/xml" />
+ </links>
+ </image>
+ """.replace(" ", "") % (locals()))
+
+ self.assertEqual(expected_image.toxml(), resp_xml.toxml())
+
def test_create_image_v1_1_no_server_ref(self):
body = dict(image=dict(name='Backup 1'))