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'})
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'})
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"})
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}}}
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}}})
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 } }})