Exemplo n.º 1
0
 def test_ps_with_filters(self):
     '''
     Check that docker.ps accept filters parameter.
     '''
     client = MagicMock()
     with patch.dict(docker_mod.__context__, {'docker.client': client}):
         docker_mod.ps_(filters={'label': 'KEY'})
         client.containers.assert_called_once_with(all=True,
                                                   filters={'label': 'KEY'})
Exemplo n.º 2
0
    def test_ps_with_filters(self):
        '''
        Check that docker.ps accept filters parameter.
        '''
        client = Mock()
        client.containers = MagicMock(return_value=[])
        get_client_mock = MagicMock(return_value=client)

        with patch.object(docker_mod, '_get_client', get_client_mock):
            docker_mod.ps_(filters={'label': 'KEY'})
            client.containers.assert_called_once_with(all=True,
                                                      filters={'label': 'KEY'})
Exemplo n.º 3
0
def test_ps_with_filters():
    """
    Check that docker.ps accept filters parameter.
    """
    client = Mock()
    client.containers = MagicMock(return_value=[])
    get_client_mock = MagicMock(return_value=client)

    with patch.object(docker_mod, "_get_client", get_client_mock):
        docker_mod.ps_(filters={"label": "KEY"})
        client.containers.assert_called_once_with(all=True,
                                                  filters={"label": "KEY"})
Exemplo n.º 4
0
def test_ps_with_host_true():
    """
    Check that docker.ps called with host is ``True``,
    include resutlt of ``network.interfaces`` command in returned result.
    """
    client = Mock()
    client.containers = MagicMock(return_value=[])
    get_client_mock = MagicMock(return_value=client)
    network_interfaces = Mock(return_value={"mocked": None})

    with patch.dict(docker_mod.__salt__,
                    {"network.interfaces": network_interfaces}):
        with patch.object(docker_mod, "_get_client", get_client_mock):
            ret = docker_mod.ps_(host=True)
            assert ret == {"host": {"interfaces": {"mocked": None}}}
Exemplo n.º 5
0
    def test_ps_with_host_true(self):
        '''
        Check that docker.ps called with host is ``True``,
        include resutlt of ``network.interfaces`` command in returned result.
        '''
        client = Mock()
        client.containers = MagicMock(return_value=[])
        get_client_mock = MagicMock(return_value=client)
        network_interfaces = Mock(return_value={'mocked': None})

        with patch.dict(docker_mod.__salt__,
                        {'network.interfaces': network_interfaces}):
            with patch.object(docker_mod, '_get_client', get_client_mock):
                ret = docker_mod.ps_(host=True)
                self.assertEqual(ret,
                                 {'host': {'interfaces': {'mocked': None}}})
Exemplo n.º 6
0
 def test_ps_with_host_true(self):
     '''
     Check that docker.ps called with host is ``True``,
     include resutlt of ``network.interfaces`` command in returned result.
     '''
     network_interfaces = Mock(return_value={'mocked': None})
     with patch.dict(docker_mod.__salt__,
                     {'network.interfaces': network_interfaces}):
         with patch.dict(docker_mod.__context__,
                         {'docker.client': MagicMock()}):
             ret = docker_mod.ps_(host=True)
             self.assertEqual(ret,
                              {'host': {
                                  'interfaces': {
                                      'mocked': None
                                  }
                              }})