QuantumLearning/tests/test_operations.py

104 lines
2.6 KiB
Python

from __future__ import annotations
import subprocess
from quantum_learning.config import project_root
def test_bootstrap_script_help_works():
result = subprocess.run(
["bash", "scripts/bootstrap_mac.sh", "--help"],
cwd=project_root(),
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0
assert "Usage:" in result.stdout
def test_app_script_help_works():
result = subprocess.run(
["bash", "scripts/app.sh", "--help"],
cwd=project_root(),
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0
assert "Consumer-facing control surface" in result.stdout
def test_validation_script_help_works():
result = subprocess.run(
["bash", "scripts/run_validation.sh", "--help"],
cwd=project_root(),
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0
assert "--full" in result.stdout
def test_project_status_script_runs():
result = subprocess.run(
["bash", "scripts/project_status.sh"],
cwd=project_root(),
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0
assert "Git:" in result.stdout
assert "Validation:" in result.stdout
assert "Jupyter UI state:" in result.stdout
def test_app_status_runs():
result = subprocess.run(
["bash", "scripts/app.sh", "status"],
cwd=project_root(),
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0
assert "Consumer:" in result.stdout
assert "Reset:" in result.stdout
def test_app_script_uses_detached_launch_and_stale_runtime_cleanup():
text = (project_root() / "scripts" / "app.sh").read_text()
assert "cleanup_stale_runtime_files" in text
assert "purge_runtime_artifacts" in text
assert "reset-state" in text
assert "nohup " in text
def test_operations_docs_use_tested_command_forms():
root = project_root()
expected_commands = [
"bash ./scripts/app.sh bootstrap",
"bash ./scripts/app.sh status",
"bash ./scripts/app.sh reset-state",
"bash ./scripts/app.sh validate --quick",
]
for relative_path in ("README.md", "FIRST_RUN.md", "OPERATIONS.md"):
text = (root / relative_path).read_text()
for command in expected_commands:
assert command in text
def test_jupyter_runtime_noise_is_ignored():
text = (project_root() / ".gitignore").read_text()
assert ".jupyter_data/nbsignatures.db" in text
assert ".jupyter_data/notebook_secret" in text