mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-14 11:06:13 +05:00
test: stabilize archivebox ci shards
This commit is contained in:
parent
ce6dbdf1a0
commit
8aaa236a15
@ -114,6 +114,7 @@ def test_cli_api_add_search_update_remove_over_server(tmp_path):
|
||||
"filter_patterns": [target_url],
|
||||
"batch_size": 1,
|
||||
"continuous": False,
|
||||
"index_only": True,
|
||||
},
|
||||
timeout=20,
|
||||
)
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import time
|
||||
|
||||
from archivebox.tests.conftest import run_archivebox_cmd, cli_env
|
||||
|
||||
import pytest
|
||||
@ -25,26 +27,36 @@ def _install_chrome(tmp_path, env):
|
||||
assert install_process.returncode == 0, install_process.stderr or install_process.stdout
|
||||
|
||||
|
||||
def test_title_is_extracted(tmp_path, initialized_archive):
|
||||
def _wait_for_snapshot_title(data_dir, *, timeout=30):
|
||||
deadline = time.time() + timeout
|
||||
title = None
|
||||
while time.time() < deadline:
|
||||
with use_archivebox_db(data_dir):
|
||||
title = Snapshot.objects.values_list("title", flat=True).get()
|
||||
if title:
|
||||
return title
|
||||
time.sleep(0.5)
|
||||
return title
|
||||
|
||||
|
||||
def test_title_is_extracted(tmp_path, initialized_archive, recursive_test_site):
|
||||
"""Test that title is extracted from the page."""
|
||||
env = cli_env(disable_extractors=True)
|
||||
env.update({"SAVE_TITLE": "true"})
|
||||
_install_chrome(tmp_path, env)
|
||||
add_process = run_archivebox_cmd(
|
||||
["add", "--plugins=chrome,wget,title", "https://example.com"],
|
||||
["add", "--plugins=chrome,wget,title", recursive_test_site["root_url"]],
|
||||
cwd=tmp_path,
|
||||
env=env,
|
||||
)
|
||||
assert add_process.returncode == 0, add_process.stderr or add_process.stdout
|
||||
|
||||
with use_archivebox_db(tmp_path):
|
||||
title = Snapshot.objects.values_list("title", flat=True).get()
|
||||
|
||||
title = _wait_for_snapshot_title(tmp_path)
|
||||
assert title is not None
|
||||
assert "Example" in title
|
||||
assert "Root" in title
|
||||
|
||||
|
||||
def test_title_is_listed_by_search_alias(tmp_path, initialized_archive):
|
||||
def test_title_is_listed_by_search_alias(tmp_path, initialized_archive, recursive_test_site):
|
||||
"""
|
||||
https://github.com/ArchiveBox/ArchiveBox/issues/330
|
||||
Unencoded content should not be rendered as it facilitates xss injections
|
||||
@ -54,7 +66,7 @@ def test_title_is_listed_by_search_alias(tmp_path, initialized_archive):
|
||||
env.update({"SAVE_TITLE": "true"})
|
||||
_install_chrome(tmp_path, env)
|
||||
add_process = run_archivebox_cmd(
|
||||
["add", "--plugins=chrome,wget,title", "https://example.com"],
|
||||
["add", "--plugins=chrome,wget,title", recursive_test_site["root_url"]],
|
||||
cwd=tmp_path,
|
||||
env=env,
|
||||
)
|
||||
@ -67,4 +79,4 @@ def test_title_is_listed_by_search_alias(tmp_path, initialized_archive):
|
||||
assert list_process.returncode == 0, list_process.stderr or list_process.stdout
|
||||
|
||||
output = list_process.stdout
|
||||
assert "https://example.com" in output
|
||||
assert recursive_test_site["root_url"] in output
|
||||
|
||||
@ -41,6 +41,8 @@ def _runtime_env(data_dir: Path, bin_dir: Path) -> dict[str, str]:
|
||||
"LIB_BIN_DIR": str(data_dir / "lib" / "bin"),
|
||||
"ABXPKG_LIB_DIR": str(data_dir / "lib"),
|
||||
"LITEPARSE_ENABLED": "True",
|
||||
"TIMEOUT": "180",
|
||||
"ABXPKG_INSTALL_TIMEOUT": "180",
|
||||
"PATH": os.pathsep.join(entry for entry in path_entries if entry),
|
||||
}
|
||||
|
||||
@ -55,7 +57,7 @@ def test_install_persists_machine_binary_config_and_recovers_stale_path(initiali
|
||||
_cmd_result = run_archivebox_cmd(
|
||||
["install", "--binproviders=env", "liteparse"],
|
||||
cwd=initialized_archive,
|
||||
timeout=120,
|
||||
timeout=240,
|
||||
env=_runtime_env(initialized_archive, bootstrap_bin_dir),
|
||||
)
|
||||
stdout, stderr, returncode = _cmd_result.stdout, _cmd_result.stderr, _cmd_result.returncode
|
||||
|
||||
Loading…
Reference in New Issue
Block a user