Skip to content

Add comprehensive unit tests: 55% → 100% coverage - #4

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783177305-add-unit-tests
Open

Add comprehensive unit tests: 55% → 100% coverage#4
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783177305-add-unit-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Raises test coverage from 55% (7 tests) to 100% (69 tests) by adding unit tests for every previously uncovered module.

Before → After

Module Before After
app/main.py 0% 100%
app/qr.py 0% 100%
app/seed.py 0% 100%
app/db.py 78% 100%
app/models.py 93% 100%

New test files

  • tests/test_api.py — 29 tests covering all FastAPI endpoints via TestClient: CRUD for boxes/orders, GET /districts, POST /redeem, admin stats/refund/seed, plus the lifespan auto-seed path, local_only 403 rejection, and create_order race-condition 409.
  • tests/test_db_extra.py — 19 tests for Store methods not exercised by test_flow.py: partners(), boxes_available(district=…) filtering, partner_boxes(), orders(), partner_orders(), order_by_code() miss, _effective_status with invalid date, refund of issued/nonexistent orders, reset(), count(), stats no-show/active branches.
  • tests/test_models.py — 7 tests for Box/Order computed fields (discount, category_ru, emoji) and edge cases (value_est=0, _utcnow awareness).
  • tests/test_qr.py — 3 tests: SVG output correctness, no newlines, scale parameter effect.
  • tests/test_seed.py — 4 tests: partner/box counts, availability, idempotency across double-seed.

All tests use tmp_path fixtures for DB isolation; API tests patch the global store to avoid side effects.

Link to Devin session: https://app.devin.ai/sessions/483840f3650040e49f52a49056a6800a
Requested by: @wpalish

- test_api.py: all FastAPI endpoints (health, boxes, orders, partners, redeem, admin, lifespan, local_only, race condition)
- test_qr.py: QR SVG generation
- test_seed.py: demo data seeding and idempotency
- test_db_extra.py: Store methods (partners, filters, orders list, refund edges, reset, count, stats branches)
- test_models.py: computed fields (discount, category_ru, emoji) and edge cases

69 tests total, all passing.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@wpalish wpalish self-assigned this Jul 4, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

wpalish pushed a commit that referenced this pull request Jul 16, 2026
…арточка); +контраст футера

По UX-ревью:
- #1 localStorage-нотис был плавающей центр-карточкой (читалось как «глюк»
  поверх секций) → тонкая полоса во всю ширину, приклеена к низу (над bottom-nav
  на мобиле, к краю на десктопе). Показ один раз (флаг ym_cookies уже был).
- #6 контраст копирайта/FAQ-текста в футере поднят (.6→.78, .7→.82 opacity) —
  запас под WCAG AA.
Уже было в коде: #4 срочность («🔥 осталось N» + окно выдачи), #7 соцсети на
светлом --on-ink (не бледные). Требуют ассетов (отдельно): #2 превью карты,
#3 логотипы партнёров/отзывы, #5 лого-марка, #8 PWA-бейджи.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant