-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57da2b2
commit 1556717
Showing
2 changed files
with
18 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,7 @@ | |
from warc2zim.url_rewriting import canonicalize | ||
from warc2zim.converter import iter_warc_records | ||
from warc2zim.utils import get_record_url | ||
|
||
# Import last to not mask the warc2zim module | ||
from warc2zim.main import warc2zim | ||
from warc2zim.main import main | ||
|
||
TEST_DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") | ||
|
||
|
@@ -189,7 +187,7 @@ def test_canonicalize(self): | |
|
||
def test_warc_to_zim_specify_params_and_metadata(self, tmp_path): | ||
zim_output = "zim-out-filename.zim" | ||
warc2zim( | ||
main( | ||
[ | ||
"-v", | ||
os.path.join(TEST_DATA_DIR, "example-response.warc"), | ||
|
@@ -270,7 +268,7 @@ def test_warc_to_zim(self, cmdline, tmp_path): | |
|
||
cmdline.extend(["--output", str(tmp_path), "--name", filename]) | ||
|
||
warc2zim(cmdline) | ||
main(cmdline) | ||
|
||
zimfile = filename + "_" + time.strftime("%Y-%m") + ".zim" | ||
|
||
|
@@ -287,7 +285,7 @@ def test_warc_to_zim(self, cmdline, tmp_path): | |
|
||
def test_same_domain_only(self, tmp_path): | ||
zim_output = "same-domain.zim" | ||
warc2zim( | ||
main( | ||
[ | ||
os.path.join(TEST_DATA_DIR, "example-revisit.warc.gz"), | ||
"--favicon", | ||
|
@@ -315,7 +313,7 @@ def test_same_domain_only(self, tmp_path): | |
|
||
def test_skip_self_redirect(self, tmp_path): | ||
zim_output = "self-redir.zim" | ||
warc2zim( | ||
main( | ||
[ | ||
os.path.join(TEST_DATA_DIR, "self-redirect.warc"), | ||
"--output", | ||
|
@@ -340,7 +338,7 @@ def test_skip_self_redirect(self, tmp_path): | |
|
||
def test_include_domains_favicon_and_language(self, tmp_path): | ||
zim_output = "spt.zim" | ||
warc2zim( | ||
main( | ||
[ | ||
os.path.join(TEST_DATA_DIR, "single-page-test.warc"), | ||
"-i", | ||
|
@@ -380,7 +378,7 @@ def test_include_domains_favicon_and_language(self, tmp_path): | |
|
||
def test_all_warcs_root_dir(self, tmp_path): | ||
zim_output = "test-all.zim" | ||
warc2zim( | ||
main( | ||
[ | ||
os.path.join(TEST_DATA_DIR), | ||
"--output", | ||
|
@@ -418,7 +416,7 @@ def test_all_warcs_root_dir(self, tmp_path): | |
|
||
def test_fuzzy_urls(self, tmp_path, fuzzycheck): | ||
zim_output = fuzzycheck["filename"] + ".zim" | ||
warc2zim( | ||
main( | ||
[ | ||
os.path.join(TEST_DATA_DIR, fuzzycheck["filename"]), | ||
"--output", | ||
|
@@ -445,7 +443,7 @@ def test_local_replay_viewer_url(self, tmp_path): | |
with open(tmp_path / "sw.js", "wt") as fh: | ||
fh.write(res.text) | ||
|
||
warc2zim( | ||
main( | ||
[ | ||
"-v", | ||
os.path.join(TEST_DATA_DIR, "example-response.warc"), | ||
|
@@ -465,7 +463,7 @@ def test_local_replay_viewer_url(self, tmp_path): | |
def test_error_bad_replay_viewer_url(self, tmp_path): | ||
zim_output_not_created = "zim-out-not-created.zim" | ||
with pytest.raises(Exception) as e: | ||
warc2zim( | ||
main( | ||
[ | ||
"-v", | ||
os.path.join(TEST_DATA_DIR, "example-response.warc"), | ||
|
@@ -486,7 +484,7 @@ def test_error_bad_replay_viewer_url(self, tmp_path): | |
def test_error_bad_main_page(self, tmp_path): | ||
zim_output_not_created = "zim-out-not-created.zim" | ||
with pytest.raises(Exception) as e: | ||
warc2zim( | ||
main( | ||
[ | ||
"-v", | ||
os.path.join(TEST_DATA_DIR, "example-response.warc"), | ||
|
@@ -504,15 +502,15 @@ def test_error_bad_main_page(self, tmp_path): | |
def test_args_only(self): | ||
# error, name required | ||
with pytest.raises(SystemExit) as e: | ||
warc2zim([]) | ||
main([]) | ||
assert e.code == 2 | ||
|
||
# error, no such output directory | ||
with pytest.raises(Exception) as e: | ||
warc2zim(["--name", "test", "--output", "/no-such-dir"]) | ||
main(["--name", "test", "--output", "/no-such-dir"]) | ||
|
||
# success, special error code for no output files | ||
assert warc2zim(["--name", "test", "--output", "./"]) == 100 | ||
assert main(["--name", "test", "--output", "./"]) == 100 | ||
|
||
def test_custom_css(self, tmp_path): | ||
custom_css = b"* { background-color: red; }" | ||
|
@@ -522,7 +520,7 @@ def test_custom_css(self, tmp_path): | |
|
||
zim_output = "test-css.zim" | ||
|
||
warc2zim( | ||
main( | ||
[ | ||
os.path.join(TEST_DATA_DIR, "example-response.warc"), | ||
"--output", | ||
|
@@ -549,7 +547,7 @@ def test_custom_css_remote(self, tmp_path): | |
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-reboot.css" | ||
) | ||
|
||
warc2zim( | ||
main( | ||
[ | ||
os.path.join(TEST_DATA_DIR, "example-response.warc"), | ||
"--output", | ||
|