From c7221d046008f6bc980b6cb97f868e9ef8655070 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 4 Jan 2013 13:01:06 -0500 Subject: update version urls to working v2 urls the GET /v2/ API call is documented to return urls to both wadl and pdf documents. However our call returned non working urls to 1.1 versions of those documents. Fix this. Also fix the unit tests to actually test the output of versions. Previously we were over stubbing the test_verions.py so it was testing only itself, and not the output you'd actually get from the real versions.py module. Renamed the variables used for the expected variables to reduce confusion about what is an expected variable vs. the variables coming from versions.py to try to ensure we don't have cicular always passing tests in the future. Fixes bug #1076109 Change-Id: I1047b8c48ff053eed5ad4afa8eae5833f70d0893 --- nova/api/openstack/compute/versions.py | 4 +- nova/tests/api/openstack/compute/test_versions.py | 48 +++++++++++------------ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/nova/api/openstack/compute/versions.py b/nova/api/openstack/compute/versions.py index 76e37cf41..5c416908e 100644 --- a/nova/api/openstack/compute/versions.py +++ b/nova/api/openstack/compute/versions.py @@ -26,9 +26,9 @@ from nova.openstack.common import timeutils LINKS = { 'v2.0': { 'pdf': 'http://docs.openstack.org/' - 'api/openstack-compute/1.1/os-compute-devguide-1.1.pdf', + 'api/openstack-compute/2/os-compute-devguide-2.pdf', 'wadl': 'http://docs.openstack.org/' - 'api/openstack-compute/1.1/wadl/os-compute-1.1.wadl', + 'api/openstack-compute/2/wadl/os-compute-2.wadl' }, } diff --git a/nova/tests/api/openstack/compute/test_versions.py b/nova/tests/api/openstack/compute/test_versions.py index 16790860c..28b109215 100644 --- a/nova/tests/api/openstack/compute/test_versions.py +++ b/nova/tests/api/openstack/compute/test_versions.py @@ -37,17 +37,17 @@ NS = { } -LINKS = { +EXP_LINKS = { 'v2.0': { 'pdf': 'http://docs.openstack.org/' - 'api/openstack-compute/1.1/os-compute-devguide-1.1.pdf', + 'api/openstack-compute/2/os-compute-devguide-2.pdf', 'wadl': 'http://docs.openstack.org/' - 'api/openstack-compute/1.1/wadl/os-compute-1.1.wadl', + 'api/openstack-compute/2/wadl/os-compute-2.wadl', }, } -VERSIONS = { +EXP_VERSIONS = { "v2.0": { "id": "v2.0", "status": "CURRENT", @@ -56,12 +56,12 @@ VERSIONS = { { "rel": "describedby", "type": "application/pdf", - "href": LINKS['v2.0']['pdf'], + "href": EXP_LINKS['v2.0']['pdf'], }, { "rel": "describedby", "type": "application/vnd.sun.wadl+xml", - "href": LINKS['v2.0']['wadl'], + "href": EXP_LINKS['v2.0']['wadl'], }, ], "media-types": [ @@ -79,9 +79,6 @@ VERSIONS = { class VersionsTest(test.TestCase): - def setUp(self): - super(VersionsTest, self).setUp() - self.stubs.Set(versions, 'VERSIONS', VERSIONS) def test_get_version_list(self): req = webob.Request.blank('/') @@ -132,12 +129,12 @@ class VersionsTest(test.TestCase): { "rel": "describedby", "type": "application/pdf", - "href": LINKS['v2.0']['pdf'], + "href": EXP_LINKS['v2.0']['pdf'], }, { "rel": "describedby", "type": "application/vnd.sun.wadl+xml", - "href": LINKS['v2.0']['wadl'], + "href": EXP_LINKS['v2.0']['wadl'], }, ], "media-types": [ @@ -176,12 +173,12 @@ class VersionsTest(test.TestCase): { "rel": "describedby", "type": "application/pdf", - "href": LINKS['v2.0']['pdf'], + "href": EXP_LINKS['v2.0']['pdf'], }, { "rel": "describedby", "type": "application/vnd.sun.wadl+xml", - "href": LINKS['v2.0']['wadl'], + "href": EXP_LINKS['v2.0']['wadl'], }, ], "media-types": [ @@ -210,7 +207,7 @@ class VersionsTest(test.TestCase): version = etree.XML(res.body) xmlutil.validate_schema(version, 'version') - expected = VERSIONS['v2.0'] + expected = EXP_VERSIONS['v2.0'] self.assertTrue(version.xpath('/ns:version', namespaces=NS)) media_types = version.xpath('ns:media-types/ns:media-type', namespaces=NS) @@ -240,7 +237,7 @@ class VersionsTest(test.TestCase): for i, v in enumerate(['v2.0']): version = versions[i] - expected = VERSIONS[v] + expected = EXP_VERSIONS[v] for key in ['id', 'status', 'updated']: self.assertEqual(version.get(key), expected[key]) (link,) = version.xpath('atom:link', namespaces=NS) @@ -278,11 +275,11 @@ class VersionsTest(test.TestCase): self.assertEqual(entry.links[0]['href'], 'http://localhost/v2/') self.assertEqual(entry.links[0]['rel'], 'self') self.assertEqual(entry.links[1], { - 'href': LINKS['v2.0']['pdf'], + 'href': EXP_LINKS['v2.0']['pdf'], 'type': 'application/pdf', 'rel': 'describedby'}) self.assertEqual(entry.links[2], { - 'href': LINKS['v2.0']['wadl'], + 'href': EXP_LINKS['v2.0']['wadl'], 'type': 'application/vnd.sun.wadl+xml', 'rel': 'describedby'}) @@ -368,8 +365,11 @@ class VersionsTest(test.TestCase): self.assertEqual(version.get('status'), 'CURRENT') media_types = version.xpath('ns:media-types/ns:media-type', namespaces=NS) - self.assertTrue(common.compare_media_types(media_types, - VERSIONS['v2.0']['media-types'])) + self.assertTrue(common. + compare_media_types(media_types, + EXP_VERSIONS['v2.0']['media-types'] + )) + links = version.xpath('atom:link', namespaces=NS) self.assertTrue(common.compare_links(links, [{'rel': 'self', 'href': 'http://localhost/v2/images/1'}])) @@ -512,7 +512,7 @@ class VersionsSerializerTests(test.TestCase): "id": "2.7", "updated": "2011-07-18T11:30:00Z", "status": "DEPRECATED", - "media-types": VERSIONS['v2.0']['media-types'], + "media-types": EXP_VERSIONS['v2.0']['media-types'], "links": [ { "rel": "self", @@ -601,12 +601,12 @@ class VersionsSerializerTests(test.TestCase): { "rel": "describedby", "type": "application/pdf", - "href": LINKS['v2.0']['pdf'], + "href": EXP_LINKS['v2.0']['pdf'], }, { "rel": "describedby", "type": "application/vnd.sun.wadl+xml", - "href": LINKS['v2.0']['wadl'], + "href": EXP_LINKS['v2.0']['wadl'], }, ], "media-types": [ @@ -651,9 +651,9 @@ class VersionsSerializerTests(test.TestCase): self.assertEqual(entry.links[1], { 'rel': 'describedby', 'type': 'application/pdf', - 'href': LINKS['v2.0']['pdf']}) + 'href': EXP_LINKS['v2.0']['pdf']}) self.assertEqual(entry.links[2], { 'rel': 'describedby', 'type': 'application/vnd.sun.wadl+xml', - 'href': LINKS['v2.0']['wadl'], + 'href': EXP_LINKS['v2.0']['wadl'], }) -- cgit