summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Waldon <brian.waldon@rackspace.com>2011-03-30 15:06:46 +0000
committerTarmac <>2011-03-30 15:06:46 +0000
commiteaeaea0b5fb063124c04e05a30f9160890e8c4f9 (patch)
treee3a1599a0991af22c3ce690b7f4ab2140969b7c3
parent0e17f86bc315322d5221f2b6fec205bcb656c474 (diff)
parent343b969f7d790282b7b76bcb23b9d0d578d716b9 (diff)
downloadnova-eaeaea0b5fb063124c04e05a30f9160890e8c4f9.tar.gz
nova-eaeaea0b5fb063124c04e05a30f9160890e8c4f9.tar.xz
nova-eaeaea0b5fb063124c04e05a30f9160890e8c4f9.zip
Adding Content-Type code to openstack.api.versions.Versions wsgi.Application
-rw-r--r--nova/api/openstack/versions.py10
-rw-r--r--nova/tests/api/openstack/test_versions.py26
2 files changed, 34 insertions, 2 deletions
diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/versions.py
index 33f1dd628..3f9d91934 100644
--- a/nova/api/openstack/versions.py
+++ b/nova/api/openstack/versions.py
@@ -15,8 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import webob
import webob.dec
-import webob.exc
from nova import wsgi
import nova.api.openstack.views.versions
@@ -51,4 +51,10 @@ class Versions(wsgi.Application):
}
content_type = req.best_match_content_type()
- return wsgi.Serializer(metadata).serialize(response, content_type)
+ body = wsgi.Serializer(metadata).serialize(response, content_type)
+
+ response = webob.Response()
+ response.content_type = content_type
+ response.body = body
+
+ return response
diff --git a/nova/tests/api/openstack/test_versions.py b/nova/tests/api/openstack/test_versions.py
index ebb59a9a6..2640a4ddb 100644
--- a/nova/tests/api/openstack/test_versions.py
+++ b/nova/tests/api/openstack/test_versions.py
@@ -34,8 +34,10 @@ class VersionsTest(test.TestCase):
def test_get_version_list(self):
req = webob.Request.blank('/')
+ req.accept = "application/json"
res = req.get_response(fakes.wsgi_app())
self.assertEqual(res.status_int, 200)
+ self.assertEqual(res.content_type, "application/json")
versions = json.loads(res.body)["versions"]
expected = [
{
@@ -61,6 +63,30 @@ class VersionsTest(test.TestCase):
]
self.assertEqual(versions, expected)
+ def test_get_version_list_xml(self):
+ req = webob.Request.blank('/')
+ req.accept = "application/xml"
+ res = req.get_response(fakes.wsgi_app())
+ self.assertEqual(res.status_int, 200)
+ self.assertEqual(res.content_type, "application/xml")
+
+ expected = """<versions>
+ <version id="v1.1" status="CURRENT">
+ <links>
+ <link href="http://localhost/v1.1" rel="self"/>
+ </links>
+ </version>
+ <version id="v1.0" status="DEPRECATED">
+ <links>
+ <link href="http://localhost/v1.0" rel="self"/>
+ </links>
+ </version>
+ </versions>""".replace(" ", "").replace("\n", "")
+
+ actual = res.body.replace(" ", "").replace("\n", "")
+
+ self.assertEqual(expected, actual)
+
def test_view_builder(self):
base_url = "http://example.org/"