summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docker/api/daemon.py3
-rw-r--r--docker/errors.py2
-rw-r--r--docker/version.py2
-rw-r--r--docs/change-log.md12
-rw-r--r--docs/containers.rst1
-rw-r--r--docs/secrets.rst1
-rw-r--r--tests/integration/api_service_test.py4
-rw-r--r--tests/unit/api_test.py6
-rw-r--r--tests/unit/errors_test.py65
9 files changed, 88 insertions, 8 deletions
diff --git a/docker/api/daemon.py b/docker/api/daemon.py
index 00367bc..91c777f 100644
--- a/docker/api/daemon.py
+++ b/docker/api/daemon.py
@@ -68,9 +68,10 @@ class DaemonApiMixin(object):
'until': until,
'filters': filters
}
+ url = self._url('/events')
return self._stream_helper(
- self._get(self._url('/events'), params=params, stream=True),
+ self._get(url, params=params, stream=True, timeout=None),
decode=decode
)
diff --git a/docker/errors.py b/docker/errors.py
index d9b197d..03b89c1 100644
--- a/docker/errors.py
+++ b/docker/errors.py
@@ -59,7 +59,7 @@ class APIError(requests.exceptions.HTTPError, DockerException):
@property
def status_code(self):
- if self.response:
+ if self.response is not None:
return self.response.status_code
def is_client_error(self):
diff --git a/docker/version.py b/docker/version.py
index b2474bd..08c792b 100644
--- a/docker/version.py
+++ b/docker/version.py
@@ -1,2 +1,2 @@
-version = "2.2.0"
+version = "2.2.1"
version_info = tuple([int(d) for d in version.split("-")[0].split(".")])
diff --git a/docs/change-log.md b/docs/change-log.md
index c04cd4b..a6f5c57 100644
--- a/docs/change-log.md
+++ b/docs/change-log.md
@@ -1,6 +1,18 @@
Change log
==========
+2.2.1
+-----
+
+[List of PRs / issues for this release](https://github.com/docker/docker-py/milestone/32?closed=1)
+
+### Bugfixes
+
+* Fixed a bug where the `status_code` attribute of `APIError` exceptions would
+ not reflect the expected value.
+* Fixed an issue where the `events` method would time out unexpectedly if no
+ data was sent by the engine for a given amount of time.
+
2.2.0
-----
diff --git a/docs/containers.rst b/docs/containers.rst
index 9b27a30..20529b0 100644
--- a/docs/containers.rst
+++ b/docs/containers.rst
@@ -40,6 +40,7 @@ Container objects
.. automethod:: logs
.. automethod:: pause
.. automethod:: put_archive
+ .. automethod:: reload
.. automethod:: remove
.. automethod:: rename
.. automethod:: resize
diff --git a/docs/secrets.rst b/docs/secrets.rst
index 49e1498..d1c39f1 100644
--- a/docs/secrets.rst
+++ b/docs/secrets.rst
@@ -26,4 +26,5 @@ Secret objects
The raw representation of this object from the server.
+ .. automethod:: reload
.. automethod:: remove
diff --git a/tests/integration/api_service_test.py b/tests/integration/api_service_test.py
index 3bfabe9..6858ad0 100644
--- a/tests/integration/api_service_test.py
+++ b/tests/integration/api_service_test.py
@@ -363,7 +363,7 @@ class ServiceTest(BaseAPIIntegrationTest):
self.tmp_secrets.append(secret_id)
secret_ref = docker.types.SecretReference(secret_id, secret_name)
container_spec = docker.types.ContainerSpec(
- 'busybox', ['top'], secrets=[secret_ref]
+ 'busybox', ['sleep', '999'], secrets=[secret_ref]
)
task_tmpl = docker.types.TaskTemplate(container_spec)
name = self.get_service_name()
@@ -388,7 +388,7 @@ class ServiceTest(BaseAPIIntegrationTest):
self.tmp_secrets.append(secret_id)
secret_ref = docker.types.SecretReference(secret_id, secret_name)
container_spec = docker.types.ContainerSpec(
- 'busybox', ['top'], secrets=[secret_ref]
+ 'busybox', ['sleep', '999'], secrets=[secret_ref]
)
task_tmpl = docker.types.TaskTemplate(container_spec)
name = self.get_service_name()
diff --git a/tests/unit/api_test.py b/tests/unit/api_test.py
index b632d20..83848c5 100644
--- a/tests/unit/api_test.py
+++ b/tests/unit/api_test.py
@@ -229,7 +229,7 @@ class DockerApiTest(BaseAPIClientTest):
url_prefix + 'events',
params={'since': None, 'until': None, 'filters': None},
stream=True,
- timeout=DEFAULT_TIMEOUT_SECONDS
+ timeout=None
)
def test_events_with_since_until(self):
@@ -249,7 +249,7 @@ class DockerApiTest(BaseAPIClientTest):
'filters': None
},
stream=True,
- timeout=DEFAULT_TIMEOUT_SECONDS
+ timeout=None
)
def test_events_with_filters(self):
@@ -268,7 +268,7 @@ class DockerApiTest(BaseAPIClientTest):
'filters': expected_filters
},
stream=True,
- timeout=DEFAULT_TIMEOUT_SECONDS
+ timeout=None
)
def _socket_path_for_client_session(self, client):
diff --git a/tests/unit/errors_test.py b/tests/unit/errors_test.py
index 876ede3..b78af4e 100644
--- a/tests/unit/errors_test.py
+++ b/tests/unit/errors_test.py
@@ -1,5 +1,7 @@
import unittest
+import requests
+
from docker.errors import (APIError, DockerException,
create_unexpected_kwargs_error)
@@ -11,6 +13,69 @@ class APIErrorTest(unittest.TestCase):
except DockerException:
pass
+ def test_status_code_200(self):
+ """The status_code property is present with 200 response."""
+ resp = requests.Response()
+ resp.status_code = 200
+ err = APIError('', response=resp)
+ assert err.status_code == 200
+
+ def test_status_code_400(self):
+ """The status_code property is present with 400 response."""
+ resp = requests.Response()
+ resp.status_code = 400
+ err = APIError('', response=resp)
+ assert err.status_code == 400
+
+ def test_status_code_500(self):
+ """The status_code property is present with 500 response."""
+ resp = requests.Response()
+ resp.status_code = 500
+ err = APIError('', response=resp)
+ assert err.status_code == 500
+
+ def test_is_server_error_200(self):
+ """Report not server error on 200 response."""
+ resp = requests.Response()
+ resp.status_code = 200
+ err = APIError('', response=resp)
+ assert err.is_server_error() is False
+
+ def test_is_server_error_300(self):
+ """Report not server error on 300 response."""
+ resp = requests.Response()
+ resp.status_code = 300
+ err = APIError('', response=resp)
+ assert err.is_server_error() is False
+
+ def test_is_server_error_400(self):
+ """Report not server error on 400 response."""
+ resp = requests.Response()
+ resp.status_code = 400
+ err = APIError('', response=resp)
+ assert err.is_server_error() is False
+
+ def test_is_server_error_500(self):
+ """Report server error on 500 response."""
+ resp = requests.Response()
+ resp.status_code = 500
+ err = APIError('', response=resp)
+ assert err.is_server_error() is True
+
+ def test_is_client_error_500(self):
+ """Report not client error on 500 response."""
+ resp = requests.Response()
+ resp.status_code = 500
+ err = APIError('', response=resp)
+ assert err.is_client_error() is False
+
+ def test_is_client_error_400(self):
+ """Report client error on 400 response."""
+ resp = requests.Response()
+ resp.status_code = 400
+ err = APIError('', response=resp)
+ assert err.is_client_error() is True
+
class CreateUnexpectedKwargsErrorTest(unittest.TestCase):
def test_create_unexpected_kwargs_error_single(self):