summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-09-01 06:08:43 -0700
committerBob Halley <halley@dnspython.org>2020-09-01 06:08:43 -0700
commitd33bc6bcb6572e23ff3bfb7091a7a1046bac7e60 (patch)
tree347490fc14527bd8a652b41d74b80dad30f92324 /tests
parent674cdfc8ba30e12810645eee4531c943518abc16 (diff)
downloaddnspython-d33bc6bcb6572e23ff3bfb7091a7a1046bac7e60.tar.gz
check for TTL type errors in rdataset/rrset from_text; allow text-form TTLs there.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_rdata.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_rdata.py b/tests/test_rdata.py
index 4071403..66ed67c 100644
--- a/tests/test_rdata.py
+++ b/tests/test_rdata.py
@@ -35,6 +35,7 @@ from dns.rdtypes.ANY.GPOS import GPOS
import dns.rdtypes.ANY.RRSIG
import dns.rdtypes.util
import dns.tokenizer
+import dns.ttl
import dns.wire
import tests.stxt_module
@@ -743,5 +744,16 @@ class UtilTestCase(unittest.TestCase):
dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX,
r'\# 4 000aC000')
+ def test_rdataset_ttl_conversion(self):
+ rds1 = dns.rdataset.from_text('in', 'a', 300, '10.0.0.1')
+ self.assertEqual(rds1.ttl, 300)
+ rds2 = dns.rdataset.from_text('in', 'a', '5m', '10.0.0.1')
+ self.assertEqual(rds2.ttl, 300)
+ with self.assertRaises(ValueError):
+ dns.rdataset.from_text('in', 'a', 1.6, '10.0.0.1')
+ with self.assertRaises(dns.ttl.BadTTL):
+ dns.rdataset.from_text('in', 'a', '10.0.0.1', '10.0.0.2')
+
+
if __name__ == '__main__':
unittest.main()