Skip to content

Commit

Permalink
Merge pull request #1536 from docker/2.2.1-release
Browse files Browse the repository at this point in the history
2.2.1 release
  • Loading branch information
shin- authored Mar 28, 2017
2 parents b474ea2 + 4a51e78 commit 599aa1a
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docker/api/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ def events(self, since=None, until=None, filters=None, decode=None):
'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
)

Expand Down
2 changes: 1 addition & 1 deletion docker/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __str__(self):

@property
def status_code(self):
if self.response:
if self.response is not None:
return self.response.status_code

def is_client_error(self):
Expand Down
2 changes: 1 addition & 1 deletion docker/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "2.2.0"
version = "2.2.1"
version_info = tuple([int(d) for d in version.split("-")[0].split(".")])
12 changes: 12 additions & 0 deletions docs/change-log.md
Original file line number Diff line number Diff line change
@@ -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
-----

Expand Down
1 change: 1 addition & 0 deletions docs/containers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Container objects
.. automethod:: logs
.. automethod:: pause
.. automethod:: put_archive
.. automethod:: reload
.. automethod:: remove
.. automethod:: rename
.. automethod:: resize
Expand Down
1 change: 1 addition & 0 deletions docs/secrets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ Secret objects
The raw representation of this object from the server.

.. automethod:: reload
.. automethod:: remove
4 changes: 2 additions & 2 deletions tests/integration/api_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def test_create_service_with_secret(self):
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()
Expand All @@ -388,7 +388,7 @@ def test_create_service_with_unicode_secret(self):
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()
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def test_events(self):
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):
Expand All @@ -249,7 +249,7 @@ def test_events_with_since_until(self):
'filters': None
},
stream=True,
timeout=DEFAULT_TIMEOUT_SECONDS
timeout=None
)

def test_events_with_filters(self):
Expand All @@ -268,7 +268,7 @@ def test_events_with_filters(self):
'filters': expected_filters
},
stream=True,
timeout=DEFAULT_TIMEOUT_SECONDS
timeout=None
)

def _socket_path_for_client_session(self, client):
Expand Down
65 changes: 65 additions & 0 deletions tests/unit/errors_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import unittest

import requests

from docker.errors import (APIError, DockerException,
create_unexpected_kwargs_error)

Expand All @@ -11,6 +13,69 @@ def test_api_error_is_caught_by_dockerexception(self):
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):
Expand Down

0 comments on commit 599aa1a

Please sign in to comment.