def test_ps_with_filters(self): ''' Check that dockerng.ps accept filters parameter. ''' client = MagicMock() with patch.dict(dockerng_mod.__context__, {'docker.client': client}): dockerng_mod.ps_(filters={'label': 'KEY'}) client.containers.assert_called_once_with(all=True, filters={'label': 'KEY'})
def test_ps_with_filters(self): ''' Check that dockerng.ps accept filters parameter. ''' client = MagicMock() with patch.dict(dockerng_mod.__context__, {'docker.client': client}): dockerng_mod.ps_(filters={'label': 'KEY'}) client.containers.assert_called_once_with( all=True, filters={'label': 'KEY'})
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'})
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. ''' network_interfaces = Mock(return_value={'mocked': None}) with patch.dict(dockerng_mod.__salt__, {'network.interfaces': network_interfaces}): with patch.dict(dockerng_mod.__context__, {'docker.client': MagicMock()}): ret = dockerng_mod.ps_(host=True) self.assertEqual(ret, {'host': {'interfaces': {'mocked': None}}})
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 } }})