Merge "Fixed httplib2 mocking (bug 1050091, bug 1050097)"
This commit is contained in:
		| @@ -91,7 +91,10 @@ class Manager(object): | ||||
|         methods = {"PUT": self.api.put, | ||||
|                    "POST": self.api.post} | ||||
|         try: | ||||
|             resp, body = methods[method](url, body=body) | ||||
|             if body is not None: | ||||
|                 resp, body = methods[method](url, body=body) | ||||
|             else: | ||||
|                 resp, body = methods[method](url) | ||||
|         except KeyError: | ||||
|             raise exceptions.ClientException("Invalid update method: %s" | ||||
|                                              % method) | ||||
|   | ||||
| @@ -139,7 +139,7 @@ class EC2Tests(utils.TestCase): | ||||
|         user_id = 'usr' | ||||
|         access = 'access' | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "status": 204, | ||||
|             "body": "", | ||||
|         }) | ||||
|  | ||||
|   | ||||
| @@ -83,7 +83,7 @@ class EndpointTests(utils.TestCase): | ||||
|  | ||||
|     def test_delete(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "status": 204, | ||||
|             "body": "", | ||||
|         }) | ||||
|         httplib2.Http.request(urlparse.urljoin(self.TEST_URL, | ||||
|   | ||||
| @@ -66,7 +66,7 @@ class RoleTests(utils.TestCase): | ||||
|  | ||||
|     def test_delete(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "status": 204, | ||||
|             "body": "", | ||||
|         }) | ||||
|         httplib2.Http.request(urlparse.urljoin(self.TEST_URL, | ||||
| @@ -147,62 +147,60 @@ class RoleTests(utils.TestCase): | ||||
|  | ||||
|     def test_add_user_role(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "body": json.dumps({}), | ||||
|             "status": 204, | ||||
|             "body": '', | ||||
|         }) | ||||
|  | ||||
|         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)) | ||||
|                               headers=self.TEST_REQUEST_HEADERS) \ | ||||
|             .AndReturn((resp, resp['body'])) | ||||
|         self.mox.ReplayAll() | ||||
|  | ||||
|         self.client.roles.add_user_role('foo', 'barrr') | ||||
|  | ||||
|     def test_add_user_role_tenant(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "body": json.dumps({}), | ||||
|             "status": 204, | ||||
|             "body": '', | ||||
|         }) | ||||
|  | ||||
|         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)) | ||||
|                               headers=self.TEST_REQUEST_HEADERS) \ | ||||
|             .AndReturn((resp, resp['body'])) | ||||
|         self.mox.ReplayAll() | ||||
|  | ||||
|         self.client.roles.add_user_role('foo', 'barrr', '4') | ||||
|  | ||||
|     def test_remove_user_role(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "body": json.dumps({}), | ||||
|             "status": 204, | ||||
|             "body": '', | ||||
|         }) | ||||
|  | ||||
|         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, resp['body'])) | ||||
|         self.mox.ReplayAll() | ||||
|  | ||||
|         self.client.roles.remove_user_role('foo', 'barrr') | ||||
|  | ||||
|     def test_remove_user_role_tenant(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "body": json.dumps({}), | ||||
|             "status": 204, | ||||
|             "body": '', | ||||
|         }) | ||||
|  | ||||
|         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, resp['body'])) | ||||
|         self.mox.ReplayAll() | ||||
|  | ||||
|         self.client.roles.remove_user_role('foo', 'barrr', '4') | ||||
|   | ||||
| @@ -83,7 +83,7 @@ class TenantTests(utils.TestCase): | ||||
|  | ||||
|     def test_delete(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "status": 204, | ||||
|             "body": "", | ||||
|         }) | ||||
|         httplib2.Http.request(urlparse.urljoin(self.TEST_URL, | ||||
| @@ -260,31 +260,30 @@ class TenantTests(utils.TestCase): | ||||
|  | ||||
|     def test_add_user(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "body": json.dumps({}), | ||||
|             "status": 204, | ||||
|             "body": '', | ||||
|         }) | ||||
|  | ||||
|         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)) | ||||
|                               headers=self.TEST_REQUEST_HEADERS) \ | ||||
|             .AndReturn((resp, resp['body'])) | ||||
|         self.mox.ReplayAll() | ||||
|  | ||||
|         self.client.tenants.add_user('4', 'foo', 'barrr') | ||||
|  | ||||
|     def test_remove_user(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "body": json.dumps({}), | ||||
|             "status": 204, | ||||
|             "body": '', | ||||
|         }) | ||||
|  | ||||
|         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, resp['body'])) | ||||
|         self.mox.ReplayAll() | ||||
|  | ||||
|         self.client.tenants.remove_user('4', 'foo', 'barrr') | ||||
| @@ -299,16 +298,15 @@ class TenantTests(utils.TestCase): | ||||
|             }, | ||||
|         } | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "body": json.dumps({}), | ||||
|             "status": 204, | ||||
|             "body": '', | ||||
|         }) | ||||
|  | ||||
|         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)) | ||||
|                               headers=self.TEST_REQUEST_HEADERS) \ | ||||
|             .AndReturn((resp, resp['body'])) | ||||
|         self.mox.ReplayAll() | ||||
|  | ||||
|         # make tenant object with manager | ||||
| @@ -327,15 +325,15 @@ class TenantTests(utils.TestCase): | ||||
|             }, | ||||
|         } | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "body": json.dumps({}), | ||||
|             "status": 204, | ||||
|             "body": '', | ||||
|         }) | ||||
|  | ||||
|         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, resp['body'])) | ||||
|         self.mox.ReplayAll() | ||||
|  | ||||
|         # make tenant object with manager | ||||
|   | ||||
| @@ -18,7 +18,7 @@ class TokenTests(utils.TestCase): | ||||
|  | ||||
|     def test_delete(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "status": 204, | ||||
|             "body": ""}) | ||||
|  | ||||
|         req = httplib2.Http.request( | ||||
|   | ||||
| @@ -82,7 +82,7 @@ class UserTests(utils.TestCase): | ||||
|  | ||||
|     def test_delete(self): | ||||
|         resp = httplib2.Response({ | ||||
|             "status": 200, | ||||
|             "status": 204, | ||||
|             "body": "", | ||||
|         }) | ||||
|         httplib2.Http.request(urlparse.urljoin(self.TEST_URL, 'v2.0/users/1'), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jenkins
					Jenkins