@mock.patch('compose.service.log', autospec=True)
def test_only_log_warning_when_host_ports_clash(self, mock_log):
    self.mock_client.inspect_image.return_value = {'Id': 'abcd'}
    ParallelStreamWriter.instance = None
    name = 'foo'
    service = Service(name, client=self.mock_client, ports=['8080:80'])
    service.scale(0)
    assert (not mock_log.warn.called)
    service.scale(1)
    assert (not mock_log.warn.called)
    service.scale(2)
    mock_log.warn.assert_called_once_with('The "{}" service specifies a port on the host. If multiple containers for this service are created on a single host, the port will clash.'.format(name))
@mock.patch('compose.service.log', autospec=True)
def test_only_log_warning_when_host_ports_clash(self, mock_log):
    self.mock_client.inspect_image.return_value = {'Id': 'abcd'}
    ParallelStreamWriter.instance = None
    name = 'foo'
    service = Service(name, client=self.mock_client, ports=['8080:80'])
    service.scale(0)
    assert (not mock_log.warn.called)
    service.scale(1)
    assert (not mock_log.warn.called)
    service.scale(2)
    mock_log.warn.assert_called_once_with('The "{}" service specifies a port on the host. If multiple containers for this service are created on a single host, the port will clash.'.format(name))