Kaydet (Commit) 599aa1a8 authored tarafından Joffrey F's avatar Joffrey F Kaydeden (comit) GitHub

Merge pull request #1536 from docker/2.2.1-release

2.2.1 release
...@@ -68,9 +68,10 @@ class DaemonApiMixin(object): ...@@ -68,9 +68,10 @@ class DaemonApiMixin(object):
'until': until, 'until': until,
'filters': filters 'filters': filters
} }
url = self._url('/events')
return self._stream_helper( return self._stream_helper(
self._get(self._url('/events'), params=params, stream=True), self._get(url, params=params, stream=True, timeout=None),
decode=decode decode=decode
) )
......
...@@ -59,7 +59,7 @@ class APIError(requests.exceptions.HTTPError, DockerException): ...@@ -59,7 +59,7 @@ class APIError(requests.exceptions.HTTPError, DockerException):
@property @property
def status_code(self): def status_code(self):
if self.response: if self.response is not None:
return self.response.status_code return self.response.status_code
def is_client_error(self): def is_client_error(self):
......
version = "2.2.0" version = "2.2.1"
version_info = tuple([int(d) for d in version.split("-")[0].split(".")]) version_info = tuple([int(d) for d in version.split("-")[0].split(".")])
Change log 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 2.2.0
----- -----
......
...@@ -40,6 +40,7 @@ Container objects ...@@ -40,6 +40,7 @@ Container objects
.. automethod:: logs .. automethod:: logs
.. automethod:: pause .. automethod:: pause
.. automethod:: put_archive .. automethod:: put_archive
.. automethod:: reload
.. automethod:: remove .. automethod:: remove
.. automethod:: rename .. automethod:: rename
.. automethod:: resize .. automethod:: resize
......
...@@ -26,4 +26,5 @@ Secret objects ...@@ -26,4 +26,5 @@ Secret objects
The raw representation of this object from the server. The raw representation of this object from the server.
.. automethod:: reload
.. automethod:: remove .. automethod:: remove
...@@ -363,7 +363,7 @@ class ServiceTest(BaseAPIIntegrationTest): ...@@ -363,7 +363,7 @@ class ServiceTest(BaseAPIIntegrationTest):
self.tmp_secrets.append(secret_id) self.tmp_secrets.append(secret_id)
secret_ref = docker.types.SecretReference(secret_id, secret_name) secret_ref = docker.types.SecretReference(secret_id, secret_name)
container_spec = docker.types.ContainerSpec( container_spec = docker.types.ContainerSpec(
'busybox', ['top'], secrets=[secret_ref] 'busybox', ['sleep', '999'], secrets=[secret_ref]
) )
task_tmpl = docker.types.TaskTemplate(container_spec) task_tmpl = docker.types.TaskTemplate(container_spec)
name = self.get_service_name() name = self.get_service_name()
...@@ -388,7 +388,7 @@ class ServiceTest(BaseAPIIntegrationTest): ...@@ -388,7 +388,7 @@ class ServiceTest(BaseAPIIntegrationTest):
self.tmp_secrets.append(secret_id) self.tmp_secrets.append(secret_id)
secret_ref = docker.types.SecretReference(secret_id, secret_name) secret_ref = docker.types.SecretReference(secret_id, secret_name)
container_spec = docker.types.ContainerSpec( container_spec = docker.types.ContainerSpec(
'busybox', ['top'], secrets=[secret_ref] 'busybox', ['sleep', '999'], secrets=[secret_ref]
) )
task_tmpl = docker.types.TaskTemplate(container_spec) task_tmpl = docker.types.TaskTemplate(container_spec)
name = self.get_service_name() name = self.get_service_name()
......
...@@ -229,7 +229,7 @@ class DockerApiTest(BaseAPIClientTest): ...@@ -229,7 +229,7 @@ class DockerApiTest(BaseAPIClientTest):
url_prefix + 'events', url_prefix + 'events',
params={'since': None, 'until': None, 'filters': None}, params={'since': None, 'until': None, 'filters': None},
stream=True, stream=True,
timeout=DEFAULT_TIMEOUT_SECONDS timeout=None
) )
def test_events_with_since_until(self): def test_events_with_since_until(self):
...@@ -249,7 +249,7 @@ class DockerApiTest(BaseAPIClientTest): ...@@ -249,7 +249,7 @@ class DockerApiTest(BaseAPIClientTest):
'filters': None 'filters': None
}, },
stream=True, stream=True,
timeout=DEFAULT_TIMEOUT_SECONDS timeout=None
) )
def test_events_with_filters(self): def test_events_with_filters(self):
...@@ -268,7 +268,7 @@ class DockerApiTest(BaseAPIClientTest): ...@@ -268,7 +268,7 @@ class DockerApiTest(BaseAPIClientTest):
'filters': expected_filters 'filters': expected_filters
}, },
stream=True, stream=True,
timeout=DEFAULT_TIMEOUT_SECONDS timeout=None
) )
def _socket_path_for_client_session(self, client): def _socket_path_for_client_session(self, client):
......
import unittest import unittest
import requests
from docker.errors import (APIError, DockerException, from docker.errors import (APIError, DockerException,
create_unexpected_kwargs_error) create_unexpected_kwargs_error)
...@@ -11,6 +13,69 @@ class APIErrorTest(unittest.TestCase): ...@@ -11,6 +13,69 @@ class APIErrorTest(unittest.TestCase):
except DockerException: except DockerException:
pass 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): class CreateUnexpectedKwargsErrorTest(unittest.TestCase):
def test_create_unexpected_kwargs_error_single(self): def test_create_unexpected_kwargs_error_single(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment