Esempio n. 1
0
 def test_create_with_labels_dictlist(self, *args):
     '''
     Create container with labels dictlist.
     '''
     __salt__ = {
         'config.get': Mock(),
         'mine.send': Mock(),
     }
     host_config = {}
     client = Mock()
     client.api_version = '1.19'
     client.create_host_config.return_value = host_config
     client.create_container.return_value = {}
     with patch.dict(docker_mod.__dict__, {'__salt__': __salt__}):
         with patch.dict(docker_mod.__context__, {'docker.client': client}):
             docker_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,
         image='image',
         name='ctn',
     )
Esempio n. 2
0
 def test_create_send_host_config(self, *args):
     '''
     Check host_config object is passed to create_container.
     '''
     __salt__ = {
         'config.get': Mock(),
         'mine.send': Mock(),
     }
     host_config = {'PublishAllPorts': True}
     client = Mock()
     client.api_version = '1.19'
     client.create_host_config.return_value = host_config
     client.create_container.return_value = {}
     with patch.dict(docker_mod.__dict__, {'__salt__': __salt__}):
         with patch.dict(docker_mod.__context__, {'docker.client': client}):
             docker_mod.create('image', name='ctn', publish_all_ports=True)
     client.create_container.assert_called_once_with(
         host_config=host_config, image='image', name='ctn')
Esempio n. 3
0
 def test_create_with_arg_cmd(self, *args):
     '''
     When cmd argument is passed check it is renamed to command.
     '''
     __salt__ = {
         'config.get': Mock(),
         'mine.send': Mock(),
     }
     host_config = {}
     client = Mock()
     client.api_version = '1.19'
     client.create_host_config.return_value = host_config
     client.create_container.return_value = {}
     with patch.dict(docker_mod.__dict__, {'__salt__': __salt__}):
         with patch.dict(docker_mod.__context__, {'docker.client': client}):
             docker_mod.create('image', cmd='ls', name='ctn')
     client.create_container.assert_called_once_with(
         command='ls', host_config=host_config, image='image', name='ctn')