From 162e10163645940f881b54d0a0754c3b9502ad51 Mon Sep 17 00:00:00 2001 From: bot-backend Date: Sat, 12 Sep 2026 14:15:21 +0000 Subject: [PATCH] =?UTF-8?q?perf(tradein-tests):=20=D1=83=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D1=80=D0=B5=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5?= =?UTF-8?q?=20=D0=BF=D0=B0=D1=83=D0=B7=D1=8B=20=D0=B8=D0=B7=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D0=B2,=20=D0=B2=D0=BE=D0=BB=D0=BD=D0=B0=202?= =?UTF-8?q?=20(#3503)=20Co-authored-by:=20bot-backend=20=20Co-committed-by:=20bot-backend=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/tests/test_3398_estimator_valuations_proxy_pool.py | 3 +++ tradein-mvp/backend/tests/test_alerts_become_events.py | 2 +- tradein-mvp/backend/tests/test_backfill_wave2.py | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tradein-mvp/backend/tests/test_3398_estimator_valuations_proxy_pool.py b/tradein-mvp/backend/tests/test_3398_estimator_valuations_proxy_pool.py index 6c019c49..d1edecb2 100644 --- a/tradein-mvp/backend/tests/test_3398_estimator_valuations_proxy_pool.py +++ b/tradein-mvp/backend/tests/test_3398_estimator_valuations_proxy_pool.py @@ -342,6 +342,9 @@ def _yandex_with_pool(monkeypatch: pytest.MonkeyPatch, *, get: Any) -> _Counting patch( "scraper_kit.providers.yandex.valuation._CurlCffiSession", _fake_curl_session(get=get) ), + # На успехе fetch_house_history зовёт настоящий anti-ban sleep_between_requests + # (5с jitter) — тесту нужен только факт release-lease, не сама пауза. + patch("scraper_kit.base.asyncio.sleep", new_callable=AsyncMock), ): _call_yandex(_db_cache_miss()) return provider diff --git a/tradein-mvp/backend/tests/test_alerts_become_events.py b/tradein-mvp/backend/tests/test_alerts_become_events.py index 82b0b0f7..c4446e18 100644 --- a/tradein-mvp/backend/tests/test_alerts_become_events.py +++ b/tradein-mvp/backend/tests/test_alerts_become_events.py @@ -70,7 +70,7 @@ def glitchtip_events() -> Iterator[list[dict[str, Any]]]: yield events finally: # Иначе на каждый тест остаётся фоновый поток транспорта. - client.close() + client.close(timeout=0) def event_texts(events: list[dict[str, Any]]) -> list[str]: diff --git a/tradein-mvp/backend/tests/test_backfill_wave2.py b/tradein-mvp/backend/tests/test_backfill_wave2.py index 178986ab..e91c9889 100644 --- a/tradein-mvp/backend/tests/test_backfill_wave2.py +++ b/tradein-mvp/backend/tests/test_backfill_wave2.py @@ -215,7 +215,8 @@ async def test_backfill_yandex_addresses_error_on_non_200(): return_value=mock_session, ), ): - result = await backfill_yandex_addresses(MagicMock(), limit=10) + # request_delay_sec=0: реальный анти-бот sleep(3с) тут не нужен, 1 item в батче. + result = await backfill_yandex_addresses(MagicMock(), limit=10, request_delay_sec=0) assert result.errors == 1 assert result.saved == 0