test_cli_schedule.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env python3
  2. """
  3. Tests for archivebox schedule command.
  4. Verify schedule creates scheduled crawl records.
  5. """
  6. import os
  7. import subprocess
  8. import sqlite3
  9. from .fixtures import *
  10. def test_schedule_creates_scheduled_crawl(tmp_path, process, disable_extractors_dict):
  11. """Test that schedule command creates a scheduled crawl."""
  12. os.chdir(tmp_path)
  13. result = subprocess.run(
  14. ['archivebox', 'schedule', '--every=day', '--depth=0', 'https://example.com'],
  15. capture_output=True,
  16. env=disable_extractors_dict,
  17. timeout=30,
  18. )
  19. # Should complete (creating schedule or showing usage)
  20. assert result.returncode in [0, 1, 2]
  21. def test_schedule_with_every_flag(tmp_path, process, disable_extractors_dict):
  22. """Test schedule with --every flag."""
  23. os.chdir(tmp_path)
  24. result = subprocess.run(
  25. ['archivebox', 'schedule', '--every=week', '--depth=0', 'https://example.com'],
  26. capture_output=True,
  27. env=disable_extractors_dict,
  28. timeout=30,
  29. )
  30. assert result.returncode in [0, 1, 2]
  31. def test_schedule_list_shows_schedules(tmp_path, process):
  32. """Test that schedule can list existing schedules."""
  33. os.chdir(tmp_path)
  34. # Try to list schedules
  35. result = subprocess.run(
  36. ['archivebox', 'schedule', '--list'],
  37. capture_output=True,
  38. text=True,
  39. timeout=30,
  40. )
  41. # Should show schedules or empty list
  42. assert result.returncode in [0, 1, 2]