]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
more test coverage for dns.query._matches_destination()
authorBob Halley <halley@dnspython.org>
Tue, 1 Sep 2020 13:38:18 +0000 (06:38 -0700)
committerBob Halley <halley@dnspython.org>
Tue, 1 Sep 2020 13:38:18 +0000 (06:38 -0700)
tests/test_query.py

index a13833ef12140e3143af1dde4007555dfe925db7..7a1ec718a92cb1ceb6e8567329f50cbc0b468d8c 100644 (file)
@@ -540,3 +540,32 @@ class LowLevelWaitTests(unittest.TestCase):
         finally:
             l.close()
             r.close()
+
+
+class MiscTests(unittest.TestCase):
+    def test_matches_destination(self):
+        self.assertTrue(dns.query._matches_destination(socket.AF_INET,
+                                                       ('10.0.0.1', 1234),
+                                                       ('10.0.0.1', 1234),
+                                                       True))
+        self.assertTrue(dns.query._matches_destination(socket.AF_INET6,
+                                                       ('1::2', 1234),
+                                                       ('0001::2', 1234),
+                                                       True))
+        self.assertTrue(dns.query._matches_destination(socket.AF_INET,
+                                                       ('10.0.0.1', 1234),
+                                                       None,
+                                                       True))
+        self.assertFalse(dns.query._matches_destination(socket.AF_INET,
+                                                        ('10.0.0.1', 1234),
+                                                        ('10.0.0.2', 1234),
+                                                        True))
+        self.assertFalse(dns.query._matches_destination(socket.AF_INET,
+                                                        ('10.0.0.1', 1234),
+                                                        ('10.0.0.1', 1235),
+                                                        True))
+        with self.assertRaises(dns.query.UnexpectedSource):
+            dns.query._matches_destination(socket.AF_INET,
+                                           ('10.0.0.1', 1234),
+                                           ('10.0.0.1', 1235),
+                                           False)