@@ -116,7 +116,7 @@ def test_scenario_1_hello_world_creation(self) -> None:
116116
117117 if not execution_success :
118118 # Try LLM-based verification for more flexible checking
119- file_content = self .framework ._get_file_content ("hello_world.py" ) # noqa: SLF001
119+ file_content = self .framework .get_file_content ("hello_world.py" )
120120 if file_content :
121121 self .logger .info ("File content: %s" , file_content )
122122 llm_verified = self .framework .llm_verify_output (
@@ -206,14 +206,27 @@ def test_scenario_2_pull_request_creation(self) -> None:
206206
207207 self .logger .info ("Test Scenario 2 completed successfully" )
208208
209- def test_scenario_3_pr_comment_operation (self ) -> None : # noqa: C901
209+ def test_scenario_3_pr_comment_operation (self ) -> None :
210210 """Test Scenario 3: Pull request comment-based operation.
211211
212212 Adds comment to existing PR asking to modify file for multiple
213213 classification model evaluation with accuracy and confusion matrix.
214214 """
215215 self .logger .info ("Starting Test Scenario 3: PR comment operation" )
216216
217+ # Get or create a PR for testing
218+ pr_number = self ._get_or_create_pr_for_scenario_3 ()
219+
220+ # Add comment and run agent
221+ self ._add_comment_and_run_agent (pr_number )
222+
223+ # Verify the results
224+ self ._verify_scenario_3_results ()
225+
226+ self .logger .info ("Test Scenario 3 completed successfully" )
227+
228+ def _get_or_create_pr_for_scenario_3 (self ) -> int :
229+ """Get existing PR or create one for scenario 3."""
217230 # Prerequisite: Ensure there's an open PR (run scenario 2 first if needed)
218231 latest_pr = None
219232 if hasattr (self .framework , "get_latest_pull_request" ):
@@ -234,16 +247,17 @@ def test_scenario_3_pr_comment_operation(self) -> None: # noqa: C901
234247 if not latest_pr :
235248 self .fail ("Could not find or create a pull request for testing" )
236249
237- pr_number = latest_pr ["number" ] if self .platform == "github" else latest_pr ["iid" ]
250+ return latest_pr ["number" ] if self .platform == "github" else latest_pr ["iid" ]
238251
252+ def _add_comment_and_run_agent (self , pr_number : int ) -> None :
253+ """Add comment to PR and run the coding agent."""
239254 # Step 1: Add comment to PR
240255 comment_text = """1. hello_world.pyファイルを読み込んで現在のコードを理解して
2412562. hello_world.pyファイルを変更して、scikit-learnの複数の分類モデルで
242257それぞれ性能を正答率と混同行列評価できる様に修正して
2432583. レビューや議論は必要ないので、このブランチにコミットして"""
244259
245260 # Add coding agent label to the comment (implementation-specific)
246-
247261 self .framework .add_pr_comment (pr_number , comment_text )
248262 self .logger .info ("Added comment to PR #%s" , pr_number )
249263
@@ -262,11 +276,13 @@ def test_scenario_3_pr_comment_operation(self) -> None: # noqa: C901
262276 self .logger .info ("Waiting for comment processing..." )
263277 time .sleep (30 ) # Give some time for processing
264278
279+ def _verify_scenario_3_results (self ) -> None :
280+ """Verify the results of scenario 3."""
265281 # Step 4: Verify the file was updated with multiple models and evaluation
266282 self .logger .info ("Verifying hello_world.py updates..." )
267283
268284 # Get the updated file content
269- file_content = self .framework ._get_file_content ("hello_world.py" ) # noqa: SLF001
285+ file_content = self .framework .get_file_content ("hello_world.py" )
270286 assert file_content is not None , "Could not retrieve updated hello_world.py content"
271287
272288 # Use LLM to verify the content meets requirements
@@ -278,6 +294,10 @@ def test_scenario_3_pr_comment_operation(self) -> None: # noqa: C901
278294 assert llm_verified , "LLM verification failed for updated hello_world.py content"
279295
280296 # Step 5: Try to execute the file and verify output contains accuracy and confusion matrix
297+ self ._verify_execution_or_content (file_content )
298+
299+ def _verify_execution_or_content (self , file_content : str ) -> None :
300+ """Verify file execution or analyze content as fallback."""
281301 try :
282302 execution_success = self .framework .verify_python_execution (
283303 "hello_world.py" , "accuracy" ,
@@ -305,8 +325,6 @@ def test_scenario_3_pr_comment_operation(self) -> None: # noqa: C901
305325 )
306326 assert content_verified , "File content does not meet requirements based on LLM analysis"
307327
308- self .logger .info ("Test Scenario 3 completed successfully" )
309-
310328
311329if __name__ == "__main__" :
312330 # Configure logging for test execution
0 commit comments