fix: Resolve failing tests after CLI and error handling refactoring

Fix all test failures introduced by recent architectural changes:

• Issue Creator Tests:
  - Fixed mock API responses to include required fields (created_at, updated_at, html_url)
  - Added input validation for empty titles back to issue creator
  - Updated test expectations to match new error handling patterns
  - Created helper function for complete mock responses

• Issue Fetcher Test:
  - Updated mock target from tddai.issue_fetcher.subprocess to gitea.http_client.subprocess
  - Fixed test assertions to match new error handling with specific exception chaining
  - Test now properly validates API error translation

• Makefile Integration Test:
  - Implemented lazy initialization in tddai_cli.py to prevent import-time configuration errors
  - Replaced eager CLI framework initialization with _get_cli() lazy pattern
  - Preserves normal CLI functionality while fixing test environment compatibility

• Result: All 171 tests now pass (169 passed, 2 skipped)
• Maintains backward compatibility of CLI interface
• Validates that refactored error handling works correctly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-26 17:15:36 +02:00
parent 235e6831ed
commit 6713768ea6
4 changed files with 71 additions and 33 deletions

View File

@@ -40,6 +40,10 @@ class IssueCreator:
Raises:
IssueError: If creation fails
"""
# Validate input
if not title or not title.strip():
raise IssueError("Issue title cannot be empty")
try:
issue = self.gitea_client.issues.create(
title=title,