test_init.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. # archivebox init
  2. # archivebox add
  3. import os
  4. import subprocess
  5. from pathlib import Path
  6. import json
  7. from .fixtures import *
  8. def test_init(tmp_path, process):
  9. assert "Initializing a new ArchiveBox collection in this folder..." in process.stdout.decode("utf-8")
  10. def test_update(tmp_path, process):
  11. os.chdir(tmp_path)
  12. update_process = subprocess.run(['archivebox', 'init'], capture_output=True)
  13. assert "Updating existing ArchiveBox collection in this folder" in update_process.stdout.decode("utf-8")
  14. def test_add_link(tmp_path, process):
  15. os.chdir(tmp_path)
  16. add_process = subprocess.run(['archivebox', 'add', 'http://example.com'], capture_output=True)
  17. archived_item_path = list(tmp_path.glob('archive/**/*'))[0]
  18. assert "index.json" in [x.name for x in archived_item_path.iterdir()]
  19. with open(archived_item_path / "index.json", "r") as f:
  20. output_json = json.load(f)
  21. assert "Example Domain" == output_json['history']['title'][0]['output']
  22. with open(tmp_path / "index.html", "r") as f:
  23. output_html = f.read()
  24. assert "Example Domain" in output_html