summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@play-bow.org>2020-06-30 07:27:43 -0700
committerBob Halley <halley@play-bow.org>2020-06-30 07:27:43 -0700
commit6610b8d2f0bc623cef5a0248e5704dc357662a4a (patch)
treebe59f99474272278fd9a8dbf09454c665b72cc2b
parent7ad83a3f0412ac800791a0237ad7e03789cd8fcf (diff)
downloaddnspython-6610b8d2f0bc623cef5a0248e5704dc357662a4a.tar.gz
increase test coverage
-rw-r--r--tests/test_ttl.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_ttl.py b/tests/test_ttl.py
new file mode 100644
index 0000000..07c512b
--- /dev/null
+++ b/tests/test_ttl.py
@@ -0,0 +1,24 @@
+# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
+
+import unittest
+
+import dns.ttl
+
+class TTLTestCase(unittest.TestCase):
+
+ def test_bind_style_ok(self):
+ ttl = dns.ttl.from_text('2w1d1h1m1s')
+ self.assertEqual(ttl, 2 * 604800 + 86400 + 3600 + 60 + 1)
+
+ def test_bind_style_ok2(self):
+ # no one should do this, but it is legal! :)
+ ttl = dns.ttl.from_text('1s2w1m1d1h')
+ self.assertEqual(ttl, 2 * 604800 + 86400 + 3600 + 60 + 1)
+
+ def test_bind_style_bad_unit(self):
+ with self.assertRaises(dns.ttl.BadTTL):
+ dns.ttl.from_text('5y')
+
+ def test_bind_style_no_unit(self):
+ with self.assertRaises(dns.ttl.BadTTL):
+ dns.ttl.from_text('1d5')