From 2d785404eda907ea39fe6928491d87bff49bcd94 Mon Sep 17 00:00:00 2001 From: Christopher MacGown Date: Sun, 7 Aug 2011 10:59:11 -0700 Subject: [PATCH] pep8 cleanups after the rebase --- novaclient/client.py | 4 ++-- tests/v1_1/test_auth.py | 29 ++++++++++++++++------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/novaclient/client.py b/novaclient/client.py index e745e497d..e04c323e8 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -134,7 +134,7 @@ class HTTPClient(httplib2.Http): self.version = part break - if not self.version == "v2.0": #FIXME(chris): This should be better. + if not self.version == "v2.0": # FIXME(chris): This should be better. headers = {'X-Auth-User': self.user, 'X-Auth-Key': self.apikey} if self.projectid: @@ -158,7 +158,7 @@ class HTTPClient(httplib2.Http): ["nova"][0]["publicURL"] self.auth_token = body["auth"]["token"]["id"] - #TODO(chris): Implement service_catalog + #TODO(chris): Implement service_catalog self.service_catalog = None def _munge_get_url(self, url): diff --git a/tests/v1_1/test_auth.py b/tests/v1_1/test_auth.py index 9f3d8ab07..a9a55629c 100644 --- a/tests/v1_1/test_auth.py +++ b/tests/v1_1/test_auth.py @@ -12,27 +12,30 @@ from tests import utils class AuthenticateAgainstKeystoneTests(utils.TestCase): def test_authenticate_success(self): cs = client.Client("username", "apikey", "project_id", "auth_url/v2.0") - resp = {"auth": {"token": {"expires": "12345", "id": "FAKE_ID"}, - "serviceCatalog": { - "nova": [{"adminURL": "http://localhost:8774/v1.1", - "region": "RegionOne", - "internalURL": "http://localhost:8774/v1.1", - "publicURL": "http://localhost:8774/v1.1/"}]}}} + resp = {"auth": + {"token": {"expires": "12345", "id": "FAKE_ID"}, + "serviceCatalog": { + "nova": [ + {"adminURL": "http://localhost:8774/v1.1", + "region": "RegionOne", + "internalURL": "http://localhost:8774/v1.1", + "publicURL": "http://localhost:8774/v1.1/"}]}}} auth_response = httplib2.Response({ - "status": 204, + "status": 204, "body": json.dumps(resp), }) - mock_request = mock.Mock(return_value=(auth_response, json.dumps(resp))) + mock_request = mock.Mock(return_value=(auth_response, + json.dumps(resp))) @mock.patch.object(httplib2.Http, "request", mock_request) def test_auth_call(): cs.client.authenticate() headers = {'User-Agent': cs.client.USER_AGENT, - 'Content-Type': 'application/json',} + 'Content-Type': 'application/json', } body = {'passwordCredentials': {'username': cs.client.user, 'password': cs.client.apikey, - 'tenantId': cs.client.projectid,}} + 'tenantId': cs.client.projectid, }} token_url = urlparse.urljoin(cs.client.auth_url, "tokens") mock_request.assert_called_with(token_url, "POST", @@ -40,12 +43,11 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): body=json.dumps(body)) self.assertEqual(cs.client.management_url, - resp["auth"]["serviceCatalog"]["nova"][0]["publicURL"]) + resp["auth"]["serviceCatalog"]["nova"][0]["publicURL"]) self.assertEqual(cs.client.auth_token, resp["auth"]["token"]["id"]) test_auth_call() - def test_authenticate_failure(self): cs = client.Client("username", "apikey", "project_id", "auth_url/v2.0") resp = {"unauthorized": {"message": "Unauthorized", "code": "401"}} @@ -54,7 +56,8 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): "body": json.dumps(resp), }) - mock_request = mock.Mock(return_value=(auth_response, json.dumps(resp))) + mock_request = mock.Mock(return_value=(auth_response, + json.dumps(resp))) @mock.patch.object(httplib2.Http, "request", mock_request) def test_auth_call():