100 lines
3.5 KiB
Python
100 lines
3.5 KiB
Python
"""Tests for task fix-install-update-flow.
|
|||
|
|
|
||
|
|
Covers R1-R8 from tasks/fix-install-update-flow/SPEC.md: git URL argument,
|
||
|
|
venv cwd fix, Windows venv path, hook copy-vs-symlink, version check.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
_FRAMEWORK = Path.home() / ".automaton"
|
||
|
|
_INSTALL_SH = _FRAMEWORK / "scripts" / "install.sh"
|
||
|
|
_UPDATE_SH = _FRAMEWORK / "scripts" / "update.sh"
|
||
|
|
_UPGRADE_SH = _FRAMEWORK / "scripts" / "upgrade.sh"
|
||
|
|
_INSTALL_HOOKS_SH = _FRAMEWORK / "scripts" / "install-hooks.sh"
|
||
|
|
|
||
|
|
|
||
|
|
class TestInstallShGitUrl:
|
||
|
|
def test_install_sh_requires_git_url(self):
|
||
|
|
content = _INSTALL_SH.read_text()
|
||
|
|
assert "GIT_URL" in content
|
||
|
|
assert '${1:-}' in content or '"${1:-}"' in content
|
||
|
|
|
||
|
|
def test_install_sh_no_hardcoded_url(self):
|
||
|
|
content = _INSTALL_SH.read_text()
|
||
|
|
assert "10.37.0.86" not in content
|
||
|
|
assert "hermes/automaton" not in content
|
||
|
|
|
||
|
|
def test_install_sh_has_usage_message(self):
|
||
|
|
content = _INSTALL_SH.read_text()
|
||
|
|
assert "Usage:" in content
|
||
|
|
assert "git-url" in content.lower() or "git url" in content.lower()
|
||
|
|
|
||
|
|
def test_install_sh_has_irreversibility_warning(self):
|
||
|
|
content = _INSTALL_SH.read_text()
|
||
|
|
assert "cannot be changed" in content or "carefully" in content
|
||
|
|
|
||
|
|
|
||
|
|
class TestInstallShVenv:
|
||
|
|
def test_install_sh_venv_in_framework_dir(self):
|
||
|
|
content = _INSTALL_SH.read_text()
|
||
|
|
assert "$FRAMEWORK_DIR/.venv" in content or '"$FRAMEWORK_DIR/.venv"' in content
|
||
|
|
assert 'requirements.txt' in content
|
||
|
|
assert "$FRAMEWORK_DIR/requirements.txt" in content
|
||
|
|
|
||
|
|
def test_install_sh_windows_venv_path(self):
|
||
|
|
content = _INSTALL_SH.read_text()
|
||
|
|
assert "Scripts/python.exe" in content
|
||
|
|
assert "VENV_PY" in content
|
||
|
|
|
||
|
|
def test_install_sh_uses_m_pip(self):
|
||
|
|
content = _INSTALL_SH.read_text()
|
||
|
|
assert "-m pip" in content
|
||
|
|
|
||
|
|
def test_install_sh_no_relative_venv(self):
|
||
|
|
content = _INSTALL_SH.read_text()
|
||
|
|
lines = content.splitlines()
|
||
|
|
for line in lines:
|
||
|
|
stripped = line.strip()
|
||
|
|
if stripped.startswith(".venv/bin/pip"):
|
||
|
|
pytest.fail("install.sh still has relative .venv/bin/pip path")
|
||
|
|
if 'venv .venv' in stripped and "FRAMEWORK_DIR" not in stripped:
|
||
|
|
pytest.fail("install.sh creates .venv without FRAMEWORK_DIR")
|
||
|
|
|
||
|
|
|
||
|
|
class TestInstallShVersionCheck:
|
||
|
|
def test_install_sh_has_version_check(self):
|
||
|
|
content = _INSTALL_SH.read_text()
|
||
|
|
assert "--version" in content
|
||
|
|
assert "status.py" in content
|
||
|
|
|
||
|
|
|
||
|
|
class TestHookConsistency:
|
||
|
|
def test_update_sh_uses_cp_for_hooks(self):
|
||
|
|
content = _UPDATE_SH.read_text()
|
||
|
|
assert "cp " in content or 'cp "' in content
|
||
|
|
assert 'ln -sf' not in content
|
||
|
|
|
||
|
|
def test_upgrade_sh_uses_cp_for_hooks(self):
|
||
|
|
content = _UPGRADE_SH.read_text()
|
||
|
|
assert "cp " in content or 'cp "' in content
|
||
|
|
assert 'ln -sf' not in content
|
||
|
|
|
||
|
|
def test_install_hooks_sh_uses_cp(self):
|
||
|
|
content = _INSTALL_HOOKS_SH.read_text()
|
||
|
|
assert "cp " in content or 'cp "' in content
|
||
|
|
|
||
|
|
def test_update_sh_has_chmod(self):
|
||
|
|
content = _UPDATE_SH.read_text()
|
||
|
|
assert "chmod +x" in content
|
||
|
|
|
||
|
|
def test_upgrade_sh_has_chmod(self):
|
||
|
|
content = _UPGRADE_SH.read_text()
|
||
|
|
assert "chmod +x" in content
|
||
|
|
|
||
|
|
def test_upgrade_sh_no_symlink_check(self):
|
||
|
|
content = _UPGRADE_SH.read_text()
|
||
|
|
assert "readlink" not in content
|
||
|
|
assert "-L " not in content or "-L\"" not in content
|