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

tests-extra: add Response.check_no_rr as a complement to check_rr

parent b0d6acc6
......@@ -56,7 +56,7 @@ 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=None, rname=None, rtype=None):
def _check_rr(self, expect, section=None, rname=None, rtype=None):
"""
Check for a presence of a RR with given name and type.
"""
......@@ -76,17 +76,28 @@ class Response(object):
continue
if rtype is not None and rtype != rrset.rdtype:
continue
found = True
break
else:
found = False
if found != expect:
set_err("CHECK RR PRESENCE")
check_log("ERROR: CHECK RR PRESENCE")
detail_log("!Missing RR name=%s type=%s section=%s" % (
detail_log("!%s RR name=%s type=%s section=%s" % (
"Missing" if expect else "Extra",
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_rr(self, section=None, rname=None, rtype=None):
self._check_rr(True, section, rname, rtype)
def check_no_rr(self, section=None, rname=None, rtype=None):
self._check_rr(False, section, rname, rtype)
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