test_schedule.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env python3
  2. """Integration tests for archivebox schedule command."""
  3. import os
  4. import subprocess
  5. import pytest
  6. from .fixtures import process, disable_extractors_dict
  7. def test_schedule_show_lists_jobs(tmp_path, process):
  8. """Test that --show lists current scheduled jobs."""
  9. os.chdir(tmp_path)
  10. result = subprocess.run(
  11. ['archivebox', 'schedule', '--show'],
  12. capture_output=True,
  13. text=True,
  14. )
  15. # Should either show jobs or indicate no jobs
  16. assert 'no' in result.stdout.lower() or 'archivebox' in result.stdout.lower() or result.returncode == 0
  17. def test_schedule_clear_removes_jobs(tmp_path, process):
  18. """Test that --clear removes scheduled jobs."""
  19. os.chdir(tmp_path)
  20. result = subprocess.run(
  21. ['archivebox', 'schedule', '--clear'],
  22. capture_output=True,
  23. text=True,
  24. )
  25. # Should complete successfully (may have no jobs to clear)
  26. assert result.returncode == 0
  27. def test_schedule_every_requires_valid_period(tmp_path, process):
  28. """Test that --every requires valid time period."""
  29. os.chdir(tmp_path)
  30. result = subprocess.run(
  31. ['archivebox', 'schedule', '--every=invalid_period', 'https://example.com/feed.xml'],
  32. capture_output=True,
  33. text=True,
  34. )
  35. # Should fail with invalid period
  36. assert result.returncode != 0 or 'invalid' in result.stdout.lower()
  37. class TestScheduleCLI:
  38. """Test the CLI interface for schedule command."""
  39. def test_cli_help(self, tmp_path, process):
  40. """Test that --help works for schedule command."""
  41. os.chdir(tmp_path)
  42. result = subprocess.run(
  43. ['archivebox', 'schedule', '--help'],
  44. capture_output=True,
  45. text=True,
  46. )
  47. assert result.returncode == 0
  48. assert '--every' in result.stdout
  49. assert '--show' in result.stdout
  50. assert '--clear' in result.stdout
  51. assert '--depth' in result.stdout
  52. if __name__ == '__main__':
  53. pytest.main([__file__, '-v'])