Tests for Interface work orders and general fixes #133

Merged
GFMpt13 merged 18 commits from db-interface-work_orders into main 2025-11-18 16:01:19 +00:00
GFMpt13 commented 2025-11-07 17:13:12 +00:00 (Migrated from github.com)

Created tests for the work orders interface.
Made a general fix in the dependecy, we had a clash between bson and pymongo. Also corrected models after the fix.

Created tests for the work orders interface. Made a general fix in the dependecy, we had a clash between bson and pymongo. Also corrected models after the fix.
duarteneves5 (Migrated from github.com) reviewed 2025-11-07 17:13:12 +00:00
vascodias23 (Migrated from github.com) reviewed 2025-11-07 17:13:12 +00:00
miguelmiranda20 (Migrated from github.com) reviewed 2025-11-07 17:13:12 +00:00
GFMpt13 commented 2025-11-13 12:35:36 +00:00 (Migrated from github.com)

Thanks @AndreFerreira5 for fixing the DB test problems

Thanks @AndreFerreira5 for fixing the DB test problems
AndreFerreira5 commented 2025-11-13 12:38:21 +00:00 (Migrated from github.com)

no problem!
i will use this opportunity to explain what was wrong and how i fixed it.

the problem: a centralized test database was being used for testing, which means two concurrent tests could conflict and error
the solution: create a random database name (using a nonce) for each test run, separating the runs with different dbs

note: the created dbs exist only during the test run, so they are short-lived

no problem! i will use this opportunity to explain what was wrong and how i fixed it. the problem: a centralized test database was being used for testing, which means two concurrent tests could conflict and error the solution: create a random database name (using a nonce) for each test run, separating the runs with different dbs note: the created dbs exist only during the test run, so they are short-lived
GFMpt13 commented 2025-11-14 17:57:52 +00:00 (Migrated from github.com)

Refactor and Final Code Review

Changes

-Created custom exception hierarchy for work order operations
-Refactored repository to use decorator pattern for error handling
-Enhanced docstrings and inline documentation
-Added FastAPI exception handlers for proper HTTP responses
-Updated tests to use custom exceptions

Business Rules Enforced

  • RB02: Only one active work order per vehicle (enforced via partial unique index and ActiveWorkOrderExistsError)

Breaking Changes

None - Internal refactoring only

Testing

  • All existing tests pass
  • Updated test for ActiveWorkOrderExistsError
  • Verified exception handling in integration scenarios

Closes #110
(#111, #112, #113, #114)

## Refactor and Final Code Review ### Changes -Created custom exception hierarchy for work order operations -Refactored repository to use decorator pattern for error handling -Enhanced docstrings and inline documentation -Added FastAPI exception handlers for proper HTTP responses -Updated tests to use custom exceptions ### Business Rules Enforced - **RB02**: Only one active work order per vehicle (enforced via partial unique index and `ActiveWorkOrderExistsError`) ### Breaking Changes None - Internal refactoring only ### Testing - [x] All existing tests pass - [x] Updated test for `ActiveWorkOrderExistsError` - [x] Verified exception handling in integration scenarios ### Related Issues Closes #110 (#111, #112, #113, #114)
GFMpt13 commented 2025-11-14 17:58:54 +00:00 (Migrated from github.com)

Please review @AndreFerreira5 @miguelmiranda20 @vascodias23 @duarteneves5

Please review @AndreFerreira5 @miguelmiranda20 @vascodias23 @duarteneves5
AndreFerreira5 (Migrated from github.com) requested changes 2025-11-18 15:53:00 +00:00
AndreFerreira5 (Migrated from github.com) left a comment

i reviewed your changes and almost everything is ready for the merge, except for the misplaced exception_handlers.py, which you should move to the exceptions folder and rename it as handler.py. as it is, it is a bit redundant, because you created a fodler named api.

i reviewed your changes and almost everything is ready for the merge, except for the misplaced _exception_handlers.py_, which you should move to the _exceptions_ folder and rename it as _handler.py_. as it is, it is a bit redundant, because you created a fodler named _api_.
AndreFerreira5 (Migrated from github.com) approved these changes 2025-11-18 16:01:11 +00:00
AndreFerreira5 (Migrated from github.com) left a comment

looks good to me! you have a green light from me

looks good to me! you have a green light from me
Sign in to join this conversation.
No description provided.