def test_duplicate(net_str, net2_str=None, dup_found=True):
usres_monitor.add_net(ipaddr.IPNetwork(net_str))
try:
usres_monitor.add_net(
ipaddr.IPNetwork(net2_str if net2_str else net_str)
)
except USRESMonitorException as e:
if "it was already in the db" in str(e):
test_outcome("test_duplicate",
"{} and {}".format(
net_str,
net2_str if net2_str else net_str),
"OK" if dup_found else "FAIL")
if not dup_found:
raise AssertionError("Duplicate found")
return
test_outcome("test_duplicate",
"{} and {}".format(
net_str,
net2_str if net2_str else net_str),
"FAIL" if dup_found else "OK")
if dup_found:
raise AssertionError("Duplicate not found")
评论列表
文章目录