diff options
| author | Sebastiaan van Stijn <github@gone.nl> | 2019-01-09 00:35:03 +0100 |
|---|---|---|
| committer | Sebastiaan van Stijn <github@gone.nl> | 2019-01-09 21:23:11 +0100 |
| commit | 219c52141e3cd15db3348c5420220f640323499f (patch) | |
| tree | 73c187dc41fb7d133e8b5d7bc03f15034fb5ecdb /tests/unit | |
| parent | 5455c04f75cac6bf05a9f076a1f02c3cf8498a2e (diff) | |
| download | docker-py-219c52141e3cd15db3348c5420220f640323499f.tar.gz | |
Regression 443 test: relax status-code check
This test was testing for a 500 status, but this status
is actually a bug in the API (as it's due to an invalid
request), and the API should actually return a 400 status.
To make this test handle both situations, relax the test
to accept either a 4xx or 5xx status.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'tests/unit')
| -rw-r--r-- | tests/unit/errors_test.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/unit/errors_test.py b/tests/unit/errors_test.py index e27a9b1..2134f86 100644 --- a/tests/unit/errors_test.py +++ b/tests/unit/errors_test.py @@ -79,6 +79,27 @@ 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 |
