homelab-butler/tests/test_streamscope_deploy.py

38 lines
1.2 KiB
Python

import app
def test_streamscope_deploy_replaces_legacy_container_before_compose(monkeypatch):
assert "streamscope/static/assets/longterm-metrics.js" in app.SPEEDTEST_REPO_FILES
files = {path: "placeholder" for path in app.SPEEDTEST_REPO_FILES}
files["compose.yaml"] = """services:
streamscope:
build: .
ports:
- '127.0.0.1:8080:8080'
environment:
ADMIN_PASSWORD: "${ADMIN_PASSWORD:?required}"
SESSION_SECRET: "${SESSION_SECRET:?required}"
volumes:
- /app-config/speedtest/data:/data
cap_add:
- NET_RAW
"""
files["Dockerfile"] = "FROM python:3.13-slim\nRUN apt-get install -y mtr-tiny\n"
commands = []
monkeypatch.setattr(app, "_remote_python", lambda script: (0, "", ""))
def fake_ssh(host, command, timeout=600):
commands.append(command)
return 0, "ok", ""
monkeypatch.setattr(app, "_ssh", fake_ssh)
result = app._deploy_speedtest_compose(
files,
"correct-horse-battery-staple",
"streamscope-session-secret-with-entropy",
)
deploy = next(command for command in commands if "compose up -d --remove-orphans" in command)
assert "docker rm -f speedtest" in deploy
assert result["application"] == "streamscope"