Commit db2c81d2 authored by Jan Včelák's avatar Jan Včelák 🚀

tests-extra: add Response.check_rr() into API

parent 5f1eb8b5
......@@ -56,6 +56,34 @@ class Response(object):
flag_val = dns.flags.edns_from_text(flag)
isset(not(self.resp.ednsflags & flag_val), "NO %s FLAG" % flag)
def check_rr(self, _section="answer", rname=None, rtype=None):
"""
Check for a presence of a RR with given name and type.
"""
section = getattr(self.resp, _section)
if rname is not None:
rname = dns.name.from_text(rname)
if rtype is not None:
rtype = dns.rdatatype.from_text(rtype)
assert rname or rtype
for rrset in section:
if rname is not None and rname != rrset.name:
continue
if rtype is not None and rtype != rrset.rdtype:
continue
break
else:
set_err("CHECK RR PRESENCE")
check_log("ERROR: CHECK RR PRESENCE")
detail_log("!Missing RR name=%s type=%s section=%s" % (
str(rname) if rname is not None else "",
dns.rdatatype.to_text(rtype) if rtype is not None else "",
_section
))
detail_log(SEP)
def check_record(self, section="answer", rtype=None, ttl=None, rdata=None,
nordata=None):
'''Checks given section for particular record/rdata'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment