From 5a99705797ae27f9796a7d593d12926e4f4f34cc Mon Sep 17 00:00:00 2001 From: can1357 Date: Sun, 21 Jun 2026 18:51:24 +0200 Subject: [PATCH] feat(python/robomp): added authorizes_impl support to task directive processing - Included authorizes_impl field when attaching threads to directives. - Added a test case to ensure the author authorization flag is preserved during directive hydration. --- python/robomp/src/tasks.py | 8 +++++++- python/robomp/tests/test_tasks_directive.py | 22 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/python/robomp/src/tasks.py b/python/robomp/src/tasks.py index d78ff4978..5597d5550 100644 --- a/python/robomp/src/tasks.py +++ b/python/robomp/src/tasks.py @@ -155,7 +155,13 @@ async def _attach_thread( if directive is None: return None thread = await _fetch_thread(github, repo, number, is_pr=is_pr) - return DirectiveInfo(body=directive.body, author=directive.author, thread=thread, pragmas=directive.pragmas) + return DirectiveInfo( + body=directive.body, + author=directive.author, + thread=thread, + pragmas=directive.pragmas, + authorizes_impl=directive.authorizes_impl, + ) async def _resolve_repo_and_issue( diff --git a/python/robomp/tests/test_tasks_directive.py b/python/robomp/tests/test_tasks_directive.py index 331804207..dc3ac5fcb 100644 --- a/python/robomp/tests/test_tasks_directive.py +++ b/python/robomp/tests/test_tasks_directive.py @@ -2,7 +2,9 @@ from __future__ import annotations -from robomp.tasks import _directive_from_payload +import pytest +from robomp.tasks import _attach_thread, _directive_from_payload +from robomp.worker import DirectiveInfo def test_directive_from_payload_parses_pragmas() -> None: @@ -65,3 +67,21 @@ def test_directive_from_payload_parses_implementation_authorization() -> None: def test_directive_from_payload_returns_none_for_missing_directive() -> None: assert _directive_from_payload({}) is None assert _directive_from_payload({"_robomp_directive": "not-a-mapping"}) is None + + +async def test_attach_thread_preserves_authorizes_impl(monkeypatch: pytest.MonkeyPatch) -> None: + async def fake_fetch_thread(*args, **kwargs): + return () + + monkeypatch.setattr("robomp.tasks._fetch_thread", fake_fetch_thread) + + directive = DirectiveInfo( + body="test body", + author="test_author", + authorizes_impl=True, + ) + hydrated = await _attach_thread(None, directive, "owner/repo", 42, is_pr=False) + assert hydrated is not None + assert hydrated.body == "test body" + assert hydrated.author == "test_author" + assert hydrated.authorizes_impl is True