test_cli_manage.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python3
  2. """
  3. Tests for archivebox manage command.
  4. Verify manage command runs Django management commands.
  5. """
  6. import os
  7. import subprocess
  8. import sqlite3
  9. from .fixtures import *
  10. def test_manage_help_works(tmp_path, process):
  11. """Test that manage help command works."""
  12. os.chdir(tmp_path)
  13. result = subprocess.run(
  14. ['archivebox', 'manage', 'help'],
  15. capture_output=True,
  16. text=True,
  17. timeout=30,
  18. )
  19. assert result.returncode == 0
  20. assert len(result.stdout) > 100
  21. def test_manage_showmigrations_works(tmp_path, process):
  22. """Test that manage showmigrations works."""
  23. os.chdir(tmp_path)
  24. result = subprocess.run(
  25. ['archivebox', 'manage', 'showmigrations'],
  26. capture_output=True,
  27. text=True,
  28. timeout=30,
  29. )
  30. assert result.returncode == 0
  31. # Should show migration status
  32. assert 'core' in result.stdout or '[' in result.stdout
  33. def test_manage_dbshell_command_exists(tmp_path, process):
  34. """Test that manage dbshell command is recognized."""
  35. os.chdir(tmp_path)
  36. result = subprocess.run(
  37. ['archivebox', 'manage', 'help', 'dbshell'],
  38. capture_output=True,
  39. text=True,
  40. timeout=30,
  41. )
  42. # Should show help for dbshell
  43. assert result.returncode == 0
  44. assert 'dbshell' in result.stdout or 'database' in result.stdout.lower()
  45. def test_manage_check_works(tmp_path, process):
  46. """Test that manage check works."""
  47. os.chdir(tmp_path)
  48. result = subprocess.run(
  49. ['archivebox', 'manage', 'check'],
  50. capture_output=True,
  51. text=True,
  52. timeout=30,
  53. )
  54. # Check should complete
  55. assert result.returncode in [0, 1]