[WorkOrders] - Write Failing DB Tests for CRUD Operations #112

Closed
opened 2025-11-05 20:05:56 +00:00 by duarteneves5 · 2 comments
duarteneves5 commented 2025-11-05 20:05:56 +00:00 (Migrated from github.com)

Following TDD, write tests before implementation. These tests will fail, as the interface methods are empty.

Tasks:

  • Set up the pytest file (e.g., tests/test_workOrder_repo.py).
  • Create database fixtures (e.g., a test database, a sample client fixture, a sample workOrder fixture).
  • Write a test for test_create_workOrder_success.
  • Write a test for test_get_workOrder_by_id_success.
  • Write a test for test_get_workOrder_by_id_not_found.
  • Write a test for test_get_workOrders_by_vehicle_id_returns_list.
  • Write a test for test_get_workOrders_by_client_id_returns_list.
  • Write a test for test_get_by_work_order_number.
  • Write a test for test_get_active_by_vehicle_id.
  • Write a test for test_create_work_order_fails_on_active_vehicle.
  • Write a test for test_update_workOrder_success (e.g., updating items).
  • Write a test for test_delete_workOrder_success.
  • Run pytest and confirm all new tests fail as expected.
Following TDD, write tests *before* implementation. These tests will fail, as the interface methods are empty. **Tasks:** - [x] Set up the `pytest` file (e.g., `tests/test_workOrder_repo.py`). - [x] Create database fixtures (e.g., a test database, a sample `client` fixture, a sample `workOrder` fixture). - [x] Write a test for `test_create_workOrder_success`. - [x] Write a test for `test_get_workOrder_by_id_success`. - [x] Write a test for `test_get_workOrder_by_id_not_found`. - [x] Write a test for `test_get_workOrders_by_vehicle_id_returns_list`. - [x] Write a test for `test_get_workOrders_by_client_id_returns_list`. - [x] Write a test for `test_get_by_work_order_number`. - [x] Write a test for `test_get_active_by_vehicle_id`. - [x] Write a test for `test_create_work_order_fails_on_active_vehicle`. - [x] Write a test for `test_update_workOrder_success` (e.g., updating `items`). - [x] Write a test for `test_delete_workOrder_success`. - [x] Run `pytest` and confirm all new tests fail as expected.
GFMpt13 commented 2025-11-07 15:24:07 +00:00 (Migrated from github.com)

I have removed test_get_workOrders_by_appointment_id_returns_list. That logic cannot exist in the WorkOrderRepo because the WorkOrder model does not have an appointment_id. That test belongs in Route/Service test file, where we can mock both the AppointmentRepo and WorkOrderRepo.

I have removed test_get_workOrders_by_appointment_id_returns_list. That logic cannot exist in the WorkOrderRepo because the WorkOrder model does not have an appointment_id. That test belongs in Route/Service test file, where we can mock both the AppointmentRepo and WorkOrderRepo.
GFMpt13 commented 2025-11-07 15:26:49 +00:00 (Migrated from github.com)

I have added tests for get_by_work_order_number and get_active_by_vehicle_id, as these are critical methods defined in the interface. I also added a test for the most important business rule, test_create_work_order_fails_on_active_vehicle (RB02).

I have added tests for get_by_work_order_number and get_active_by_vehicle_id, as these are critical methods defined in the interface. I also added a test for the most important business rule, test_create_work_order_fails_on_active_vehicle (RB02).
Sign in to join this conversation.
No description provided.