1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

pytest/dns: use self.assertIn() and .assertNotIn()

These give a more detailed message than assertTrue(x in y).

They were new in Python 3.1, so we avoided them until recently.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Douglas Bagnall 2021-03-24 15:16:21 +13:00 committed by Jeremy Allison
parent 820c735578
commit 49f434ca08
3 changed files with 14 additions and 14 deletions

View File

@ -108,15 +108,15 @@ class SambaDnsUpdateTests(samba.tests.BlackboxTestCase):
dns_c = "samba_dnsupdate --verbose --use-file={0}".format(tmp_uc)
out = get_string(self.check_output(dns_c))
self.assertFalse(site_name.lower() in out, out)
self.assertNotIn(site_name.lower(), out)
self.samdb.modify(m)
shutil.copyfile(uc_fn, tmp_uc)
out = get_string(self.check_output(dns_c))
self.assertFalse("No DNS updates needed" in out, out)
self.assertTrue(site_name.lower() in out, out)
self.assertNotIn("No DNS updates needed", out)
self.assertIn(site_name.lower(), out)
result = cmd._run("samba-tool %s" % name, 'remove', site_name)
if result is not None:

View File

@ -1107,7 +1107,7 @@ class DnsserverTests(RpcInterfaceTestCase):
expression="(&(objectClass=dnsZone)(name=_msdcs*))",
attrs=["nTSecurityDescriptor", "objectClass"])
self.assertEqual(len(zones), 1)
self.assertTrue("nTSecurityDescriptor" in zones[0])
self.assertIn("nTSecurityDescriptor", zones[0])
tmp = zones[0]["nTSecurityDescriptor"][0]
utils = sd_utils.SDUtils(self.samdb)
sd = ndr_unpack(security.descriptor, tmp)
@ -1166,7 +1166,7 @@ class DnsserverTests(RpcInterfaceTestCase):
attrs=["nTSecurityDescriptor"])
self.assertEqual(len(zones), 1)
current_dn = zones[0].dn
self.assertTrue("nTSecurityDescriptor" in zones[0])
self.assertIn("nTSecurityDescriptor", zones[0])
tmp = zones[0]["nTSecurityDescriptor"][0]
utils = sd_utils.SDUtils(self.samdb)
sd = ndr_unpack(security.descriptor, tmp)
@ -1205,7 +1205,7 @@ class DnsserverTests(RpcInterfaceTestCase):
for (key, sec_desc) in security_desc_dict:
zones = self.samdb.search(base=key, scope=ldb.SCOPE_BASE,
attrs=["nTSecurityDescriptor"])
self.assertTrue("nTSecurityDescriptor" in zones[0])
self.assertIn("nTSecurityDescriptor", zones[0])
tmp = zones[0]["nTSecurityDescriptor"][0]
utils = sd_utils.SDUtils(self.samdb)
@ -1238,7 +1238,7 @@ class DnsserverTests(RpcInterfaceTestCase):
attrs=["nTSecurityDescriptor"])
self.assertEqual(len(zones), 1)
current_dn = zones[0].dn
self.assertTrue("nTSecurityDescriptor" in zones[0])
self.assertIn("nTSecurityDescriptor", zones[0])
tmp = zones[0]["nTSecurityDescriptor"][0]
utils = sd_utils.SDUtils(self.samdb)
sd = ndr_unpack(security.descriptor, tmp)
@ -1277,7 +1277,7 @@ class DnsserverTests(RpcInterfaceTestCase):
for (key, sec_desc) in security_desc_dict:
zones = self.samdb.search(base=key, scope=ldb.SCOPE_BASE,
attrs=["nTSecurityDescriptor"])
self.assertTrue("nTSecurityDescriptor" in zones[0])
self.assertIn("nTSecurityDescriptor", zones[0])
tmp = zones[0]["nTSecurityDescriptor"][0]
utils = sd_utils.SDUtils(self.samdb)

View File

@ -1535,11 +1535,11 @@ class TestZones(DNSTest):
self.dns_update_record(name3, txt)
self.dns_update_record(name3, txt2)
# Create a tomb stoned record.
# Create a tombstoned record.
self.dns_update_record(name4, txt4)
self.dns_tombstone(name4, txt4, self.zone)
records = self.ldap_get_records(name4)
self.assertTrue("dNSTombstoned" in records[0])
self.assertIn("dNSTombstoned", records[0])
self.assertEqual(records[0]["dNSTombstoned"][0], b"TRUE")
# Create an un-tombstoned record, with dnsTombstoned: FALSE
@ -1547,7 +1547,7 @@ class TestZones(DNSTest):
self.dns_tombstone(name5, txt5, self.zone)
self.dns_update_record(name5, txt5)
records = self.ldap_get_records(name5)
self.assertTrue("dNSTombstoned" in records[0])
self.assertIn("dNSTombstoned", records[0])
self.assertEqual(records[0]["dNSTombstoned"][0], b"FALSE")
last_add = self.dns_update_record(name3, txt3)
@ -1570,7 +1570,7 @@ class TestZones(DNSTest):
self.assertEqual(len(recs), 1)
self.assertEqual(recs[0].wType, dnsp.DNS_TYPE_TOMBSTONE)
records = self.ldap_get_records(name)
self.assertTrue("dNSTombstoned" in records[0])
self.assertIn("dNSTombstoned", records[0])
self.assertEqual(records[0]["dNSTombstoned"][0], b"TRUE")
recs = self.ldap_get_dns_records(name2)
@ -1589,14 +1589,14 @@ class TestZones(DNSTest):
self.assertEqual(len(recs), 1)
self.assertEqual(recs[0].wType, dnsp.DNS_TYPE_TOMBSTONE)
records = self.ldap_get_records(name4)
self.assertTrue("dNSTombstoned" in records[0])
self.assertIn("dNSTombstoned", records[0])
self.assertEqual(records[0]["dNSTombstoned"][0], b"TRUE")
recs = self.ldap_get_dns_records(name5)
self.assertEqual(len(recs), 1)
self.assertEqual(recs[0].wType, dnsp.DNS_TYPE_TOMBSTONE)
records = self.ldap_get_records(name5)
self.assertTrue("dNSTombstoned" in records[0])
self.assertIn("dNSTombstoned", records[0])
self.assertEqual(records[0]["dNSTombstoned"][0], b"TRUE")
for make_it_work in [False, True]: