test_cli_server.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python3
  2. """
  3. Tests for archivebox server command.
  4. Verify server can start (basic smoke tests only, no full server testing).
  5. """
  6. import os
  7. import subprocess
  8. import signal
  9. import time
  10. from .fixtures import *
  11. def test_server_shows_usage_info(tmp_path, process):
  12. """Test that server command shows usage or starts."""
  13. os.chdir(tmp_path)
  14. # Just check that the command is recognized
  15. # We won't actually start a full server in tests
  16. result = subprocess.run(
  17. ['archivebox', 'server', '--help'],
  18. capture_output=True,
  19. text=True,
  20. timeout=10,
  21. )
  22. assert result.returncode == 0
  23. assert 'server' in result.stdout.lower() or 'http' in result.stdout.lower()
  24. def test_server_init_flag(tmp_path, process):
  25. """Test that --init flag runs init before starting server."""
  26. os.chdir(tmp_path)
  27. # Check init flag is recognized
  28. result = subprocess.run(
  29. ['archivebox', 'server', '--help'],
  30. capture_output=True,
  31. text=True,
  32. timeout=10,
  33. )
  34. assert result.returncode == 0
  35. assert '--init' in result.stdout or 'init' in result.stdout.lower()