Add 409 ConflictException

Change-Id: I655f1bd462f0a167d384fe469db961332051822c
This commit is contained in:
Adrian Turjak
2018-03-22 16:25:58 +13:00
parent 0ce428e807
commit 23ed0aa481
2 changed files with 9 additions and 2 deletions

View File

@@ -118,6 +118,11 @@ class BadRequestException(HttpException):
pass
class ConflictException(HttpException):
"""HTTP 409 Conflict."""
pass
class MethodNotSupported(SDKException):
"""The resource does not support this operation type."""
def __init__(self, resource, method):
@@ -162,7 +167,9 @@ def raise_from_response(response, error_message=None):
if response.status_code < 400:
return
if response.status_code == 404:
if response.status_code == 409:
cls = ConflictException
elif response.status_code == 404:
cls = NotFoundException
elif response.status_code == 400:
cls = BadRequestException

View File

@@ -203,7 +203,7 @@ class TestDomains(base.TestCase):
json=domain_data.json_response,
validate=dict(json={'domain': {'enabled': False}}))])
with testtools.ExpectedException(
openstack.cloud.OpenStackCloudHTTPError,
openstack.exceptions.ConflictException,
"Error in updating domain %s" % domain_data.domain_id
):
self.cloud.delete_domain(domain_data.domain_id)