summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2015-05-08 14:00:58 -0700
committerJoffrey F <joffrey@docker.com>2015-05-08 14:00:58 -0700
commit2fd2eebcb06ab253362a2812f56cc31c29157b61 (patch)
treee2387849c762cdd64a6664d2cfa6dee5c5f5829f
parentf28e90bfabb0f671743133210cb16a5cdd3c2a9c (diff)
downloaddocker-py-2fd2eebcb06ab253362a2812f56cc31c29157b61.tar.gz
Added deprecation warning for host config in start
-rw-r--r--docker/client.py6
-rw-r--r--tests/integration_test.py282
-rw-r--r--tests/test.py405
3 files changed, 192 insertions, 501 deletions
diff --git a/docker/client.py b/docker/client.py
index 2d1349c..4775ee7 100644
--- a/docker/client.py
+++ b/docker/client.py
@@ -1059,6 +1059,12 @@ class Client(requests.Session):
url = self._url("/containers/{0}/start".format(container))
if not start_config:
start_config = None
+ elif utils.compare_version('1.15', self._version) > 0:
+ warnings.warn(
+ 'Passing host config parameters in start() is deprecated. '
+ 'Please use host_config in create_container instead!',
+ DeprecationWarning
+ )
res = self._post_json(url, data=start_config)
self._raise_for_status(res)
diff --git a/tests/integration_test.py b/tests/integration_test.py
index 0a56912..2660900 100644
--- a/tests/integration_test.py
+++ b/tests/integration_test.py
@@ -242,113 +242,6 @@ class TestCreateContainerWithRoBinds(BaseTestCase):
self.assertFalse(inspect_data['VolumesRW'][mount_dest])
-class TestStartContainerWithBinds(BaseTestCase):
- def runTest(self):
- mount_dest = '/mnt'
- mount_origin = tempfile.mkdtemp()
- self.tmp_folders.append(mount_origin)
-
- filename = 'shared.txt'
- shared_file = os.path.join(mount_origin, filename)
- binds = {
- mount_origin: {
- 'bind': mount_dest,
- 'ro': False,
- },
- }
-
- with open(shared_file, 'w'):
- container = self.client.create_container(
- 'busybox', ['ls', mount_dest], volumes={mount_dest: {}}
- )
- container_id = container['Id']
- self.client.start(container_id, binds=binds)
- self.tmp_containers.append(container_id)
- exitcode = self.client.wait(container_id)
- self.assertEqual(exitcode, 0)
- logs = self.client.logs(container_id)
-
- os.unlink(shared_file)
- if six.PY3:
- logs = logs.decode('utf-8')
- self.assertIn(filename, logs)
- inspect_data = self.client.inspect_container(container_id)
- self.assertIn('Volumes', inspect_data)
- self.assertIn(mount_dest, inspect_data['Volumes'])
- self.assertEqual(mount_origin, inspect_data['Volumes'][mount_dest])
- self.assertIn(mount_dest, inspect_data['VolumesRW'])
- self.assertTrue(inspect_data['VolumesRW'][mount_dest])
-
-
-class TestStartContainerWithRoBinds(BaseTestCase):
- def runTest(self):
- mount_dest = '/mnt'
- mount_origin = tempfile.mkdtemp()
- self.tmp_folders.append(mount_origin)
-
- filename = 'shared.txt'
- shared_file = os.path.join(mount_origin, filename)
- binds = {
- mount_origin: {
- 'bind': mount_dest,
- 'ro': True,
- },
- }
-
- with open(shared_file, 'w'):
- container = self.client.create_container(
- 'busybox', ['ls', mount_dest], volumes={mount_dest: {}}
- )
- container_id = container['Id']
- self.client.start(container_id, binds=binds)
- self.tmp_containers.append(container_id)
- exitcode = self.client.wait(container_id)
- self.assertEqual(exitcode, 0)
- logs = self.client.logs(container_id)
-
- os.unlink(shared_file)
- if six.PY3:
- logs = logs.decode('utf-8')
- self.assertIn(filename, logs)
-
- inspect_data = self.client.inspect_container(container_id)
- self.assertIn('Volumes', inspect_data)
- self.assertIn(mount_dest, inspect_data['Volumes'])
- self.assertEqual(mount_origin, inspect_data['Volumes'][mount_dest])
- self.assertIn('VolumesRW', inspect_data)
- self.assertIn(mount_dest, inspect_data['VolumesRW'])
- self.assertFalse(inspect_data['VolumesRW'][mount_dest])
-
-
-class TestStartContainerWithFileBind(BaseTestCase):
- def runTest(self):
- mount_dest = '/myfile/myfile'
- mount_origin = tempfile.mktemp()
- try:
- binds = {
- mount_origin: {
- 'bind': mount_dest,
- 'ro': True
- },
- }
-
- with open(mount_origin, 'w') as f:
- f.write('sakuya izayoi')
-
- container = self.client.create_container(
- 'busybox', ['cat', mount_dest], volumes={mount_dest: {}}
- )
- self.client.start(container, binds=binds)
- exitcode = self.client.wait(container)
- self.assertEqual(exitcode, 0)
- logs = self.client.logs(container)
- if six.PY3:
- logs = logs.decode('utf-8')
- self.assertIn('sakuya izayoi', logs)
- finally:
- os.unlink(mount_origin)
-
-
class TestCreateContainerWithLogConfig(BaseTestCase):
def runTest(self):
config = docker.utils.LogConfig(
@@ -388,21 +281,6 @@ class TestCreateContainerReadOnlyFs(BaseTestCase):
self.assertNotEqual(res, 0)
-@unittest.skipIf(not EXEC_DRIVER_IS_NATIVE, 'Exec driver not native')
-class TestStartContainerReadOnlyFs(BaseTestCase):
- def runTest(self):
- # Presumably a bug in 1.5.0
- # https://github.com/docker/docker/issues/10695
- ctnr = self.client.create_container(
- 'busybox', ['mkdir', '/shrine'],
- )
- self.assertIn('Id', ctnr)
- self.tmp_containers.append(ctnr['Id'])
- self.client.start(ctnr, read_only=True)
- # res = self.client.wait(ctnr)
- # self.assertNotEqual(res, 0)
-
-
class TestCreateContainerWithName(BaseTestCase):
def runTest(self):
res = self.client.create_container('busybox', 'true', name='foobar')
@@ -490,29 +368,6 @@ class TestCreateContainerPrivileged(BaseTestCase):
self.assertEqual(inspect['Config']['Privileged'], True)
-class TestStartContainerPrivileged(BaseTestCase):
- def runTest(self):
- res = self.client.create_container('busybox', 'true')
- self.assertIn('Id', res)
- self.tmp_containers.append(res['Id'])
- self.client.start(res['Id'], privileged=True)
- inspect = self.client.inspect_container(res['Id'])
- self.assertIn('Config', inspect)
- self.assertIn('Id', inspect)
- self.assertTrue(inspect['Id'].startswith(res['Id']))
- self.assertIn('Image', inspect)
- self.assertIn('State', inspect)
- self.assertIn('Running', inspect['State'])
- if not inspect['State']['Running']:
- self.assertIn('ExitCode', inspect['State'])
- self.assertEqual(inspect['State']['ExitCode'], 0)
- # Since Nov 2013, the Privileged flag is no longer part of the
- # container's config exposed via the API (safety concerns?).
- #
- if 'Privileged' in inspect['Config']:
- self.assertEqual(inspect['Config']['Privileged'], True)
-
-
class TestWait(BaseTestCase):
def runTest(self):
res = self.client.create_container('busybox', ['sleep', '3'])
@@ -754,34 +609,6 @@ class TestPort(BaseTestCase):
self.client.kill(id)
-class TestStartWithPortBindings(BaseTestCase):
- def runTest(self):
-
- port_bindings = {
- '1111': ('127.0.0.1', '4567'),
- '2222': ('127.0.0.1', '4568')
- }
-
- container = self.client.create_container(
- 'busybox', ['sleep', '60'], ports=list(port_bindings.keys())
- )
- id = container['Id']
-
- self.client.start(container, port_bindings=port_bindings)
-
- # Call the port function on each biding and compare expected vs actual
- for port in port_bindings:
- actual_bindings = self.client.port(container, port)
- port_binding = actual_bindings.pop()
-
- ip, host_port = port_binding['HostIp'], port_binding['HostPort']
-
- self.assertEqual(ip, port_bindings[port][0])
- self.assertEqual(host_port, port_bindings[port][1])
-
- self.client.kill(id)
-
-
class TestMacAddress(BaseTestCase):
def runTest(self):
mac_address_expected = "02:42:ac:11:00:0a"
@@ -949,101 +776,6 @@ class TestCreateContainerWithLinks(BaseTestCase):
self.assertIn('{0}_ENV_FOO=1'.format(link_env_prefix2), logs)
-class TestStartContainerWithVolumesFrom(BaseTestCase):
- def runTest(self):
- vol_names = ['foobar_vol0', 'foobar_vol1']
-
- res0 = self.client.create_container(
- 'busybox', 'true',
- name=vol_names[0])
- container1_id = res0['Id']
- self.tmp_containers.append(container1_id)
- self.client.start(container1_id)
-
- res1 = self.client.create_container(
- 'busybox', 'true',
- name=vol_names[1])
- container2_id = res1['Id']
- self.tmp_containers.append(container2_id)
- self.client.start(container2_id)
- with self.assertRaises(docker.errors.DockerException):
- res2 = self.client.create_container(
- 'busybox', 'cat',
- detach=True, stdin_open=True,
- volumes_from=vol_names)
- res2 = self.client.create_container(
- 'busybox', 'cat',
- detach=True, stdin_open=True)
- container3_id = res2['Id']
- self.tmp_containers.append(container3_id)
- self.client.start(container3_id, volumes_from=vol_names)
-
- info = self.client.inspect_container(res2['Id'])
- self.assertCountEqual(info['HostConfig']['VolumesFrom'], vol_names)
-
-
-class TestStartContainerWithUlimits(BaseTestCase):
- def runTest(self):
- ulimit = docker.utils.Ulimit(name='nofile', soft=4096, hard=4096)
-
- res0 = self.client.create_container('busybox', 'true')
- container1_id = res0['Id']
- self.tmp_containers.append(container1_id)
- self.client.start(container1_id, ulimits=[ulimit])
-
- info = self.client.inspect_container(container1_id)
- self.assertCountEqual(info['HostConfig']['Ulimits'], [ulimit])
-
-
-class TestStartContainerWithLinks(BaseTestCase):
- def runTest(self):
- res0 = self.client.create_container(
- 'busybox', 'cat',
- detach=True, stdin_open=True,
- environment={'FOO': '1'})
-
- container1_id = res0['Id']
- self.tmp_containers.append(container1_id)
-
- self.client.start(container1_id)
-
- res1 = self.client.create_container(
- 'busybox', 'cat',
- detach=True, stdin_open=True,
- environment={'FOO': '1'})
-
- container2_id = res1['Id']
- self.tmp_containers.append(container2_id)
-
- self.client.start(container2_id)
-
- # we don't want the first /
- link_path1 = self.client.inspect_container(container1_id)['Name'][1:]
- link_alias1 = 'mylink1'
- link_env_prefix1 = link_alias1.upper()
-
- link_path2 = self.client.inspect_container(container2_id)['Name'][1:]
- link_alias2 = 'mylink2'
- link_env_prefix2 = link_alias2.upper()
-
- res2 = self.client.create_container('busybox', 'env')
- container3_id = res2['Id']
- self.tmp_containers.append(container3_id)
- self.client.start(
- container3_id,
- links={link_path1: link_alias1, link_path2: link_alias2}
- )
- self.assertEqual(self.client.wait(container3_id), 0)
-
- logs = self.client.logs(container3_id)
- if six.PY3:
- logs = logs.decode('utf-8')
- self.assertIn('{0}_NAME='.format(link_env_prefix1), logs)
- self.assertIn('{0}_ENV_FOO=1'.format(link_env_prefix1), logs)
- self.assertIn('{0}_NAME='.format(link_env_prefix2), logs)
- self.assertIn('{0}_ENV_FOO=1'.format(link_env_prefix2), logs)
-
-
class TestRestartingContainer(BaseTestCase):
def runTest(self):
container = self.client.create_container(
@@ -1190,20 +922,6 @@ class TestCreateContainerWithHostPidMode(BaseTestCase):
self.assertEqual(host_config['PidMode'], 'host')
-class TestStartContainerWithHostPidMode(BaseTestCase):
- def runTest(self):
- ctnr = self.client.create_container(
- 'busybox', 'true'
- )
- self.assertIn('Id', ctnr)
- self.tmp_containers.append(ctnr['Id'])
- self.client.start(ctnr, pid_mode='host')
- inspect = self.client.inspect_container(ctnr)
- self.assertIn('HostConfig', inspect)
- host_config = inspect['HostConfig']
- self.assertIn('PidMode', host_config)
- self.assertEqual(host_config['PidMode'], 'host')
-
#################
# LINKS TESTS #
#################
diff --git a/tests/test.py b/tests/test.py
index efcb37c..75a9223 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -47,6 +47,7 @@ except ImportError:
DEFAULT_TIMEOUT_SECONDS = docker.client.constants.DEFAULT_TIMEOUT_SECONDS
warnings.simplefilter('error')
+warnings.filterwarnings('error')
create_host_config = docker.utils.create_host_config
@@ -972,244 +973,210 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
)
def test_start_container_with_lxc_conf(self):
- try:
- self.client.start(
- fake_api.FAKE_CONTAINER_ID,
- lxc_conf={'lxc.conf.k': 'lxc.conf.value'}
- )
- except Exception as e:
- self.fail('Command should not raise exception: {0}'.format(e))
- args = fake_request.call_args
- self.assertEqual(
- args[0][0],
- url_prefix + 'containers/3cc2351ab11b/start'
- )
- self.assertEqual(
- json.loads(args[1]['data']),
- {"LxcConf": [{"Value": "lxc.conf.value", "Key": "lxc.conf.k"}]}
- )
- self.assertEqual(
- args[1]['headers'],
- {'Content-Type': 'application/json'}
- )
- self.assertEqual(
- args[1]['timeout'],
- DEFAULT_TIMEOUT_SECONDS
- )
+ if six.PY2:
+ try:
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID,
+ lxc_conf={'lxc.conf.k': 'lxc.conf.value'}
+ )
+ except DeprecationWarning as e:
+ return
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ else:
+ self.fail('Expected a DeprecationWarning')
+ else:
+ with self.assertWarns(DeprecationWarning):
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID,
+ lxc_conf={'lxc.conf.k': 'lxc.conf.value'}
+ )
def test_start_container_with_lxc_conf_compat(self):
- try:
- self.client.start(
- fake_api.FAKE_CONTAINER_ID,
- lxc_conf=[{'Key': 'lxc.conf.k', 'Value': 'lxc.conf.value'}]
- )
- except Exception as e:
- self.fail('Command should not raise exception: {0}'.format(e))
-
- args = fake_request.call_args
- self.assertEqual(args[0][0], url_prefix +
- 'containers/3cc2351ab11b/start')
- self.assertEqual(
- json.loads(args[1]['data']),
- {"LxcConf": [{"Key": "lxc.conf.k", "Value": "lxc.conf.value"}]}
- )
- self.assertEqual(args[1]['headers'],
- {'Content-Type': 'application/json'})
- self.assertEqual(
- args[1]['timeout'],
- DEFAULT_TIMEOUT_SECONDS
- )
+ if six.PY2:
+ try:
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID,
+ lxc_conf=[{'Key': 'lxc.conf.k', 'Value': 'lxc.conf.value'}]
+ )
+ except DeprecationWarning as e:
+ return
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ else:
+ self.fail('Expected a DeprecationWarning')
+ else:
+ with self.assertWarns(DeprecationWarning):
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID,
+ lxc_conf=[{'Key': 'lxc.conf.k', 'Value': 'lxc.conf.value'}]
+ )
def test_start_container_with_binds_ro(self):
- try:
- mount_dest = '/mnt'
- mount_origin = '/tmp'
- self.client.start(fake_api.FAKE_CONTAINER_ID,
- binds={mount_origin: {
- "bind": mount_dest,
- "ro": True
- }})
- except Exception as e:
- self.fail('Command should not raise exception: {0}'.format(e))
-
- args = fake_request.call_args
- self.assertEqual(args[0][0], url_prefix +
- 'containers/3cc2351ab11b/start')
- self.assertEqual(
- json.loads(args[1]['data']), {"Binds": ["/tmp:/mnt:ro"]}
- )
- self.assertEqual(args[1]['headers'],
- {'Content-Type': 'application/json'})
- self.assertEqual(
- args[1]['timeout'],
- DEFAULT_TIMEOUT_SECONDS)
+ mount_dest = '/mnt'
+ mount_origin = '/tmp'
+
+ if six.PY2:
+ try:
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID, binds={
+ mount_origin: {
+ "bind": mount_dest,
+ "ro": True
+ }
+ }
+ )
+ except DeprecationWarning as e:
+ return
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ else:
+ self.fail('Expected a DeprecationWarning')
+ else:
+ with self.assertWarns(DeprecationWarning):
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID, binds={
+ mount_origin: {
+ "bind": mount_dest,
+ "ro": True
+ }
+ }
+ )
def test_start_container_with_binds_rw(self):
- try:
- mount_dest = '/mnt'
- mount_origin = '/tmp'
- self.client.start(fake_api.FAKE_CONTAINER_ID,
- binds={mount_origin: {
- "bind": mount_dest, "ro": False}})
- except Exception as e:
- self.fail('Command should not raise exception: {0}'.format(e))
-
- args = fake_request.call_args
- self.assertEqual(args[0][0], url_prefix +
- 'containers/3cc2351ab11b/start')
- self.assertEqual(
- json.loads(args[1]['data']), {"Binds": ["/tmp:/mnt:rw"]}
- )
- self.assertEqual(args[1]['headers'],
- {'Content-Type': 'application/json'})
- self.assertEqual(
- args[1]['timeout'],
- DEFAULT_TIMEOUT_SECONDS
- )
+ mount_dest = '/mnt'
+ mount_origin = '/tmp'
+ if six.PY2:
+ try:
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID, binds={
+ mount_origin: {"bind": mount_dest, "ro": False}
+ }
+ )
+ except DeprecationWarning as e:
+ return
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ else:
+ self.fail('Expected a DeprecationWarning')
+ else:
+ with self.assertWarns(DeprecationWarning):
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID, binds={
+ mount_origin: {"bind": mount_dest, "ro": False}
+ }
+ )
def test_start_container_with_port_binds(self):
self.maxDiff = None
- try:
- self.client.start(fake_api.FAKE_CONTAINER_ID, port_bindings={
- 1111: None,
- 2222: 2222,
- '3333/udp': (3333,),
- 4444: ('127.0.0.1',),
- 5555: ('127.0.0.1', 5555),
- 6666: [('127.0.0.1',), ('192.168.0.1',)]
- })
- except Exception as e:
- self.fail('Command should not raise exception: {0}'.format(e))
-
- args = fake_request.call_args
- self.assertEqual(args[0][0], url_prefix +
- 'containers/3cc2351ab11b/start')
- data = json.loads(args[1]['data'])
- self.assertTrue('1111/tcp' in data['PortBindings'])
- self.assertTrue('2222/tcp' in data['PortBindings'])
- self.assertTrue('3333/udp' in data['PortBindings'])
- self.assertTrue('4444/tcp' in data['PortBindings'])
- self.assertTrue('5555/tcp' in data['PortBindings'])
- self.assertTrue('6666/tcp' in data['PortBindings'])
- self.assertEqual(
- [{"HostPort": "", "HostIp": ""}],
- data['PortBindings']['1111/tcp']
- )
- self.assertEqual(
- [{"HostPort": "2222", "HostIp": ""}],
- data['PortBindings']['2222/tcp']
- )
- self.assertEqual(
- [{"HostPort": "3333", "HostIp": ""}],
- data['PortBindings']['3333/udp']
- )
- self.assertEqual(
- [{"HostPort": "", "HostIp": "127.0.0.1"}],
- data['PortBindings']['4444/tcp']
- )
- self.assertEqual(
- [{"HostPort": "5555", "HostIp": "127.0.0.1"}],
- data['PortBindings']['5555/tcp']
- )
- self.assertEqual(len(data['PortBindings']['6666/tcp']), 2)
- self.assertEqual(args[1]['headers'],
- {'Content-Type': 'application/json'})
- self.assertEqual(
- args[1]['timeout'],
- DEFAULT_TIMEOUT_SECONDS
- )
+ if six.PY2:
+ try:
+ self.client.start(fake_api.FAKE_CONTAINER_ID, port_bindings={
+ 1111: None,
+ 2222: 2222,
+ '3333/udp': (3333,),
+ 4444: ('127.0.0.1',),
+ 5555: ('127.0.0.1', 5555),
+ 6666: [('127.0.0.1',), ('192.168.0.1',)]
+ })
+ except DeprecationWarning as e:
+ return
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ else:
+ self.fail('Expected a DeprecationWarning')
+ else:
+ with self.assertWarns(DeprecationWarning):
+ self.client.start(fake_api.FAKE_CONTAINER_ID, port_bindings={
+ 1111: None,
+ 2222: 2222,
+ '3333/udp': (3333,),
+ 4444: ('127.0.0.1',),
+ 5555: ('127.0.0.1', 5555),
+ 6666: [('127.0.0.1',), ('192.168.0.1',)]
+ })
def test_start_container_with_links(self):
# one link
- try:
- link_path = 'path'
- alias = 'alias'
- self.client.start(fake_api.FAKE_CONTAINER_ID,
- links={link_path: alias})
- except Exception as e:
- self.fail('Command should not raise exception: {0}'.format(e))
-
- args = fake_request.call_args
- self.assertEqual(
- args[0][0],
- url_prefix + 'containers/3cc2351ab11b/start'
- )
- self.assertEqual(
- json.loads(args[1]['data']), {"Links": ["path:alias"]}
- )
- self.assertEqual(
- args[1]['headers'],
- {'Content-Type': 'application/json'}
- )
+ link_path = 'path'
+ alias = 'alias'
+
+ if six.PY2:
+ try:
+ self.client.start(fake_api.FAKE_CONTAINER_ID,
+ links={link_path: alias})
+ except DeprecationWarning as e:
+ return
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ else:
+ self.fail('Expected a DeprecationWarning')
+ else:
+ with self.assertWarns(DeprecationWarning):
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID, links={link_path: alias}
+ )
def test_start_container_with_multiple_links(self):
- try:
- link_path = 'path'
- alias = 'alias'
- self.client.start(
- fake_api.FAKE_CONTAINER_ID,
- links={
- link_path + '1': alias + '1',
- link_path + '2': alias + '2'
- }
- )
- except Exception as e:
- self.fail('Command should not raise exception: {0}'.format(e))
-
- args = fake_request.call_args
- self.assertEqual(
- args[0][0],
- url_prefix + 'containers/3cc2351ab11b/start'
- )
- self.assertEqual(
- json.loads(args[1]['data']),
- {"Links": ["path1:alias1", "path2:alias2"]}
- )
- self.assertEqual(
- args[1]['headers'],
- {'Content-Type': 'application/json'}
- )
+ link_path = 'path'
+ alias = 'alias'
+ if six.PY2:
+ try:
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID,
+ links={
+ link_path + '1': alias + '1',
+ link_path + '2': alias + '2'
+ }
+ )
+ except DeprecationWarning as e:
+ return
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ else:
+ self.fail('Expected a DeprecationWarning')
+ else:
+ with self.assertWarns(DeprecationWarning):
+ self.client.start(
+ fake_api.FAKE_CONTAINER_ID,
+ links={
+ link_path + '1': alias + '1',
+ link_path + '2': alias + '2'
+ }
+ )
def test_start_container_with_links_as_list_of_tuples(self):
# one link
- try:
- link_path = 'path'
- alias = 'alias'
- self.client.start(fake_api.FAKE_CONTAINER_ID,
- links=[(link_path, alias)])
- except Exception as e:
- self.fail('Command should not raise exception: {0}'.format(e))
-
- args = fake_request.call_args
- self.assertEqual(
- args[0][0],
- url_prefix + 'containers/3cc2351ab11b/start'
- )
- self.assertEqual(
- json.loads(args[1]['data']), {"Links": ["path:alias"]}
- )
- self.assertEqual(
- args[1]['headers'], {'Content-Type': 'application/json'}
- )
+ link_path = 'path'
+ alias = 'alias'
+ if six.PY2:
+ try:
+ self.client.start(fake_api.FAKE_CONTAINER_ID,
+ links=[(link_path, alias)])
+ except DeprecationWarning as e:
+ return
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ else:
+ self.fail('Expected a DeprecationWarning')
+ else:
+ with self.assertWarns(DeprecationWarning):
+ self.client.start(fake_api.FAKE_CONTAINER_ID,
+ links=[(link_path, alias)])
def test_start_container_privileged(self):
- try:
- self.client.start(fake_api.FAKE_CONTAINER_ID, privileged=True)
- except Exception as e:
- self.fail('Command should not raise exception: {0}'.format(e))
-
- args = fake_request.call_args
- self.assertEqual(
- args[0][0],
- url_prefix + 'containers/3cc2351ab11b/start'
- )
- self.assertEqual(json.loads(args[1]['data']), {"Privileged": True})
- self.assertEqual(args[1]['headers'],
- {'Content-Type': 'application/json'})
- self.assertEqual(
- args[1]['timeout'],
- DEFAULT_TIMEOUT_SECONDS
- )
+ if six.PY2:
+ try:
+ self.client.start(fake_api.FAKE_CONTAINER_ID, privileged=True)
+ except DeprecationWarning as e:
+ return
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ else:
+ self.fail('Expected a DeprecationWarning')
+ else:
+ with self.assertWarns(DeprecationWarning):
+ self.client.start(fake_api.FAKE_CONTAINER_ID, privileged=True)
def test_start_container_with_dict_instead_of_id(self):
try: