fix: mock secrets in tests to prevent LLM_API_KEY access

This commit is contained in:
Jon Michael Aanes (aider) 2025-04-15 00:43:32 +02:00
parent 8f8b91bf5e
commit 6c4e17999b

View File

@ -23,10 +23,11 @@ class TestSolveIssueInRepository:
self.issue_description = "This is a test issue" self.issue_description = "This is a test issue"
self.issue_number = "123" self.issue_number = "123"
@patch('aider_gitea.secrets.llm_api_key', return_value="fake-api-key")
@patch('aider_gitea.run_cmd') @patch('aider_gitea.run_cmd')
@patch('aider_gitea.push_changes') @patch('aider_gitea.push_changes')
@patch('subprocess.run') @patch('subprocess.run')
def test_solve_issue_with_aider_changes(self, mock_subprocess_run, mock_push_changes, mock_run_cmd): def test_solve_issue_with_aider_changes(self, mock_subprocess_run, mock_push_changes, mock_run_cmd, mock_llm_api_key):
# Setup mocks # Setup mocks
mock_run_cmd.return_value = True mock_run_cmd.return_value = True
mock_push_changes.return_value = True mock_push_changes.return_value = True
@ -53,10 +54,11 @@ class TestSolveIssueInRepository:
assert mock_run_cmd.call_count >= 8 # Verify all expected commands were run assert mock_run_cmd.call_count >= 8 # Verify all expected commands were run
mock_push_changes.assert_called_once() mock_push_changes.assert_called_once()
@patch('aider_gitea.secrets.llm_api_key', return_value="fake-api-key")
@patch('aider_gitea.run_cmd') @patch('aider_gitea.run_cmd')
@patch('aider_gitea.push_changes') @patch('aider_gitea.push_changes')
@patch('subprocess.run') @patch('subprocess.run')
def test_solve_issue_without_aider_changes(self, mock_subprocess_run, mock_push_changes, mock_run_cmd): def test_solve_issue_without_aider_changes(self, mock_subprocess_run, mock_push_changes, mock_run_cmd, mock_llm_api_key):
# Setup mocks # Setup mocks
mock_run_cmd.return_value = True mock_run_cmd.return_value = True