mirror of
https://github.com/basnijholt/compose-farm.git
synced 2026-08-01 02:40:34 +01:00
Some checks failed
CI / test (macos-latest, 3.11) (push) Has been cancelled
CI / test (macos-latest, 3.12) (push) Has been cancelled
CI / test (macos-latest, 3.13) (push) Has been cancelled
CI / test (ubuntu-latest, 3.11) (push) Has been cancelled
CI / test (ubuntu-latest, 3.12) (push) Has been cancelled
CI / test (ubuntu-latest, 3.13) (push) Has been cancelled
CI / browser-tests (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Update README.md / update_readme (push) Has been cancelled
CI / lint (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
* cli: Add web startup banner * cli: Align web startup banner * cli: Tweak web banner spacing * cli: Color web banner attic window * cli: Color attic banner window red * cli: Center web banner windows * cli: Keep web banner roof continuous * cli: Add spacing to web banner body
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
"""Tests for the web CLI command."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from types import SimpleNamespace
|
|
from typing import Any
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
from compose_farm.cli import app
|
|
from compose_farm.cli.web import _compose_farm_banner
|
|
|
|
|
|
def test_compose_farm_banner_is_aligned() -> None:
|
|
"""Banner contains the expected aligned ASCII art."""
|
|
assert _compose_farm_banner().plain == (
|
|
" .-^-.\n"
|
|
" .-' _ '-.\n"
|
|
" / |_| \\\n"
|
|
" /-------------\\\n"
|
|
" / [] [] [] \\\n"
|
|
" /_________________\\\n"
|
|
" | |\n"
|
|
" | COMPOSE FARM |\n"
|
|
" |_________________|"
|
|
)
|
|
|
|
|
|
def test_web_command_prints_banner_and_starts_uvicorn(monkeypatch: Any) -> None:
|
|
"""Web prints startup logs before delegating to uvicorn."""
|
|
calls: list[tuple[tuple[Any, ...], dict[str, Any]]] = []
|
|
|
|
def fake_run(*args: Any, **kwargs: Any) -> None:
|
|
calls.append((args, kwargs))
|
|
|
|
monkeypatch.setitem(sys.modules, "uvicorn", SimpleNamespace(run=fake_run))
|
|
|
|
result = CliRunner().invoke(app, ["web", "--host", "127.0.0.1", "--port", "9999"])
|
|
|
|
assert result.exit_code == 0
|
|
assert "COMPOSE FARM" in result.output
|
|
assert "Starting Compose Farm Web UI" in result.output
|
|
assert calls == [
|
|
(
|
|
("compose_farm.web:create_app",),
|
|
{
|
|
"factory": True,
|
|
"host": "127.0.0.1",
|
|
"port": 9999,
|
|
"reload": False,
|
|
"log_level": "info",
|
|
},
|
|
)
|
|
]
|