Files
roboco/tests/unit/services/test_git_commit_trailer.py
T
Renn F a82a4f9fd4 fix(.gitignore): anchor Python build artifacts; recover panel/src/lib (28 files)
The 'lib/' rule (intended for Python virtualenv at repo root) was matching panel/src/lib/, hiding the entire panel API client + utility tree from git. Anchored Python build-artifact rules to the repo root with a leading slash so they only match at the top level. Adds 28 panel/src/lib files that should have been tracked from day one.
2026-05-02 03:18:47 +02:00

51 lines
1.7 KiB
Python

"""Unit tests: commit-trailer links use ROBOCO_PUBLIC_BASE_URL."""
import importlib
import pytest
import roboco.config as config_module
from roboco.templates.git.commit import CommitContext, build_commit_message
def _make_ctx() -> CommitContext:
return CommitContext(
task_id="t-1",
root_task_id="r-1",
agent_slug="be-dev-1",
session_id="s-1",
commit_type="feat",
scope=None,
description="add user authentication",
)
def test_build_commit_message_uses_given_api_base() -> None:
"""build_commit_message embeds the api_base it receives."""
ctx = _make_ctx()
out = build_commit_message(ctx, "https://roboco.example.com/api")
assert "https://roboco.example.com/api" in out
assert "127.0.0.1" not in out
def test_build_commit_message_strips_trailing_slash() -> None:
"""Trailing slash on api_base is stripped to avoid double slashes."""
ctx = _make_ctx()
out = build_commit_message(ctx, "https://roboco.example.com/api/")
assert "//tasks/" not in out
assert "https://roboco.example.com/api/tasks/" in out
def test_links_use_public_base_url(monkeypatch: pytest.MonkeyPatch) -> None:
"""settings.public_base_url drives the api_base passed to build_commit_message."""
monkeypatch.setenv("ROBOCO_PUBLIC_BASE_URL", "https://roboco.example.com")
importlib.reload(config_module)
try:
settings = config_module.Settings()
api_base = settings.public_base_url.rstrip("/") + "/api"
ctx = _make_ctx()
out = build_commit_message(ctx, api_base)
assert "https://roboco.example.com" in out
assert "127.0.0.1" not in out
finally:
importlib.reload(config_module)