[Invoices] Test Setup (Mock) #190

Closed
opened 2026-01-19 22:27:54 +00:00 by duarteneves5 · 0 comments
duarteneves5 commented 2026-01-19 22:27:54 +00:00 (Migrated from github.com)

Create tests/test_routes/test_invoices.py.
Configure AsyncMock for InvoiceRepo.

Test Create (Emission):

  • test_create_invoice_success (201 Created - returns full snapshot).
  • test_create_invoice_missing_address (Mock repo raising ClientAddressMissingError, expect 400).
  • test_create_invoice_work_order_not_found (Expect 404 if WO doesn't exist - logic inside Repo or Service).

Test Read:

  • test_get_invoice_by_id_success (200 OK).
  • test_get_invoice_by_id_not_found (Mock repo returning None or raising error, expect 404).

Test Read (Filters):

  • test_get_invoices_by_client (Mock repo.get_invoices_by_client_id, expect 200).
  • test_get_invoices_by_work_order (Mock repo.get_invoices_by_work_order_id, expect 200).

Test Update (Status):

  • test_update_invoice_status_success (200 OK - e.g., marking as PAID).
  • test_update_invoice_not_found (Expect 404).
Create `tests/test_routes/test_invoices.py`. Configure `AsyncMock` for `InvoiceRepo`. **Test Create (Emission):** - `test_create_invoice_success` (201 Created - returns full snapshot). - `test_create_invoice_missing_address` (Mock repo raising `ClientAddressMissingError`, expect 400). - `test_create_invoice_work_order_not_found` (Expect 404 if WO doesn't exist - logic inside Repo or Service). **Test Read:** - `test_get_invoice_by_id_success` (200 OK). - `test_get_invoice_by_id_not_found` (Mock repo returning `None` or raising error, expect 404). **Test Read (Filters):** - `test_get_invoices_by_client` (Mock `repo.get_invoices_by_client_id`, expect 200). - `test_get_invoices_by_work_order` (Mock `repo.get_invoices_by_work_order_id`, expect 200). **Test Update (Status):** - `test_update_invoice_status_success` (200 OK - e.g., marking as PAID). - `test_update_invoice_not_found` (Expect 404).
Sign in to join this conversation.
No description provided.