35 lines
950 B
Python
35 lines
950 B
Python
"""Unit: install.sh static contract checks."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
class TestInstallScript(unittest.TestCase):
|
|
def test_shell_syntax(self):
|
|
result = subprocess.run(
|
|
["sh", "-n", str(ROOT / "install.sh")],
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
self.assertEqual("", result.stderr)
|
|
self.assertEqual(0, result.returncode)
|
|
|
|
def test_contract_phrases(self):
|
|
script = (ROOT / "install.sh").read_text(encoding="utf-8")
|
|
self.assertIn("python3", script)
|
|
self.assertIn("docker info", script)
|
|
self.assertIn("pipx install --force", script)
|
|
self.assertIn("pip install --user --upgrade", script)
|
|
self.assertIn('"${BOT_BOTTLE_BIN}" doctor', script)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|