diff options
author | Joe Heck <heckj@mac.com> | 2012-06-01 18:07:26 -0700 |
---|---|---|
committer | Joe Heck <heckj@mac.com> | 2012-06-01 18:07:26 -0700 |
commit | 52b392281ef301c4ee85ae071ec8e26facdcbbdc (patch) | |
tree | e8d130985996627314e457dbd637157c34a1600d /tests/v2_0 | |
parent | aa9761433065a260dc2b571deb10957347a76d4e (diff) | |
download | python-keystoneclient-52b392281ef301c4ee85ae071ec8e26facdcbbdc.tar.gz |
pep8 1.1 changes and updates
Change-Id: I8bc3582bb3f35a3d841bb1e8c03b62ba61ff92d7
Diffstat (limited to 'tests/v2_0')
-rw-r--r-- | tests/v2_0/test_auth.py | 60 | ||||
-rw-r--r-- | tests/v2_0/test_discovery.py | 55 | ||||
-rw-r--r-- | tests/v2_0/test_ec2.py | 34 | ||||
-rw-r--r-- | tests/v2_0/test_endpoints.py | 28 | ||||
-rw-r--r-- | tests/v2_0/test_roles.py | 60 | ||||
-rw-r--r-- | tests/v2_0/test_services.py | 40 | ||||
-rw-r--r-- | tests/v2_0/test_tenants.py | 84 | ||||
-rw-r--r-- | tests/v2_0/test_tokens.py | 16 | ||||
-rw-r--r-- | tests/v2_0/test_users.py | 52 |
9 files changed, 215 insertions, 214 deletions
diff --git a/tests/v2_0/test_auth.py b/tests/v2_0/test_auth.py index 8dc4c11..62bbf10 100644 --- a/tests/v2_0/test_auth.py +++ b/tests/v2_0/test_auth.py @@ -28,27 +28,27 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): "id": self.TEST_TOKEN, "tenant": { "id": self.TEST_TENANT_ID - }, }, + }, "user": { "id": self.TEST_USER - }, - "serviceCatalog": self.TEST_SERVICE_CATALOG, }, - } + "serviceCatalog": self.TEST_SERVICE_CATALOG, + }, + } self.TEST_REQUEST_BODY = { "auth": { "passwordCredentials": { "username": self.TEST_USER, "password": self.TEST_TOKEN, - }, - "tenantId": self.TEST_TENANT_ID, }, - } + "tenantId": self.TEST_TENANT_ID, + }, + } self.TEST_REQUEST_HEADERS = { 'Content-Type': 'application/json', 'User-Agent': 'python-keystoneclient', - } + } def test_authenticate_failure(self): _auth = 'auth' @@ -61,21 +61,21 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): "unauthorized": { "message": "Unauthorized", "code": "401", - }, - }), - }) + }, + }), + }) # Implicit retry on API calls, so it gets called twice httplib2.Http.request(self.TEST_URL + "/tokens", 'POST', body=json.dumps(self.TEST_REQUEST_BODY), headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) httplib2.Http.request(self.TEST_URL + "/tokens", 'POST', body=json.dumps(self.TEST_REQUEST_BODY), headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() # Workaround for issue with assertRaises on python2.6 @@ -95,16 +95,16 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): { "headers": { 'location': self.TEST_ADMIN_URL + "/tokens", - }, + }, "status": 305, "body": "Use proxy", - }, + }, { "headers": {}, "status": 200, "body": correct_response, - }, - ] + }, + ] responses = [(to_http_response(resp), resp['body']) for resp in dict_responses] @@ -112,12 +112,12 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): 'POST', body=json.dumps(self.TEST_REQUEST_BODY), headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn(responses[0]) + .AndReturn(responses[0]) httplib2.Http.request(self.TEST_ADMIN_URL + "/tokens", 'POST', body=json.dumps(self.TEST_REQUEST_BODY), headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn(responses[1]) + .AndReturn(responses[1]) self.mox.ReplayAll() cs = client.Client(username=self.TEST_USER, @@ -127,7 +127,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): self.assertEqual(cs.management_url, self.TEST_RESPONSE_DICT["access"]["serviceCatalog"][3] - ['endpoints'][0]["adminURL"]) + ['endpoints'][0]["adminURL"]) self.assertEqual(cs.auth_token, self.TEST_RESPONSE_DICT["access"]["token"]["id"]) @@ -135,13 +135,13 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_RESPONSE_DICT), - }) + }) httplib2.Http.request(self.TEST_URL + "/tokens", 'POST', body=json.dumps(self.TEST_REQUEST_BODY), headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() cs = client.Client(username=self.TEST_USER, @@ -150,7 +150,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): auth_url=self.TEST_URL) self.assertEqual(cs.management_url, self.TEST_RESPONSE_DICT["access"]["serviceCatalog"][3] - ['endpoints'][0]["adminURL"]) + ['endpoints'][0]["adminURL"]) self.assertEqual(cs.auth_token, self.TEST_RESPONSE_DICT["access"]["token"]["id"]) @@ -160,13 +160,13 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_RESPONSE_DICT), - }) + }) httplib2.Http.request(self.TEST_URL + "/tokens", 'POST', body=json.dumps(self.TEST_REQUEST_BODY), headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() cs = client.Client(username=self.TEST_USER, @@ -183,13 +183,13 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_RESPONSE_DICT), - }) + }) httplib2.Http.request(self.TEST_URL + "/tokens", 'POST', body=json.dumps(self.TEST_REQUEST_BODY), headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() cs = client.Client(token=self.TEST_TOKEN, @@ -197,7 +197,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): auth_url=self.TEST_URL) self.assertEqual(cs.management_url, self.TEST_RESPONSE_DICT["access"]["serviceCatalog"][3] - ['endpoints'][0]["adminURL"]) + ['endpoints'][0]["adminURL"]) self.assertEqual(cs.auth_token, self.TEST_RESPONSE_DICT["access"]["token"]["id"]) @@ -210,13 +210,13 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_RESPONSE_DICT), - }) + }) httplib2.Http.request(self.TEST_URL + "/tokens", 'POST', body=json.dumps(self.TEST_REQUEST_BODY), headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() cs = client.Client(token=self.TEST_TOKEN, diff --git a/tests/v2_0/test_discovery.py b/tests/v2_0/test_discovery.py index 75a1be9..1e417c7 100644 --- a/tests/v2_0/test_discovery.py +++ b/tests/v2_0/test_discovery.py @@ -26,14 +26,14 @@ class DiscoverKeystoneTests(utils.UnauthenticatedTestCase): "id": "v2.0", "status": "beta", "updated": "2011-11-19T00:00:00Z", - "links": [{ - "rel": "self", - "href": "http://127.0.0.1:5000/v2.0/", - }, { - "rel": "describedby", - "type": "text/html", - "href": "http://docs.openstack.org/api/" - "openstack-identity-service/2.0/content/", + "links": [ + {"rel": "self", + "href": "http://127.0.0.1:5000/v2.0/", + }, + {"rel": "describedby", + "type": "text/html", + "href": "http://docs.openstack.org/api/" + "openstack-identity-service/2.0/content/", }, { "rel": "describedby", "type": "application/pdf", @@ -46,32 +46,31 @@ class DiscoverKeystoneTests(utils.UnauthenticatedTestCase): "href": "http://127.0.0.1:5000/v2.0/identity.wadl", }], "media-types": [{ - "base": "application/xml", - "type": "application/" - "vnd.openstack.identity-v2.0+xml", - }, { - "base": "application/json", - "type": "application/" - "vnd.openstack.identity-v2.0+json", - }], + "base": "application/xml", + "type": "application/vnd.openstack.identity-v2.0+xml", + }, + { + "base": "application/json", + "type": "application/vnd.openstack.identity-v2.0+json", }], - }, - } + }], + }, + } self.TEST_REQUEST_HEADERS = { 'User-Agent': 'python-keystoneclient', 'Accept': 'application/json', - } + } def test_get_versions(self): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_RESPONSE_DICT), - }) + }) httplib2.Http.request(self.TEST_ROOT_URL, 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() cs = client.Client() @@ -79,20 +78,21 @@ class DiscoverKeystoneTests(utils.UnauthenticatedTestCase): self.assertIsInstance(versions, dict) self.assertIn('message', versions) self.assertIn('v2.0', versions) - self.assertEquals(versions['v2.0']['url'], + self.assertEquals( + versions['v2.0']['url'], self.TEST_RESPONSE_DICT['versions']['values'][0]['links'][0] - ['href']) + ['href']) def test_get_version_local(self): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_RESPONSE_DICT), - }) + }) httplib2.Http.request("http://localhost:35357", 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() cs = client.Client() @@ -100,6 +100,7 @@ class DiscoverKeystoneTests(utils.UnauthenticatedTestCase): self.assertIsInstance(versions, dict) self.assertIn('message', versions) self.assertIn('v2.0', versions) - self.assertEquals(versions['v2.0']['url'], + self.assertEquals( + versions['v2.0']['url'], self.TEST_RESPONSE_DICT['versions']['values'][0]['links'][0] - ['href']) + ['href']) diff --git a/tests/v2_0/test_ec2.py b/tests/v2_0/test_ec2.py index e6917de..7a15291 100644 --- a/tests/v2_0/test_ec2.py +++ b/tests/v2_0/test_ec2.py @@ -13,19 +13,19 @@ class EC2Tests(utils.TestCase): self.TEST_REQUEST_HEADERS = { 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_POST_HEADERS = { 'Content-Type': 'application/json', 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } def test_create(self): user_id = 'usr' tenant_id = 'tnt' req_body = { "tenant_id": tenant_id, - } + } resp_body = { "credential": { "access": "access", @@ -33,12 +33,12 @@ class EC2Tests(utils.TestCase): "tenant_id": tenant_id, "created": "12/12/12", "enabled": True, - } } + } resp = httplib2.Response({ "status": 200, "body": json.dumps(resp_body), - }) + }) url = urlparse.urljoin(self.TEST_URL, 'v2.0/users/%s/credentials/OS-EC2' % user_id) @@ -46,7 +46,7 @@ class EC2Tests(utils.TestCase): 'POST', body=json.dumps(req_body), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() cred = self.client.ec2.create(user_id, tenant_id) @@ -66,12 +66,12 @@ class EC2Tests(utils.TestCase): "tenant_id": tenant_id, "created": "12/12/12", "enabled": True, - } } + } resp = httplib2.Response({ "status": 200, "body": json.dumps(resp_body), - }) + }) url = urlparse.urljoin(self.TEST_URL, 'v2.0/users/%s/credentials/OS-EC2/%s' % @@ -79,7 +79,7 @@ class EC2Tests(utils.TestCase): httplib2.Http.request(url, 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() cred = self.client.ec2.get(user_id, 'access') @@ -101,29 +101,29 @@ class EC2Tests(utils.TestCase): "tenant_id": tenant_id, "created": "12/12/12", "enabled": True, - }, + }, { "access": "another", "secret": "key", "tenant_id": tenant_id, "created": "12/12/31", "enabled": True, - } - ] - } + } + ] } + } resp = httplib2.Response({ "status": 200, "body": json.dumps(resp_body), - }) + }) url = urlparse.urljoin(self.TEST_URL, 'v2.0/users/%s/credentials/OS-EC2' % user_id) httplib2.Http.request(url, 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() creds = self.client.ec2.list(user_id) @@ -141,7 +141,7 @@ class EC2Tests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": "", - }) + }) url = urlparse.urljoin(self.TEST_URL, 'v2.0/users/%s/credentials/OS-EC2/%s' % @@ -149,7 +149,7 @@ class EC2Tests(utils.TestCase): httplib2.Http.request(url, 'DELETE', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() self.client.ec2.delete(user_id, access) diff --git a/tests/v2_0/test_endpoints.py b/tests/v2_0/test_endpoints.py index 0c071c3..7bd813d 100644 --- a/tests/v2_0/test_endpoints.py +++ b/tests/v2_0/test_endpoints.py @@ -13,12 +13,12 @@ class EndpointTests(utils.TestCase): self.TEST_REQUEST_HEADERS = { 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_POST_HEADERS = { 'Content-Type': 'application/json', 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_ENDPOINTS = { 'endpoints': [ { @@ -27,16 +27,16 @@ class EndpointTests(utils.TestCase): 'internalurl': 'http://host-1:8774/v1.1/$(tenant_id)s', 'publicurl': 'http://host-1:8774/v1.1/$(tenant_id)s', 'region': 'RegionOne', - }, + }, { 'adminurl': 'http://host-1:8774/v1.1/$(tenant_id)s', 'id': '8f9531231e044e218824b0e58688d263', 'internalurl': 'http://host-1:8774/v1.1/$(tenant_id)s', 'publicurl': 'http://host-1:8774/v1.1/$(tenant_id)s', 'region': 'RegionOne', - } - ] - } + } + ] + } def test_create(self): req_body = { @@ -46,8 +46,8 @@ class EndpointTests(utils.TestCase): "internalurl": "http://host-3:8774/v1.1/$(tenant_id)s", "adminurl": "http://host-3:8774/v1.1/$(tenant_id)s", "service_id": "e044e21", - } } + } resp_body = { "endpoint": { @@ -56,20 +56,20 @@ class EndpointTests(utils.TestCase): "id": "1fd485b2ffd54f409a5ecd42cba11401", "internalurl": "http://host-3:8774/v1.1/$(tenant_id)s", "publicurl": "http://host-3:8774/v1.1/$(tenant_id)s", - } } + } resp = httplib2.Response({ "status": 200, "body": json.dumps(resp_body), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/endpoints'), 'POST', body=json.dumps(req_body), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() endpoint = self.client.endpoints.create( @@ -85,12 +85,12 @@ class EndpointTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": "", - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/endpoints/8f953'), 'DELETE', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() self.client.endpoints.delete('8f953') @@ -99,13 +99,13 @@ class EndpointTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_ENDPOINTS), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/endpoints'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() endpoint_list = self.client.endpoints.list() diff --git a/tests/v2_0/test_roles.py b/tests/v2_0/test_roles.py index 558467a..0d14d0f 100644 --- a/tests/v2_0/test_roles.py +++ b/tests/v2_0/test_roles.py @@ -13,50 +13,50 @@ class RoleTests(utils.TestCase): self.TEST_REQUEST_HEADERS = { 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_POST_HEADERS = { 'Content-Type': 'application/json', 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_ROLES = { "roles": { "values": [ { "name": "admin", "id": 1, - }, + }, { "name": "member", "id": 2, - } - ], - }, - } + } + ], + }, + } def test_create(self): req_body = { "role": { "name": "sysadmin", - } } + } resp_body = { "role": { "name": "sysadmin", "id": 3, - } } + } resp = httplib2.Response({ "status": 200, "body": json.dumps(resp_body), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/roles'), 'POST', body=json.dumps(req_body), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() role = self.client.roles.create(req_body['role']['name']) @@ -68,12 +68,12 @@ class RoleTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": "", - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/roles/1'), 'DELETE', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() self.client.roles.delete(1) @@ -83,13 +83,13 @@ class RoleTests(utils.TestCase): "status": 200, "body": json.dumps({ 'role': self.TEST_ROLES['roles']['values'][0], - }), - }) + }), + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/roles/1'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() role = self.client.roles.get(1) @@ -101,13 +101,13 @@ class RoleTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_ROLES), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/roles'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() role_list = self.client.roles.list() @@ -117,13 +117,13 @@ class RoleTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_ROLES), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/foo/roles'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() role_list = self.client.roles.roles_for_user('foo') @@ -133,13 +133,13 @@ class RoleTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_ROLES), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/barrr/users/foo/roles'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() role_list = self.client.roles.roles_for_user('foo', 'barrr') @@ -149,14 +149,14 @@ class RoleTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps({}), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/foo/roles/OS-KSADM/barrr'), 'PUT', body='null', headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, None)) + .AndReturn((resp, None)) self.mox.ReplayAll() self.client.roles.add_user_role('foo', 'barrr') @@ -165,14 +165,14 @@ class RoleTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps({}), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/4/users/foo/roles/OS-KSADM/barrr'), 'PUT', body='null', headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, None)) + .AndReturn((resp, None)) self.mox.ReplayAll() self.client.roles.add_user_role('foo', 'barrr', '4') @@ -181,13 +181,13 @@ class RoleTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps({}), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/foo/roles/OS-KSADM/barrr'), 'DELETE', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, None)) + .AndReturn((resp, None)) self.mox.ReplayAll() self.client.roles.remove_user_role('foo', 'barrr') @@ -196,13 +196,13 @@ class RoleTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps({}), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/4/users/foo/roles/OS-KSADM/barrr'), 'DELETE', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, None)) + .AndReturn((resp, None)) self.mox.ReplayAll() self.client.roles.remove_user_role('foo', 'barrr', '4') diff --git a/tests/v2_0/test_services.py b/tests/v2_0/test_services.py index a9f4c0b..12de671 100644 --- a/tests/v2_0/test_services.py +++ b/tests/v2_0/test_services.py @@ -13,12 +13,12 @@ class ServiceTests(utils.TestCase): self.TEST_REQUEST_HEADERS = { 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_POST_HEADERS = { 'Content-Type': 'application/json', 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_SERVICES = { "OS-KSADM:services": { "values": [ @@ -27,16 +27,16 @@ class ServiceTests(utils.TestCase): "type": "compute", "description": "Nova-compatible service.", "id": 1 - }, + }, { "name": "keystone", "type": "identity", "description": "Keystone-compatible service.", "id": 2 - }, - ], - }, - } + }, + ], + }, + } def test_create(self): req_body = { @@ -44,33 +44,33 @@ class ServiceTests(utils.TestCase): "name": "swift", "type": "object-store", "description": "Swift-compatible service.", - } } + } resp_body = { "OS-KSADM:service": { "name": "swift", "type": "object-store", "description": "Swift-compatible service.", "id": 3, - } } + } resp = httplib2.Response({ "status": 200, "body": json.dumps(resp_body), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/services'), 'POST', body=json.dumps(req_body), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() service = self.client.services.create( - req_body['OS-KSADM:service']['name'], - req_body['OS-KSADM:service']['type'], - req_body['OS-KSADM:service']['description']) + req_body['OS-KSADM:service']['name'], + req_body['OS-KSADM:service']['type'], + req_body['OS-KSADM:service']['description']) self.assertTrue(isinstance(service, services.Service)) self.assertEqual(service.id, 3) self.assertEqual(service.name, req_body['OS-KSADM:service']['name']) @@ -79,12 +79,12 @@ class ServiceTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": "", - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/services/1'), 'DELETE', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() self.client.services.delete(1) @@ -94,12 +94,12 @@ class ServiceTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps({'OS-KSADM:service': test_services}), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/services/1'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() service = self.client.services.get(1) @@ -112,13 +112,13 @@ class ServiceTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_SERVICES), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/OS-KSADM/services'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() service_list = self.client.services.list() diff --git a/tests/v2_0/test_tenants.py b/tests/v2_0/test_tenants.py index 0c573da..bb07f66 100644 --- a/tests/v2_0/test_tenants.py +++ b/tests/v2_0/test_tenants.py @@ -13,12 +13,12 @@ class TenantTests(utils.TestCase): self.TEST_REQUEST_HEADERS = { 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_POST_HEADERS = { 'Content-Type': 'application/json', 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_TENANTS = { "tenants": { "values": [ @@ -27,20 +27,20 @@ class TenantTests(utils.TestCase): "description": "A description change!", "name": "invisible_to_admin", "id": 3, - }, + }, { "enabled": True, "description": "None", "name": "demo", "id": 2, - }, + }, { "enabled": True, "description": "None", "name": "admin", "id": 1, - } - ], + } + ], "links": [], }, } @@ -51,26 +51,26 @@ class TenantTests(utils.TestCase): "name": "tenantX", "description": "Like tenant 9, but better.", "enabled": True - }, - } + }, + } resp_body = { "tenant": { "name": "tenantX", "enabled": True, "id": 4, "description": "Like tenant 9, but better.", - } } + } resp = httplib2.Response({ "status": 200, "body": json.dumps(resp_body), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants'), 'POST', body=json.dumps(req_body), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() tenant = self.client.tenants.create(req_body['tenant']['name'], @@ -85,12 +85,12 @@ class TenantTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": "", - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/1'), 'DELETE', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() self.client.tenants.delete(1) @@ -100,13 +100,13 @@ class TenantTests(utils.TestCase): "status": 200, "body": json.dumps({ 'tenant': self.TEST_TENANTS['tenants']['values'][2], - }), - }) + }), + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/1'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() t = self.client.tenants.get(1) @@ -118,13 +118,13 @@ class TenantTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_TENANTS), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() tenant_list = self.client.tenants.list() @@ -134,13 +134,13 @@ class TenantTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_TENANTS), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants?limit=1'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() tenant_list = self.client.tenants.list(limit=1) @@ -150,13 +150,13 @@ class TenantTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_TENANTS), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants?marker=1'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() tenant_list = self.client.tenants.list(marker=1) @@ -166,13 +166,13 @@ class TenantTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_TENANTS), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants?marker=1&limit=1'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() tenant_list = self.client.tenants.list(limit=1, marker=1) @@ -185,27 +185,27 @@ class TenantTests(utils.TestCase): "name": "tenantX", "description": "I changed you!", "enabled": False, - }, - } + }, + } resp_body = { "tenant": { "name": "tenantX", "enabled": False, "id": 4, "description": "I changed you!", - }, - } + }, + } resp = httplib2.Response({ "status": 200, "body": json.dumps(resp_body), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/4'), 'POST', body=json.dumps(req_body), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() tenant = self.client.tenants.update(req_body['tenant']['id'], @@ -222,14 +222,14 @@ class TenantTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps({}), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/4/users/foo/roles/OS-KSADM/barrr'), 'PUT', body='null', headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, None)) + .AndReturn((resp, None)) self.mox.ReplayAll() self.client.tenants.add_user('4', 'foo', 'barrr') @@ -238,13 +238,13 @@ class TenantTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps({}), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/4/users/foo/roles/OS-KSADM/barrr'), 'DELETE', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, None)) + .AndReturn((resp, None)) self.mox.ReplayAll() self.client.tenants.remove_user('4', 'foo', 'barrr') @@ -256,19 +256,19 @@ class TenantTests(utils.TestCase): "name": "tenantX", "description": "I changed you!", "enabled": False, - }, - } + }, + } resp = httplib2.Response({ "status": 200, "body": json.dumps({}), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/4/users/foo/roles/OS-KSADM/barrr'), 'PUT', body='null', headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, None)) + .AndReturn((resp, None)) self.mox.ReplayAll() # make tenant object with manager @@ -284,18 +284,18 @@ class TenantTests(utils.TestCase): "name": "tenantX", "description": "I changed you!", "enabled": False, - }, - } + }, + } resp = httplib2.Response({ "status": 200, "body": json.dumps({}), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/tenants/4/users/foo/roles/OS-KSADM/barrr'), 'DELETE', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, None)) + .AndReturn((resp, None)) self.mox.ReplayAll() # make tenant object with manager diff --git a/tests/v2_0/test_tokens.py b/tests/v2_0/test_tokens.py index a8abc95..4bd5ae2 100644 --- a/tests/v2_0/test_tokens.py +++ b/tests/v2_0/test_tokens.py @@ -9,12 +9,12 @@ class TokenTests(utils.TestCase): def setUp(self): super(TokenTests, self).setUp() self.TEST_REQUEST_HEADERS = { - 'X-Auth-Token': 'aToken', - 'User-Agent': 'python-keystoneclient'} + 'X-Auth-Token': 'aToken', + 'User-Agent': 'python-keystoneclient'} self.TEST_POST_HEADERS = { - 'Content-Type': 'application/json', - 'X-Auth-Token': 'aToken', - 'User-Agent': 'python-keystoneclient'} + 'Content-Type': 'application/json', + 'X-Auth-Token': 'aToken', + 'User-Agent': 'python-keystoneclient'} def test_delete(self): resp = httplib2.Response({ @@ -22,9 +22,9 @@ class TokenTests(utils.TestCase): "body": ""}) req = httplib2.Http.request( - urlparse.urljoin(self.TEST_URL, 'v2.0/tokens/1'), - 'DELETE', - headers=self.TEST_REQUEST_HEADERS) + urlparse.urljoin(self.TEST_URL, 'v2.0/tokens/1'), + 'DELETE', + headers=self.TEST_REQUEST_HEADERS) req.AndReturn((resp, resp['body'])) self.mox.ReplayAll() diff --git a/tests/v2_0/test_users.py b/tests/v2_0/test_users.py index d894b92..e9c9b47 100644 --- a/tests/v2_0/test_users.py +++ b/tests/v2_0/test_users.py @@ -13,12 +13,12 @@ class UserTests(utils.TestCase): self.TEST_REQUEST_HEADERS = { 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_POST_HEADERS = { 'Content-Type': 'application/json', 'X-Auth-Token': 'aToken', 'User-Agent': 'python-keystoneclient', - } + } self.TEST_USERS = { "users": { "values": [ @@ -27,16 +27,16 @@ class UserTests(utils.TestCase): "enabled": True, "id": 1, "name": "admin", - }, + }, { "email": "None", "enabled": True, "id": 2, "name": "demo", - }, - ] - } + }, + ] } + } def test_create(self): req_body = { @@ -46,8 +46,8 @@ class UserTests(utils.TestCase): "tenantId": 2, "email": "test@example.com", "enabled": True, - } } + } resp_body = { "user": { "name": "gabriel", @@ -56,18 +56,18 @@ class UserTests(utils.TestCase): "id": 3, "password": "test", "email": "test@example.com", - } } + } resp = httplib2.Response({ "status": 200, "body": json.dumps(resp_body), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users'), 'POST', body=json.dumps(req_body), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() user = self.client.users.create(req_body['user']['name'], @@ -84,11 +84,11 @@ class UserTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": "", - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/1'), 'DELETE', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() self.client.users.delete(1) @@ -98,13 +98,13 @@ class UserTests(utils.TestCase): "status": 200, "body": json.dumps({ 'user': self.TEST_USERS['users']['values'][0], - }) }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/1'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() u = self.client.users.get(1) @@ -116,13 +116,13 @@ class UserTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_USERS), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() user_list = self.client.users.list() @@ -132,13 +132,13 @@ class UserTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_USERS), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users?limit=1'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() user_list = self.client.users.list(limit=1) @@ -148,13 +148,13 @@ class UserTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_USERS), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users?marker=1'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() user_list = self.client.users.list(marker=1) @@ -164,13 +164,13 @@ class UserTests(utils.TestCase): resp = httplib2.Response({ "status": 200, "body": json.dumps(self.TEST_USERS), - }) + }) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users?marker=1&limit=1'), 'GET', headers=self.TEST_REQUEST_HEADERS) \ - .AndReturn((resp, resp['body'])) + .AndReturn((resp, resp['body'])) self.mox.ReplayAll() user_list = self.client.users.list(limit=1, marker=1) @@ -193,25 +193,25 @@ class UserTests(utils.TestCase): 'PUT', body=json.dumps(req_2), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp_2, resp_2['body'])) + .AndReturn((resp_2, resp_2['body'])) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/2/OS-KSADM/password'), 'PUT', body=json.dumps(req_1), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp_1, resp_1['body'])) + .AndReturn((resp_1, resp_1['body'])) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/2/OS-KSADM/tenant'), 'PUT', body=json.dumps(req_3), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp_3, resp_3['body'])) + .AndReturn((resp_3, resp_3['body'])) httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/2/OS-KSADM/enabled'), 'PUT', body=json.dumps(req_4), headers=self.TEST_POST_HEADERS) \ - .AndReturn((resp_4, resp_4['body'])) + .AndReturn((resp_4, resp_4['body'])) self.mox.ReplayAll() user = self.client.users.update(2, |