From 1c2b071fd9f4dd9145c23792de8f50790807c2f6 Mon Sep 17 00:00:00 2001 From: Benton Edmondson Date: Tue, 7 Jun 2022 23:48:34 -0400 Subject: [PATCH] tests run twice to verify redownloaded acsm can still be converted --- tests/tests.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/tests.py b/tests/tests.py index 60d25a7..168c5b6 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -17,6 +17,7 @@ if len(sys.argv) != 2: file=sys.stderr, ) sys.exit() +workspace = Path(sys.argv[1]) print("Testing " + str(knock)) @@ -26,11 +27,6 @@ if result.returncode != 0: sys.exit() print("---") -workspace = Path(sys.argv[1]) -if workspace.exists(): - shutil.rmtree(workspace) -workspace.mkdir() - html = requests.get( "https://www.adobe.com/solutions/ebook/digital-editions/sample-ebook-library.html" ).text @@ -48,20 +44,27 @@ for a_tag in soup.find_all("a"): if len(links) >= 10: break -for i, link in enumerate(links): - i = str(i) - print("Testing URL #" + i + ":\n" + link) - file = workspace.joinpath(i + ".acsm") +for time in ["first", "second"]: - r = requests.get(link) - open(file, "wb").write(r.content) + if workspace.exists(): + shutil.rmtree(workspace) + workspace.mkdir() - result = subprocess.run([knock, file]) + for i, link in enumerate(links): + i = str(i) - if result.returncode != 0: - print("Test failed: knock failed to convert a file") - sys.exit() + print("Testing URL #" + i + " for the " + time + " time:\n" + link) + file = workspace.joinpath(i + ".acsm") - print("Success\n---") + r = requests.get(link) + open(file, "wb").write(r.content) + + result = subprocess.run([knock, file]) + + if result.returncode != 0: + print("Test failed: knock failed to convert a file") + sys.exit() + + print("Success\n---") print("All tests passed")