def test_ensure_image_exists_force_build(self):
    service = Service('foo', client=self.mock_client, build={'context': '.'})
    self.mock_client.inspect_image.return_value = {'Id': 'abc123'}
    self.mock_client.build.return_value = ['{"stream": "Successfully built abcd"}']
    with mock.patch('compose.service.log', autospec=True) as mock_log:
        service.ensure_image_exists(do_build=BuildAction.force)
    assert (not mock_log.warn.called)
    assert (self.mock_client.build.call_count == 1)
    (self.mock_client.build.call_args[1]['tag'] == 'default_foo')
def test_ensure_image_exists_force_build(self):
    service = Service('foo', client=self.mock_client, build={'context': '.'})
    self.mock_client.inspect_image.return_value = {'Id': 'abc123'}
    self.mock_client.build.return_value = ['{"stream": "Successfully built abcd"}']
    with mock.patch('compose.service.log', autospec=True) as mock_log:
        service.ensure_image_exists(do_build=BuildAction.force)
    assert (not mock_log.warn.called)
    assert (self.mock_client.build.call_count == 1)
    (self.mock_client.build.call_args[1]['tag'] == 'default_foo')