'If C{allowQuery} returns C{False},
L{server.DNSServerFactory.messageReceived} calls L{server.sendReply}
with a message whose C{rCode} is L{dns.EREFUSED}.'

def test_allowQueryFalse(self):

    class SendReplyException(Exception, ):
        pass
    class RaisingDNSServerFactory(server.DNSServerFactory, ):
        def allowQuery(self, *args, **kwargs):
            return False
        def sendReply(self, *args, **kwargs):
            raise SendReplyException(args, kwargs)
    f = RaisingDNSServerFactory()
    e = self.assertRaises(SendReplyException, f.messageReceived, message=dns.Message(), proto=None, address=None)
    ((proto, message, address), kwargs) = e.args
    self.assertEqual(message.rCode, dns.EREFUSED)
