diff options
| author | William Wolf <throughnothing@gmail.com> | 2011-07-26 11:15:44 -0400 |
|---|---|---|
| committer | William Wolf <throughnothing@gmail.com> | 2011-07-26 11:15:44 -0400 |
| commit | 696dc56b74a08d224beccdfd644536ec4217321d (patch) | |
| tree | b04117b66dcfdf691cf89d03341d1010cd41e3e8 | |
| parent | c41423cdf3f1345e2be3c248f576d848253fd8a3 (diff) | |
updated atom tests
| -rw-r--r-- | nova/api/openstack/versions.py | 14 | ||||
| -rw-r--r-- | nova/tests/api/openstack/test_versions.py | 111 |
2 files changed, 65 insertions, 60 deletions
diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/versions.py index c250dac8c..03b99f342 100644 --- a/nova/api/openstack/versions.py +++ b/nova/api/openstack/versions.py @@ -115,7 +115,7 @@ class VersionV10(object): return { "version" : { "id": "v1.0", - "status": "CURRENT", + "status": "DEPRECATED", "updated": "2011-01-21T11:33:21Z", "links": [ { @@ -415,7 +415,15 @@ def create_resource(version='1.0'): 'application/xml': VersionsXMLSerializer(), 'application/atom+xml': VersionsAtomSerializer(), } - serializer = wsgi.ResponseSerializer(body_serializers) - return wsgi.Resource(controller, serializer=serializer) + supported_content_types = ('application/json', + 'application/xml', + 'application/atom+xml') + deserializer = wsgi.RequestDeserializer( + supported_content_types=supported_content_types) + + + + return wsgi.Resource(controller, serializer=serializer, + deserializer=deserializer) diff --git a/nova/tests/api/openstack/test_versions.py b/nova/tests/api/openstack/test_versions.py index c48f397a1..88fe71041 100644 --- a/nova/tests/api/openstack/test_versions.py +++ b/nova/tests/api/openstack/test_versions.py @@ -271,75 +271,73 @@ class VersionsTest(test.TestCase): self.assertEqual(expected, actual) def test_get_version_1_0_detail_atom(self): - #TODO req = webob.Request.blank('/v1.0/') - req.accept = "application/xml" + req.accept = "application/atom+xml" res = req.get_response(fakes.wsgi_app()) self.assertEqual(res.status_int, 200) - self.assertEqual(res.content_type, "application/xml") + self.assertEqual("application/atom+xml", res.content_type) expected = """ - <version id="v1.0" status="CURRENT" - updated="2011-01-21T11:33:21Z" - xmlns="http://docs.openstack.org/common/api/v1.0" - xmlns:atom="http://www.w3.org/2005/Atom"> - - <media-types> - <media-type base="application/xml" - type="application/vnd.openstack.compute-v1.0+xml"/> - <media-type base="application/json" - type="application/vnd.openstack.compute-v1.0+json"/> - </media-types> - - <atom:link href="http://servers.api.openstack.org/v1.0/" - rel="self"/> - - <atom:link href="http://docs.rackspacecloud.com/servers/ - api/v1.0/cs-devguide-20110125.pdf" - rel="describedby" - type="application/pdf"/> - - <atom:link href="http://docs.rackspacecloud.com/servers/ - api/v1.0/application.wadl" - rel="describedby" - type="application/vnd.sun.wadl+xml"/> - </version>""".replace(" ", "").replace("\n", "") + <feed xmlns="http://www.w3.org/2005/Atom"> + <title type="text">About This Version</title> + <updated>2011-01-21T11:33:21Z</updated> + <id>http://servers.api.openstack.org/v1.0/</id> + <author> + <name>Rackspace</name> + <uri>http://www.rackspace.com/</uri> + </author> + <link href="http://servers.api.openstack.org/v1.0/" rel="self"/> + <entry> + <id>http://servers.api.openstack.org/v1.0/</id> + <title type="text">Version v1.0</title> + <updated>2011-01-21T11:33:21Z</updated> + <link href="http://servers.api.openstack.org/v1.0/" rel="self"/> + <link href="http://docs.rackspacecloud.com/servers/ + api/v1.0/cs-devguide-20110125.pdf" + rel="describedby" type="application/pdf"/> + <link href="http://docs.rackspacecloud.com/servers/ + api/v1.0/application.wadl" + rel="describedby" type="application/vnd.sun.wadl+xml"/> + <content type="text"> + Version v1.0 DEPRECATED (2011-01-21T11:33:21Z) + </content> + </entry> + </feed>""".replace(" ", "").replace("\n", "") actual = res.body.replace(" ", "").replace("\n", "") self.assertEqual(expected, actual) def test_get_version_1_1_detail_atom(self): - #TODO req = webob.Request.blank('/v1.1/') - req.accept = "application/xml" + req.accept = "application/atom+xml" res = req.get_response(fakes.wsgi_app()) self.assertEqual(res.status_int, 200) - self.assertEqual(res.content_type, "application/xml") + self.assertEqual("application/atom+xml", res.content_type) expected = """ - <version id="v1.1" status="CURRENT" - updated="2011-01-21T11:33:21Z" - xmlns="http://docs.openstack.org/common/api/v1.1" - xmlns:atom="http://www.w3.org/2005/Atom"> - - <media-types> - <media-type base="application/xml" - type="application/vnd.openstack.compute-v1.1+xml"/> - <media-type base="application/json" - type="application/vnd.openstack.compute-v1.1+json"/> - </media-types> - - <atom:link href="http://servers.api.openstack.org/v1.1/" - rel="self"/> - - <atom:link href="http://docs.rackspacecloud.com/servers/ - api/v1.1/cs-devguide-20110125.pdf" - rel="describedby" - type="application/pdf"/> - - <atom:link href="http://docs.rackspacecloud.com/servers/ - api/v1.1/application.wadl" - rel="describedby" - type="application/vnd.sun.wadl+xml"/> - </version>""".replace(" ", "").replace("\n", "") + <feed xmlns="http://www.w3.org/2005/Atom"> + <title type="text">About This Version</title> + <updated>2011-01-21T11:33:21Z</updated> + <id>http://servers.api.openstack.org/v1.1/</id> + <author> + <name>Rackspace</name> + <uri>http://www.rackspace.com/</uri> + </author> + <link href="http://servers.api.openstack.org/v1.1/" rel="self"/> + <entry> + <id>http://servers.api.openstack.org/v1.1/</id> + <title type="text">Version v1.1</title> + <updated>2011-01-21T11:33:21Z</updated> + <link href="http://servers.api.openstack.org/v1.1/" rel="self"/> + <link href="http://docs.rackspacecloud.com/servers/ + api/v1.1/cs-devguide-20110125.pdf" + rel="describedby" type="application/pdf"/> + <link href="http://docs.rackspacecloud.com/servers/ + api/v1.1/application.wadl" + rel="describedby" type="application/vnd.sun.wadl+xml"/> + <content type="text"> + Version v1.1 CURRENT (2011-01-21T11:33:21Z) + </content> + </entry> + </feed>""".replace(" ", "").replace("\n", "") actual = res.body.replace(" ", "").replace("\n", "") self.assertEqual(expected, actual) @@ -621,7 +619,6 @@ class VersionsTest(test.TestCase): #self.assertEqual(val, media_node.get(key)) def test_version_detail_atom_serializer(self): - #TODO versions_data = { "version" : { "id": "v1.1", |
