mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Add client_args_mock back to test
I removed this incorrectly in resolving a merge conflict.
This commit is contained in:
parent
a7a78da984
commit
0c608d7417
@ -46,6 +46,33 @@ class DockerngTestCase(TestCase):
|
||||
except AttributeError:
|
||||
docker_version = 0,
|
||||
|
||||
client_args_mock = MagicMock(return_value={
|
||||
'create_container': [
|
||||
'image', 'command', 'hostname', 'user', 'detach', 'stdin_open',
|
||||
'tty', 'ports', 'environment', 'volumes', 'network_disabled',
|
||||
'name', 'entrypoint', 'working_dir', 'domainname', 'cpuset',
|
||||
'host_config', 'mac_address', 'labels', 'volume_driver',
|
||||
'stop_signal', 'networking_config', 'healthcheck',
|
||||
'stop_timeout'],
|
||||
'host_config': [
|
||||
'binds', 'port_bindings', 'lxc_conf', 'publish_all_ports',
|
||||
'links', 'privileged', 'dns', 'dns_search', 'volumes_from',
|
||||
'network_mode', 'restart_policy', 'cap_add', 'cap_drop',
|
||||
'devices', 'extra_hosts', 'read_only', 'pid_mode', 'ipc_mode',
|
||||
'security_opt', 'ulimits', 'log_config', 'mem_limit',
|
||||
'memswap_limit', 'mem_reservation', 'kernel_memory',
|
||||
'mem_swappiness', 'cgroup_parent', 'group_add', 'cpu_quota',
|
||||
'cpu_period', 'blkio_weight', 'blkio_weight_device',
|
||||
'device_read_bps', 'device_write_bps', 'device_read_iops',
|
||||
'device_write_iops', 'oom_kill_disable', 'shm_size', 'sysctls',
|
||||
'tmpfs', 'oom_score_adj', 'dns_opt', 'cpu_shares',
|
||||
'cpuset_cpus', 'userns_mode', 'pids_limit', 'isolation',
|
||||
'auto_remove', 'storage_opt'],
|
||||
'networking_config': [
|
||||
'aliases', 'links', 'ipv4_address', 'ipv6_address',
|
||||
'link_local_ips'],
|
||||
})
|
||||
|
||||
def test_ps_with_host_true(self):
|
||||
'''
|
||||
Check that dockerng.ps called with host is ``True``,
|
||||
@ -106,7 +133,8 @@ class DockerngTestCase(TestCase):
|
||||
'container_resource.run': MagicMock(),
|
||||
'cp.cache_file': MagicMock(return_value=False)}):
|
||||
with patch.object(dockerng_mod, '_get_client', get_client_mock):
|
||||
command('container', *args)
|
||||
with patch.object(dockerng_mod, 'get_client_args', self.client_args_mock):
|
||||
command('container', *args)
|
||||
mine_send.assert_called_with('dockerng.ps', verbose=True, all=True,
|
||||
host=True)
|
||||
|
||||
@ -132,7 +160,8 @@ class DockerngTestCase(TestCase):
|
||||
|
||||
with patch.dict(dockerng_mod.__dict__, {'__salt__': __salt__}):
|
||||
with patch.object(dockerng_mod, '_get_client', get_client_mock):
|
||||
dockerng_mod.create('image', cmd='ls', name='ctn')
|
||||
with patch.object(dockerng_mod, 'get_client_args', self.client_args_mock):
|
||||
dockerng_mod.create('image', cmd='ls', name='ctn')
|
||||
client.create_container.assert_called_once_with(
|
||||
command='ls',
|
||||
host_config=host_config,
|
||||
@ -161,7 +190,8 @@ class DockerngTestCase(TestCase):
|
||||
|
||||
with patch.dict(dockerng_mod.__dict__, {'__salt__': __salt__}):
|
||||
with patch.object(dockerng_mod, '_get_client', get_client_mock):
|
||||
dockerng_mod.create('image', name='ctn', publish_all_ports=True)
|
||||
with patch.object(dockerng_mod, 'get_client_args', self.client_args_mock):
|
||||
dockerng_mod.create('image', name='ctn', publish_all_ports=True)
|
||||
client.create_container.assert_called_once_with(
|
||||
host_config=host_config,
|
||||
image='image',
|
||||
@ -190,12 +220,13 @@ class DockerngTestCase(TestCase):
|
||||
|
||||
with patch.dict(dockerng_mod.__dict__, {'__salt__': __salt__}):
|
||||
with patch.object(dockerng_mod, '_get_client', get_client_mock):
|
||||
dockerng_mod.create(
|
||||
'image',
|
||||
name='ctn',
|
||||
labels={'KEY': 'VALUE'},
|
||||
validate_input=True,
|
||||
)
|
||||
with patch.object(dockerng_mod, 'get_client_args', self.client_args_mock):
|
||||
dockerng_mod.create(
|
||||
'image',
|
||||
name='ctn',
|
||||
labels={'KEY': 'VALUE'},
|
||||
validate_input=True,
|
||||
)
|
||||
client.create_container.assert_called_once_with(
|
||||
labels={'KEY': 'VALUE'},
|
||||
host_config=host_config,
|
||||
@ -225,12 +256,13 @@ class DockerngTestCase(TestCase):
|
||||
get_client_mock = MagicMock(return_value=client)
|
||||
with patch.dict(dockerng_mod.__dict__, {'__salt__': __salt__}):
|
||||
with patch.object(dockerng_mod, '_get_client', get_client_mock):
|
||||
dockerng_mod.create(
|
||||
'image',
|
||||
name='ctn',
|
||||
labels=['KEY1', 'KEY2'],
|
||||
validate_input=True,
|
||||
)
|
||||
with patch.object(dockerng_mod, 'get_client_args', self.client_args_mock):
|
||||
dockerng_mod.create(
|
||||
'image',
|
||||
name='ctn',
|
||||
labels=['KEY1', 'KEY2'],
|
||||
validate_input=True,
|
||||
)
|
||||
client.create_container.assert_called_once_with(
|
||||
labels=['KEY1', 'KEY2'],
|
||||
host_config=host_config,
|
||||
@ -262,13 +294,14 @@ class DockerngTestCase(TestCase):
|
||||
with patch.dict(dockerng_mod.__dict__,
|
||||
{'__salt__': __salt__}):
|
||||
with patch.object(dockerng_mod, '_get_client', get_client_mock):
|
||||
self.assertRaises(SaltInvocationError,
|
||||
dockerng_mod.create,
|
||||
'image',
|
||||
name='ctn',
|
||||
labels=22,
|
||||
validate_input=True,
|
||||
)
|
||||
with patch.object(dockerng_mod, 'get_client_args', self.client_args_mock):
|
||||
self.assertRaises(SaltInvocationError,
|
||||
dockerng_mod.create,
|
||||
'image',
|
||||
name='ctn',
|
||||
labels=22,
|
||||
validate_input=True,
|
||||
)
|
||||
|
||||
@skipIf(docker_version < (1, 4, 0),
|
||||
'docker module must be installed to run this test or is too old. >=1.4.0')
|
||||
@ -293,12 +326,13 @@ class DockerngTestCase(TestCase):
|
||||
|
||||
with patch.dict(dockerng_mod.__dict__, {'__salt__': __salt__}):
|
||||
with patch.object(dockerng_mod, '_get_client', get_client_mock):
|
||||
dockerng_mod.create(
|
||||
'image',
|
||||
name='ctn',
|
||||
labels=[{'KEY1': 'VALUE1'}, {'KEY2': 'VALUE2'}],
|
||||
validate_input=True,
|
||||
)
|
||||
with patch.object(dockerng_mod, 'get_client_args', self.client_args_mock):
|
||||
dockerng_mod.create(
|
||||
'image',
|
||||
name='ctn',
|
||||
labels=[{'KEY1': 'VALUE1'}, {'KEY2': 'VALUE2'}],
|
||||
validate_input=True,
|
||||
)
|
||||
client.create_container.assert_called_once_with(
|
||||
labels={'KEY1': 'VALUE1', 'KEY2': 'VALUE2'},
|
||||
host_config=host_config,
|
||||
|
Loading…
Reference in New Issue
Block a user