Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Data models for the Workshop API."""

from pydantic import BaseModel
from pydantic import BaseModel, Field
from typing import Optional


class ProfileCreate(BaseModel):
"""Schema for creating a new profile."""

username: str
bio: str
bio: str = Field(..., max_length=500)
age: Optional[int] = None


Expand Down
8 changes: 8 additions & 0 deletions tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ def test_get_profile(clean_store):
def test_get_nonexistent_profile(clean_store):
response = client.get("/profile/nobody")
assert response.status_code == 404


def test_create_profile_with_too_long_bio(clean_store):
response = client.post(
"/profile",
json={"username": "alice", "bio": "x" * 501, "age": 22},
)
assert response.status_code == 422