Skip to content

Commit 599aa1a

Browse files
authored
Merge pull request #1536 from docker/2.2.1-release
2.2.1 release
2 parents b474ea2 + 4a51e78 commit 599aa1a

File tree

9 files changed

+88
-8
lines changed

9 files changed

+88
-8
lines changed

docker/api/daemon.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ def events(self, since=None, until=None, filters=None, decode=None):
6868
'until': until,
6969
'filters': filters
7070
}
71+
url = self._url('/events')
7172

7273
return self._stream_helper(
73-
self._get(self._url('/events'), params=params, stream=True),
74+
self._get(url, params=params, stream=True, timeout=None),
7475
decode=decode
7576
)
7677

docker/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __str__(self):
5959

6060
@property
6161
def status_code(self):
62-
if self.response:
62+
if self.response is not None:
6363
return self.response.status_code
6464

6565
def is_client_error(self):

docker/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "2.2.0"
1+
version = "2.2.1"
22
version_info = tuple([int(d) for d in version.split("-")[0].split(".")])

docs/change-log.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
Change log
22
==========
33

4+
2.2.1
5+
-----
6+
7+
[List of PRs / issues for this release](https://github.com/docker/docker-py/milestone/32?closed=1)
8+
9+
### Bugfixes
10+
11+
* Fixed a bug where the `status_code` attribute of `APIError` exceptions would
12+
not reflect the expected value.
13+
* Fixed an issue where the `events` method would time out unexpectedly if no
14+
data was sent by the engine for a given amount of time.
15+
416
2.2.0
517
-----
618

docs/containers.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Container objects
4040
.. automethod:: logs
4141
.. automethod:: pause
4242
.. automethod:: put_archive
43+
.. automethod:: reload
4344
.. automethod:: remove
4445
.. automethod:: rename
4546
.. automethod:: resize

docs/secrets.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ Secret objects
2626
2727
The raw representation of this object from the server.
2828

29+
.. automethod:: reload
2930
.. automethod:: remove

tests/integration/api_service_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def test_create_service_with_secret(self):
363363
self.tmp_secrets.append(secret_id)
364364
secret_ref = docker.types.SecretReference(secret_id, secret_name)
365365
container_spec = docker.types.ContainerSpec(
366-
'busybox', ['top'], secrets=[secret_ref]
366+
'busybox', ['sleep', '999'], secrets=[secret_ref]
367367
)
368368
task_tmpl = docker.types.TaskTemplate(container_spec)
369369
name = self.get_service_name()
@@ -388,7 +388,7 @@ def test_create_service_with_unicode_secret(self):
388388
self.tmp_secrets.append(secret_id)
389389
secret_ref = docker.types.SecretReference(secret_id, secret_name)
390390
container_spec = docker.types.ContainerSpec(
391-
'busybox', ['top'], secrets=[secret_ref]
391+
'busybox', ['sleep', '999'], secrets=[secret_ref]
392392
)
393393
task_tmpl = docker.types.TaskTemplate(container_spec)
394394
name = self.get_service_name()

tests/unit/api_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def test_events(self):
229229
url_prefix + 'events',
230230
params={'since': None, 'until': None, 'filters': None},
231231
stream=True,
232-
timeout=DEFAULT_TIMEOUT_SECONDS
232+
timeout=None
233233
)
234234

235235
def test_events_with_since_until(self):
@@ -249,7 +249,7 @@ def test_events_with_since_until(self):
249249
'filters': None
250250
},
251251
stream=True,
252-
timeout=DEFAULT_TIMEOUT_SECONDS
252+
timeout=None
253253
)
254254

255255
def test_events_with_filters(self):
@@ -268,7 +268,7 @@ def test_events_with_filters(self):
268268
'filters': expected_filters
269269
},
270270
stream=True,
271-
timeout=DEFAULT_TIMEOUT_SECONDS
271+
timeout=None
272272
)
273273

274274
def _socket_path_for_client_session(self, client):

tests/unit/errors_test.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import unittest
22

3+
import requests
4+
35
from docker.errors import (APIError, DockerException,
46
create_unexpected_kwargs_error)
57

@@ -11,6 +13,69 @@ def test_api_error_is_caught_by_dockerexception(self):
1113
except DockerException:
1214
pass
1315

16+
def test_status_code_200(self):
17+
"""The status_code property is present with 200 response."""
18+
resp = requests.Response()
19+
resp.status_code = 200
20+
err = APIError('', response=resp)
21+
assert err.status_code == 200
22+
23+
def test_status_code_400(self):
24+
"""The status_code property is present with 400 response."""
25+
resp = requests.Response()
26+
resp.status_code = 400
27+
err = APIError('', response=resp)
28+
assert err.status_code == 400
29+
30+
def test_status_code_500(self):
31+
"""The status_code property is present with 500 response."""
32+
resp = requests.Response()
33+
resp.status_code = 500
34+
err = APIError('', response=resp)
35+
assert err.status_code == 500
36+
37+
def test_is_server_error_200(self):
38+
"""Report not server error on 200 response."""
39+
resp = requests.Response()
40+
resp.status_code = 200
41+
err = APIError('', response=resp)
42+
assert err.is_server_error() is False
43+
44+
def test_is_server_error_300(self):
45+
"""Report not server error on 300 response."""
46+
resp = requests.Response()
47+
resp.status_code = 300
48+
err = APIError('', response=resp)
49+
assert err.is_server_error() is False
50+
51+
def test_is_server_error_400(self):
52+
"""Report not server error on 400 response."""
53+
resp = requests.Response()
54+
resp.status_code = 400
55+
err = APIError('', response=resp)
56+
assert err.is_server_error() is False
57+
58+
def test_is_server_error_500(self):
59+
"""Report server error on 500 response."""
60+
resp = requests.Response()
61+
resp.status_code = 500
62+
err = APIError('', response=resp)
63+
assert err.is_server_error() is True
64+
65+
def test_is_client_error_500(self):
66+
"""Report not client error on 500 response."""
67+
resp = requests.Response()
68+
resp.status_code = 500
69+
err = APIError('', response=resp)
70+
assert err.is_client_error() is False
71+
72+
def test_is_client_error_400(self):
73+
"""Report client error on 400 response."""
74+
resp = requests.Response()
75+
resp.status_code = 400
76+
err = APIError('', response=resp)
77+
assert err.is_client_error() is True
78+
1479

1580
class CreateUnexpectedKwargsErrorTest(unittest.TestCase):
1681
def test_create_unexpected_kwargs_error_single(self):

0 commit comments

Comments
 (0)