CI / checks (push) Skipped
CI / checks (pull_request) Successful in 5m17s
Every live test that touches a repository gets one of its own from e2e_support.fresh_repo, made by the test operator as an operator makes a project's (D4, D8): seeded from tests/integration/seed/ (the sandbox's package, without past runs' leftovers), the agent's account a collaborator with write access, main protected (pushes only by the owner, an approval to merge), and a deploy key generated for the run. It is deleted afterwards (NISSE_E2E_KEEP_REPOS keeps it); scripts/e2e-cleanup.sh deletes leftovers. - Both e2e fixtures use it; per-run base branches are gone. The merge helper approves first, as the protection now requires. - test_gitea_live uses it, so CI needs NISSE_OPERATOR_TOKEN and no longer writes the sandbox deploy key (NISSE_PUSH_KEY). - A live test of the helper: seeded, shared with the agent, protected against it, deleted. - nisse-test.yaml's project entry is a placeholder; pytest and ruff skip the seed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
38 lines
877 B
Python
38 lines
877 B
Python
import pytest
|
|
|
|
from sandbox import truncate
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"text, n, expected",
|
|
[
|
|
("", 1, ""),
|
|
("abc", 3, "abc"),
|
|
("abc", 10, "abc"),
|
|
("abcd", 3, "ab\u2026"),
|
|
("hello world", 5, "hell\u2026"),
|
|
("ab", 1, "\u2026"),
|
|
("a", 1, "a"),
|
|
("h\u00e9llo w\u00f6rld", 4, "h\u00e9l\u2026"),
|
|
],
|
|
)
|
|
def test_truncate_cases(text, n, expected):
|
|
assert truncate(text, n) == expected
|
|
|
|
|
|
@pytest.mark.parametrize("n", range(1, 16))
|
|
def test_result_never_exceeds_n(n):
|
|
assert len(truncate("hello world!!", n)) <= n
|
|
|
|
|
|
def test_uses_single_ellipsis_char():
|
|
result = truncate("hello world", 5)
|
|
assert result.endswith("\u2026")
|
|
assert not result.endswith("...")
|
|
|
|
|
|
@pytest.mark.parametrize("n", [0, -5])
|
|
def test_invalid_n_raises(n):
|
|
with pytest.raises(ValueError):
|
|
truncate("abc", n)
|