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:
49
tddai_cli.py
49
tddai_cli.py
@@ -15,48 +15,55 @@ sys.path.insert(0, str(Path(__file__).parent))
|
||||
|
||||
from cli import CLIFramework
|
||||
|
||||
# Initialize CLI framework
|
||||
cli = CLIFramework()
|
||||
# Lazy initialization of CLI framework
|
||||
_cli_framework = None
|
||||
|
||||
def _get_cli():
|
||||
"""Get CLI framework instance (lazy initialization)."""
|
||||
global _cli_framework
|
||||
if _cli_framework is None:
|
||||
_cli_framework = CLIFramework()
|
||||
return _cli_framework
|
||||
|
||||
|
||||
def workspace_status():
|
||||
"""Show current workspace status."""
|
||||
cli.workspace_status()
|
||||
_get_cli().workspace_status()
|
||||
|
||||
|
||||
def start_issue(issue_number: int):
|
||||
"""Start working on an issue."""
|
||||
cli.start_issue(issue_number)
|
||||
_get_cli().start_issue(issue_number)
|
||||
|
||||
|
||||
def finish_issue():
|
||||
"""Finish current issue workspace."""
|
||||
cli.finish_issue()
|
||||
_get_cli().finish_issue()
|
||||
|
||||
|
||||
def add_test_guidance():
|
||||
"""Show guidance for adding tests."""
|
||||
cli.add_test_guidance()
|
||||
_get_cli().add_test_guidance()
|
||||
|
||||
|
||||
def list_issues():
|
||||
"""List all issues."""
|
||||
cli.list_issues()
|
||||
_get_cli().list_issues()
|
||||
|
||||
|
||||
def list_open_issues():
|
||||
"""List only open issues."""
|
||||
cli.list_open_issues()
|
||||
_get_cli().list_open_issues()
|
||||
|
||||
|
||||
def show_issue(issue_number: int):
|
||||
"""Show detailed issue information."""
|
||||
cli.show_issue(issue_number)
|
||||
_get_cli().show_issue(issue_number)
|
||||
|
||||
|
||||
def create_issue(title: str, body: str, issue_type: str = "enhancement"):
|
||||
"""Create a new issue."""
|
||||
cli.create_issue(title, body, issue_type)
|
||||
_get_cli().create_issue(title, body, issue_type)
|
||||
|
||||
|
||||
def create_enhancement_issue(title: str, use_case: str, technical_requirements: str = "",
|
||||
@@ -73,7 +80,7 @@ def create_enhancement_issue(title: str, use_case: str, technical_requirements:
|
||||
if dependencies:
|
||||
deps_list = [line.strip() for line in dependencies.split('\n') if line.strip()]
|
||||
|
||||
cli.create_enhancement_issue(
|
||||
_get_cli().create_enhancement_issue(
|
||||
title=title,
|
||||
use_case=use_case,
|
||||
technical_requirements=technical_requirements,
|
||||
@@ -85,52 +92,52 @@ def create_enhancement_issue(title: str, use_case: str, technical_requirements:
|
||||
|
||||
def create_from_template(template_file: str, **kwargs):
|
||||
"""Create issue from template file."""
|
||||
cli.create_from_template(template_file, **kwargs)
|
||||
_get_cli().create_from_template(template_file, **kwargs)
|
||||
|
||||
|
||||
def analyze_coverage(issue_number: int):
|
||||
"""Analyze test coverage for a specific issue."""
|
||||
cli.analyze_coverage(issue_number)
|
||||
_get_cli().analyze_coverage(issue_number)
|
||||
|
||||
|
||||
def setup_project_management():
|
||||
"""Setup project management labels and milestones."""
|
||||
cli.setup_project_management()
|
||||
_get_cli().setup_project_management()
|
||||
|
||||
|
||||
def move_issue_to_state(issue_number: int, state: str):
|
||||
"""Move issue to a specific project state."""
|
||||
cli.move_issue_to_state(issue_number, state)
|
||||
_get_cli().move_issue_to_state(issue_number, state)
|
||||
|
||||
|
||||
def set_issue_priority(issue_number: int, priority: str):
|
||||
"""Set issue priority."""
|
||||
cli.set_issue_priority(issue_number, priority)
|
||||
_get_cli().set_issue_priority(issue_number, priority)
|
||||
|
||||
|
||||
def create_milestone(title: str, description: str = ""):
|
||||
"""Create a new milestone (project)."""
|
||||
cli.create_milestone(title, description)
|
||||
_get_cli().create_milestone(title, description)
|
||||
|
||||
|
||||
def list_milestones():
|
||||
"""List all milestones."""
|
||||
cli.list_milestones()
|
||||
_get_cli().list_milestones()
|
||||
|
||||
|
||||
def assign_issue_to_milestone(issue_number: int, milestone_id: int):
|
||||
"""Assign issue to a milestone."""
|
||||
cli.assign_issue_to_milestone(issue_number, milestone_id)
|
||||
_get_cli().assign_issue_to_milestone(issue_number, milestone_id)
|
||||
|
||||
|
||||
def project_overview():
|
||||
"""Show project management overview."""
|
||||
cli.project_overview()
|
||||
_get_cli().project_overview()
|
||||
|
||||
|
||||
def issue_index(format_type="tsv", sort_by="number", filter_state=None, filter_priority=None, include_state=False):
|
||||
"""Output compact index of all issues for Unix processing."""
|
||||
cli.issue_index(
|
||||
_get_cli().issue_index(
|
||||
format_type=format_type,
|
||||
sort_by=sort_by,
|
||||
filter_state=filter_state,
|
||||
|
||||
Reference in New Issue
Block a user