diff options
author | Bob Halley <halley@dnspython.org> | 2020-06-19 09:26:50 -0700 |
---|---|---|
committer | Bob Halley <halley@dnspython.org> | 2020-06-19 09:26:50 -0700 |
commit | 299b4ee6ac0af229d4b90dd77080bf597a11ebc5 (patch) | |
tree | cd02e632c4ba41ec8ee775dca63433a69da0ce3d | |
parent | d41946f9ceea1afaece68700d072a4ad9211a62a (diff) | |
download | dnspython-299b4ee6ac0af229d4b90dd77080bf597a11ebc5.tar.gz |
more EDNS coverage
-rw-r--r-- | tests/test_edns.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_edns.py b/tests/test_edns.py index f4d6075..a640a74 100644 --- a/tests/test_edns.py +++ b/tests/test_edns.py @@ -16,6 +16,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +import operator import unittest from io import BytesIO @@ -111,3 +112,29 @@ class OptionTestCase(unittest.TestCase): with self.assertRaises(ValueError): dns.edns.ECSOption.from_text('1.2.3.4/2001:4b98::1/24') + + def test_basic_relations(self): + o1 = dns.edns.ECSOption.from_text('1.2.3.0/24/0') + o2 = dns.edns.ECSOption.from_text('1.2.4.0/24/0') + self.assertTrue(o1 == o1) + self.assertTrue(o1 != o2) + self.assertTrue(o1 < o2) + self.assertTrue(o1 <= o2) + self.assertTrue(o2 > o1) + self.assertTrue(o2 >= o1) + o1 = dns.edns.ECSOption.from_text('1.2.4.0/23/0') + o2 = dns.edns.ECSOption.from_text('1.2.4.0/24/0') + self.assertTrue(o1 < o2) + o1 = dns.edns.ECSOption.from_text('1.2.4.0/24/0') + o2 = dns.edns.ECSOption.from_text('1.2.4.0/24/1') + self.assertTrue(o1 < o2) + + def test_incompatible_relations(self): + o1 = dns.edns.GenericOption(3, b'data') + o2 = dns.edns.ECSOption.from_text('1.2.3.5/24/0') + for oper in [operator.lt, operator.le, operator.ge, operator.gt]: + self.assertRaises(TypeError, lambda: oper(o1, o2)) + self.assertFalse(o1 == o2) + self.assertTrue(o1 != o2) + self.assertFalse(o1 == 123) + self.assertTrue(o1 != 123) |