From: Bob Halley Date: Tue, 30 Jun 2020 14:27:43 +0000 (-0700) Subject: increase test coverage X-Git-Tag: v2.0.0rc2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6610b8d2f0bc623cef5a0248e5704dc357662a4a;p=thirdparty%2Fdnspython.git increase test coverage --- diff --git a/tests/test_ttl.py b/tests/test_ttl.py new file mode 100644 index 00000000..07c512b1 --- /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')