commit 1d106f36b15960a63fc09fbf737ef98586645856 Author: Arturo Filastò arturo@filasto.net Date: Tue Nov 6 19:10:34 2012 +0100
Add basic unittest for testing of DNS --- tests/test_dns.py | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/tests/test_dns.py b/tests/test_dns.py new file mode 100644 index 0000000..e9bb524 --- /dev/null +++ b/tests/test_dns.py @@ -0,0 +1,24 @@ +# +# This unittest is to verify that our usage of the twisted DNS resolver does +# not break with new versions of twisted. + +import pdb +from twisted.trial import unittest + +from twisted.internet import reactor + +from twisted.names import dns +from twisted.names.client import Resolver + +class DNSTest(unittest.TestCase): + def test_a_lookup_ooni_query(self): + def done_query(message, *arg): + answer = message.answers[0] + self.assertEqual(answer.type, 1) + + dns_query = [dns.Query('ooni.nu', type=dns.A)] + resolver = Resolver(servers=[('8.8.8.8', 53)]) + d = resolver.queryUDP(dns_query) + d.addCallback(done_query) + return d +
tor-commits@lists.torproject.org