Add tests utility service request #73
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📌 Utility Service Request tests
This PR introduces comprehensive unit tests for the core functionality of the
Utility Service RequestDocType in theutility_billingapp. The goal is to ensure all critical business logic functions as expected, including validation, contract generation, customer creation, and sales document generation.✅ What’s Covered
The following tests were added:
test_validate_contract_dates_auto_sets_end_dateend_dateis auto-calculated correctly fromstart_dateandcontract_length_months.test_on_submit_creates_customer_when_enabledtest_create_contract_successContractdocument is created and correctly linked to the service request.test_get_utility_bill_structure_details_returns_itemstest_create_sales_order_doc_creates_order_successfullySales Orderfrom a service request, with correct customer linkage.test_create_sales_invoice_doc_creates_invoice_successfullySales Invoicefrom a service request, with correct customer linkage.🧪 Test Design Considerations
Fixtures Setup (
setUp)Customer,Item, andUtility Bill Structurerecords.self.created_docsfor cleanup.Clean Teardown (
tearDown)frappe.delete_doc.frappe.db.rollback()to ensure test isolation.Reusable Helper
create_utility_service_request()simplifies creation of a consistent base document with optional overrides.Test Isolation
DocStrings
🛠 How to Run Tests
From your Frappe bench directory:
bench --site [your-site-name] run-tests --doctype "Utility Service Request"