36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
from django.test import override_settings
|
|
|
|
from config.checks import check_required_dev_commands
|
|
|
|
|
|
@override_settings(DEBUG=False, TESTING=False)
|
|
def test_command_check_is_silent_in_production_runtime() -> None:
|
|
"""Production runtime must not warn about dev-only command dependencies."""
|
|
with patch("config.checks.shutil.which", return_value=None):
|
|
warnings = check_required_dev_commands()
|
|
|
|
assert warnings == []
|
|
|
|
|
|
@override_settings(DEBUG=True, TESTING=False)
|
|
def test_command_check_warns_and_mentions_dev_only_dependencies() -> None:
|
|
"""Dev runtime must warn and clearly label these dependencies as dev-only."""
|
|
|
|
def fake_which(command: str) -> str | None:
|
|
if command == "curl":
|
|
return None
|
|
return f"/usr/bin/{command}"
|
|
|
|
with patch("config.checks.shutil.which", side_effect=fake_which):
|
|
warnings = check_required_dev_commands()
|
|
|
|
assert len(warnings) == 1
|
|
warning = warnings[0]
|
|
assert warning.id == "tussilago.W001"
|
|
assert warning.hint is not None
|
|
assert "Dev-only tooling missing" in warning.hint
|
|
assert "curl" in warning.hint
|