summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wolf <throughnothing@gmail.com>2011-07-26 18:10:36 -0400
committerWilliam Wolf <throughnothing@gmail.com>2011-07-26 18:10:36 -0400
commit6dbd7583f4f1ca4be59e163c4c568423a91cd29e (patch)
treeb987e41204b437811f97132e603fd7c253f61495
parente14754bbdbacaf6943c4061e3488f2580acd26ad (diff)
pep8 fixes
-rw-r--r--nova/api/openstack/__init__.py4
-rw-r--r--nova/api/openstack/versions.py31
-rw-r--r--nova/tests/api/openstack/test_versions.py52
3 files changed, 41 insertions, 46 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index 0dfad0ef6..96a2f20e0 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -116,8 +116,8 @@ class APIRouter(base_wsgi.Router):
'select': 'POST',
'boot': 'POST'})
- mapper.connect("versions", "/",
- controller=versions.create_resource(version),
+ mapper.connect("versions", "/",
+ controller=versions.create_resource(version),
action='show')
mapper.resource("console", "consoles",
diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/versions.py
index 4b567957d..58c767d5c 100644
--- a/nova/api/openstack/versions.py
+++ b/nova/api/openstack/versions.py
@@ -25,12 +25,12 @@ from nova.api.openstack import wsgi
ATOM_XMLNS = "http://www.w3.org/2005/Atom"
-VERSIONS = {
+VERSIONS = {
"v1.0": {
- "version" : {
+ "version" : {
"id": "v1.0",
"status": "DEPRECATED",
- "updated": "2011-01-21T11:33:21Z",
+ "updated": "2011-01-21T11:33:21Z",
"links": [
{
"rel": "self",
@@ -41,7 +41,7 @@ VERSIONS = {
"type": "application/pdf",
"href": "http://docs.rackspacecloud.com/"
"servers/api/v1.0/cs-devguide-20110125.pdf"
- },
+ },
{
"rel": "describedby",
"type": "application/vnd.sun.wadl+xml",
@@ -62,7 +62,7 @@ VERSIONS = {
},
},
"v1.1": {
- "version" : {
+ "version" : {
"id": "v1.1",
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
@@ -76,7 +76,7 @@ VERSIONS = {
"type": "application/pdf",
"href": "http://docs.rackspacecloud.com/"
"servers/api/v1.1/cs-devguide-20110125.pdf"
- },
+ },
{
"rel": "describedby",
"type": "application/vnd.sun.wadl+xml",
@@ -99,8 +99,6 @@ VERSIONS = {
}
-
-
class Versions(wsgi.Resource):
@classmethod
def factory(cls, global_config, **local_config):
@@ -192,7 +190,7 @@ class Versions(wsgi.Resource):
builder = nova.api.openstack.views.versions.get_view_builder(request)
choices = [
- builder.build_choices(version, request)
+ builder.build_choices(version, request)
for version in version_objs]
return dict(choices=choices)
@@ -207,6 +205,7 @@ class VersionV11(object):
def show(self, req):
return VERSIONS['v1.1']
+
class VersionsRequestDeserializer(wsgi.RequestDeserializer):
def get_action_args(self, request_environment):
"""Parse dictionary created by routes library."""
@@ -220,8 +219,8 @@ class VersionsRequestDeserializer(wsgi.RequestDeserializer):
class VersionsXMLSerializer(wsgi.XMLDictSerializer):
- #TODO(wwolf): this is temporary until we get rid of toprettyxml
- # in the base class (XMLDictSerializer), which I plan to do in
+ #TODO(wwolf): this is temporary until we get rid of toprettyxml
+ # in the base class (XMLDictSerializer), which I plan to do in
# another branch
def to_xml_string(self, node, has_atom=False):
self._add_xmlns(node, has_atom)
@@ -244,7 +243,7 @@ class VersionsXMLSerializer(wsgi.XMLDictSerializer):
base.appendChild(node)
return base
-
+
def _create_version_node(self, version, create_ns=False):
version_node = self._xml_doc.createElement('version')
if create_ns:
@@ -278,7 +277,7 @@ class VersionsXMLSerializer(wsgi.XMLDictSerializer):
return self.to_xml_string(node)
- def show(self,data):
+ def show(self, data):
self._xml_doc = minidom.Document()
node = self._create_version_node(data['version'], True)
@@ -292,8 +291,8 @@ class VersionsXMLSerializer(wsgi.XMLDictSerializer):
class VersionsAtomSerializer(wsgi.XMLDictSerializer):
- #TODO(wwolf): this is temporary until we get rid of toprettyxml
- # in the base class (XMLDictSerializer), which I plan to do in
+ #TODO(wwolf): this is temporary until we get rid of toprettyxml
+ # in the base class (XMLDictSerializer), which I plan to do in
# another branch
def to_xml_string(self, node, has_atom=False):
self._add_xmlns(node, has_atom)
@@ -455,7 +454,5 @@ def create_resource(version='1.0'):
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 f33ef5e6a..587b085c3 100644
--- a/nova/tests/api/openstack/test_versions.py
+++ b/nova/tests/api/openstack/test_versions.py
@@ -35,7 +35,6 @@ class VersionsTest(test.TestCase):
self.stubs = stubout.StubOutForTesting()
fakes.stub_out_auth(self.stubs)
-
def tearDown(self):
super(VersionsTest, self).tearDown()
@@ -182,12 +181,11 @@ class VersionsTest(test.TestCase):
for media_node in media_type_nodes:
self.assertEqual(media_node.tag.split('}')[1], 'media-type')
-
expected = """
- <version id="v1.0" status="DEPRECATED"
- updated="2011-01-21T11:33:21Z"
- xmlns="http://docs.openstack.org/common/api/v1.0"
- xmlns:atom="http://www.w3.org/2005/Atom">
+ <version id="v1.0" status="DEPRECATED"
+ 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"
@@ -206,8 +204,8 @@ class VersionsTest(test.TestCase):
<atom:link href="http://docs.rackspacecloud.com/servers/
api/v1.0/application.wadl"
- rel="describedby"
- type="application/vnd.sun.wadl+xml"/>
+ rel="describedby"
+ type="application/vnd.sun.wadl+xml"/>
</version>""".replace(" ", "").replace("\n", "")
actual = res.body.replace(" ", "").replace("\n", "")
@@ -220,10 +218,10 @@ class VersionsTest(test.TestCase):
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/xml")
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">
+ <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"
@@ -242,8 +240,8 @@ class VersionsTest(test.TestCase):
<atom:link href="http://docs.rackspacecloud.com/servers/
api/v1.1/application.wadl"
- rel="describedby"
- type="application/vnd.sun.wadl+xml"/>
+ rel="describedby"
+ type="application/vnd.sun.wadl+xml"/>
</version>""".replace(" ", "").replace("\n", "")
actual = res.body.replace(" ", "").replace("\n", "")
@@ -290,7 +288,8 @@ class VersionsTest(test.TestCase):
<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://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"/>
@@ -326,7 +325,8 @@ class VersionsTest(test.TestCase):
<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://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"/>
@@ -407,13 +407,13 @@ class VersionsTest(test.TestCase):
{
"base": "application/xml",
"type": "application/vnd.openstack.compute-v1.1+xml"
- },
+ },
{
"base": "application/json",
"type": "application/vnd.openstack.compute-v1.1+json"
},
],
- },
+ },
{
"id": "v1.0",
"status": "DEPRECATED",
@@ -432,13 +432,12 @@ class VersionsTest(test.TestCase):
"base": "application/json",
"type": "application/vnd.openstack.compute-v1.0+json"
},
- ],
+ ],
},
- ],}
+ ], }
self.assertDictMatch(expected, json.loads(res.body))
-
def test_view_builder(self):
base_url = "http://example.org/"
@@ -507,10 +506,10 @@ class VersionsTest(test.TestCase):
def test_version_detail_xml_serializer(self):
version_data = {
- "version" : {
+ "version" : {
"id": "v1.0",
"status": "CURRENT",
- "updated": "2011-01-21T11:33:21Z",
+ "updated": "2011-01-21T11:33:21Z",
"links": [
{
"rel": "self",
@@ -521,7 +520,7 @@ class VersionsTest(test.TestCase):
"type": "application/pdf",
"href": "http://docs.rackspacecloud.com/"
"servers/api/v1.0/cs-devguide-20110125.pdf"
- },
+ },
{
"rel": "describedby",
"type": "application/vnd.sun.wadl+xml",
@@ -568,7 +567,6 @@ class VersionsTest(test.TestCase):
for key, val in version_data['version']['links'][i].items():
self.assertEqual(val, link.get(key))
-
def test_versions_list_atom_serializer(self):
versions_data = {
'versions': [
@@ -644,7 +642,7 @@ class VersionsTest(test.TestCase):
def test_version_detail_atom_serializer(self):
versions_data = {
- "version" : {
+ "version" : {
"id": "v1.1",
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
@@ -658,7 +656,7 @@ class VersionsTest(test.TestCase):
"type": "application/pdf",
"href": "http://docs.rackspacecloud.com/"
"servers/api/v1.1/cs-devguide-20110125.pdf"
- },
+ },
{
"rel": "describedby",
"type": "application/vnd.sun.wadl+xml",