예제 #1
0
    def test_ps_with_filters(self):
        '''
        Check that dockerng.ps accept filters parameter.
        '''
        client = Mock()
        client.containers = MagicMock(return_value=[])
        get_client_mock = MagicMock(return_value=client)

        with patch.object(dockerng_mod, '_get_client', get_client_mock):
            dockerng_mod.ps_(filters={'label': 'KEY'})
            client.containers.assert_called_once_with(all=True,
                                                      filters={'label': 'KEY'})
예제 #2
0
    def test_ps_with_host_true(self):
        '''
        Check that dockerng.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(dockerng_mod.__salt__,
                        {'network.interfaces': network_interfaces}):
            with patch.object(dockerng_mod, '_get_client', get_client_mock):
                ret = dockerng_mod.ps_(host=True)
                self.assertEqual(ret,
                                 {'host': {
                                     'interfaces': {
                                         'mocked': None
                                     }
                                 }})