diff options
Diffstat (limited to 'tests/unit/errors_test.py')
-rw-r--r-- | tests/unit/errors_test.py | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/tests/unit/errors_test.py b/tests/unit/errors_test.py index e27a9b1..f8c3a66 100644 --- a/tests/unit/errors_test.py +++ b/tests/unit/errors_test.py @@ -79,18 +79,39 @@ class APIErrorTest(unittest.TestCase): err = APIError('', response=resp) assert err.is_client_error() is True + def test_is_error_300(self): + """Report no error on 300 response.""" + resp = requests.Response() + resp.status_code = 300 + err = APIError('', response=resp) + assert err.is_error() is False + + def test_is_error_400(self): + """Report error on 400 response.""" + resp = requests.Response() + resp.status_code = 400 + err = APIError('', response=resp) + assert err.is_error() is True + + def test_is_error_500(self): + """Report error on 500 response.""" + resp = requests.Response() + resp.status_code = 500 + err = APIError('', response=resp) + assert err.is_error() is True + def test_create_error_from_exception(self): - resp = requests.Response() - resp.status_code = 500 - err = APIError('') + resp = requests.Response() + resp.status_code = 500 + err = APIError('') + try: + resp.raise_for_status() + except requests.exceptions.HTTPError as e: try: - resp.raise_for_status() - except requests.exceptions.HTTPError as e: - try: - create_api_error_from_http_exception(e) - except APIError as e: - err = e - assert err.is_server_error() is True + create_api_error_from_http_exception(e) + except APIError as e: + err = e + assert err.is_server_error() is True class ContainerErrorTest(unittest.TestCase): @@ -105,7 +126,7 @@ class ContainerErrorTest(unittest.TestCase): err = ContainerError(container, exit_status, command, image, stderr) msg = ("Command '{}' in image '{}' returned non-zero exit status {}" - ).format(command, image, exit_status, stderr) + ).format(command, image, exit_status) assert str(err) == msg def test_container_with_stderr(self): |