Implement Routes for WorkOrders #167

Closed
opened 2025-12-11 17:39:46 +00:00 by GFMpt13 · 0 comments
GFMpt13 commented 2025-12-11 17:39:46 +00:00 (Migrated from github.com)

Implement the REST endpoints for the WorkOrder entity, connecting the API layer to the existing WorkOrderRepo.

This includes handling the creation flow (triggering auto-numbering), enforcing Business Rule RB02 (one active WO per vehicle), and advanced filtering.

Technical Requirements:

  • File: src/routers/work_orders.py
  • Prefix: /work-orders
  • Tags: ["Work Orders"]
  • Dependency: Inject WorkOrderRepo using Depends().
  • Testing: Use AsyncMock to mock the repository layer. Do not connect to the real database.

Exception Mapping Strategy:

  • WorkOrderNotFoundError -> 404 Not Found
  • ActiveWorkOrderExistsError -> 409 Conflict (Message: "This vehicle already has an active work order")
  • WorkOrderNumberConflictError -> 500 Internal Server Error (This is a race condition/system error)
  • WorkOrderDatabaseError -> 500 Internal Server Error

TDD Checklist:

Implement the REST endpoints for the WorkOrder entity, connecting the API layer to the existing WorkOrderRepo. This includes handling the creation flow (triggering auto-numbering), enforcing Business Rule RB02 (one active WO per vehicle), and advanced filtering. Technical Requirements: - File: src/routers/work_orders.py - Prefix: /work-orders - Tags: ["Work Orders"] - Dependency: Inject WorkOrderRepo using Depends(). - Testing: Use AsyncMock to mock the repository layer. Do not connect to the real database. Exception Mapping Strategy: - WorkOrderNotFoundError -> 404 Not Found - ActiveWorkOrderExistsError -> 409 Conflict (Message: "This vehicle already has an active work order") - WorkOrderNumberConflictError -> 500 Internal Server Error (This is a race condition/system error) - WorkOrderDatabaseError -> 500 Internal Server Error TDD Checklist: - [x] #170 - [x] #171 - [x] #172
Sign in to join this conversation.
No description provided.