import pytest from unittest.mock import AsyncMock, patch from api_calls.current import get_current, Current from exceptions import ApiException @pytest.mark.asyncio async def test_get_current_success(): mock_data = { "id": 420, "week": 1, "freeze": False, "season": 2025, "bet_week": 12, # should be cast to string "trade_deadline": 10, "pick_trade_start": 20, "pick_trade_end": 30, "playoffs_begin": 40 } with patch("api_calls.current.db_get", new_callable=AsyncMock) as mock_db_get: mock_db_get.return_value = mock_data result = await get_current() assert isinstance(result, Current) assert result.id == 420 assert result.bet_week == "12" # validated and cast to string assert result.season == 2025 @pytest.mark.asyncio async def test_get_current_returns_default_on_none(): with patch("api_calls.current.db_get", new_callable=AsyncMock) as mock_db_get: mock_db_get.return_value = None with pytest.raises(ApiException): await get_current()