Skip to content

fix(level6): correct project API checker contracts - #66

Merged
michalmaj merged 1 commit into
mainfrom
fix/level6-project-checkers
Oct 1, 2026
Merged

michalmaj merged 1 commit into
mainfrom
fix/level6-project-checkers

Conversation

@michalmaj

Copy link
Copy Markdown
Owner

Summary

Micro-hotfix following the final Level 6 quality gate. Narrow scope: two checker files, no architecture changes.

  • P01 check.py: the happy-path gate sent monster_name="Goblin", but the request schema's Literal["goblin", "orc", "dragon"] is lowercase-only — matching both task.py's scaffold and the README's documented contract. Any implementation faithful to that contract got 422 on the happy path and could never pass the project. Fixed to send "goblin"; added an explicit check that "Goblin" (wrong case) still correctly 422s, so the case-sensitivity of the contract stays enforced rather than silently dropped.
  • P02 check.py: GET /monsters only checked len(monsters) >= 2, so a hardcoded two-item fake list passed. Now compares the response against the real catalog (task/repository.py's _CATALOG) by value — name, hp, atk, def_ — as a set, since the API contract doesn't guarantee ordering. Doesn't require calling any specific repository method.

Explicitly not touched

M01–M08, P03, Level 5, Level 7, no new quality gates, no schema/contract changes (lowercase Literal stays lowercase; _CATALOG stays the single source of truth).

Test plan

  • P01: reference solution → PASS; lowercase "goblin" happy path → 200; uppercase "Goblin" → 422; unknown "Phoenix" → 422; scaffold → FAIL
  • P02: reference solution (Variant A, repo.list_all() direct) → PASS; hardcoded fake 2-item catalog → FAIL; Variant B (different function names/helpers/route order, still backed by the real repo) → PASS; existing lookup → correct data; missing lookup → 404; scaffold → FAIL
  • P03: full boss-fight checker smoke test → PASS (no regression)
  • tools/author_check.py → 727 checks passed, 0 errors
  • tools/course_status.py → Level 6 fully green
  • No leftover __pycache__, .pytest_cache, session files; git status --short clean except the two intended files

🤖 Generated with Claude Code

- P01 check.py: the happy-path test sent monster_name="Goblin" while the
  request schema's Literal is lowercase-only ("goblin", "orc", "dragon"),
  matching the README's documented contract. No implementation faithful
  to that contract could ever pass this gate. Fixed to send "goblin", and
  added an explicit case-sensitivity check confirming "Goblin" still 422s.
- P02 check.py: GET /monsters only checked len(monsters) >= 2, so a
  hardcoded two-item fake list passed. Now compares the response against
  the real catalog in task/repository.py's _CATALOG by value (name, hp,
  atk, def_), as a set since the API contract doesn't guarantee ordering.
@michalmaj
michalmaj merged commit 69e2482 into main Oct 1, 2026
1 check passed
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