@@ -43,6 +43,26 @@ def _inline_comment_payload(*, fork: bool = False) -> dict:
4343 return payload
4444
4545
46+ def _issue_comment_payload () -> dict :
47+ return {
48+ "action" : "created" ,
49+ "comment" : {
50+ "id" : 123 ,
51+ "body" : "@askserge please review" ,
52+ "author_association" : "MEMBER" ,
53+ "user" : {"login" : "reviewer" },
54+ },
55+ "issue" : {
56+ "number" : 13827 ,
57+ "state" : "open" ,
58+ "pull_request" : {
59+ "url" : "https://api.github.com/repos/huggingface/diffusers/pulls/13827"
60+ },
61+ },
62+ "repository" : {"full_name" : "huggingface/diffusers" },
63+ }
64+
65+
4666class ActionRunnerTests (unittest .TestCase ):
4767 def test_empty_llm_api_key_fails_before_review (self ) -> None :
4868 event_path = _write_event (_inline_comment_payload ())
@@ -121,6 +141,26 @@ def test_llm_api_key_is_stripped_before_review(self) -> None:
121141 cfg = run_followup .call_args .args [0 ]
122142 self .assertEqual (cfg .llm_api_key , "token-with-newline" )
123143
144+ def test_direct_pr_review_forces_comment_event (self ) -> None :
145+ event_path = _write_event (_issue_comment_payload ())
146+ self .addCleanup (os .remove , event_path )
147+ env = {
148+ "GITHUB_EVENT_NAME" : "issue_comment" ,
149+ "GITHUB_EVENT_PATH" : event_path ,
150+ "GITHUB_TOKEN" : "github-token" ,
151+ "LLM_API_KEY" : "token" ,
152+ }
153+
154+ with (
155+ patch .dict (os .environ , env , clear = True ),
156+ patch ("reviewbot.action_runner.run_review" ) as run_review ,
157+ patch ("reviewbot.action_runner.GitHubClient" ),
158+ ):
159+ code = action_runner .main ()
160+
161+ self .assertEqual (code , 0 )
162+ self .assertTrue (run_review .call_args .kwargs ["force_comment_event" ])
163+
124164 def test_llm_response_error_is_logged_without_traceback (self ) -> None :
125165 event_path = _write_event (_inline_comment_payload ())
126166 self .addCleanup (os .remove , event_path )
0 commit comments