'A successful external IP lookup returns the local interface\'s IP.'

@capture_logging((lambda test, logger: assertHasAction(test, logger, LOG_GET_EXTERNAL_IP, True, {u'host': u'localhost', u'port': test.destination_port}, {u'local_ip': u'127.0.0.1'})))
def test_successful_get_external_ip(self, logger):

    class FakeSocket(object, ):
        def __init__(self, *args):
            self.addr = ('0.0.0.0', 0)
        def getsockname(self):
            return self.addr
        def connect(self, addr):
            self.addr = (addr[0], 12345)
    self.patch(socket, 'socket', FakeSocket())
    self.assertEqual(u'127.0.0.1', _get_external_ip(u'localhost', self.destination_port))
