diff options
| author | William Wolf <throughnothing@gmail.com> | 2011-07-27 14:35:47 -0400 |
|---|---|---|
| committer | William Wolf <throughnothing@gmail.com> | 2011-07-27 14:35:47 -0400 |
| commit | c20a4845afc47d124017de698657c1713dc11e7f (patch) | |
| tree | 9f4125b85026adf1b710796b2ab88947b12b36a0 | |
| parent | 22beaf8802fdc44242f4a96e291c4fbb60af0e3a (diff) | |
fixed xmlns issue
| -rw-r--r-- | nova/api/openstack/versions.py | 8 | ||||
| -rw-r--r-- | nova/tests/api/openstack/test_versions.py | 17 |
2 files changed, 11 insertions, 14 deletions
diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/versions.py index e063ff272..b38c48939 100644 --- a/nova/api/openstack/versions.py +++ b/nova/api/openstack/versions.py @@ -25,7 +25,7 @@ from nova.api.openstack import wsgi ATOM_XMLNS = "http://www.w3.org/2005/Atom" -OS_XMLNS_BASE = "http://docs.openstack.org/common/api/" +OS_XMLNS_BASE = "http://docs.openstack.org/common/api/v1.0" VERSIONS = { "v1.0": { "version": { @@ -235,7 +235,7 @@ class VersionsXMLSerializer(wsgi.XMLDictSerializer): def _versions_to_xml(self, versions, name="versions", xmlns=None): root = self._xml_doc.createElement(name) - root.setAttribute("xmlns", "%sv1.0" % OS_XMLNS_BASE) + root.setAttribute("xmlns", OS_XMLNS_BASE) root.setAttribute("xmlns:atom", ATOM_XMLNS) for version in versions: @@ -256,7 +256,7 @@ class VersionsXMLSerializer(wsgi.XMLDictSerializer): def _create_version_node(self, version, create_ns=False): version_node = self._xml_doc.createElement('version') if create_ns: - xmlns = "%s%s" % (OS_XMLNS_BASE, version['id']) + xmlns = OS_XMLNS_BASE xmlns_atom = "http://www.w3.org/2005/Atom" version_node.setAttribute('xmlns', xmlns) version_node.setAttribute('xmlns:atom', xmlns_atom) @@ -296,7 +296,7 @@ class VersionsXMLSerializer(wsgi.XMLDictSerializer): def multi(self, data): self._xml_doc = minidom.Document() node = self._versions_to_xml(data['choices'], 'choices', - xmlns="%sv1.0" % OS_XMLNS_BASE) + xmlns=OS_XMLNS_BASE) return self.to_xml_string(node) diff --git a/nova/tests/api/openstack/test_versions.py b/nova/tests/api/openstack/test_versions.py index 3f7867ff4..bc9000900 100644 --- a/nova/tests/api/openstack/test_versions.py +++ b/nova/tests/api/openstack/test_versions.py @@ -173,8 +173,7 @@ class VersionsTest(test.TestCase): self.assertEqual(res.content_type, "application/xml") root = xml.etree.ElementTree.XML(res.body) self.assertEqual(root.tag.split('}')[1], "version") - self.assertEqual(root.tag.split('}')[0].strip('{'), - "%sv1.0" % OS_XMLNS_BASE) + self.assertEqual(root.tag.split('}')[0].strip('{'), OS_XMLNS_BASE) children = list(root) media_types = children[0] @@ -188,7 +187,7 @@ class VersionsTest(test.TestCase): expected = """ <version id="v1.0" status="DEPRECATED" updated="2011-01-21T11:33:21Z" - xmlns="%sv1.0" + xmlns="%s" xmlns:atom="http://www.w3.org/2005/Atom"> <media-types> @@ -224,7 +223,7 @@ class VersionsTest(test.TestCase): expected = """ <version id="v1.1" status="CURRENT" updated="2011-01-21T11:33:21Z" - xmlns="%sv1.1" + xmlns="%s" xmlns:atom="http://www.w3.org/2005/Atom"> <media-types> @@ -259,7 +258,7 @@ class VersionsTest(test.TestCase): self.assertEqual(res.content_type, "application/xml") expected = """ - <versions xmlns="%sv1.0" xmlns:atom="%s"> + <versions xmlns="%s" xmlns:atom="%s"> <version id="v1.1" status="CURRENT" updated="2011-07-18T11:30:00Z"> <atom:link href="http://localhost/v1.1/" rel="self"/> </version> @@ -451,7 +450,7 @@ class VersionsTest(test.TestCase): self.assertEqual(res.content_type, "application/xml") expected = """ - <choices xmlns="%sv1.0" xmlns:atom="%s"> + <choices xmlns="%s" xmlns:atom="%s"> <version id="v1.1" status="CURRENT"> <media-types> <media-type base="application/xml" @@ -584,8 +583,7 @@ class VersionsTest(test.TestCase): root = xml.etree.ElementTree.XML(response) self.assertEqual(root.tag.split('}')[1], "versions") - self.assertEqual(root.tag.split('}')[0].strip('{'), - "%sv1.0" % OS_XMLNS_BASE) + self.assertEqual(root.tag.split('}')[0].strip('{'), OS_XMLNS_BASE) version = list(root)[0] self.assertEqual(version.tag.split('}')[1], "version") self.assertEqual(version.get('id'), @@ -623,8 +621,7 @@ class VersionsTest(test.TestCase): root = xml.etree.ElementTree.XML(response) self.assertEqual(root.tag.split('}')[1], "choices") - self.assertEqual(root.tag.split('}')[0].strip('{'), - "%sv1.0" % OS_XMLNS_BASE) + self.assertEqual(root.tag.split('}')[0].strip('{'), OS_XMLNS_BASE) version = list(root)[0] self.assertEqual(version.tag.split('}')[1], "version") self.assertEqual(version.get('id'), versions_data['choices'][0]['id']) |
