Conversation
Test Results173 tests +90 173 ✅ +90 0s ⏱️ ±0s Results for commit e94fa6b. ± Comparison against base commit 06f46ff. This pull request removes 3 and adds 93 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
| description: str | ||
| start_datetime: datetime | ||
| end_datetime: datetime | ||
| location: str | None = None |
There was a problem hiding this comment.
| location: str | None = None | |
| location: Optional[str] = None |
| date_published: datetime | ||
| date_last_edited: datetime | ||
|
|
||
| admin: Optional[object] = None |
There was a problem hiding this comment.
| admin: Optional[object] = None | |
| admin: Optional["Admin"] = None |
- Add GET /api/news (paginated, published only, most-recent-first)
- Add GET /api/news/{id} (404 for drafts or nonexistent)
- Add GET /api/senators (filterable: search, district_id, committee, session)
- Add GET /api/senators/{id} (with committee assignments, any session)
- Add app/utils/pagination.py reusable paginate() helper
- Add app/schemas/pagination.py PaginatedResponse[T] generic envelope
- Register both routers in app/main.py
- Add try/except guard for PR #37 NewsDTO/SenatorDTO schemas
- Add tests/routes/ integration test suite (43 tests, SQLite in-memory)
- 13 tests for news endpoints
- 26 tests for senator endpoints
- conftest seeds districts, admin, news, committees, senators, memberships
126 tests pass, 0 failures
|
I incorporated the None = None fix. Your recommended admin fix appears to be a SQLAlchemy model, so it cannot be easily incorporated into the DTO. Please let me know if I am wrong here. For now, I incorporated the AccountDTO in its place, as it appears to have the ability to reflect the admin account. I have yet to make NewsDTO check if the AccountDTO has the role of admin, as I am waiting for your review. |
calebyhan
left a comment
There was a problem hiding this comment.
I just went ahead and changed NewsDTO to match the TDD for now. As for making NewsDTO check if AccountDTO has role of admin, we don't need to for this scope, as the database constraint enforces that with the Foreign Key. NewsDTO is an output DTO anyways, so we wouldn't put that check here.
LGTM! thanks
- Add GET /api/news (paginated, published only, most-recent-first)
- Add GET /api/news/{id} (404 for drafts or nonexistent)
- Add GET /api/senators (filterable: search, district_id, committee, session)
- Add GET /api/senators/{id} (with committee assignments, any session)
- Add app/utils/pagination.py reusable paginate() helper
- Add app/schemas/pagination.py PaginatedResponse[T] generic envelope
- Register both routers in app/main.py
- Add try/except guard for PR #37 NewsDTO/SenatorDTO schemas
- Add tests/routes/ integration test suite (43 tests, SQLite in-memory)
- 13 tests for news endpoints
- 26 tests for senator endpoints
- conftest seeds districts, admin, news, committees, senators, memberships
126 tests pass, 0 failures
Motivation:
The API needs a typed contract between backend and frontend. Output DTOs define exactly what the frontend receives and ensure consistent serialization from SQLAlchemy models.
Changes:
Added all DTOs for the project ( in separate files within app/schemas ), including:
SenatorDTO, CommitteeAssignmentDTO, CommitteeDTO, LeadershipDTO, NewsDTO
LegislationDTO, LegislationActionDTO, CalendarEventDTO, CarouselSlideDTO
FinanceHearingConfigDTO, FinanceHearingDateDTO, StaffDTO, DistrictDTO
BudgetDataDTO, StaticPageDTO, AccountDTO
Exported via init.py
Added pydantic==2.7.1 to requirments
Added unit tests ( in tests/schemas/test_schemas.py ) for each DTO:
Instantiated from mock data
Verified serialization (model_dump)
Verified nested, recursive, and optional fields
Verified computed fields like NewsDTO.author_name
Notes:
I also noticed that the Technical Design Document Section 4.5.1, the section relating to the requirements of the DTO's, did not have the CalendarEventDTO. However, the ticket this is responding to asked for a CalendarEventDTO, so I made it with field types of what I believed to be applicable.
Closes #10