Beispiel #1
0
 def test_simplifier(self):
     """
     L{ComplexResolverSimplifier} translates an L{IHostnameResolver} into an
     L{IResolverSimple} for applications that still expect the old
     interfaces to be in place.
     """
     self.pool, self.doThreadWork = deterministicPool()
     self.reactor, self.doReactorWork = deterministicReactorThreads()
     self.getter = FakeAddrInfoGetter()
     self.resolver = GAIResolver(self.reactor, lambda: self.pool,
                                 self.getter.getaddrinfo)
     simpleResolver = ComplexResolverSimplifier(self.resolver)
     self.getter.addResultForHost('example.com', ('192.168.3.4', 4321))
     success = simpleResolver.getHostByName('example.com')
     failure = simpleResolver.getHostByName('nx.example.com')
     self.doThreadWork()
     self.doReactorWork()
     self.doThreadWork()
     self.doReactorWork()
     self.assertEqual(self.failureResultOf(failure).type, DNSLookupError)
     self.assertEqual(self.successResultOf(success), '192.168.3.4')
 def test_simplifier(self):
     """
     L{ComplexResolverSimplifier} translates an L{IHostnameResolver} into an
     L{IResolverSimple} for applications that still expect the old
     interfaces to be in place.
     """
     self.pool, self.doThreadWork = deterministicPool()
     self.reactor, self.doReactorWork = deterministicReactorThreads()
     self.getter = FakeAddrInfoGetter()
     self.resolver = GAIResolver(self.reactor, lambda: self.pool,
                                 self.getter.getaddrinfo)
     simpleResolver = ComplexResolverSimplifier(self.resolver)
     self.getter.addResultForHost('example.com', ('192.168.3.4', 4321))
     success = simpleResolver.getHostByName('example.com')
     failure = simpleResolver.getHostByName('nx.example.com')
     self.doThreadWork()
     self.doReactorWork()
     self.doThreadWork()
     self.doReactorWork()
     self.assertEqual(self.failureResultOf(failure).type, DNSLookupError)
     self.assertEqual(self.successResultOf(success), '192.168.3.4')