From 589d995276f4868a1801d5d41f9a527a6323dbb9 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Fri, 16 Dec 2011 11:36:47 +0100 Subject: s4 dns: Give better test output on RCODE mismatch --- source4/scripting/python/samba/tests/dns.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/scripting/python/samba/tests/dns.py b/source4/scripting/python/samba/tests/dns.py index 60003fcf7a..ed78d56dd3 100644 --- a/source4/scripting/python/samba/tests/dns.py +++ b/source4/scripting/python/samba/tests/dns.py @@ -28,11 +28,30 @@ from samba.tests import TestCase class DNSTest(TestCase): + def errstr(self, errcode): + "Return a readable error code" + string_codes = [ + "OK", + "FORMERR", + "SERVFAIL", + "NXDOMAIN", + "NOTIMP", + "REFUSED", + "YXDOMAIN", + "YXRRSET", + "NXRRSET", + "NOTAUTH", + "NOTZONE", + ] + + return string_codes[errcode] + + def assert_dns_rcode_equals(self, packet, rcode): "Helper function to check return code" p_errcode = packet.operation & 0x000F self.assertEquals(p_errcode, rcode, "Expected RCODE %s, got %s" % \ - (rcode, p_errcode)) + (self.errstr(rcode), self.errstr(p_errcode))) def assert_dns_opcode_equals(self, packet, opcode): "Helper function to check opcode" -- cgit