Codebase list cinder-tempest-plugin / 496ea79
Extracted HTTP response codes to constants There are several places in the source code where HTTP response codes are used as numeric values. Status codes 200, 202, 204, 400, 403, 404, 405 and 413 under tests/functional, tests/tempest and tests/unit/api are replaced with symbolic constants from six.moves.http_client thus improves code readability. More patches will be submitted to address other status codes. Partial-Bug: #1520159 Change-Id: Idc4d3ee8469e7a41dda2d33f4e0629442bbbce4c poojajadhav 9 years ago
1 changed file(s) with 10 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
1616 import time
1717
1818 from oslo_serialization import jsonutils as json
19 from six.moves import http_client
1920 from tempest import exceptions
2021 from tempest.lib.common import rest_client
2122 from tempest.lib import exceptions as lib_exc
4041 post_body = json.dumps({'consistencygroup': post_body})
4142 resp, body = self.post('consistencygroups', post_body)
4243 body = json.loads(body)
43 self.expected_success(202, resp.status)
44 self.expected_success(http_client.ACCEPTED, resp.status)
4445 return rest_client.ResponseBody(resp, body)
4546
4647 def create_consistencygroup_from_src(self, **kwargs):
5758 post_body = json.dumps({'consistencygroup-from-src': post_body})
5859 resp, body = self.post('consistencygroups/create_from_src', post_body)
5960 body = json.loads(body)
60 self.expected_success(202, resp.status)
61 self.expected_success(http_client.ACCEPTED, resp.status)
6162 return rest_client.ResponseBody(resp, body)
6263
6364 def delete_consistencygroup(self, cg_id):
6667 post_body = json.dumps({'consistencygroup': post_body})
6768 resp, body = self.post('consistencygroups/%s/delete' % cg_id,
6869 post_body)
69 self.expected_success(202, resp.status)
70 self.expected_success(http_client.ACCEPTED, resp.status)
7071 return rest_client.ResponseBody(resp, body)
7172
7273 def show_consistencygroup(self, cg_id):
7475 url = "consistencygroups/%s" % str(cg_id)
7576 resp, body = self.get(url)
7677 body = json.loads(body)
77 self.expected_success(200, resp.status)
78 self.expected_success(http_client.OK, resp.status)
7879 return rest_client.ResponseBody(resp, body)
7980
8081 def list_consistencygroups(self, detail=False):
8485 url += "/detail"
8586 resp, body = self.get(url)
8687 body = json.loads(body)
87 self.expected_success(200, resp.status)
88 self.expected_success(http_client.OK, resp.status)
8889 return rest_client.ResponseBody(resp, body)
8990
9091 def create_cgsnapshot(self, consistencygroup_id, **kwargs):
9798 post_body = json.dumps({'cgsnapshot': post_body})
9899 resp, body = self.post('cgsnapshots', post_body)
99100 body = json.loads(body)
100 self.expected_success(202, resp.status)
101 self.expected_success(http_client.ACCEPTED, resp.status)
101102 return rest_client.ResponseBody(resp, body)
102103
103104 def delete_cgsnapshot(self, cgsnapshot_id):
104105 """Delete a consistency group snapshot."""
105106 resp, body = self.delete('cgsnapshots/%s' % (str(cgsnapshot_id)))
106 self.expected_success(202, resp.status)
107 self.expected_success(http_client.ACCEPTED, resp.status)
107108 return rest_client.ResponseBody(resp, body)
108109
109110 def show_cgsnapshot(self, cgsnapshot_id):
111112 url = "cgsnapshots/%s" % str(cgsnapshot_id)
112113 resp, body = self.get(url)
113114 body = json.loads(body)
114 self.expected_success(200, resp.status)
115 self.expected_success(http_client.OK, resp.status)
115116 return rest_client.ResponseBody(resp, body)
116117
117118 def list_cgsnapshots(self, detail=False):
121122 url += "/detail"
122123 resp, body = self.get(url)
123124 body = json.loads(body)
124 self.expected_success(200, resp.status)
125 self.expected_success(http_client.OK, resp.status)
125126 return rest_client.ResponseBody(resp, body)
126127
127128 def wait_for_consistencygroup_status(self, cg_id, status):