2020-07-08 02:10:36 +12:00
|
|
|
import subprocess
|
2020-07-08 02:49:28 +12:00
|
|
|
import json
|
2020-07-08 02:10:36 +12:00
|
|
|
|
|
|
|
from .fixtures import *
|
|
|
|
|
2020-07-08 02:49:28 +12:00
|
|
|
def test_depth_flag_is_accepted(process):
|
2020-07-08 02:10:36 +12:00
|
|
|
arg_process = subprocess.run(["archivebox", "add", "https://example.com", "--depth=0"], capture_output=True)
|
2020-07-08 02:49:28 +12:00
|
|
|
assert 'unrecognized arguments: --depth' not in arg_process.stderr.decode('utf-8')
|
|
|
|
|
|
|
|
def test_depth_flag_0_crawls_only_the_arg_page(tmp_path, process):
|
|
|
|
arg_process = subprocess.run(["archivebox", "add", "https://example.com", "--depth=0"], capture_output=True)
|
|
|
|
archived_item_path = list(tmp_path.glob('archive/**/*'))[0]
|
|
|
|
with open(archived_item_path / "index.json", "r") as f:
|
|
|
|
output_json = json.load(f)
|
2020-07-08 03:07:44 +12:00
|
|
|
assert output_json["base_url"] == "example.com"
|
|
|
|
|
|
|
|
def test_depth_flag_1_crawls_the_page_AND_links(tmp_path, process):
|
|
|
|
arg_process = subprocess.run(["archivebox", "add", "https://example.com", "--depth=1"], capture_output=True)
|
|
|
|
with open(tmp_path / "index.json", "r") as f:
|
|
|
|
archive_file = f.read()
|
|
|
|
assert "https://example.com" in archive_file
|
|
|
|
assert "https://www.iana.org/domains/example" in archive_file
|