Files
agentic-studio/kipina-codebench/prompts/golden-compact-py.md

1.3 KiB

REFERENCE PATTERNS (follow exactly):

STACK: SQLAlchemy 2.0 + Pydantic v2 + FastAPI + SQLite

models.py: from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column class Base(DeclarativeBase): pass Fields: Mapped[type] = mapped_column(SqlType, default=...) Nullable: Mapped[str | None] = mapped_column(Text, default=None) Status: Mapped[str] = mapped_column(String(20), default="pending") FK: Mapped[int] = mapped_column(ForeignKey("table.id")) End: Base.metadata.create_all(bind=engine)

schemas.py: class EntityCreate(BaseModel): fields with defaults class EntityResponse(EntityCreate): id: int model_config = ConfigDict(from_attributes=True)

main.py: def get_db(): yield SessionLocal(); finally close POST /{table}/ → 201, model_dump() GET /{table}/ → list GET /{table}/{id} → 404 if not found PUT /{table}/{id} → model_dump(), setattr loop DELETE /{table}/{id} → 204

test_main.py: test.db + override_get_db + TestClient Unique descriptive data per test ("Buy milk", "Fetchable task"...) test_create → 201 + assert "id" in json test_list → post first, get, assert len >= 1 test_get_by_id → post, get by id, assert id matches test_not_found → get /99999 → 404 test_update → post, put with ALL required fields, assert 200 test_delete → post, delete 204, get again → 404