Complete Phase 4.1 test suite updates - all 174 tests passing
Fixed all remaining test failures after Pydantic v2 migration: Core fixes: - Date handling: Convert date objects to ISO strings across 4 files - Model serialization: Use model_dump(mode='json') for JSON compatibility - Optional fields: Made time_period_months Optional[int] in models - Dict access: Replace .get() with getattr() for dynamic attributes Test updates: - Updated 50+ test fixtures from dicts to Deal models - Fixed date-based tests to use recent dates for time filtering - Added missing imports (CoordinatePoint, MarketActivityScore, DealStatistics) - Updated assertions from dict keys to model attributes (snake_case) Files modified: - nadlan_mcp/govmap/market_analysis.py - nadlan_mcp/govmap/statistics.py - nadlan_mcp/govmap/models.py - nadlan_mcp/fastmcp_server.py - tests/test_govmap_client.py - tests/test_fastmcp_tools.py - .cursor/plans/TEST-UPDATE-STATUS.md (comprehensive documentation) Result: 174/174 tests passing (100%) ✅ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -121,16 +121,23 @@ def calculate_deal_statistics(deals: List[Deal]) -> DealStatistics:
|
||||
date_range_dict = None
|
||||
if deal_dates:
|
||||
try:
|
||||
# Parse ISO date strings to get earliest and latest
|
||||
# Convert dates to ISO strings for consistent formatting
|
||||
from datetime import date as date_type
|
||||
parsed_dates = []
|
||||
for date_str in deal_dates:
|
||||
for d in deal_dates:
|
||||
try:
|
||||
# Handle ISO format with timezone (e.g., "2025-01-01T00:00:00.000Z")
|
||||
if 'T' in date_str:
|
||||
date_str = date_str.split('T')[0]
|
||||
parsed_dates.append(date_str)
|
||||
# Handle date objects (from Pydantic models)
|
||||
if isinstance(d, date_type):
|
||||
parsed_dates.append(d.isoformat())
|
||||
else:
|
||||
# Handle string dates
|
||||
date_str = str(d)
|
||||
# Handle ISO format with timezone (e.g., "2025-01-01T00:00:00.000Z")
|
||||
if 'T' in date_str:
|
||||
date_str = date_str.split('T')[0]
|
||||
parsed_dates.append(date_str)
|
||||
except (ValueError, TypeError):
|
||||
logger.warning(f"Invalid date format: {date_str}")
|
||||
logger.warning(f"Invalid date format: {d}")
|
||||
continue
|
||||
|
||||
if parsed_dates:
|
||||
@@ -140,7 +147,7 @@ def calculate_deal_statistics(deals: List[Deal]) -> DealStatistics:
|
||||
"latest": sorted_dates[-1],
|
||||
}
|
||||
except (ValueError, TypeError):
|
||||
logger.warning("Invalid date format: {date_range_dict}")
|
||||
logger.warning("Invalid date format in date range calculation")
|
||||
pass
|
||||
|
||||
return DealStatistics(
|
||||
|
||||
Reference in New Issue
Block a user