from unittest.mock import Mock from pr_review.python_general import ( StandardPRWaiter, PythonGeneralPromptBuilder, PythonGeneralPRAnalyzer, ) class TestStandardPRWaiter: def test_wait_for_analysis_ready_immediate(self): """Test that standard waiter returns immediately.""" mock_github_client = Mock() pr_data = { 'diff': [], 'comments': [], 'pr_title': 'Test PR', 'pr_body': 'Test body', } mock_github_client.get_pr_details.return_value = pr_data waiter = StandardPRWaiter() result = waiter.wait_for_analysis_ready(mock_github_client, 123, 600) assert result == pr_data mock_github_client.get_pr_details.assert_called_once_with(123) class TestPythonGeneralPromptBuilder: def test_build_prompt(self): """Test building Python/general prompt.""" builder = PythonGeneralPromptBuilder() pr_data = { 'pr_title': 'Add new feature', 'pr_body': 'This PR adds a new feature to the codebase', 'diff': [{'filename': 'main.py', 'patch': 'added new function'}], 'comments': [{'body': 'LGTM'}, {'body': 'Consider adding tests'}], } result = builder.build_prompt(pr_data) assert 'Add new feature' in result assert 'This PR adds a new feature to the codebase' in result assert 'LGTM' in result assert 'Consider adding tests' in result assert 'Python/General Code Review Prompt' in result assert 'Code Quality & Best Practices' in result class TestPythonGeneralPRAnalyzer: def test_post_process_analysis(self): """Test header de-emphasis.""" mock_github_client = Mock() mock_llm_client = Mock() mock_prompt_builder = Mock() mock_pr_waiter = Mock() analyzer = PythonGeneralPRAnalyzer( mock_github_client, mock_llm_client, mock_prompt_builder, mock_pr_waiter ) analysis = '# Header 1\n## Header 2\n### Header 3\n#### Header 4' result = analyzer.post_process_analysis(analysis) expected = '#### Header 1\n#### Header 2\n#### Header 3\n#### Header 4' assert result == expected