'L{server.DNSServerFactory.handleQuery} adds
L{server.DNSServerFactory.resolver.gotResolverError} as an errback to
the deferred returned by L{server.DNSServerFactory.resolver.query}. It
is called with the query failure, the original protocol, message and
origin address.'

def test_handleQueryErrback(self):

    f = server.DNSServerFactory()
    d = defer.Deferred()
    class FakeResolver(object, ):
        def query(self, *args, **kwargs):
            return d
    f.resolver = FakeResolver()
    gotResolverErrorArgs = []
    def fakeGotResolverError(*args, **kwargs):
        gotResolverErrorArgs.append((args, kwargs))
    f.gotResolverError = fakeGotResolverError
    m = dns.Message()
    m.addQuery('one.example.com')
    stubProtocol = NoopProtocol()
    dummyAddress = object()
    f.handleQuery(message=m, protocol=stubProtocol, address=dummyAddress)
    stubFailure = failure.Failure(Exception())
    d.errback(stubFailure)
    self.assertEqual(gotResolverErrorArgs, [((stubFailure, stubProtocol, m, dummyAddress), {})])
