Esempio n. 1
0
 def test_resolve_bytes(self, fac):
     socks_ep = Mock()
     d = socks.resolve(socks_ep, b'meejah.ca')
     self.assertEqual(1, len(fac.mock_calls))
     self.assertTrue(
         isinstance(fac.mock_calls[0][1][0], text_type)
     )
     return d
Esempio n. 2
0
    def test_resolve(self):
        socks_ep = Mock()
        transport = proto_helpers.StringTransport()

        def connect(factory):
            factory.startFactory()
            proto = factory.buildProtocol("addr")
            proto.makeConnection(transport)
            # XXX sadness: we probably "should" just feed the right
            # bytes to the protocol to convince it a connection is
            # made ... *or* we can cheat and just do the callback
            # directly...
            proto._machine._when_done.fire("the dns answer")
            return proto
        socks_ep.connect = connect
        hn = yield socks.resolve(socks_ep, u'meejah.ca')
        self.assertEqual(hn, "the dns answer")