Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
7fabcdaa
Kaydet (Commit)
7fabcdaa
authored
Şub 01, 2018
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update wait to always return a dict
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
0a86ff0b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
74 additions
and
35 deletions
+74
-35
container.py
docker/api/container.py
+3
-7
containers.py
docker/models/containers.py
+3
-3
version.py
docker/version.py
+1
-1
change-log.md
docs/change-log.md
+41
-0
api_container_test.py
tests/integration/api_container_test.py
+19
-17
base.py
tests/integration/base.py
+1
-1
models_containers_test.py
tests/integration/models_containers_test.py
+2
-2
fake_api_client.py
tests/unit/fake_api_client.py
+1
-1
models_containers_test.py
tests/unit/models_containers_test.py
+3
-3
No files found.
docker/api/container.py
Dosyayı görüntüle @
7fabcdaa
...
@@ -1207,8 +1207,8 @@ class ContainerApiMixin(object):
...
@@ -1207,8 +1207,8 @@ class ContainerApiMixin(object):
or ``removed``
or ``removed``
Returns:
Returns:
(
int or dict): The exit code of the container. Returns the full API
(
dict): The API's response as a Python dictionary, including
response if no ``StatusCode`` field is included
.
the container's exit code under the ``StatusCode`` attribute
.
Raises:
Raises:
:py:class:`requests.exceptions.ReadTimeout`
:py:class:`requests.exceptions.ReadTimeout`
...
@@ -1226,8 +1226,4 @@ class ContainerApiMixin(object):
...
@@ -1226,8 +1226,4 @@ class ContainerApiMixin(object):
params
[
'condition'
]
=
condition
params
[
'condition'
]
=
condition
res
=
self
.
_post
(
url
,
timeout
=
timeout
,
params
=
params
)
res
=
self
.
_post
(
url
,
timeout
=
timeout
,
params
=
params
)
self
.
_raise_for_status
(
res
)
return
self
.
_result
(
res
,
True
)
json_
=
res
.
json
()
if
'StatusCode'
in
json_
:
return
json_
[
'StatusCode'
]
return
json_
docker/models/containers.py
Dosyayı görüntüle @
7fabcdaa
...
@@ -448,8 +448,8 @@ class Container(Model):
...
@@ -448,8 +448,8 @@ class Container(Model):
or ``removed``
or ``removed``
Returns:
Returns:
(
int): The exit code of the container. Returns ``-1`` if the API
(
dict): The API's response as a Python dictionary, including
responds without a
``StatusCode`` attribute.
the container's exit code under the
``StatusCode`` attribute.
Raises:
Raises:
:py:class:`requests.exceptions.ReadTimeout`
:py:class:`requests.exceptions.ReadTimeout`
...
@@ -758,7 +758,7 @@ class ContainerCollection(Collection):
...
@@ -758,7 +758,7 @@ class ContainerCollection(Collection):
stdout
=
stdout
,
stderr
=
stderr
,
stream
=
True
,
follow
=
True
stdout
=
stdout
,
stderr
=
stderr
,
stream
=
True
,
follow
=
True
)
)
exit_status
=
container
.
wait
()
exit_status
=
container
.
wait
()
[
'StatusCode'
]
if
exit_status
!=
0
:
if
exit_status
!=
0
:
out
=
None
out
=
None
if
not
kwargs
.
get
(
'auto_remove'
):
if
not
kwargs
.
get
(
'auto_remove'
):
...
...
docker/version.py
Dosyayı görüntüle @
7fabcdaa
version
=
"
2.8.0-dev
"
version
=
"
3.0.0
"
version_info
=
tuple
([
int
(
d
)
for
d
in
version
.
split
(
"-"
)[
0
]
.
split
(
"."
)])
version_info
=
tuple
([
int
(
d
)
for
d
in
version
.
split
(
"-"
)[
0
]
.
split
(
"."
)])
docs/change-log.md
Dosyayı görüntüle @
7fabcdaa
Change log
Change log
==========
==========
3.
0.0
-----
[
List of PRs / issues for this release
](
https://github.com/docker/docker-py/milestone/39?closed=1
)
### Breaking changes
*
Support for API version < 1.21 has been removed.
*
The following methods have been removed:
*
`APIClient.copy`
has been removed. Users should use
`APIClient.get_archive`
instead.
*
`APIClient.insert`
has been removed. Users may use
`APIClient.put_archive`
combined with
`APIClient.commit`
to replicate the method's behavior.
*
`utils.ping_registry`
and
`utils.ping`
have been removed.
*
The following parameters have been removed:
*
`stream`
in
`APIClient.build`
*
`cpu_shares`
,
`cpuset`
,
`dns`
,
`mem_limit`
,
`memswap_limit`
,
`volume_driver`
,
`volumes_from`
in
`APIClient.create_container`
. These are
all replaced by their equivalent in
`create_host_config`
*
`insecure_registry`
in
`APIClient.login`
,
`APIClient.pull`
,
`APIClient.push`
,
`DockerClient.images.push`
and
`DockerClient.images.pull`
*
`viz`
in
`APIClient.images`
*
The following parameters have been renamed:
*
`endpoint_config`
in
`APIClient.create_service`
and
`APIClient.update_service`
is now
`endpoint_spec`
*
`name`
in
`DockerClient.images.pull`
is now
`repository`
*
The return value for the following methods has changed:
*
`APIClient.wait`
and
`Container.wait`
now return a
``dict``
representing
the API's response instead of returning the status code directly.
*
`DockerClient.images.load`
now returns a list of
`Image`
objects that have
for the images that were loaded, instead of a log stream.
*
`Container.exec_run`
now returns a tuple of (exit_code, output) instead of
just the output.
*
`DockerClient.images.build`
now returns a tuple of (image, build_logs)
instead of just the image object.
*
`APIClient.export`
,
`APIClient.get_archive`
and
`APIClient.get_image`
now
return generators streaming the raw binary data from the server's response.
*
When no tag is provided,
`DockerClient.images.pull`
now returns a list of
`Image`
s associated to the pulled repository instead of just the
`latest`
image.
2.
7.0
2.
7.0
-----
-----
...
...
tests/integration/api_container_test.py
Dosyayı görüntüle @
7fabcdaa
...
@@ -102,7 +102,7 @@ class CreateContainerTest(BaseAPIIntegrationTest):
...
@@ -102,7 +102,7 @@ class CreateContainerTest(BaseAPIIntegrationTest):
container3_id
=
res2
[
'Id'
]
container3_id
=
res2
[
'Id'
]
self
.
tmp_containers
.
append
(
container3_id
)
self
.
tmp_containers
.
append
(
container3_id
)
self
.
client
.
start
(
container3_id
)
self
.
client
.
start
(
container3_id
)
assert
self
.
client
.
wait
(
container3_id
)
==
0
assert
self
.
client
.
wait
(
container3_id
)
[
'StatusCode'
]
==
0
logs
=
self
.
client
.
logs
(
container3_id
)
logs
=
self
.
client
.
logs
(
container3_id
)
if
six
.
PY3
:
if
six
.
PY3
:
...
@@ -169,7 +169,7 @@ class CreateContainerTest(BaseAPIIntegrationTest):
...
@@ -169,7 +169,7 @@ class CreateContainerTest(BaseAPIIntegrationTest):
assert
'Id'
in
ctnr
assert
'Id'
in
ctnr
self
.
tmp_containers
.
append
(
ctnr
[
'Id'
])
self
.
tmp_containers
.
append
(
ctnr
[
'Id'
])
self
.
client
.
start
(
ctnr
)
self
.
client
.
start
(
ctnr
)
res
=
self
.
client
.
wait
(
ctnr
)
res
=
self
.
client
.
wait
(
ctnr
)
[
'StatusCode'
]
assert
res
!=
0
assert
res
!=
0
def
create_container_with_name
(
self
):
def
create_container_with_name
(
self
):
...
@@ -771,7 +771,7 @@ class StartContainerTest(BaseAPIIntegrationTest):
...
@@ -771,7 +771,7 @@ class StartContainerTest(BaseAPIIntegrationTest):
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
self
.
client
.
start
(
id
)
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
==
0
,
cmd
assert
exitcode
==
0
,
cmd
...
@@ -781,7 +781,7 @@ class WaitTest(BaseAPIIntegrationTest):
...
@@ -781,7 +781,7 @@ class WaitTest(BaseAPIIntegrationTest):
id
=
res
[
'Id'
]
id
=
res
[
'Id'
]
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
start
(
id
)
self
.
client
.
start
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
==
0
assert
exitcode
==
0
inspect
=
self
.
client
.
inspect_container
(
id
)
inspect
=
self
.
client
.
inspect_container
(
id
)
assert
'Running'
in
inspect
[
'State'
]
assert
'Running'
in
inspect
[
'State'
]
...
@@ -794,7 +794,7 @@ class WaitTest(BaseAPIIntegrationTest):
...
@@ -794,7 +794,7 @@ class WaitTest(BaseAPIIntegrationTest):
id
=
res
[
'Id'
]
id
=
res
[
'Id'
]
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
start
(
res
)
self
.
client
.
start
(
res
)
exitcode
=
self
.
client
.
wait
(
res
)
exitcode
=
self
.
client
.
wait
(
res
)
[
'StatusCode'
]
assert
exitcode
==
0
assert
exitcode
==
0
inspect
=
self
.
client
.
inspect_container
(
res
)
inspect
=
self
.
client
.
inspect_container
(
res
)
assert
'Running'
in
inspect
[
'State'
]
assert
'Running'
in
inspect
[
'State'
]
...
@@ -815,7 +815,9 @@ class WaitTest(BaseAPIIntegrationTest):
...
@@ -815,7 +815,9 @@ class WaitTest(BaseAPIIntegrationTest):
)
)
self
.
tmp_containers
.
append
(
ctnr
)
self
.
tmp_containers
.
append
(
ctnr
)
self
.
client
.
start
(
ctnr
)
self
.
client
.
start
(
ctnr
)
assert
self
.
client
.
wait
(
ctnr
,
condition
=
'removed'
,
timeout
=
5
)
==
0
assert
self
.
client
.
wait
(
ctnr
,
condition
=
'removed'
,
timeout
=
5
)[
'StatusCode'
]
==
0
class
LogsTest
(
BaseAPIIntegrationTest
):
class
LogsTest
(
BaseAPIIntegrationTest
):
...
@@ -827,7 +829,7 @@ class LogsTest(BaseAPIIntegrationTest):
...
@@ -827,7 +829,7 @@ class LogsTest(BaseAPIIntegrationTest):
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
start
(
id
)
self
.
client
.
start
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
==
0
assert
exitcode
==
0
logs
=
self
.
client
.
logs
(
id
)
logs
=
self
.
client
.
logs
(
id
)
assert
logs
==
(
snippet
+
'
\n
'
)
.
encode
(
encoding
=
'ascii'
)
assert
logs
==
(
snippet
+
'
\n
'
)
.
encode
(
encoding
=
'ascii'
)
...
@@ -841,7 +843,7 @@ Line2'''
...
@@ -841,7 +843,7 @@ Line2'''
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
start
(
id
)
self
.
client
.
start
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
==
0
assert
exitcode
==
0
logs
=
self
.
client
.
logs
(
id
,
tail
=
1
)
logs
=
self
.
client
.
logs
(
id
,
tail
=
1
)
assert
logs
==
'Line2
\n
'
.
encode
(
encoding
=
'ascii'
)
assert
logs
==
'Line2
\n
'
.
encode
(
encoding
=
'ascii'
)
...
@@ -858,7 +860,7 @@ Line2'''
...
@@ -858,7 +860,7 @@ Line2'''
for
chunk
in
self
.
client
.
logs
(
id
,
stream
=
True
,
follow
=
True
):
for
chunk
in
self
.
client
.
logs
(
id
,
stream
=
True
,
follow
=
True
):
logs
+=
chunk
logs
+=
chunk
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
==
0
assert
exitcode
==
0
assert
logs
==
(
snippet
+
'
\n
'
)
.
encode
(
encoding
=
'ascii'
)
assert
logs
==
(
snippet
+
'
\n
'
)
.
encode
(
encoding
=
'ascii'
)
...
@@ -871,7 +873,7 @@ Line2'''
...
@@ -871,7 +873,7 @@ Line2'''
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
start
(
id
)
self
.
client
.
start
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
==
0
assert
exitcode
==
0
logs
=
self
.
client
.
logs
(
container
)
logs
=
self
.
client
.
logs
(
container
)
assert
logs
==
(
snippet
+
'
\n
'
)
.
encode
(
encoding
=
'ascii'
)
assert
logs
==
(
snippet
+
'
\n
'
)
.
encode
(
encoding
=
'ascii'
)
...
@@ -884,7 +886,7 @@ Line2'''
...
@@ -884,7 +886,7 @@ Line2'''
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
start
(
id
)
self
.
client
.
start
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
==
0
assert
exitcode
==
0
logs
=
self
.
client
.
logs
(
id
,
tail
=
0
)
logs
=
self
.
client
.
logs
(
id
,
tail
=
0
)
assert
logs
==
''
.
encode
(
encoding
=
'ascii'
)
assert
logs
==
''
.
encode
(
encoding
=
'ascii'
)
...
@@ -898,7 +900,7 @@ Line2'''
...
@@ -898,7 +900,7 @@ Line2'''
self
.
tmp_containers
.
append
(
container
)
self
.
tmp_containers
.
append
(
container
)
self
.
client
.
start
(
container
)
self
.
client
.
start
(
container
)
exitcode
=
self
.
client
.
wait
(
container
)
exitcode
=
self
.
client
.
wait
(
container
)
[
'StatusCode'
]
assert
exitcode
==
0
assert
exitcode
==
0
logs_until_1
=
self
.
client
.
logs
(
container
,
until
=
1
)
logs_until_1
=
self
.
client
.
logs
(
container
,
until
=
1
)
assert
logs_until_1
==
b
''
assert
logs_until_1
==
b
''
...
@@ -912,7 +914,7 @@ class DiffTest(BaseAPIIntegrationTest):
...
@@ -912,7 +914,7 @@ class DiffTest(BaseAPIIntegrationTest):
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
self
.
client
.
start
(
id
)
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
==
0
assert
exitcode
==
0
diff
=
self
.
client
.
diff
(
id
)
diff
=
self
.
client
.
diff
(
id
)
test_diff
=
[
x
for
x
in
diff
if
x
.
get
(
'Path'
,
None
)
==
'/test'
]
test_diff
=
[
x
for
x
in
diff
if
x
.
get
(
'Path'
,
None
)
==
'/test'
]
...
@@ -925,7 +927,7 @@ class DiffTest(BaseAPIIntegrationTest):
...
@@ -925,7 +927,7 @@ class DiffTest(BaseAPIIntegrationTest):
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
self
.
client
.
start
(
id
)
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
==
0
assert
exitcode
==
0
diff
=
self
.
client
.
diff
(
container
)
diff
=
self
.
client
.
diff
(
container
)
test_diff
=
[
x
for
x
in
diff
if
x
.
get
(
'Path'
,
None
)
==
'/test'
]
test_diff
=
[
x
for
x
in
diff
if
x
.
get
(
'Path'
,
None
)
==
'/test'
]
...
@@ -997,7 +999,7 @@ class KillTest(BaseAPIIntegrationTest):
...
@@ -997,7 +999,7 @@ class KillTest(BaseAPIIntegrationTest):
self
.
client
.
kill
(
self
.
client
.
kill
(
id
,
signal
=
signal
.
SIGKILL
if
not
IS_WINDOWS_PLATFORM
else
9
id
,
signal
=
signal
.
SIGKILL
if
not
IS_WINDOWS_PLATFORM
else
9
)
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
!=
0
assert
exitcode
!=
0
container_info
=
self
.
client
.
inspect_container
(
id
)
container_info
=
self
.
client
.
inspect_container
(
id
)
assert
'State'
in
container_info
assert
'State'
in
container_info
...
@@ -1012,7 +1014,7 @@ class KillTest(BaseAPIIntegrationTest):
...
@@ -1012,7 +1014,7 @@ class KillTest(BaseAPIIntegrationTest):
self
.
client
.
start
(
id
)
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
kill
(
id
,
signal
=
'SIGKILL'
)
self
.
client
.
kill
(
id
,
signal
=
'SIGKILL'
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
!=
0
assert
exitcode
!=
0
container_info
=
self
.
client
.
inspect_container
(
id
)
container_info
=
self
.
client
.
inspect_container
(
id
)
assert
'State'
in
container_info
assert
'State'
in
container_info
...
@@ -1027,7 +1029,7 @@ class KillTest(BaseAPIIntegrationTest):
...
@@ -1027,7 +1029,7 @@ class KillTest(BaseAPIIntegrationTest):
self
.
client
.
start
(
id
)
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
kill
(
id
,
signal
=
9
)
self
.
client
.
kill
(
id
,
signal
=
9
)
exitcode
=
self
.
client
.
wait
(
id
)
exitcode
=
self
.
client
.
wait
(
id
)
[
'StatusCode'
]
assert
exitcode
!=
0
assert
exitcode
!=
0
container_info
=
self
.
client
.
inspect_container
(
id
)
container_info
=
self
.
client
.
inspect_container
(
id
)
assert
'State'
in
container_info
assert
'State'
in
container_info
...
...
tests/integration/base.py
Dosyayı görüntüle @
7fabcdaa
...
@@ -96,7 +96,7 @@ class BaseAPIIntegrationTest(BaseIntegrationTest):
...
@@ -96,7 +96,7 @@ class BaseAPIIntegrationTest(BaseIntegrationTest):
container
=
self
.
client
.
create_container
(
*
args
,
**
kwargs
)
container
=
self
.
client
.
create_container
(
*
args
,
**
kwargs
)
self
.
tmp_containers
.
append
(
container
)
self
.
tmp_containers
.
append
(
container
)
self
.
client
.
start
(
container
)
self
.
client
.
start
(
container
)
exitcode
=
self
.
client
.
wait
(
container
)
exitcode
=
self
.
client
.
wait
(
container
)
[
'StatusCode'
]
if
exitcode
!=
0
:
if
exitcode
!=
0
:
output
=
self
.
client
.
logs
(
container
)
output
=
self
.
client
.
logs
(
container
)
...
...
tests/integration/models_containers_test.py
Dosyayı görüntüle @
7fabcdaa
...
@@ -309,8 +309,8 @@ class ContainerTest(BaseIntegrationTest):
...
@@ -309,8 +309,8 @@ class ContainerTest(BaseIntegrationTest):
container
=
client
.
containers
.
run
(
"alpine"
,
"sh -c 'exit 0'"
,
container
=
client
.
containers
.
run
(
"alpine"
,
"sh -c 'exit 0'"
,
detach
=
True
)
detach
=
True
)
self
.
tmp_containers
.
append
(
container
.
id
)
self
.
tmp_containers
.
append
(
container
.
id
)
assert
container
.
wait
()
==
0
assert
container
.
wait
()
[
'StatusCode'
]
==
0
container
=
client
.
containers
.
run
(
"alpine"
,
"sh -c 'exit 1'"
,
container
=
client
.
containers
.
run
(
"alpine"
,
"sh -c 'exit 1'"
,
detach
=
True
)
detach
=
True
)
self
.
tmp_containers
.
append
(
container
.
id
)
self
.
tmp_containers
.
append
(
container
.
id
)
assert
container
.
wait
()
==
1
assert
container
.
wait
()
[
'StatusCode'
]
==
1
tests/unit/fake_api_client.py
Dosyayı görüntüle @
7fabcdaa
...
@@ -46,7 +46,7 @@ def make_fake_api_client():
...
@@ -46,7 +46,7 @@ def make_fake_api_client():
'logs.return_value'
:
[
b
'hello world
\n
'
],
'logs.return_value'
:
[
b
'hello world
\n
'
],
'networks.return_value'
:
fake_api
.
get_fake_network_list
()[
1
],
'networks.return_value'
:
fake_api
.
get_fake_network_list
()[
1
],
'start.return_value'
:
None
,
'start.return_value'
:
None
,
'wait.return_value'
:
0
,
'wait.return_value'
:
{
'StatusCode'
:
0
}
,
})
})
mock_client
.
_version
=
docker
.
constants
.
DEFAULT_DOCKER_API_VERSION
mock_client
.
_version
=
docker
.
constants
.
DEFAULT_DOCKER_API_VERSION
return
mock_client
return
mock_client
...
...
tests/unit/models_containers_test.py
Dosyayı görüntüle @
7fabcdaa
...
@@ -234,7 +234,7 @@ class ContainerCollectionTest(unittest.TestCase):
...
@@ -234,7 +234,7 @@ class ContainerCollectionTest(unittest.TestCase):
def
test_run_with_error
(
self
):
def
test_run_with_error
(
self
):
client
=
make_fake_client
()
client
=
make_fake_client
()
client
.
api
.
logs
.
return_value
=
"some error"
client
.
api
.
logs
.
return_value
=
"some error"
client
.
api
.
wait
.
return_value
=
1
client
.
api
.
wait
.
return_value
=
{
'StatusCode'
:
1
}
with
pytest
.
raises
(
docker
.
errors
.
ContainerError
)
as
cm
:
with
pytest
.
raises
(
docker
.
errors
.
ContainerError
)
as
cm
:
client
.
containers
.
run
(
'alpine'
,
'echo hello world'
)
client
.
containers
.
run
(
'alpine'
,
'echo hello world'
)
...
@@ -260,7 +260,7 @@ class ContainerCollectionTest(unittest.TestCase):
...
@@ -260,7 +260,7 @@ class ContainerCollectionTest(unittest.TestCase):
client
.
api
.
remove_container
.
assert_not_called
()
client
.
api
.
remove_container
.
assert_not_called
()
client
=
make_fake_client
()
client
=
make_fake_client
()
client
.
api
.
wait
.
return_value
=
1
client
.
api
.
wait
.
return_value
=
{
'StatusCode'
:
1
}
with
pytest
.
raises
(
docker
.
errors
.
ContainerError
):
with
pytest
.
raises
(
docker
.
errors
.
ContainerError
):
client
.
containers
.
run
(
"alpine"
)
client
.
containers
.
run
(
"alpine"
)
client
.
api
.
remove_container
.
assert_not_called
()
client
.
api
.
remove_container
.
assert_not_called
()
...
@@ -270,7 +270,7 @@ class ContainerCollectionTest(unittest.TestCase):
...
@@ -270,7 +270,7 @@ class ContainerCollectionTest(unittest.TestCase):
client
.
api
.
remove_container
.
assert_called_with
(
FAKE_CONTAINER_ID
)
client
.
api
.
remove_container
.
assert_called_with
(
FAKE_CONTAINER_ID
)
client
=
make_fake_client
()
client
=
make_fake_client
()
client
.
api
.
wait
.
return_value
=
1
client
.
api
.
wait
.
return_value
=
{
'StatusCode'
:
1
}
with
pytest
.
raises
(
docker
.
errors
.
ContainerError
):
with
pytest
.
raises
(
docker
.
errors
.
ContainerError
):
client
.
containers
.
run
(
"alpine"
,
remove
=
True
)
client
.
containers
.
run
(
"alpine"
,
remove
=
True
)
client
.
api
.
remove_container
.
assert_called_with
(
FAKE_CONTAINER_ID
)
client
.
api
.
remove_container
.
assert_called_with
(
FAKE_CONTAINER_ID
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment