def checkTCPEndpoint(self, hint, expected_host, expected_port): ep, host = get_endpoint(hint, {"tcp": DefaultTCP()}) self.failUnless(isinstance(ep, endpoints.TCP4ClientEndpoint), ep) # note: this is fragile, and will break when Twisted changes the # internals of TCP4ClientEndpoint. Hopefully we'll switch to # HostnameEndpoint before then. Although that will break too. self.failUnlessEqual(ep._host, expected_host) self.failUnlessEqual(ep._port, expected_port)
def checkTCPEndpoint(self, hint, expected_host, expected_port): d = get_endpoint(hint, {"tcp": tcp.default()}) (ep, host) = self.successResultOf(d) self.failUnless(isinstance(ep, endpoints.HostnameEndpoint), ep) # note: this is fragile, and will break when Twisted changes the # internals of HostnameEndpoint. self.failUnlessEqual(ep._host, expected_host) self.failUnlessEqual(ep._port, expected_port)
def checkTCPEndpoint(self, hint, expected_host, expected_port): with mock.patch("foolscap.connections.tcp.HostnameEndpoint", side_effect=FakeHostnameEndpoint): d = get_endpoint(hint, {"tcp": tcp.default()}, ConnectionInfo()) (ep, host) = self.successResultOf(d) self.assertTrue(isinstance(ep, FakeHostnameEndpoint), ep) self.assertIs(ep.reactor, reactor) self.assertEqual(ep.host, expected_host) self.assertEqual(ep.port, expected_port)
def checkUnknownEndpoint(self, hint): d = get_endpoint(hint, {"tcp": tcp.default()}, ConnectionInfo()) self.failureResultOf(d, ipb.InvalidHintError)
def checkUnknownEndpoint(self, hint): d = get_endpoint(hint, {"tcp": tcp.default()}) self.failureResultOf(d, ipb.InvalidHintError)
def checkBadTCPEndpoint(self, hint): d = get_endpoint(hint, {"tcp": tcp.default()}, ConnectionInfo()) self.failureResultOf(d, ipb.InvalidHintError)