refactor(test): move contact and address creation to bootstrap (backport #54406) (#54410)

Co-authored-by: ruthra kumar <ruthra@erpnext.com>
This commit is contained in:
mergify[bot]
2026-04-22 00:24:36 +05:30
committed by GitHub
parent 193a44f298
commit 5923618df3
5 changed files with 50 additions and 140 deletions

View File

@@ -16,49 +16,6 @@ ReportFilters = dict[str, Any]
ReportName = NewType("ReportName", str)
def create_test_contact_and_address():
frappe.db.sql("delete from tabContact")
frappe.db.sql("delete from `tabContact Email`")
frappe.db.sql("delete from `tabContact Phone`")
frappe.db.sql("delete from tabAddress")
frappe.db.sql("delete from `tabDynamic Link`")
frappe.get_doc(
{
"doctype": "Address",
"address_title": "_Test Address for Customer",
"address_type": "Office",
"address_line1": "Station Road",
"city": "_Test City",
"state": "Test State",
"country": "India",
"links": [{"link_doctype": "Customer", "link_name": "_Test Customer"}],
}
).insert()
contact = frappe.get_doc(
{
"doctype": "Contact",
"first_name": "_Test Contact for _Test Customer",
"links": [{"link_doctype": "Customer", "link_name": "_Test Customer"}],
}
)
contact.add_email("test_contact_customer@example.com", is_primary=True)
contact.add_phone("+91 0000000000", is_primary_phone=True)
contact.insert()
contact_two = frappe.get_doc(
{
"doctype": "Contact",
"first_name": "_Test Contact 2 for _Test Customer",
"links": [{"link_doctype": "Customer", "link_name": "_Test Customer"}],
}
)
contact_two.add_email("test_contact_two_customer@example.com", is_primary=True)
contact_two.add_phone("+92 0000000000", is_primary_phone=True)
contact_two.insert()
def execute_script_report(
report_name: ReportName,
module: str,
@@ -242,6 +199,7 @@ class BootStrapTestData:
self.make_sales_partner()
self.make_activity_type()
self.make_address()
self.make_contact()
self.update_support_settings()
self.update_selling_settings()
self.update_stock_settings()
@@ -2883,9 +2841,38 @@ class BootStrapTestData:
{"link_doctype": "Customer", "link_name": "_Test Customer 1", "doctype": "Dynamic Link"}
],
},
{
"doctype": "Address",
"address_title": "_Test Address for Customer",
"address_type": "Office",
"address_line1": "Station Road",
"city": "_Test City",
"state": "Test State",
"country": "India",
"links": [{"link_doctype": "Customer", "link_name": "_Test Customer"}],
},
]
self.make_records(["address_title", "address_type"], records)
def make_contact(self):
records = [
{
"doctype": "Contact",
"first_name": "_Test Contact for _Test Customer",
"email_ids": [{"email_id": "test_contact_customer@example.com", "is_primary": True}],
"phone_nos": [{"phone": "+91 0000000000", "is_primary_phone": True}],
"links": [{"link_doctype": "Customer", "link_name": "_Test Customer"}],
},
{
"doctype": "Contact",
"first_name": "_Test Contact 2 for _Test Customer",
"email_ids": [{"email_id": "test_contact_two_customer@example.com", "is_primary": True}],
"phone_nos": [{"phone": "+92 0000000000", "is_primary_phone": True}],
"links": [{"link_doctype": "Customer", "link_name": "_Test Customer"}],
},
]
self.make_records(["first_name"], records)
def make_dimensions(self):
records = [
{