Beispiel #1
0
def test_connect_container_to_network():
    """
    test connect_container_to_network
    """
    __salt__ = {
        "config.get": Mock(),
        "mine.send": Mock(),
    }
    client = Mock()
    client.api_version = "1.21"
    get_client_mock = MagicMock(return_value=client)

    context = {"docker.exec_driver": "docker-exec"}

    with patch.dict(docker_mod.__dict__, {"__salt__": __salt__}):
        with patch.dict(docker_mod.__context__, context):
            with patch.object(docker_mod, "_get_client", get_client_mock):
                docker_mod.connect_container_to_network("container", "foo")
    client.connect_container_to_network.assert_called_once_with(
        "container", "foo")
Beispiel #2
0
    def test_connect_container_to_network(self, *args):
        '''
        test connect_container_to_network
        '''
        __salt__ = {
            'config.get': Mock(),
            'mine.send': Mock(),
        }
        host_config = {}
        client = Mock()
        client.api_version = '1.21'
        get_client_mock = MagicMock(return_value=client)

        context = {'docker.exec_driver': 'docker-exec'}

        with patch.dict(docker_mod.__dict__, {'__salt__': __salt__}):
            with patch.dict(docker_mod.__context__, context):
                with patch.object(docker_mod, '_get_client', get_client_mock):
                    docker_mod.connect_container_to_network('container', 'foo')
        client.connect_container_to_network.assert_called_once_with(
            'container', 'foo')
Beispiel #3
0
    def test_connect_container_to_network(self, *args):
        '''
        test inspect network.
        '''
        __salt__ = {
            'config.get': Mock(),
            'mine.send': Mock(),
        }
        host_config = {}
        client = Mock()
        client.api_version = '1.21'

        context = {
            'docker.client': client,
            'docker.exec_driver': 'docker-exec'
        }

        with patch.dict(docker_mod.__dict__, {'__salt__': __salt__}):
            with patch.dict(docker_mod.__context__, context):
                docker_mod.connect_container_to_network('container', 'foo')
        client.connect_container_to_network.assert_called_once_with(
            'container', 'foo', None)