def test_create_when_removed_containers_are_listed(self):
    self.mock_client.containers.return_value = [{'Id': 'rm_cont_id', 'Name': 'rm_cont', 'Image': 'img_id'}]

    def inspect(name):
        if (name == 'rm_cont_id'):
            raise NotFound(message='Not Found')
        if (name == 'new_cont_id'):
            return {'Id': 'new_cont_id'}
        raise NotImplementedError('incomplete mock')
    self.mock_client.inspect_container.side_effect = inspect
    self.mock_client.inspect_image.return_value = {'Id': 'imageid'}
    self.mock_client.create_container.return_value = {'Id': 'new_cont_id'}
    service = Service('foo', client=self.mock_client)
    assert (service.create_container().id == 'new_cont_id')
def test_create_when_removed_containers_are_listed(self):
    self.mock_client.containers.return_value = [{'Id': 'rm_cont_id', 'Name': 'rm_cont', 'Image': 'img_id'}]

    def inspect(name):
        if (name == 'rm_cont_id'):
            raise NotFound(message='Not Found')
        if (name == 'new_cont_id'):
            return {'Id': 'new_cont_id'}
        raise NotImplementedError('incomplete mock')
    self.mock_client.inspect_container.side_effect = inspect
    self.mock_client.inspect_image.return_value = {'Id': 'imageid'}
    self.mock_client.create_container.return_value = {'Id': 'new_cont_id'}
    service = Service('foo', client=self.mock_client)
    assert (service.create_container().id == 'new_cont_id')