diff options
| author | William Wolf <throughnothing@gmail.com> | 2011-07-27 15:29:15 -0400 |
|---|---|---|
| committer | William Wolf <throughnothing@gmail.com> | 2011-07-27 15:29:15 -0400 |
| commit | 2ac60cd773bb25e19b50c082e0860b1c495d1527 (patch) | |
| tree | 2b71386fde2fc63e35016e058ccde707281435bb | |
| parent | c20a4845afc47d124017de698657c1713dc11e7f (diff) | |
update everything to use global VERSIONS
| -rw-r--r-- | nova/api/openstack/versions.py | 49 | ||||
| -rw-r--r-- | nova/tests/api/openstack/test_versions.py | 18 |
2 files changed, 26 insertions, 41 deletions
diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/versions.py index b38c48939..32ee64339 100644 --- a/nova/api/openstack/versions.py +++ b/nova/api/openstack/versions.py @@ -143,20 +143,14 @@ class Versions(wsgi.Resource): return self._versions_multi_choice(request) def _versions_list(self, request): - version_objs = [ - { - "id": "v1.1", - "status": "CURRENT", - #TODO(wwolf) get correct value for these - "updated": "2011-07-18T11:30:00Z", - }, - { - "id": "v1.0", - "status": "DEPRECATED", - #TODO(wwolf) get correct value for these - "updated": "2010-10-09T11:30:00Z", - }, - ] + version_objs = [] + for version in VERSIONS: + version = VERSIONS[version]['version'] + version_objs.append({ + "id": version['id'], + "status": version['status'], + "updated": version['updated'], + }) builder = nova.api.openstack.views.versions.get_view_builder(request) versions = [builder.build(version) for version in version_objs] @@ -164,28 +158,19 @@ class Versions(wsgi.Resource): def _versions_multi_choice(self, request): #TODO - version_objs = [ - { - "id": "v1.1", - "status": "CURRENT", + version_objs = [] + for version in VERSIONS: + version = VERSIONS[version]['version'] + version_objs.append({ + "id": version['id'], + "status": version['status'], "links": [ { - "rel": "self", + "rel": "self" } ], - "media-types": VERSIONS['v1.1']['version']['media-types'], - }, - { - "id": "v1.0", - "status": "DEPRECATED", - "links": [ - { - "rel": "self", - } - ], - "media-types": VERSIONS['v1.0']['version']['media-types'], - }, - ] + "media-types": version['media-types'] + }) builder = nova.api.openstack.views.versions.get_view_builder(request) choices = [ diff --git a/nova/tests/api/openstack/test_versions.py b/nova/tests/api/openstack/test_versions.py index bc9000900..f059b140d 100644 --- a/nova/tests/api/openstack/test_versions.py +++ b/nova/tests/api/openstack/test_versions.py @@ -53,7 +53,7 @@ class VersionsTest(test.TestCase): { "id": "v1.1", "status": "CURRENT", - "updated": "2011-07-18T11:30:00Z", + "updated": "2011-01-21T11:33:21Z", "links": [ { "rel": "self", @@ -63,7 +63,7 @@ class VersionsTest(test.TestCase): { "id": "v1.0", "status": "DEPRECATED", - "updated": "2010-10-09T11:30:00Z", + "updated": "2011-01-21T11:33:21Z", "links": [ { "rel": "self", @@ -259,11 +259,11 @@ class VersionsTest(test.TestCase): expected = """ <versions xmlns="%s" xmlns:atom="%s"> - <version id="v1.1" status="CURRENT" updated="2011-07-18T11:30:00Z"> + <version id="v1.1" status="CURRENT" updated="2011-01-21T11:33:21Z"> <atom:link href="http://localhost/v1.1/" rel="self"/> </version> <version id="v1.0" status="DEPRECATED" - updated="2010-10-09T11:30:00Z"> + updated="2011-01-21T11:33:21Z"> <atom:link href="http://localhost/v1.0/" rel="self"/> </version> </versions>""".replace(" ", "").replace("\n", "") % (OS_XMLNS_BASE, @@ -357,7 +357,7 @@ class VersionsTest(test.TestCase): expected = """ <feed xmlns="http://www.w3.org/2005/Atom"> <title type="text">Available API Versions</title> - <updated>2011-07-18T11:30:00Z</updated> + <updated>2011-01-21T11:33:21Z</updated> <id>http://localhost/</id> <author> <name>Rackspace</name> @@ -367,19 +367,19 @@ class VersionsTest(test.TestCase): <entry> <id>http://localhost/v1.1/</id> <title type="text">Version v1.1</title> - <updated>2011-07-18T11:30:00Z</updated> + <updated>2011-01-21T11:33:21Z</updated> <link href="http://localhost/v1.1/" rel="self"/> <content type="text"> - Version v1.1 CURRENT (2011-07-18T11:30:00Z) + Version v1.1 CURRENT (2011-01-21T11:33:21Z) </content> </entry> <entry> <id>http://localhost/v1.0/</id> <title type="text">Version v1.0</title> - <updated>2010-10-09T11:30:00Z</updated> + <updated>2011-01-21T11:33:21Z</updated> <link href="http://localhost/v1.0/" rel="self"/> <content type="text"> - Version v1.0 DEPRECATED (2010-10-09T11:30:00Z) + Version v1.0 DEPRECATED (2011-01-21T11:33:21Z) </content> </entry> </feed> |
