mirror of https://github.com/docker/docker-py.git
commit
e2fef06bbc
|
|
@ -24,25 +24,22 @@ import requests
|
||||||
import requests.exceptions
|
import requests.exceptions
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
from . import constants
|
||||||
|
from . import errors
|
||||||
from .auth import auth
|
from .auth import auth
|
||||||
from .unixconn import unixconn
|
from .unixconn import unixconn
|
||||||
from .ssladapter import ssladapter
|
from .ssladapter import ssladapter
|
||||||
from .utils import utils, check_resource
|
from .utils import utils, check_resource
|
||||||
from . import errors
|
|
||||||
from .tls import TLSConfig
|
from .tls import TLSConfig
|
||||||
|
|
||||||
|
|
||||||
if not six.PY3:
|
if not six.PY3:
|
||||||
import websocket
|
import websocket
|
||||||
|
|
||||||
DEFAULT_DOCKER_API_VERSION = '1.18'
|
|
||||||
DEFAULT_TIMEOUT_SECONDS = 60
|
|
||||||
STREAM_HEADER_SIZE_BYTES = 8
|
|
||||||
|
|
||||||
|
|
||||||
class Client(requests.Session):
|
class Client(requests.Session):
|
||||||
def __init__(self, base_url=None, version=None,
|
def __init__(self, base_url=None, version=None,
|
||||||
timeout=DEFAULT_TIMEOUT_SECONDS, tls=False):
|
timeout=constants.DEFAULT_TIMEOUT_SECONDS, tls=False):
|
||||||
super(Client, self).__init__()
|
super(Client, self).__init__()
|
||||||
|
|
||||||
if tls and not base_url.startswith('https://'):
|
if tls and not base_url.startswith('https://'):
|
||||||
|
|
@ -70,7 +67,7 @@ class Client(requests.Session):
|
||||||
|
|
||||||
# version detection needs to be after unix adapter mounting
|
# version detection needs to be after unix adapter mounting
|
||||||
if version is None:
|
if version is None:
|
||||||
self._version = DEFAULT_DOCKER_API_VERSION
|
self._version = constants.DEFAULT_DOCKER_API_VERSION
|
||||||
elif isinstance(version, six.string_types):
|
elif isinstance(version, six.string_types):
|
||||||
if version.lower() == 'auto':
|
if version.lower() == 'auto':
|
||||||
self._version = self._retrieve_server_version()
|
self._version = self._retrieve_server_version()
|
||||||
|
|
@ -218,7 +215,7 @@ class Client(requests.Session):
|
||||||
if len(buf[walker:]) < 8:
|
if len(buf[walker:]) < 8:
|
||||||
break
|
break
|
||||||
_, length = struct.unpack_from('>BxxxL', buf[walker:])
|
_, length = struct.unpack_from('>BxxxL', buf[walker:])
|
||||||
start = walker + STREAM_HEADER_SIZE_BYTES
|
start = walker + constants.STREAM_HEADER_SIZE_BYTES
|
||||||
end = start + length
|
end = start + length
|
||||||
walker = end
|
walker = end
|
||||||
yield buf[start:end]
|
yield buf[start:end]
|
||||||
|
|
@ -236,7 +233,7 @@ class Client(requests.Session):
|
||||||
socket.settimeout(None)
|
socket.settimeout(None)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
header = response.raw.read(STREAM_HEADER_SIZE_BYTES)
|
header = response.raw.read(constants.STREAM_HEADER_SIZE_BYTES)
|
||||||
if not header:
|
if not header:
|
||||||
break
|
break
|
||||||
_, length = struct.unpack('>BxxxL', header)
|
_, length = struct.unpack('>BxxxL', header)
|
||||||
|
|
@ -310,11 +307,18 @@ class Client(requests.Session):
|
||||||
def build(self, path=None, tag=None, quiet=False, fileobj=None,
|
def build(self, path=None, tag=None, quiet=False, fileobj=None,
|
||||||
nocache=False, rm=False, stream=False, timeout=None,
|
nocache=False, rm=False, stream=False, timeout=None,
|
||||||
custom_context=False, encoding=None, pull=True,
|
custom_context=False, encoding=None, pull=True,
|
||||||
forcerm=False, dockerfile=None):
|
forcerm=False, dockerfile=None, container_limits=None):
|
||||||
remote = context = headers = None
|
remote = context = headers = None
|
||||||
|
container_limits = container_limits or {}
|
||||||
if path is None and fileobj is None:
|
if path is None and fileobj is None:
|
||||||
raise TypeError("Either path or fileobj needs to be provided.")
|
raise TypeError("Either path or fileobj needs to be provided.")
|
||||||
|
|
||||||
|
for key in container_limits.keys():
|
||||||
|
if key not in constants.CONTAINER_LIMITS_KEYS:
|
||||||
|
raise errors.DockerException(
|
||||||
|
'Invalid container_limits key {0}'.format(key)
|
||||||
|
)
|
||||||
|
|
||||||
if custom_context:
|
if custom_context:
|
||||||
if not fileobj:
|
if not fileobj:
|
||||||
raise TypeError("You must specify fileobj with custom_context")
|
raise TypeError("You must specify fileobj with custom_context")
|
||||||
|
|
@ -357,8 +361,9 @@ class Client(requests.Session):
|
||||||
'rm': rm,
|
'rm': rm,
|
||||||
'forcerm': forcerm,
|
'forcerm': forcerm,
|
||||||
'pull': pull,
|
'pull': pull,
|
||||||
'dockerfile': dockerfile
|
'dockerfile': dockerfile,
|
||||||
}
|
}
|
||||||
|
params.update(container_limits)
|
||||||
|
|
||||||
if context is not None:
|
if context is not None:
|
||||||
headers = {'Content-Type': 'application/tar'}
|
headers = {'Content-Type': 'application/tar'}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
DEFAULT_DOCKER_API_VERSION = '1.18'
|
||||||
|
DEFAULT_TIMEOUT_SECONDS = 60
|
||||||
|
STREAM_HEADER_SIZE_BYTES = 8
|
||||||
|
CONTAINER_LIMITS_KEYS = [
|
||||||
|
'memory', 'memswap', 'cpushares', 'cpusetcpus'
|
||||||
|
]
|
||||||
|
|
@ -65,6 +65,12 @@ correct value (e.g `gzip`).
|
||||||
* pull (bool): Downloads any updates to the FROM image in Dockerfiles
|
* pull (bool): Downloads any updates to the FROM image in Dockerfiles
|
||||||
* forcerm (bool): Always remove intermediate containers, even after unsuccessful builds
|
* forcerm (bool): Always remove intermediate containers, even after unsuccessful builds
|
||||||
* dockerfile (str): path within the build context to the Dockerfile
|
* dockerfile (str): path within the build context to the Dockerfile
|
||||||
|
* container_limits (dict): A dictionary of limits applied to each container
|
||||||
|
created by the build process. Valid keys:
|
||||||
|
- memory (int): set memory limit for build
|
||||||
|
- memswap (int): Total memory (memory + swap), -1 to disable swap
|
||||||
|
- cpushares (int): CPU shares (relative weight)
|
||||||
|
- cpusetcpus (str): CPUs in which to allow exection, e.g., `"0-3"`, `"0,1"`
|
||||||
|
|
||||||
**Returns** (generator): A generator of the build output
|
**Returns** (generator): A generator of the build output
|
||||||
|
|
||||||
|
|
|
||||||
159
tests/test.py
159
tests/test.py
|
|
@ -44,6 +44,8 @@ except ImportError:
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
|
||||||
|
DEFAULT_TIMEOUT_SECONDS = docker.client.constants.DEFAULT_TIMEOUT_SECONDS
|
||||||
|
|
||||||
warnings.simplefilter('error')
|
warnings.simplefilter('error')
|
||||||
create_host_config = docker.utils.create_host_config
|
create_host_config = docker.utils.create_host_config
|
||||||
|
|
||||||
|
|
@ -73,7 +75,7 @@ def fake_resp(url, data=None, **kwargs):
|
||||||
|
|
||||||
fake_request = mock.Mock(side_effect=fake_resp)
|
fake_request = mock.Mock(side_effect=fake_resp)
|
||||||
url_prefix = 'http+docker://localunixsocket/v{0}/'.format(
|
url_prefix = 'http+docker://localunixsocket/v{0}/'.format(
|
||||||
docker.client.DEFAULT_DOCKER_API_VERSION)
|
docker.client.constants.DEFAULT_DOCKER_API_VERSION)
|
||||||
|
|
||||||
|
|
||||||
class Cleanup(object):
|
class Cleanup(object):
|
||||||
|
|
@ -150,7 +152,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
|
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'version',
|
url_prefix + 'version',
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_retrieve_server_version(self):
|
def test_retrieve_server_version(self):
|
||||||
|
|
@ -175,7 +177,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
|
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'info',
|
url_prefix + 'info',
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_search(self):
|
def test_search(self):
|
||||||
|
|
@ -187,7 +189,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'images/search',
|
url_prefix + 'images/search',
|
||||||
params={'term': 'busybox'},
|
params={'term': 'busybox'},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_image_viz(self):
|
def test_image_viz(self):
|
||||||
|
|
@ -260,7 +262,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'images/json',
|
url_prefix + 'images/json',
|
||||||
params={'filter': None, 'only_ids': 0, 'all': 1},
|
params={'filter': None, 'only_ids': 0, 'all': 1},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_images_quiet(self):
|
def test_images_quiet(self):
|
||||||
|
|
@ -271,7 +273,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'images/json',
|
url_prefix + 'images/json',
|
||||||
params={'filter': None, 'only_ids': 1, 'all': 1},
|
params={'filter': None, 'only_ids': 1, 'all': 1},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_image_ids(self):
|
def test_image_ids(self):
|
||||||
|
|
@ -283,7 +285,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'images/json',
|
url_prefix + 'images/json',
|
||||||
params={'filter': None, 'only_ids': 1, 'all': 0},
|
params={'filter': None, 'only_ids': 1, 'all': 0},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_images_filters(self):
|
def test_images_filters(self):
|
||||||
|
|
@ -296,7 +298,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
url_prefix + 'images/json',
|
url_prefix + 'images/json',
|
||||||
params={'filter': None, 'only_ids': 0, 'all': 0,
|
params={'filter': None, 'only_ids': 0, 'all': 0,
|
||||||
'filters': '{"dangling": ["true"]}'},
|
'filters': '{"dangling": ["true"]}'},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_list_containers(self):
|
def test_list_containers(self):
|
||||||
|
|
@ -315,7 +317,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
'trunc_cmd': 0,
|
'trunc_cmd': 0,
|
||||||
'before': None
|
'before': None
|
||||||
},
|
},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
|
|
@ -666,7 +668,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
args[1]['headers'], {'Content-Type': 'application/json'}
|
args[1]['headers'], {'Content-Type': 'application/json'}
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
|
args[1]['timeout'], DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_start_container_none(self):
|
def test_start_container_none(self):
|
||||||
|
|
@ -711,7 +713,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_lxc_conf_compat(self):
|
def test_create_container_with_lxc_conf_compat(self):
|
||||||
|
|
@ -737,7 +739,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_binds_ro(self):
|
def test_create_container_with_binds_ro(self):
|
||||||
|
|
@ -766,7 +768,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_binds_rw(self):
|
def test_create_container_with_binds_rw(self):
|
||||||
|
|
@ -795,7 +797,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_port_binds(self):
|
def test_create_container_with_port_binds(self):
|
||||||
|
|
@ -851,7 +853,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_mac_address(self):
|
def test_create_container_with_mac_address(self):
|
||||||
|
|
@ -960,7 +962,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_start_container_with_lxc_conf(self):
|
def test_start_container_with_lxc_conf(self):
|
||||||
|
|
@ -986,7 +988,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_start_container_with_lxc_conf_compat(self):
|
def test_start_container_with_lxc_conf_compat(self):
|
||||||
|
|
@ -1009,7 +1011,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_start_container_with_binds_ro(self):
|
def test_start_container_with_binds_ro(self):
|
||||||
|
|
@ -1034,7 +1036,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS)
|
DEFAULT_TIMEOUT_SECONDS)
|
||||||
|
|
||||||
def test_start_container_with_binds_rw(self):
|
def test_start_container_with_binds_rw(self):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1056,7 +1058,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_start_container_with_port_binds(self):
|
def test_start_container_with_port_binds(self):
|
||||||
|
|
@ -1108,7 +1110,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_start_container_with_links(self):
|
def test_start_container_with_links(self):
|
||||||
|
|
@ -1200,7 +1202,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
{'Content-Type': 'application/json'})
|
{'Content-Type': 'application/json'})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'],
|
args[1]['timeout'],
|
||||||
docker.client.DEFAULT_TIMEOUT_SECONDS
|
DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_start_container_with_dict_instead_of_id(self):
|
def test_start_container_with_dict_instead_of_id(self):
|
||||||
|
|
@ -1218,7 +1220,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
args[1]['headers'], {'Content-Type': 'application/json'}
|
args[1]['headers'], {'Content-Type': 'application/json'}
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
|
args[1]['timeout'], DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_restart_policy(self):
|
def test_create_container_with_restart_policy(self):
|
||||||
|
|
@ -1247,7 +1249,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
args[1]['headers'], {'Content-Type': 'application/json'}
|
args[1]['headers'], {'Content-Type': 'application/json'}
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
|
args[1]['timeout'], DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_added_capabilities(self):
|
def test_create_container_with_added_capabilities(self):
|
||||||
|
|
@ -1268,7 +1270,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
args[1]['headers'], {'Content-Type': 'application/json'}
|
args[1]['headers'], {'Content-Type': 'application/json'}
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
|
args[1]['timeout'], DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_dropped_capabilities(self):
|
def test_create_container_with_dropped_capabilities(self):
|
||||||
|
|
@ -1289,7 +1291,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
args[1]['headers'], {'Content-Type': 'application/json'}
|
args[1]['headers'], {'Content-Type': 'application/json'}
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
|
args[1]['timeout'], DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_devices(self):
|
def test_create_container_with_devices(self):
|
||||||
|
|
@ -1323,7 +1325,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
args[1]['headers'], {'Content-Type': 'application/json'}
|
args[1]['headers'], {'Content-Type': 'application/json'}
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
|
args[1]['timeout'], DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_labels_dict(self):
|
def test_create_container_with_labels_dict(self):
|
||||||
|
|
@ -1345,7 +1347,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
args[1]['headers'], {'Content-Type': 'application/json'}
|
args[1]['headers'], {'Content-Type': 'application/json'}
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
|
args[1]['timeout'], DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_create_container_with_labels_list(self):
|
def test_create_container_with_labels_list(self):
|
||||||
|
|
@ -1371,7 +1373,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
args[1]['headers'], {'Content-Type': 'application/json'}
|
args[1]['headers'], {'Content-Type': 'application/json'}
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
|
args[1]['timeout'], DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_resize_container(self):
|
def test_resize_container(self):
|
||||||
|
|
@ -1387,7 +1389,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/resize',
|
url_prefix + 'containers/3cc2351ab11b/resize',
|
||||||
params={'h': 15, 'w': 120},
|
params={'h': 15, 'w': 120},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_rename_container(self):
|
def test_rename_container(self):
|
||||||
|
|
@ -1402,7 +1404,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/rename',
|
url_prefix + 'containers/3cc2351ab11b/rename',
|
||||||
params={'name': 'foobar'},
|
params={'name': 'foobar'},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_wait(self):
|
def test_wait(self):
|
||||||
|
|
@ -1467,7 +1469,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
url_prefix + 'containers/3cc2351ab11b/logs',
|
url_prefix + 'containers/3cc2351ab11b/logs',
|
||||||
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
|
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
|
||||||
'tail': 'all'},
|
'tail': 'all'},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS,
|
timeout=DEFAULT_TIMEOUT_SECONDS,
|
||||||
stream=False
|
stream=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1486,7 +1488,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
url_prefix + 'containers/3cc2351ab11b/logs',
|
url_prefix + 'containers/3cc2351ab11b/logs',
|
||||||
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
|
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
|
||||||
'tail': 'all'},
|
'tail': 'all'},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS,
|
timeout=DEFAULT_TIMEOUT_SECONDS,
|
||||||
stream=False
|
stream=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1505,7 +1507,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
url_prefix + 'containers/3cc2351ab11b/logs',
|
url_prefix + 'containers/3cc2351ab11b/logs',
|
||||||
params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1,
|
params={'timestamps': 0, 'follow': 1, 'stderr': 1, 'stdout': 1,
|
||||||
'tail': 'all'},
|
'tail': 'all'},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS,
|
timeout=DEFAULT_TIMEOUT_SECONDS,
|
||||||
stream=True
|
stream=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1519,7 +1521,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
url_prefix + 'containers/3cc2351ab11b/logs',
|
url_prefix + 'containers/3cc2351ab11b/logs',
|
||||||
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
|
params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1,
|
||||||
'tail': 10},
|
'tail': 10},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS,
|
timeout=DEFAULT_TIMEOUT_SECONDS,
|
||||||
stream=False
|
stream=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1531,7 +1533,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
|
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/changes',
|
url_prefix + 'containers/3cc2351ab11b/changes',
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_diff_with_dict_instead_of_id(self):
|
def test_diff_with_dict_instead_of_id(self):
|
||||||
|
|
@ -1542,7 +1544,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
|
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/changes',
|
url_prefix + 'containers/3cc2351ab11b/changes',
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_port(self):
|
def test_port(self):
|
||||||
|
|
@ -1553,7 +1555,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
|
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/json',
|
url_prefix + 'containers/3cc2351ab11b/json',
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_stop_container(self):
|
def test_stop_container(self):
|
||||||
|
|
@ -1566,7 +1568,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/stop',
|
url_prefix + 'containers/3cc2351ab11b/stop',
|
||||||
params={'t': timeout},
|
params={'t': timeout},
|
||||||
timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS + timeout)
|
timeout=(DEFAULT_TIMEOUT_SECONDS + timeout)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_stop_container_with_dict_instead_of_id(self):
|
def test_stop_container_with_dict_instead_of_id(self):
|
||||||
|
|
@ -1580,7 +1582,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/stop',
|
url_prefix + 'containers/3cc2351ab11b/stop',
|
||||||
params={'t': timeout},
|
params={'t': timeout},
|
||||||
timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS + timeout)
|
timeout=(DEFAULT_TIMEOUT_SECONDS + timeout)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_exec_create(self):
|
def test_exec_create(self):
|
||||||
|
|
@ -1679,7 +1681,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
self.fail('Command should not raise exception: {0}'.format(e))
|
self.fail('Command should not raise exception: {0}'.format(e))
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/pause',
|
url_prefix + 'containers/3cc2351ab11b/pause',
|
||||||
timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS)
|
timeout=(DEFAULT_TIMEOUT_SECONDS)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_unpause_container(self):
|
def test_unpause_container(self):
|
||||||
|
|
@ -1689,7 +1691,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
self.fail('Command should not raise exception: {0}'.format(e))
|
self.fail('Command should not raise exception: {0}'.format(e))
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/unpause',
|
url_prefix + 'containers/3cc2351ab11b/unpause',
|
||||||
timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS)
|
timeout=(DEFAULT_TIMEOUT_SECONDS)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_kill_container(self):
|
def test_kill_container(self):
|
||||||
|
|
@ -1701,7 +1703,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/kill',
|
url_prefix + 'containers/3cc2351ab11b/kill',
|
||||||
params={},
|
params={},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_kill_container_with_dict_instead_of_id(self):
|
def test_kill_container_with_dict_instead_of_id(self):
|
||||||
|
|
@ -1713,7 +1715,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/kill',
|
url_prefix + 'containers/3cc2351ab11b/kill',
|
||||||
params={},
|
params={},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_kill_container_with_signal(self):
|
def test_kill_container_with_signal(self):
|
||||||
|
|
@ -1725,7 +1727,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/kill',
|
url_prefix + 'containers/3cc2351ab11b/kill',
|
||||||
params={'signal': signal.SIGTERM},
|
params={'signal': signal.SIGTERM},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_restart_container(self):
|
def test_restart_container(self):
|
||||||
|
|
@ -1737,7 +1739,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/restart',
|
url_prefix + 'containers/3cc2351ab11b/restart',
|
||||||
params={'t': 2},
|
params={'t': 2},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_restart_container_with_dict_instead_of_id(self):
|
def test_restart_container_with_dict_instead_of_id(self):
|
||||||
|
|
@ -1749,7 +1751,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/restart',
|
url_prefix + 'containers/3cc2351ab11b/restart',
|
||||||
params={'t': 2},
|
params={'t': 2},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_remove_container(self):
|
def test_remove_container(self):
|
||||||
|
|
@ -1761,7 +1763,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b',
|
url_prefix + 'containers/3cc2351ab11b',
|
||||||
params={'v': False, 'link': False, 'force': False},
|
params={'v': False, 'link': False, 'force': False},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_remove_container_with_dict_instead_of_id(self):
|
def test_remove_container_with_dict_instead_of_id(self):
|
||||||
|
|
@ -1773,7 +1775,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b',
|
url_prefix + 'containers/3cc2351ab11b',
|
||||||
params={'v': False, 'link': False, 'force': False},
|
params={'v': False, 'link': False, 'force': False},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_remove_link(self):
|
def test_remove_link(self):
|
||||||
|
|
@ -1785,7 +1787,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b',
|
url_prefix + 'containers/3cc2351ab11b',
|
||||||
params={'v': False, 'link': True, 'force': False},
|
params={'v': False, 'link': True, 'force': False},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_export(self):
|
def test_export(self):
|
||||||
|
|
@ -1797,7 +1799,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/export',
|
url_prefix + 'containers/3cc2351ab11b/export',
|
||||||
stream=True,
|
stream=True,
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_export_with_dict_instead_of_id(self):
|
def test_export_with_dict_instead_of_id(self):
|
||||||
|
|
@ -1809,7 +1811,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/export',
|
url_prefix + 'containers/3cc2351ab11b/export',
|
||||||
stream=True,
|
stream=True,
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_inspect_container(self):
|
def test_inspect_container(self):
|
||||||
|
|
@ -1820,7 +1822,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
|
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'containers/3cc2351ab11b/json',
|
url_prefix + 'containers/3cc2351ab11b/json',
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_container_stats(self):
|
def test_container_stats(self):
|
||||||
|
|
@ -1890,7 +1892,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
'container': '3cc2351ab11b',
|
'container': '3cc2351ab11b',
|
||||||
'author': None
|
'author': None
|
||||||
},
|
},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_remove_image(self):
|
def test_remove_image(self):
|
||||||
|
|
@ -1902,7 +1904,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'images/e9aa60c60128',
|
url_prefix + 'images/e9aa60c60128',
|
||||||
params={'force': False, 'noprune': False},
|
params={'force': False, 'noprune': False},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_image_history(self):
|
def test_image_history(self):
|
||||||
|
|
@ -1913,7 +1915,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
|
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'images/test_image/history',
|
url_prefix + 'images/test_image/history',
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_import_image(self):
|
def test_import_image(self):
|
||||||
|
|
@ -1934,7 +1936,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
'fromSrc': fake_api.FAKE_TARBALL_PATH
|
'fromSrc': fake_api.FAKE_TARBALL_PATH
|
||||||
},
|
},
|
||||||
data=None,
|
data=None,
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_import_image_from_bytes(self):
|
def test_import_image_from_bytes(self):
|
||||||
|
|
@ -1959,7 +1961,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
'Content-Type': 'application/tar',
|
'Content-Type': 'application/tar',
|
||||||
},
|
},
|
||||||
data=stream,
|
data=stream,
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_import_image_from_image(self):
|
def test_import_image_from_image(self):
|
||||||
|
|
@ -1980,7 +1982,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
'fromImage': fake_api.FAKE_IMAGE_NAME
|
'fromImage': fake_api.FAKE_IMAGE_NAME
|
||||||
},
|
},
|
||||||
data=None,
|
data=None,
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_inspect_image(self):
|
def test_inspect_image(self):
|
||||||
|
|
@ -1991,7 +1993,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
|
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'images/test_image/json',
|
url_prefix + 'images/test_image/json',
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_insert_image(self):
|
def test_insert_image(self):
|
||||||
|
|
@ -2012,7 +2014,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
'url': fake_api.FAKE_URL,
|
'url': fake_api.FAKE_URL,
|
||||||
'path': fake_api.FAKE_PATH
|
'path': fake_api.FAKE_PATH
|
||||||
},
|
},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_push_image(self):
|
def test_push_image(self):
|
||||||
|
|
@ -2031,7 +2033,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
data='{}',
|
data='{}',
|
||||||
headers={'Content-Type': 'application/json'},
|
headers={'Content-Type': 'application/json'},
|
||||||
stream=False,
|
stream=False,
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_push_image_with_tag(self):
|
def test_push_image_with_tag(self):
|
||||||
|
|
@ -2052,7 +2054,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
data='{}',
|
data='{}',
|
||||||
headers={'Content-Type': 'application/json'},
|
headers={'Content-Type': 'application/json'},
|
||||||
stream=False,
|
stream=False,
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_push_image_stream(self):
|
def test_push_image_stream(self):
|
||||||
|
|
@ -2071,7 +2073,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
data='{}',
|
data='{}',
|
||||||
headers={'Content-Type': 'application/json'},
|
headers={'Content-Type': 'application/json'},
|
||||||
stream=True,
|
stream=True,
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_tag_image(self):
|
def test_tag_image(self):
|
||||||
|
|
@ -2087,7 +2089,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
'repo': 'repo',
|
'repo': 'repo',
|
||||||
'force': 0
|
'force': 0
|
||||||
},
|
},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_tag_image_tag(self):
|
def test_tag_image_tag(self):
|
||||||
|
|
@ -2107,7 +2109,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
'repo': 'repo',
|
'repo': 'repo',
|
||||||
'force': 0
|
'force': 0
|
||||||
},
|
},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_tag_image_force(self):
|
def test_tag_image_force(self):
|
||||||
|
|
@ -2124,7 +2126,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
'repo': 'repo',
|
'repo': 'repo',
|
||||||
'force': 1
|
'force': 1
|
||||||
},
|
},
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_get_image(self):
|
def test_get_image(self):
|
||||||
|
|
@ -2136,7 +2138,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'images/e9aa60c60128/get',
|
url_prefix + 'images/e9aa60c60128/get',
|
||||||
stream=True,
|
stream=True,
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_load_image(self):
|
def test_load_image(self):
|
||||||
|
|
@ -2148,7 +2150,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
fake_request.assert_called_with(
|
fake_request.assert_called_with(
|
||||||
url_prefix + 'images/load',
|
url_prefix + 'images/load',
|
||||||
data='Byte Stream....',
|
data='Byte Stream....',
|
||||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
timeout=DEFAULT_TIMEOUT_SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
|
@ -2252,6 +2254,25 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.fail('Command should not raise exception: {0}'.format(e))
|
self.fail('Command should not raise exception: {0}'.format(e))
|
||||||
|
|
||||||
|
def test_build_container_with_container_limits(self):
|
||||||
|
try:
|
||||||
|
self.client.build('.', container_limits={
|
||||||
|
'memory': 1024 * 1024,
|
||||||
|
'cpusetcpus': 1,
|
||||||
|
'cpushares': 1000,
|
||||||
|
'memswap': 1024 * 1024 * 8
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
self.fail('Command should not raise exception: {0}'.format(e))
|
||||||
|
|
||||||
|
def test_build_container_invalid_container_limits(self):
|
||||||
|
self.assertRaises(
|
||||||
|
docker.errors.DockerException,
|
||||||
|
lambda: self.client.build('.', container_limits={
|
||||||
|
'foo': 'bar'
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# PY SPECIFIC TESTS #
|
# PY SPECIFIC TESTS #
|
||||||
#######################
|
#######################
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue