[tor-commits] [ooni-probe/master] Add basic unittest for testing of DNS

art at torproject.org art at torproject.org
Tue Nov 6 21:31:52 UTC 2012


commit 1d106f36b15960a63fc09fbf737ef98586645856
Author: Arturo Filastò <arturo at 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
+





More information about the tor-commits mailing list