test(tradein): fix #794 test regressions on main (broken by #919 early squash-merge) #921

Merged
bot-reviewer merged 1 commit from fix/794-test-regressions into main 2026-05-31 19:05:10 +00:00
Owner

Why

PR #919 was squash-merged at 18:48 — before the test-fix push (d2722df) landed — so main currently carries the pre-existing tests that the #794 refactor broke. The suite is red on main:

  • tests/test_sber_index.py — calls the old 2-arg build_sber_route and passes list[str] dashboards → TypeError / AttributeError: 'str' object has no attribute 'slug'
  • tests/test_estimator_imv_blend.py — two _fetch_dkp_corridor tests now hit the extra _load_sber_index_series db call → KeyError: 'period_month'
  • duplicate tests/services/test_sber_index.py (same basename as the root file)

(9 failures in the #919 CI run.)

Fix (tests-only, no app/ changes)

  • Update tests/test_sber_index.py to the new API: 3-arg build_sber_route(slug, ref_area, extra_filter), SberDashboard objects, dashboard.slug guards; merge in the per-dashboard route assertion + real-fixture decode + period-parse tests.
  • Patch the two tests/test_estimator_imv_blend.py dkp tests with patch("app.services.estimator._load_sber_index_series", return_value={}) (preserves original corridor-math assertions).
  • Move test_estimator_sber_time_adjust.py to tests/ root; drop the duplicate tests/services/ copies.

Verify

Affected suite green: 42 passed (tests/test_sber_index.py, test_estimator_sber_time_adjust.py, test_estimator_imv_blend.py). ruff + pre-commit clean. (Local full-suite has 2 unrelated app.mainpsycopg2 env failures that pass in CI.)

Follow-up to #794 / #919.

🤖 Generated with Claude Code

## Why PR #919 was squash-merged at 18:48 — **before** the test-fix push (`d2722df`) landed — so `main` currently carries the pre-existing tests that the #794 refactor broke. The suite is **red on `main`**: - `tests/test_sber_index.py` — calls the old 2-arg `build_sber_route` and passes `list[str]` dashboards → `TypeError` / `AttributeError: 'str' object has no attribute 'slug'` - `tests/test_estimator_imv_blend.py` — two `_fetch_dkp_corridor` tests now hit the extra `_load_sber_index_series` db call → `KeyError: 'period_month'` - duplicate `tests/services/test_sber_index.py` (same basename as the root file) (9 failures in the #919 CI run.) ## Fix (tests-only, no app/ changes) - Update `tests/test_sber_index.py` to the new API: 3-arg `build_sber_route(slug, ref_area, extra_filter)`, `SberDashboard` objects, `dashboard.slug` guards; merge in the per-dashboard route assertion + real-fixture decode + period-parse tests. - Patch the two `tests/test_estimator_imv_blend.py` dkp tests with `patch("app.services.estimator._load_sber_index_series", return_value={})` (preserves original corridor-math assertions). - Move `test_estimator_sber_time_adjust.py` to `tests/` root; drop the duplicate `tests/services/` copies. ## Verify Affected suite green: `42 passed` (`tests/test_sber_index.py`, `test_estimator_sber_time_adjust.py`, `test_estimator_imv_blend.py`). ruff + pre-commit clean. (Local full-suite has 2 unrelated `app.main`→`psycopg2` env failures that pass in CI.) Follow-up to #794 / #919. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lekss361 added 1 commit 2026-05-31 19:01:22 +00:00
PR #919 squash-merged before the test-fix push landed, so main carries the
broken pre-existing tests against the new build_sber_route/SberDashboard API.
Brings the test files to the intended post-#794 state:
- update tests/test_sber_index.py to 3-arg build_sber_route + SberDashboard list
- patch tests/test_estimator_imv_blend.py dkp tests (patch _load_sber_index_series)
- move test_estimator_sber_time_adjust.py to tests/ root, drop dup tests/services/ copies
lekss361 added the
status/review
label 2026-05-31 19:01:27 +00:00
bot-reviewer approved these changes 2026-05-31 19:05:00 +00:00
bot-reviewer left a comment
Collaborator

APPROVE — tests-only fix, восстанавливает зелёный main. Мержу.

Контекст: регрессию внёс ранний squash-merge #919 (на проверенном мной head 468bdb0 test-fix d2722df ещё не прилетел) — main остался с pre-existing тестами под старый API. Mea culpa: при ревью #919 не grep'нул существующих вызовов build_sber_route(2-arg) / test_estimator_imv_blend на cross-file impact. Этот PR закрывает дыру.

Verified (line-by-line, tests-only — 0 app/ изменений)

  • Удалён tests/services/test_sber_index.py — дубль из #919; его тесты (per_dashboard, real_fixture, period_month) смержены в root test_sber_index.py. Покрытие не потеряно, дубль-basename pytest-коллизия устранена.
  • test_estimator_imv_blend.py — 2 dkp-теста обёрнуты patch("...estimator._load_sber_index_series", return_value={}) → пустой series → _sber_time_factor=1.0 → corridor-математика без изменений, исходные assert'ы (count/low/high) сохранены. Остальное — косметика ruff (multi-line patch(...)).
  • Rename test_estimator_sber_time_adjust.py services/→root (100% similarity, чистый move).
  • root test_sber_index.py — все build_sber_route("slug","ref") → 3-arg (d.slug,"ref",d.extra_filter) через _DASH; _mock_fetch sig → SberDashboard; dashboard==dashboard.slug==; dashboards=[_DASH[...]]. Fixture-path скорректирован (parent/fixtures).

Все пути tradein-mvp/backend/tests/**, без секретов, без self-extending. Автор: 42 passed, ruff clean.

Squash-merge + delete branch. Восстанавливает CI на main для последующих PR/деплоев.

<!-- gendesign-review-bot: sha=2564cd6 verdict=approve --> ✅ **APPROVE** — tests-only fix, восстанавливает зелёный main. Мержу. Контекст: регрессию внёс ранний squash-merge #919 (на проверенном мной head `468bdb0` test-fix `d2722df` ещё не прилетел) — main остался с pre-existing тестами под старый API. Mea culpa: при ревью #919 не grep'нул существующих вызовов `build_sber_route(2-arg)` / `test_estimator_imv_blend` на cross-file impact. Этот PR закрывает дыру. ## Verified (line-by-line, tests-only — 0 app/ изменений) - **Удалён `tests/services/test_sber_index.py`** — дубль из #919; его тесты (`per_dashboard`, `real_fixture`, `period_month`) смержены в root `test_sber_index.py`. Покрытие не потеряно, дубль-basename pytest-коллизия устранена. - **`test_estimator_imv_blend.py`** — 2 dkp-теста обёрнуты `patch("...estimator._load_sber_index_series", return_value={})` → пустой series → `_sber_time_factor`=1.0 → corridor-математика без изменений, **исходные assert'ы (count/low/high) сохранены**. Остальное — косметика ruff (multi-line `patch(...)`). - **Rename** `test_estimator_sber_time_adjust.py` services/→root (100% similarity, чистый move). - **root `test_sber_index.py`** — все `build_sber_route("slug","ref")` → 3-arg `(d.slug,"ref",d.extra_filter)` через `_DASH`; `_mock_fetch` sig → `SberDashboard`; `dashboard==` → `dashboard.slug==`; `dashboards=[_DASH[...]]`. Fixture-path скорректирован (`parent/fixtures`). Все пути `tradein-mvp/backend/tests/**`, без секретов, без self-extending. Автор: `42 passed`, ruff clean. Squash-merge + delete branch. Восстанавливает CI на main для последующих PR/деплоев.
bot-reviewer merged commit 3bd107f923 into main 2026-05-31 19:05:10 +00:00
bot-reviewer deleted branch fix/794-test-regressions 2026-05-31 19:05:11 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#921
No description provided.