From ae89311a8e745e13a59169374ee9d681278c2595 Mon Sep 17 00:00:00 2001 From: ZProger Date: Fri, 4 Sep 2026 03:06:59 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=87=D0=B8=D0=BD=D0=B8=D1=82=20=D1=82?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D1=8B=2090d-=D0=B4=D0=BE=D1=85=D0=BE=D0=B4?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D0=B8,=20=D0=BF=D0=B0=D0=B4=D0=B0?= =?UTF-8?q?=D0=B2=D1=88=D0=B8=D0=B5=20=D0=B2=20CI=20=D0=B1=D0=B5=D0=B7=20C?= =?UTF-8?q?oinGecko-=D0=BA=D0=BB=D1=8E=D1=87=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/tests/test_crypto.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/tests/test_crypto.py b/backend/tests/test_crypto.py index 3a45de3..c4d1ec6 100644 --- a/backend/tests/test_crypto.py +++ b/backend/tests/test_crypto.py @@ -440,6 +440,12 @@ async def test_90d_performance_reflects_a_real_market_chart_fetch(client: AsyncC monkeypatch.setattr(crypto_service, "_fetch_market_data", _fake_fetch({"bitcoin": _point("50000")})) holding = await _add_bitcoin(client) + # get_90d_performance checks _require_api_key() itself, separately from + # _fetch_90d_change below — CI has no AURUM_COINGECKO_API_KEY configured + # (unlike a local .env), so this must be stubbed too or the route 400s + # before ever reaching the mocked fetch. + monkeypatch.setattr(crypto_service.get_settings(), "coingecko_api_key", "test-key") + async def fake_90d_change(client_, api_key, coingecko_id, vs_currency): return 12.5 if coingecko_id == "bitcoin" else None @@ -447,7 +453,7 @@ async def test_90d_performance_reflects_a_real_market_chart_fetch(client: AsyncC resp = await client.get("/crypto/performance/90d") - assert resp.status_code == 200 + assert resp.status_code == 200, resp.text assert resp.json()["items"] == [{"asset_id": holding["asset_id"], "price_change_percent": 12.5}] @@ -498,6 +504,8 @@ async def test_90d_performance_filters_by_portfolio(client: AsyncClient, monkeyp await add(portfolio_a["id"]) holding_b = await add(portfolio_b["id"]) + monkeypatch.setattr(crypto_service.get_settings(), "coingecko_api_key", "test-key") + async def fake_90d_change(client_, api_key, coingecko_id, vs_currency): return 3.0 @@ -505,6 +513,7 @@ async def test_90d_performance_filters_by_portfolio(client: AsyncClient, monkeyp resp = await client.get(f"/crypto/performance/90d?portfolio_id={portfolio_b['id']}") + assert resp.status_code == 200, resp.text items = resp.json()["items"] assert [item["asset_id"] for item in items] == [holding_b["asset_id"]]