35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from io import StringIO
|
|
from unittest.mock import patch
|
|
|
|
from django.core.management import call_command
|
|
from django.test import override_settings
|
|
|
|
|
|
@override_settings(DEBUG=True, TESTING=False)
|
|
def test_dev_command_check_is_reported_by_check_command() -> None:
|
|
"""System check must be visible through call_command without direct check import."""
|
|
|
|
def fake_which(command: str) -> str | None:
|
|
if command == "curl":
|
|
return None
|
|
return f"/usr/bin/{command}"
|
|
|
|
stderr = StringIO()
|
|
with patch("shutil.which", side_effect=fake_which):
|
|
call_command("check", "-t", "compatibility", stderr=stderr)
|
|
|
|
output = stderr.getvalue()
|
|
assert "(tussilago.W001) Missing host commands used by get_rootfs.bash." in output
|
|
assert "Dev-only tooling missing: curl." in output
|
|
|
|
|
|
@override_settings(DEBUG=False, TESTING=False)
|
|
def test_dev_command_check_is_not_reported_in_production_runtime() -> None:
|
|
"""Production runtime must not report dev-only tooling warning."""
|
|
stderr = StringIO()
|
|
with patch("shutil.which", return_value=None):
|
|
call_command("check", "-t", "compatibility", stderr=stderr)
|
|
|
|
assert "(tussilago.W001)" not in stderr.getvalue()
|