diff --git a/web_app/tests/test_dashboard.py b/web_app/tests/test_dashboard.py index 95bbc113..7e1d032b 100644 --- a/web_app/tests/test_dashboard.py +++ b/web_app/tests/test_dashboard.py @@ -17,12 +17,7 @@ from fastapi.responses import JSONResponse from fastapi.testclient import TestClient from httpx import ASGITransport, AsyncClient - -from web_app.api.dashboard import ( - get_dashboard, - position_db_connector, - router, -) +from web_app.api.dashboard import get_dashboard, position_db_connector, router from web_app.api.serializers.dashboard import DashboardResponse from web_app.contract_tools.mixins import HealthRatioMixin from web_app.contract_tools.mixins.dashboard import DashboardMixin @@ -87,9 +82,6 @@ async def test_get_dashboard_success(): "web_app.contract_tools.mixins.dashboard.DashboardMixin.get_wallet_balances", new_callable=AsyncMock, ) as mock_get_wallet_balances, patch( - "web_app.contract_tools.mixins.dashboard.DashboardMixin.get_zklend_position", - new_callable=AsyncMock, - ) as mock_get_zklend_position, patch( "web_app.contract_tools.mixins.dashboard.DashboardMixin.get_current_position_sum", new_callable=AsyncMock, ) as mock_get_current_position_sum, patch( @@ -112,15 +104,15 @@ async def test_get_dashboard_success(): "ETH": 5.0, "USDC": 1000.0, } - mock_get_zklend_position.return_value = { - "products": [ - { - "name": "ZkLend", - "groups": {"1": {"healthRatio": "1.2"}}, - "positions": [], - } - ] - } + # mock_get_zklend_position.return_value = { + # "products": [ + # { + # "name": "ZkLend", + # "groups": {"1": {"healthRatio": "1.2"}}, + # "positions": [], + # } + # ] + # } mock_get_current_position_sum.return_value = Decimal("200.0") mock_get_start_position_sum.return_value = Decimal("200.0") @@ -133,11 +125,12 @@ async def test_get_dashboard_success(): data = response.json() assert data == { - "multipliers": {"ETH": 1}, + "multipliers": {"ETH": "1"}, "start_dates": {"ETH": "2024-01-01T00:00:00"}, "current_sum": "200.0", "start_sum": "200.0", "borrowed": "200000.00", + "balance": "2.020202020202020202020202020", "health_ratio": "1.2", } @@ -157,17 +150,14 @@ async def test_get_dashboard_no_positions(): ) as mock_get_health_ratio_and_tvl, patch( "web_app.contract_tools.mixins.dashboard.DashboardMixin.get_wallet_balances", new_callable=AsyncMock, - ) as mock_get_wallet_balances, patch( - "web_app.contract_tools.mixins.dashboard.DashboardMixin.get_zklend_position", - new_callable=AsyncMock, - ) as mock_get_zklend_position: + ) as mock_get_wallet_balances: mock_get_contract_address_by_wallet_id.return_value = "0xabcdef1234567890" mock_get_positions_by_wallet_id.return_value = [] mock_get_wallet_balances.return_value = { "ETH": 5.0, "USDC": 1000.0, } - mock_get_zklend_position.return_value = {"products": []} + # mock_get_zklend_position.return_value = {"products": []} mock_get_health_ratio_and_tvl.return_value = ("1.2", "1000.0") async with AsyncClient( transport=ASGITransport(app=app), base_url=BASE_URL @@ -176,8 +166,8 @@ async def test_get_dashboard_no_positions(): assert response.is_success data = response.json() - assert data["multipliers"] == {"ETH": None} - assert data["start_dates"] == {"ETH": None} + assert data["multipliers"] == {} + assert data["start_dates"] == {} @pytest.mark.asyncio @@ -195,10 +185,7 @@ async def test_get_dashboard_no_contract_address(): ) as mock_get_health_ratio_and_tvl, patch( "web_app.contract_tools.mixins.dashboard.DashboardMixin.get_wallet_balances", new_callable=AsyncMock, - ) as mock_get_wallet_balances, patch( - "web_app.contract_tools.mixins.dashboard.DashboardMixin.get_zklend_position", - new_callable=AsyncMock, - ) as mock_get_zklend_position: + ) as mock_get_wallet_balances: mock_get_contract_address_by_wallet_id.return_value = None mock_get_positions_by_wallet_id.return_value = [] @@ -206,7 +193,7 @@ async def test_get_dashboard_no_contract_address(): "ETH": 5.0, "USDC": 1000.0, } - mock_get_zklend_position.return_value = {"products": []} + # mock_get_zklend_position.return_value = {"products": []} mock_get_health_ratio_and_tvl.return_value = ("1.2", "1000.0") async with AsyncClient( transport=ASGITransport(app=app), base_url=BASE_URL @@ -283,19 +270,21 @@ async def test_empty_positions( ) mock_db_connector.get_positions_by_wallet_id.return_value = [] DashboardMixin.get_wallet_balances = AsyncMock(return_value=MOCK_WALLET_BALANCES) - DashboardMixin.get_zklend_position = AsyncMock(return_value={"products": []}) + # DashboardMixin.get_zklend_position = AsyncMock(return_value={"products": []}) HealthRatioMixin.get_health_ratio_and_tvl = AsyncMock( return_value=("1.2", "1000.0") ) + response = await get_dashboard(VALID_WALLET_ID) assert isinstance(response, DashboardResponse) assert response.dict() == { - "multipliers": {"ETH": None}, - "start_dates": {"ETH": None}, + "multipliers": {}, + "start_dates": {}, "current_sum": Decimal("0"), "start_sum": Decimal("0"), - "borrowed": "0.0", - "health_ratio": "1.2", + "borrowed": "0", + "balance": "0", + "health_ratio": "0", }