Summary
PurchaseInvoice and Receipt are both thin subclasses of the same Document base, but their test files are independent copies with very different coverage: tests/test_purchase_invoice.py is 268 lines, tests/test_receipt.py is 51 lines and covers only five of the same test names (test_add_detail, test_delete, test_find_by_id, test_list_all, test_sync_endpoint). Everything only exercised in the purchase-invoice file — payments, detail updates/deletion with _destroy, attachments, register_payment, save round-trips — is untested for Receipt, even though the code paths are shared.
Details
Both classes differ only in _resource ("purchase_invoice" vs "receipt"), so the behavior under test is identical except for the URL segment and payload key. The current structure means:
- New
Document features get tested against one subclass only (whichever file the author copies into).
- The two files drift — they already have.
Suggested fix
Parametrize the shared Document behavior over both subclasses:
@pytest.fixture(params=[PurchaseInvoice, Receipt])
def document_cls(request):
return request.param
- Move the shared tests into a single
tests/test_document.py parametrized by document_cls, deriving expected paths from cls._resource instead of hard-coding purchase_invoices.
- Keep (or add) only genuinely subclass-specific assertions in per-class files — likely just the endpoint/
_resource values, which the parametrized suite covers anyway.
Result: Receipt inherits the full suite for free, total test code shrinks, and future Document subclasses get coverage by adding one fixture param.
Acceptance criteria
- Every shared
Document behavior test runs against both PurchaseInvoice and Receipt.
- No duplicated test bodies between the two resource types.
- Coverage for
Receipt payments/details/attachments matches PurchaseInvoice.
Summary
PurchaseInvoiceandReceiptare both thin subclasses of the sameDocumentbase, but their test files are independent copies with very different coverage:tests/test_purchase_invoice.pyis 268 lines,tests/test_receipt.pyis 51 lines and covers only five of the same test names (test_add_detail,test_delete,test_find_by_id,test_list_all,test_sync_endpoint). Everything only exercised in the purchase-invoice file — payments, detail updates/deletion with_destroy, attachments,register_payment, save round-trips — is untested forReceipt, even though the code paths are shared.Details
Both classes differ only in
_resource("purchase_invoice"vs"receipt"), so the behavior under test is identical except for the URL segment and payload key. The current structure means:Documentfeatures get tested against one subclass only (whichever file the author copies into).Suggested fix
Parametrize the shared
Documentbehavior over both subclasses:tests/test_document.pyparametrized bydocument_cls, deriving expected paths fromcls._resourceinstead of hard-codingpurchase_invoices._resourcevalues, which the parametrized suite covers anyway.Result:
Receiptinherits the full suite for free, total test code shrinks, and futureDocumentsubclasses get coverage by adding one fixture param.Acceptance criteria
Documentbehavior test runs against bothPurchaseInvoiceandReceipt.Receiptpayments/details/attachments matchesPurchaseInvoice.