Trivial: Change hardcoded values in tempest plugin
Replace hardcoded http status codes in ironic_tempest_plugin
Change-Id: Ib13d01e297e949f83b32977fc60291b6516d9b41
diff --git a/ironic_tempest_plugin/services/baremetal/base.py b/ironic_tempest_plugin/services/baremetal/base.py
index 30589e1..ec572b2 100644
--- a/ironic_tempest_plugin/services/baremetal/base.py
+++ b/ironic_tempest_plugin/services/baremetal/base.py
@@ -13,6 +13,7 @@
import functools
from oslo_serialization import jsonutils as json
+from six.moves import http_client
from six.moves.urllib import parse as urllib
from tempest.lib.common import api_version_utils
from tempest.lib.common import rest_client
@@ -133,7 +134,7 @@
resp, body = self.get(uri, headers=headers,
extra_headers=extra_headers)
- self.expected_success(200, resp.status)
+ self.expected_success(http_client.OK, resp.status)
return resp, self.deserialize(body)
@@ -149,7 +150,7 @@
else:
uri = self._get_uri(resource, uuid=uuid, permanent=permanent)
resp, body = self.get(uri)
- self.expected_success(200, resp.status)
+ self.expected_success(http_client.OK, resp.status)
return resp, self.deserialize(body)
@@ -167,7 +168,7 @@
uri = self._get_uri(resource)
resp, body = self.post(uri, body=body)
- self.expected_success(201, resp.status)
+ self.expected_success(http_client.CREATED, resp.status)
return resp, self.deserialize(body)
@@ -186,7 +187,7 @@
uri = self._get_uri(resource)
resp, body = self.post(uri, body=body)
- self.expected_success(204, resp.status)
+ self.expected_success(http_client.NO_CONTENT, resp.status)
return resp
@@ -201,7 +202,7 @@
uri = self._get_uri(resource, uuid)
resp, body = self.delete(uri)
- self.expected_success(204, resp.status)
+ self.expected_success(http_client.NO_CONTENT, resp.status)
return resp, body
def _patch_request(self, resource, uuid, patch_object):
@@ -217,7 +218,7 @@
patch_body = json.dumps(patch_object)
resp, body = self.patch(uri, body=patch_body)
- self.expected_success(200, resp.status)
+ self.expected_success(http_client.OK, resp.status)
return resp, self.deserialize(body)
@handle_errors
@@ -242,5 +243,6 @@
put_body = json.dumps(put_object)
resp, body = self.put(uri, body=put_body)
- self.expected_success([202, 204], resp.status)
+ self.expected_success([http_client.ACCEPTED, http_client.NO_CONTENT],
+ resp.status)
return resp, body
diff --git a/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py b/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
index cf1abad..6d88e7c 100644
--- a/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
+++ b/ironic_tempest_plugin/services/baremetal/v1/json/baremetal_client.py
@@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from six.moves import http_client
+
from ironic_tempest_plugin.services.baremetal import base
@@ -318,7 +320,7 @@
request = {'boot_device': boot_device, 'persistent': persistent}
resp, body = self._put_request('nodes/%s/management/boot_device' %
node_uuid, request)
- self.expected_success(204, resp.status)
+ self.expected_success(http_client.NO_CONTENT, resp.status)
return body
@base.handle_errors
@@ -330,7 +332,7 @@
"""
path = 'nodes/%s/management/boot_device' % node_uuid
resp, body = self._list_request(path)
- self.expected_success(200, resp.status)
+ self.expected_success(http_client.OK, resp.status)
return body
@base.handle_errors
@@ -342,7 +344,7 @@
"""
path = 'nodes/%s/management/boot_device/supported' % node_uuid
resp, body = self._list_request(path)
- self.expected_success(200, resp.status)
+ self.expected_success(http_client.OK, resp.status)
return body
@base.handle_errors
@@ -354,7 +356,7 @@
"""
resp, body = self._show_request('nodes/states/console', node_uuid)
- self.expected_success(200, resp.status)
+ self.expected_success(http_client.OK, resp.status)
return resp, body
@base.handle_errors
@@ -370,7 +372,7 @@
enabled = {'enabled': enabled}
resp, body = self._put_request('nodes/%s/states/console' % node_uuid,
enabled)
- self.expected_success(202, resp.status)
+ self.expected_success(http_client.ACCEPTED, resp.status)
return resp, body
@base.handle_errors
@@ -410,5 +412,5 @@
:param vif_id: An ID representing the VIF
"""
resp, body = self._delete_request('nodes/%s/vifs' % node_uuid, vif_id)
- self.expected_success(204, resp.status)
+ self.expected_success(http_client.NO_CONTENT, resp.status)
return resp, body