test_oneshot.py 1.0 KB

12345678910111213141516171819202122232425262728
  1. from pathlib import Path
  2. from .fixtures import *
  3. def test_oneshot_command_exists(tmp_path, disable_extractors_dict):
  4. os.chdir(tmp_path)
  5. process = subprocess.run(['archivebox', 'oneshot'], capture_output=True, env=disable_extractors_dict)
  6. assert not "invalid choice: 'oneshot'" in process.stderr.decode("utf-8")
  7. def test_oneshot_command_saves_page_in_right_folder(tmp_path, disable_extractors_dict):
  8. disable_extractors_dict.update({"SAVE_DOM": "true"})
  9. process = subprocess.run(
  10. [
  11. "archivebox",
  12. "oneshot",
  13. f"--out-dir={tmp_path}",
  14. "--extract=title,favicon,dom",
  15. "http://127.0.0.1:8080/static/example.com.html",
  16. ],
  17. capture_output=True,
  18. env=disable_extractors_dict,
  19. )
  20. items = ' '.join([str(x) for x in tmp_path.iterdir()])
  21. current_path = ' '.join([str(x) for x in Path.cwd().iterdir()])
  22. assert "index.json" in items
  23. assert not "index.sqlite3" in current_path
  24. assert "output.html" in items