mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
"""External-PR author/fork classification — the inbound trust decision.
|
|||
|
|
|
||
|
|
``_is_external_pr`` decides whether an open PR was authored by the org itself
|
||
|
|
or by an outside contributor. It must default to *external* (the cautious
|
||
|
|
side) for anything it does not positively recognize as internal.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
from roboco.runtime.orchestrator import AgentOrchestrator
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize(
|
||
|
|
("pr", "expected"),
|
||
|
|
[
|
||
|
|
# A fork head is always external, regardless of association.
|
||
|
|
({"is_fork": True, "author_association": "OWNER"}, True),
|
||
|
|
# Same-repo branch from a trusted association is internal (the org).
|
||
|
|
({"is_fork": False, "author_association": "OWNER"}, False),
|
||
|
|
({"is_fork": False, "author_association": "MEMBER"}, False),
|
||
|
|
({"is_fork": False, "author_association": "COLLABORATOR"}, False),
|
||
|
|
({"is_fork": False, "author_association": "member"}, False), # case-insensitive
|
||
|
|
# Outside associations are external even on a same-repo branch.
|
||
|
|
({"is_fork": False, "author_association": "CONTRIBUTOR"}, True),
|
||
|
|
({"is_fork": False, "author_association": "FIRST_TIME_CONTRIBUTOR"}, True),
|
||
|
|
({"is_fork": False, "author_association": "NONE"}, True),
|
||
|
|
({"is_fork": False, "author_association": None}, True),
|
||
|
|
# Unknown/empty shape defaults to external (cautious).
|
||
|
|
({}, True),
|
||
|
|
],
|
||
|
|
)
|
||
|
|
def test_is_external_pr(pr: dict[str, object], *, expected: bool) -> None:
|
||
|
|
assert AgentOrchestrator._is_external_pr(pr) is expected
|