summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2005-10-12 03:09:01 +0000
committerBob Halley <halley@dnspython.org>2005-10-12 03:09:01 +0000
commit8100fd2f68a7421541f20d56998841213c1bbfd8 (patch)
treefa7ab946f275895b6c3925fe1478e88af9243429
parent959d0b9eedcbbd6c92ba878496097a96496a870a (diff)
downloaddnspython-8100fd2f68a7421541f20d56998841213c1bbfd8.tar.gz
Zone.iterate_rdatasets() and Zone.iterate_rdatas() did not have a
default rdtype of dns.rdatatype.ANY as their docstrings said they did. They do now.
-rw-r--r--ChangeLog6
-rw-r--r--dns/zone.py6
-rw-r--r--tests/zone.py40
3 files changed, 50 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index e68b8f6..c82c840 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-10-12 Bob Halley <halley@dnspython.org>
+
+ * dns/zone.py: Zone.iterate_rdatasets() and Zone.iterate_rdatas()
+ did apply a default rdtype of dns.rdatatype.ANY as their
+ docstrings said they did. They now do.
+
2005-10-06 Bob Halley <halley@dnspython.org>
* dns/name.py: Added the parent() method, which returns the
diff --git a/dns/zone.py b/dns/zone.py
index bef161e..67fa432 100644
--- a/dns/zone.py
+++ b/dns/zone.py
@@ -403,7 +403,8 @@ class Zone(object):
rrset = None
return rrset
- def iterate_rdatasets(self, rdtype=None, covers=dns.rdatatype.NONE):
+ def iterate_rdatasets(self, rdtype=dns.rdatatype.ANY,
+ covers=dns.rdatatype.NONE):
"""Return a generator which yields (name, rdataset) tuples for
all rdatasets in the zone which have the specified I{rdtype}
and I{covers}. If I{rdtype} is dns.rdatatype.ANY, the default,
@@ -425,7 +426,8 @@ class Zone(object):
(rds.rdtype == rdtype and rds.covers == covers):
yield (name, rds)
- def iterate_rdatas(self, rdtype=None, covers=dns.rdatatype.NONE):
+ def iterate_rdatas(self, rdtype=dns.rdatatype.ANY,
+ covers=dns.rdatatype.NONE):
"""Return a generator which yields (name, ttl, rdata) tuples for
all rdatas in the zone which have the specified I{rdtype}
and I{covers}. If I{rdtype} is dns.rdatatype.ANY, the default,
diff --git a/tests/zone.py b/tests/zone.py
index 16af41e..ee6c6da 100644
--- a/tests/zone.py
+++ b/tests/zone.py
@@ -291,6 +291,16 @@ class ZoneTestCase(unittest.TestCase):
self.failUnless(ns == [dns.name.from_text('ns1', None),
dns.name.from_text('ns2', None)])
+ def testIterateAllRdatasets(self):
+ z = dns.zone.from_text(example_text, 'example.', relativize=True)
+ ns = [n for n, r in z.iterate_rdatasets()]
+ ns.sort()
+ self.failUnless(ns == [dns.name.from_text('@', None),
+ dns.name.from_text('@', None),
+ dns.name.from_text('bar.foo', None),
+ dns.name.from_text('ns1', None),
+ dns.name.from_text('ns2', None)])
+
def testIterateRdatas(self):
z = dns.zone.from_text(example_text, 'example.', relativize=True)
l = list(z.iterate_rdatas('A'))
@@ -305,6 +315,36 @@ class ZoneTestCase(unittest.TestCase):
'10.0.0.2'))]
self.failUnless(l == exl)
+ def testIterateAllRdatas(self):
+ z = dns.zone.from_text(example_text, 'example.', relativize=True)
+ l = list(z.iterate_rdatas())
+ l.sort()
+ exl = [(dns.name.from_text('@', None),
+ 3600,
+ dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS,
+ 'ns1')),
+ (dns.name.from_text('@', None),
+ 3600,
+ dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NS,
+ 'ns2')),
+ (dns.name.from_text('@', None),
+ 3600,
+ dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA,
+ 'foo bar 1 2 3 4 5')),
+ (dns.name.from_text('bar.foo', None),
+ 300,
+ dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.MX,
+ '0 blaz.foo')),
+ (dns.name.from_text('ns1', None),
+ 3600,
+ dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A,
+ '10.0.0.1')),
+ (dns.name.from_text('ns2', None),
+ 3600,
+ dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.A,
+ '10.0.0.2'))]
+ self.failUnless(l == exl)
+
def testTTLs(self):
z = dns.zone.from_text(ttl_example_text, 'example.', relativize=True)
n = z['@']