Skip to content

Comments

High-Priority Sprint: Code Quality & Test Coverage Improvements#65

Merged
pfrederiksen merged 2 commits intomainfrom
refactor/high-priority-sprint
Jan 12, 2026
Merged

High-Priority Sprint: Code Quality & Test Coverage Improvements#65
pfrederiksen merged 2 commits intomainfrom
refactor/high-priority-sprint

Conversation

@pfrederiksen
Copy link
Owner

Summary

Completed high-priority code quality improvements focusing on refactoring monolithic functions and improving test coverage for critical TUI components.

Changes

1. Refactor instance_detail.py (287 lines → 50-line orchestrator)

Broke down the monolithic _render_details() method into 4 focused helper methods:

  • _render_compute_section() - CPU, Memory, GPU resources (52 lines)
  • _render_network_section() - Network information (16 lines)
  • _render_storage_section() - Storage, EBS, Architecture, Additional Info (53 lines)
  • _render_pricing_section() - All pricing information (145 lines)

Benefits:

  • Main method reduced from 287 to 50 lines
  • Each section now has a single, clear responsibility
  • Much easier to maintain and modify individual sections
  • All 986 tests continue to pass

2. Add Async Pricing Worker Tests (app.py coverage: 40% → 49%)

Added 3 new tests for async background pricing workers:

  • test_fetch_pricing_background_handles_shutdown - Graceful shutdown handling
  • test_retry_pricing_skips_when_shutting_down - Retry shutdown safety
  • test_retry_pricing_with_no_failed_instances - Empty retry list handling

Coverage Improvements:

  • app.py: 40% → 49% (+9%, added 40 lines of coverage)
  • pricing_service.py: Already at 81% (exceeds 80% target)
  • Total test count: 986 → 989 tests

Test Results

All 989 tests pass, including:

  • 25 app.py tests (up from 22)
  • 91 pricing_service tests
  • 17 instance_detail tests

Notes

  • Instance detail refactoring follows the same pattern as the recently completed parser refactoring
  • Async pricing worker tests focus on testable aspects (shutdown, edge cases) rather than full async execution flows that require complex mocking
  • pricing_service.py coverage was already improved to 81% in previous work (exceeds 80% target)

Checklist

  • All tests pass (989/989)
  • Code follows project style guidelines
  • Commit messages follow conventional commits format
  • No breaking changes

\ud83e\udd16 Generated with Claude Code

pfrederiksen and others added 2 commits January 11, 2026 17:51
…tions

Extracted 4 helper methods from monolithic _render_details():
- _render_compute_section() - CPU, Memory, GPU (52 lines)
- _render_network_section() - Network info (16 lines)
- _render_storage_section() - Storage, EBS, Architecture, Additional Info (53 lines)
- _render_pricing_section() - All pricing info (145 lines)

Main _render_details() now orchestrates at 50 lines instead of 286.
All 986 tests pass.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added 3 new tests for async pricing background workers:
- test_fetch_pricing_background_handles_shutdown
- test_retry_pricing_skips_when_shutting_down
- test_retry_pricing_with_no_failed_instances

Coverage improved from 40% (178/443 lines) to 49% (218/443 lines).
Added 40 lines of coverage focusing on shutdown handling and edge cases.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@claude
Copy link

claude bot commented Jan 12, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@pfrederiksen pfrederiksen merged commit a75cac9 into main Jan 12, 2026
4 checks passed
@pfrederiksen pfrederiksen deleted the refactor/high-priority-sprint branch January 12, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant