Tests: added tools check and verify

This commit is contained in:
Doug Blank 2016-04-30 22:49:51 -04:00
parent f1644e48a6
commit a257311f5f

View File

@ -183,7 +183,34 @@ def err_does_contain(text):
os.remove(report_name + "." + ext)
else:
raise Exception("can't find '%s' in order to delete it" % (report_name + "." + ext))
return text in err
if isinstance(text, list):
return all([(line in err) for line in text])
else:
return text in err
return test_output_file
def out_does_contain(text):
def test_output_file(out, err, report_name, **options):
if options.get("files", []):
for filename in options.get("files", []):
if filename is None:
pass
elif os.path.isdir(filename):
shutil.rmtree(filename)
elif os.path.isfile(filename):
os.remove(filename)
else:
raise Exception("can't find '%s' in order to delete it" % filename)
else:
ext = options["off"]
if os.path.isfile(report_name + "." + ext):
os.remove(report_name + "." + ext)
else:
raise Exception("can't find '%s' in order to delete it" % (report_name + "." + ext))
if isinstance(text, list):
return all([(line in out) for line in text])
else:
return text in out
return test_output_file
reports.addreport(TestDynamic, "tag_report",
@ -308,5 +335,35 @@ for (report_name, off, files) in report_list:
files=files,
off=off)
reports.addcli(TestDynamic, "tool_verify",
out_does_contain(["W: Old age but no death, Person: I0004, Smith, Ingeman",
"W: Old age but no death, Person: I0058, Smith, Elaine Marie",
"W: Multiple parents, Person: I0061, Jones, Roberta Michele",
"W: Multiple parents, Person: I0063, Jones, Frank Albert",
"W: Old age but no death, Person: I0072, Iverson, Alice Hannah",
"W: Multiple parents, Person: I0076, Smith, Marie Astri",
"W: Multiple parents, Person: I0077, Smith, Susan Elizabeth",
"W: Old age but no death, Person: I0011, Smith, Hanna",
"W: Old age but no death, Person: I0009, Smith, Emil",
"W: Old age but no death, Person: I0036, Jefferson, Elna",
"W: Early marriage, Family: F0000, Smith, Martin and Jefferson, Elna"
]),
[None],
"--force",
"-O", TREE_NAME,
"-y",
"--action", "tool",
"--options", "name=verify")
reports.addcli(TestDynamic, "tool_check",
out_does_contain(["6 media objects were referenced, but not found",
"References to 6 media objects were kept"]),
[None],
"--force",
"-O", TREE_NAME,
"-y",
"--action", "tool",
"--options", "name=check")
if __name__ == "__main__":
unittest.main()