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
ad608baa
Kaydet (Commit)
ad608baa
authored
Agu 31, 2015
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #747 from aanand/integration-test-fixes
Integration test improvements
üst
9b371201
6c0f7187
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
49 deletions
+99
-49
Dockerfile
Dockerfile
+9
-1
Dockerfile-py3
Dockerfile-py3
+9
-1
Makefile
Makefile
+2
-2
integration_test.py
tests/integration_test.py
+79
-45
No files found.
Dockerfile
Dosyayı görüntüle @
ad608baa
FROM
python:2.7
FROM
python:2.7
MAINTAINER
Joffrey F <joffrey@docker.com>
MAINTAINER
Joffrey F <joffrey@docker.com>
ADD
. /home/docker-py
RUN
mkdir
/home/docker-py
WORKDIR
/home/docker-py
WORKDIR
/home/docker-py
ADD
requirements.txt /home/docker-py/requirements.txt
RUN
pip
install
-r
requirements.txt
ADD
test-requirements.txt /home/docker-py/test-requirements.txt
RUN
pip
install
-r
test-requirements.txt
RUN
pip
install
-r
test-requirements.txt
ADD
. /home/docker-py
RUN
pip
install
.
RUN
pip
install
.
Dockerfile-py3
Dosyayı görüntüle @
ad608baa
FROM python:3.4
FROM python:3.4
MAINTAINER Joffrey F <joffrey@docker.com>
MAINTAINER Joffrey F <joffrey@docker.com>
ADD . /home/docker-py
RUN mkdir /home/docker-py
WORKDIR /home/docker-py
WORKDIR /home/docker-py
ADD requirements.txt /home/docker-py/requirements.txt
RUN pip install -r requirements.txt
ADD test-requirements.txt /home/docker-py/test-requirements.txt
RUN pip install -r test-requirements.txt
RUN pip install -r test-requirements.txt
ADD . /home/docker-py
RUN pip install .
RUN pip install .
Makefile
Dosyayı görüntüle @
ad608baa
...
@@ -19,7 +19,7 @@ unit-test-py3: build-py3
...
@@ -19,7 +19,7 @@ unit-test-py3: build-py3
docker run docker-py3 py.test tests/test.py tests/utils_test.py
docker run docker-py3 py.test tests/test.py tests/utils_test.py
integration-test
:
build
integration-test
:
build
docker run
-
e
NOT_ON_HOST
=
true
-v
`
$(HOST_TMPDIR)
`
:/tmp
-v
/var/run/docker.sock:/var/run/docker.sock docker-py py.test
tests/integration_test.py
docker run
-
v
`
$(HOST_TMPDIR)
`
:/tmp
-v
/var/run/docker.sock:/var/run/docker.sock docker-py py.test
-rxs
tests/integration_test.py
integration-test-py3
:
build-py3
integration-test-py3
:
build-py3
docker run
-
e
NOT_ON_HOST
=
true
-v
`
$(HOST_TMPDIR)
`
:/tmp
-v
/var/run/docker.sock:/var/run/docker.sock docker-py3 py.test
tests/integration_test.py
docker run
-
v
`
$(HOST_TMPDIR)
`
:/tmp
-v
/var/run/docker.sock:/var/run/docker.sock docker-py3 py.test
-rxs
tests/integration_test.py
tests/integration_test.py
Dosyayı görüntüle @
ad608baa
...
@@ -28,6 +28,7 @@ import unittest
...
@@ -28,6 +28,7 @@ import unittest
import
warnings
import
warnings
import
docker
import
docker
from
docker.utils
import
kwargs_from_env
import
six
import
six
from
six.moves
import
BaseHTTPServer
from
six.moves
import
BaseHTTPServer
...
@@ -36,15 +37,41 @@ from six.moves import socketserver
...
@@ -36,15 +37,41 @@ from six.moves import socketserver
from
.test
import
Cleanup
from
.test
import
Cleanup
from
docker.errors
import
APIError
from
docker.errors
import
APIError
import
pytest
# FIXME: missing tests for
# FIXME: missing tests for
# export; history; insert; port; push; tag; get; load; stats
# export; history; insert; port; push; tag; get; load; stats
DEFAULT_BASE_URL
=
os
.
environ
.
get
(
'DOCKER_HOST'
)
EXEC_DRIVER_IS_NATIVE
=
True
NOT_ON_HOST
=
os
.
environ
.
get
(
'NOT_ON_HOST'
,
False
)
warnings
.
simplefilter
(
'error'
)
warnings
.
simplefilter
(
'error'
)
compare_version
=
docker
.
utils
.
compare_version
compare_version
=
docker
.
utils
.
compare_version
EXEC_DRIVER
=
[]
def
exec_driver_is_native
():
global
EXEC_DRIVER
if
not
EXEC_DRIVER
:
c
=
docker_client
()
EXEC_DRIVER
=
c
.
info
()[
'ExecutionDriver'
]
c
.
close
()
return
EXEC_DRIVER
.
startswith
(
'native'
)
def
docker_client
(
**
kwargs
):
return
docker
.
Client
(
**
docker_client_kwargs
(
**
kwargs
))
def
docker_client_kwargs
(
**
kwargs
):
client_kwargs
=
kwargs_from_env
(
assert_hostname
=
False
)
client_kwargs
.
update
(
kwargs
)
return
client_kwargs
def
setup_module
():
c
=
docker_client
()
c
.
pull
(
'busybox'
)
c
.
close
()
class
BaseTestCase
(
unittest
.
TestCase
):
class
BaseTestCase
(
unittest
.
TestCase
):
tmp_imgs
=
[]
tmp_imgs
=
[]
...
@@ -55,7 +82,7 @@ class BaseTestCase(unittest.TestCase):
...
@@ -55,7 +82,7 @@ class BaseTestCase(unittest.TestCase):
if
six
.
PY2
:
if
six
.
PY2
:
self
.
assertRegex
=
self
.
assertRegexpMatches
self
.
assertRegex
=
self
.
assertRegexpMatches
self
.
assertCountEqual
=
self
.
assertItemsEqual
self
.
assertCountEqual
=
self
.
assertItemsEqual
self
.
client
=
docker
.
Client
(
base_url
=
DEFAULT_BASE_URL
,
timeout
=
5
)
self
.
client
=
docker
_client
(
timeout
=
5
)
self
.
tmp_imgs
=
[]
self
.
tmp_imgs
=
[]
self
.
tmp_containers
=
[]
self
.
tmp_containers
=
[]
self
.
tmp_folders
=
[]
self
.
tmp_folders
=
[]
...
@@ -99,7 +126,7 @@ class TestInfo(BaseTestCase):
...
@@ -99,7 +126,7 @@ class TestInfo(BaseTestCase):
class
TestSearch
(
BaseTestCase
):
class
TestSearch
(
BaseTestCase
):
def
runTest
(
self
):
def
runTest
(
self
):
self
.
client
=
docker
.
Client
(
base_url
=
DEFAULT_BASE_URL
,
timeout
=
10
)
self
.
client
=
docker
_client
(
timeout
=
10
)
res
=
self
.
client
.
search
(
'busybox'
)
res
=
self
.
client
.
search
(
'busybox'
)
self
.
assertTrue
(
len
(
res
)
>=
1
)
self
.
assertTrue
(
len
(
res
)
>=
1
)
base_img
=
[
x
for
x
in
res
if
x
[
'name'
]
==
'busybox'
]
base_img
=
[
x
for
x
in
res
if
x
[
'name'
]
==
'busybox'
]
...
@@ -163,6 +190,7 @@ class TestCreateContainer(BaseTestCase):
...
@@ -163,6 +190,7 @@ class TestCreateContainer(BaseTestCase):
class
TestCreateContainerWithBinds
(
BaseTestCase
):
class
TestCreateContainerWithBinds
(
BaseTestCase
):
@pytest.mark.skipif
(
True
,
reason
=
"Doesn't work inside a container - FIXME"
)
def
runTest
(
self
):
def
runTest
(
self
):
mount_dest
=
'/mnt'
mount_dest
=
'/mnt'
mount_origin
=
tempfile
.
mkdtemp
()
mount_origin
=
tempfile
.
mkdtemp
()
...
@@ -205,6 +233,7 @@ class TestCreateContainerWithBinds(BaseTestCase):
...
@@ -205,6 +233,7 @@ class TestCreateContainerWithBinds(BaseTestCase):
class
TestCreateContainerWithRoBinds
(
BaseTestCase
):
class
TestCreateContainerWithRoBinds
(
BaseTestCase
):
@pytest.mark.skipif
(
True
,
reason
=
"Doesn't work inside a container - FIXME"
)
def
runTest
(
self
):
def
runTest
(
self
):
mount_dest
=
'/mnt'
mount_dest
=
'/mnt'
mount_origin
=
tempfile
.
mkdtemp
()
mount_origin
=
tempfile
.
mkdtemp
()
...
@@ -278,11 +307,15 @@ class CreateContainerWithLogConfigTest(BaseTestCase):
...
@@ -278,11 +307,15 @@ class CreateContainerWithLogConfigTest(BaseTestCase):
)
)
expected_msg
=
"logger: no log driver named 'asdf-nope' is registered"
expected_msg
=
"logger: no log driver named 'asdf-nope' is registered"
with
self
.
assertRaisesRegexp
(
APIError
,
expected_msg
):
with
pytest
.
raises
(
APIError
)
as
excinfo
:
# raises an internal server error 500
# raises an internal server error 500
self
.
client
.
start
(
container
)
self
.
client
.
start
(
container
)
@unittest.skip
(
"Reason: https://github.com/docker/docker/issues/15633"
)
assert
expected_msg
in
str
(
excinfo
.
value
)
@pytest.mark.skipif
(
True
,
reason
=
"https://github.com/docker/docker/issues/15633"
)
def
test_valid_no_log_driver_specified
(
self
):
def
test_valid_no_log_driver_specified
(
self
):
log_config
=
docker
.
utils
.
LogConfig
(
log_config
=
docker
.
utils
.
LogConfig
(
type
=
""
,
type
=
""
,
...
@@ -322,9 +355,11 @@ class CreateContainerWithLogConfigTest(BaseTestCase):
...
@@ -322,9 +355,11 @@ class CreateContainerWithLogConfigTest(BaseTestCase):
self
.
assertEqual
(
container_log_config
[
'Config'
],
{})
self
.
assertEqual
(
container_log_config
[
'Config'
],
{})
@unittest.skipIf
(
not
EXEC_DRIVER_IS_NATIVE
,
'Exec driver not native'
)
class
TestCreateContainerReadOnlyFs
(
BaseTestCase
):
class
TestCreateContainerReadOnlyFs
(
BaseTestCase
):
def
runTest
(
self
):
def
runTest
(
self
):
if
not
exec_driver_is_native
():
pytest
.
skip
(
'Exec driver not native'
)
ctnr
=
self
.
client
.
create_container
(
ctnr
=
self
.
client
.
create_container
(
'busybox'
,
[
'mkdir'
,
'/shrine'
],
'busybox'
,
[
'mkdir'
,
'/shrine'
],
host_config
=
self
.
client
.
create_host_config
(
host_config
=
self
.
client
.
create_host_config
(
...
@@ -563,7 +598,7 @@ class TestStop(BaseTestCase):
...
@@ -563,7 +598,7 @@ class TestStop(BaseTestCase):
self
.
assertIn
(
'State'
,
container_info
)
self
.
assertIn
(
'State'
,
container_info
)
state
=
container_info
[
'State'
]
state
=
container_info
[
'State'
]
self
.
assertIn
(
'ExitCode'
,
state
)
self
.
assertIn
(
'ExitCode'
,
state
)
if
EXEC_DRIVER_IS_NATIVE
:
if
exec_driver_is_native
()
:
self
.
assertNotEqual
(
state
[
'ExitCode'
],
0
)
self
.
assertNotEqual
(
state
[
'ExitCode'
],
0
)
self
.
assertIn
(
'Running'
,
state
)
self
.
assertIn
(
'Running'
,
state
)
self
.
assertEqual
(
state
[
'Running'
],
False
)
self
.
assertEqual
(
state
[
'Running'
],
False
)
...
@@ -581,7 +616,7 @@ class TestStopWithDictInsteadOfId(BaseTestCase):
...
@@ -581,7 +616,7 @@ class TestStopWithDictInsteadOfId(BaseTestCase):
self
.
assertIn
(
'State'
,
container_info
)
self
.
assertIn
(
'State'
,
container_info
)
state
=
container_info
[
'State'
]
state
=
container_info
[
'State'
]
self
.
assertIn
(
'ExitCode'
,
state
)
self
.
assertIn
(
'ExitCode'
,
state
)
if
EXEC_DRIVER_IS_NATIVE
:
if
exec_driver_is_native
()
:
self
.
assertNotEqual
(
state
[
'ExitCode'
],
0
)
self
.
assertNotEqual
(
state
[
'ExitCode'
],
0
)
self
.
assertIn
(
'Running'
,
state
)
self
.
assertIn
(
'Running'
,
state
)
self
.
assertEqual
(
state
[
'Running'
],
False
)
self
.
assertEqual
(
state
[
'Running'
],
False
)
...
@@ -598,7 +633,7 @@ class TestKill(BaseTestCase):
...
@@ -598,7 +633,7 @@ class TestKill(BaseTestCase):
self
.
assertIn
(
'State'
,
container_info
)
self
.
assertIn
(
'State'
,
container_info
)
state
=
container_info
[
'State'
]
state
=
container_info
[
'State'
]
self
.
assertIn
(
'ExitCode'
,
state
)
self
.
assertIn
(
'ExitCode'
,
state
)
if
EXEC_DRIVER_IS_NATIVE
:
if
exec_driver_is_native
()
:
self
.
assertNotEqual
(
state
[
'ExitCode'
],
0
)
self
.
assertNotEqual
(
state
[
'ExitCode'
],
0
)
self
.
assertIn
(
'Running'
,
state
)
self
.
assertIn
(
'Running'
,
state
)
self
.
assertEqual
(
state
[
'Running'
],
False
)
self
.
assertEqual
(
state
[
'Running'
],
False
)
...
@@ -615,7 +650,7 @@ class TestKillWithDictInsteadOfId(BaseTestCase):
...
@@ -615,7 +650,7 @@ class TestKillWithDictInsteadOfId(BaseTestCase):
self
.
assertIn
(
'State'
,
container_info
)
self
.
assertIn
(
'State'
,
container_info
)
state
=
container_info
[
'State'
]
state
=
container_info
[
'State'
]
self
.
assertIn
(
'ExitCode'
,
state
)
self
.
assertIn
(
'ExitCode'
,
state
)
if
EXEC_DRIVER_IS_NATIVE
:
if
exec_driver_is_native
()
:
self
.
assertNotEqual
(
state
[
'ExitCode'
],
0
)
self
.
assertNotEqual
(
state
[
'ExitCode'
],
0
)
self
.
assertIn
(
'Running'
,
state
)
self
.
assertIn
(
'Running'
,
state
)
self
.
assertEqual
(
state
[
'Running'
],
False
)
self
.
assertEqual
(
state
[
'Running'
],
False
)
...
@@ -861,9 +896,11 @@ class TestRestartingContainer(BaseTestCase):
...
@@ -861,9 +896,11 @@ class TestRestartingContainer(BaseTestCase):
self
.
client
.
remove_container
(
id
,
force
=
True
)
self
.
client
.
remove_container
(
id
,
force
=
True
)
@unittest.skipIf
(
not
EXEC_DRIVER_IS_NATIVE
,
'Exec driver not native'
)
class
TestExecuteCommand
(
BaseTestCase
):
class
TestExecuteCommand
(
BaseTestCase
):
def
runTest
(
self
):
def
runTest
(
self
):
if
not
exec_driver_is_native
():
pytest
.
skip
(
'Exec driver not native'
)
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
...
@@ -874,13 +911,14 @@ class TestExecuteCommand(BaseTestCase):
...
@@ -874,13 +911,14 @@ class TestExecuteCommand(BaseTestCase):
self
.
assertIn
(
'Id'
,
res
)
self
.
assertIn
(
'Id'
,
res
)
exec_log
=
self
.
client
.
exec_start
(
res
)
exec_log
=
self
.
client
.
exec_start
(
res
)
expected
=
b
'hello
\n
'
if
six
.
PY3
else
'hello
\n
'
self
.
assertEqual
(
exec_log
,
b
'hello
\n
'
)
self
.
assertEqual
(
exec_log
,
expected
)
@unittest.skipIf
(
not
EXEC_DRIVER_IS_NATIVE
,
'Exec driver not native'
)
class
TestExecuteCommandString
(
BaseTestCase
):
class
TestExecuteCommandString
(
BaseTestCase
):
def
runTest
(
self
):
def
runTest
(
self
):
if
not
exec_driver_is_native
():
pytest
.
skip
(
'Exec driver not native'
)
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
...
@@ -891,13 +929,14 @@ class TestExecuteCommandString(BaseTestCase):
...
@@ -891,13 +929,14 @@ class TestExecuteCommandString(BaseTestCase):
self
.
assertIn
(
'Id'
,
res
)
self
.
assertIn
(
'Id'
,
res
)
exec_log
=
self
.
client
.
exec_start
(
res
)
exec_log
=
self
.
client
.
exec_start
(
res
)
expected
=
b
'hello world
\n
'
if
six
.
PY3
else
'hello world
\n
'
self
.
assertEqual
(
exec_log
,
b
'hello world
\n
'
)
self
.
assertEqual
(
exec_log
,
expected
)
@unittest.skipIf
(
not
EXEC_DRIVER_IS_NATIVE
,
'Exec driver not native'
)
class
TestExecuteCommandStringAsUser
(
BaseTestCase
):
class
TestExecuteCommandStringAsUser
(
BaseTestCase
):
def
runTest
(
self
):
def
runTest
(
self
):
if
not
exec_driver_is_native
():
pytest
.
skip
(
'Exec driver not native'
)
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
...
@@ -908,13 +947,14 @@ class TestExecuteCommandStringAsUser(BaseTestCase):
...
@@ -908,13 +947,14 @@ class TestExecuteCommandStringAsUser(BaseTestCase):
self
.
assertIn
(
'Id'
,
res
)
self
.
assertIn
(
'Id'
,
res
)
exec_log
=
self
.
client
.
exec_start
(
res
)
exec_log
=
self
.
client
.
exec_start
(
res
)
expected
=
b
'default'
if
six
.
PY3
else
'default
\n
'
self
.
assertEqual
(
exec_log
,
b
'default
\n
'
)
self
.
assertEqual
(
exec_log
,
expected
)
@unittest.skipIf
(
not
EXEC_DRIVER_IS_NATIVE
,
'Exec driver not native'
)
class
TestExecuteCommandStringAsRoot
(
BaseTestCase
):
class
TestExecuteCommandStringAsRoot
(
BaseTestCase
):
def
runTest
(
self
):
def
runTest
(
self
):
if
not
exec_driver_is_native
():
pytest
.
skip
(
'Exec driver not native'
)
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
...
@@ -925,13 +965,14 @@ class TestExecuteCommandStringAsRoot(BaseTestCase):
...
@@ -925,13 +965,14 @@ class TestExecuteCommandStringAsRoot(BaseTestCase):
self
.
assertIn
(
'Id'
,
res
)
self
.
assertIn
(
'Id'
,
res
)
exec_log
=
self
.
client
.
exec_start
(
res
)
exec_log
=
self
.
client
.
exec_start
(
res
)
expected
=
b
'root'
if
six
.
PY3
else
'root
\n
'
self
.
assertEqual
(
exec_log
,
b
'root
\n
'
)
self
.
assertEqual
(
exec_log
,
expected
)
@unittest.skipIf
(
not
EXEC_DRIVER_IS_NATIVE
,
'Exec driver not native'
)
class
TestExecuteCommandStreaming
(
BaseTestCase
):
class
TestExecuteCommandStreaming
(
BaseTestCase
):
def
runTest
(
self
):
def
runTest
(
self
):
if
not
exec_driver_is_native
():
pytest
.
skip
(
'Exec driver not native'
)
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
...
@@ -941,16 +982,17 @@ class TestExecuteCommandStreaming(BaseTestCase):
...
@@ -941,16 +982,17 @@ class TestExecuteCommandStreaming(BaseTestCase):
exec_id
=
self
.
client
.
exec_create
(
id
,
[
'echo'
,
'hello
\n
world'
])
exec_id
=
self
.
client
.
exec_create
(
id
,
[
'echo'
,
'hello
\n
world'
])
self
.
assertIn
(
'Id'
,
exec_id
)
self
.
assertIn
(
'Id'
,
exec_id
)
res
=
b
''
if
six
.
PY3
else
''
res
=
b
''
for
chunk
in
self
.
client
.
exec_start
(
exec_id
,
stream
=
True
):
for
chunk
in
self
.
client
.
exec_start
(
exec_id
,
stream
=
True
):
res
+=
chunk
res
+=
chunk
expected
=
b
'hello
\n
world
\n
'
if
six
.
PY3
else
'hello
\n
world
\n
'
self
.
assertEqual
(
res
,
b
'hello
\n
world
\n
'
)
self
.
assertEqual
(
res
,
expected
)
@unittest.skipIf
(
not
EXEC_DRIVER_IS_NATIVE
,
'Exec driver not native'
)
class
TestExecInspect
(
BaseTestCase
):
class
TestExecInspect
(
BaseTestCase
):
def
runTest
(
self
):
def
runTest
(
self
):
if
not
exec_driver_is_native
():
pytest
.
skip
(
'Exec driver not native'
)
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
container
=
self
.
client
.
create_container
(
'busybox'
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
id
=
container
[
'Id'
]
...
@@ -1076,7 +1118,7 @@ class TestRemoveLink(BaseTestCase):
...
@@ -1076,7 +1118,7 @@ class TestRemoveLink(BaseTestCase):
class
TestPull
(
BaseTestCase
):
class
TestPull
(
BaseTestCase
):
def
runTest
(
self
):
def
runTest
(
self
):
self
.
client
.
close
()
self
.
client
.
close
()
self
.
client
=
docker
.
Client
(
base_url
=
DEFAULT_BASE_URL
,
timeout
=
10
)
self
.
client
=
docker
_client
(
timeout
=
10
)
try
:
try
:
self
.
client
.
remove_image
(
'busybox'
)
self
.
client
.
remove_image
(
'busybox'
)
except
docker
.
errors
.
APIError
:
except
docker
.
errors
.
APIError
:
...
@@ -1093,7 +1135,7 @@ class TestPull(BaseTestCase):
...
@@ -1093,7 +1135,7 @@ class TestPull(BaseTestCase):
class
TestPullStream
(
BaseTestCase
):
class
TestPullStream
(
BaseTestCase
):
def
runTest
(
self
):
def
runTest
(
self
):
self
.
client
.
close
()
self
.
client
.
close
()
self
.
client
=
docker
.
Client
(
base_url
=
DEFAULT_BASE_URL
,
timeout
=
10
)
self
.
client
=
docker
_client
(
timeout
=
10
)
try
:
try
:
self
.
client
.
remove_image
(
'busybox'
)
self
.
client
.
remove_image
(
'busybox'
)
except
docker
.
errors
.
APIError
:
except
docker
.
errors
.
APIError
:
...
@@ -1254,7 +1296,6 @@ class TestImportFromStream(ImportTestCase):
...
@@ -1254,7 +1296,6 @@ class TestImportFromStream(ImportTestCase):
self
.
tmp_imgs
.
append
(
img_id
)
self
.
tmp_imgs
.
append
(
img_id
)
@unittest.skipIf
(
NOT_ON_HOST
,
'Tests running inside a container'
)
class
TestImportFromURL
(
ImportTestCase
):
class
TestImportFromURL
(
ImportTestCase
):
'''Tests downloading an image over HTTP.'''
'''Tests downloading an image over HTTP.'''
...
@@ -1278,6 +1319,7 @@ class TestImportFromURL(ImportTestCase):
...
@@ -1278,6 +1319,7 @@ class TestImportFromURL(ImportTestCase):
server
.
shutdown
()
server
.
shutdown
()
@pytest.mark.skipif
(
True
,
reason
=
"Doesn't work inside a container - FIXME"
)
def
runTest
(
self
):
def
runTest
(
self
):
# The crappy test HTTP server doesn't handle large files well, so use
# The crappy test HTTP server doesn't handle large files well, so use
# a small file.
# a small file.
...
@@ -1376,6 +1418,7 @@ class TestBuildFromStringIO(BaseTestCase):
...
@@ -1376,6 +1418,7 @@ class TestBuildFromStringIO(BaseTestCase):
class
TestBuildWithDockerignore
(
Cleanup
,
BaseTestCase
):
class
TestBuildWithDockerignore
(
Cleanup
,
BaseTestCase
):
@pytest.mark.skipif
(
True
,
reason
=
'Test is brittle - FIXME'
)
def
runTest
(
self
):
def
runTest
(
self
):
if
compare_version
(
self
.
client
.
_version
,
'1.8'
)
>=
0
:
if
compare_version
(
self
.
client
.
_version
,
'1.8'
)
>=
0
:
return
return
...
@@ -1492,7 +1535,7 @@ class TestLoadJSONConfig(BaseTestCase):
...
@@ -1492,7 +1535,7 @@ class TestLoadJSONConfig(BaseTestCase):
class
TestAutoDetectVersion
(
unittest
.
TestCase
):
class
TestAutoDetectVersion
(
unittest
.
TestCase
):
def
test_client_init
(
self
):
def
test_client_init
(
self
):
client
=
docker
.
Client
(
base_url
=
DEFAULT_BASE_URL
,
version
=
'auto'
)
client
=
docker
_client
(
version
=
'auto'
)
client_version
=
client
.
_version
client_version
=
client
.
_version
api_version
=
client
.
version
(
api_version
=
False
)[
'ApiVersion'
]
api_version
=
client
.
version
(
api_version
=
False
)[
'ApiVersion'
]
self
.
assertEqual
(
client_version
,
api_version
)
self
.
assertEqual
(
client_version
,
api_version
)
...
@@ -1501,7 +1544,7 @@ class TestAutoDetectVersion(unittest.TestCase):
...
@@ -1501,7 +1544,7 @@ class TestAutoDetectVersion(unittest.TestCase):
client
.
close
()
client
.
close
()
def
test_auto_client
(
self
):
def
test_auto_client
(
self
):
client
=
docker
.
AutoVersionClient
(
base_url
=
DEFAULT_BASE_URL
)
client
=
docker
.
AutoVersionClient
(
**
docker_client_kwargs
()
)
client_version
=
client
.
_version
client_version
=
client
.
_version
api_version
=
client
.
version
(
api_version
=
False
)[
'ApiVersion'
]
api_version
=
client
.
version
(
api_version
=
False
)[
'ApiVersion'
]
self
.
assertEqual
(
client_version
,
api_version
)
self
.
assertEqual
(
client_version
,
api_version
)
...
@@ -1509,7 +1552,7 @@ class TestAutoDetectVersion(unittest.TestCase):
...
@@ -1509,7 +1552,7 @@ class TestAutoDetectVersion(unittest.TestCase):
self
.
assertEqual
(
client_version
,
api_version_2
)
self
.
assertEqual
(
client_version
,
api_version_2
)
client
.
close
()
client
.
close
()
with
self
.
assertRaises
(
docker
.
errors
.
DockerException
):
with
self
.
assertRaises
(
docker
.
errors
.
DockerException
):
docker
.
AutoVersionClient
(
base_url
=
DEFAULT_BASE_URL
,
version
=
'1.11'
)
docker
.
AutoVersionClient
(
**
docker_client_kwargs
(
version
=
'1.11'
)
)
class
TestConnectionTimeout
(
unittest
.
TestCase
):
class
TestConnectionTimeout
(
unittest
.
TestCase
):
...
@@ -1544,7 +1587,7 @@ class UnixconnTestCase(unittest.TestCase):
...
@@ -1544,7 +1587,7 @@ class UnixconnTestCase(unittest.TestCase):
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
'always'
)
warnings
.
simplefilter
(
'always'
)
client
=
docker
.
Client
(
base_url
=
DEFAULT_BASE_URL
)
client
=
docker
_client
(
)
client
.
images
()
client
.
images
()
client
.
close
()
client
.
close
()
del
client
del
client
...
@@ -1582,12 +1625,3 @@ class TestRegressions(BaseTestCase):
...
@@ -1582,12 +1625,3 @@ class TestRegressions(BaseTestCase):
ctnr
=
self
.
client
.
create_container
(
'busybox'
,
[
'sleep'
,
'2'
])
ctnr
=
self
.
client
.
create_container
(
'busybox'
,
[
'sleep'
,
'2'
])
self
.
client
.
start
(
ctnr
)
self
.
client
.
start
(
ctnr
)
self
.
client
.
stop
(
ctnr
)
self
.
client
.
stop
(
ctnr
)
if
__name__
==
'__main__'
:
c
=
docker
.
Client
(
base_url
=
DEFAULT_BASE_URL
)
c
.
pull
(
'busybox'
)
exec_driver
=
c
.
info
()[
'ExecutionDriver'
]
EXEC_DRIVER_IS_NATIVE
=
exec_driver
.
startswith
(
'native'
)
c
.
close
()
unittest
.
main
()
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