refactor(test): move create_test_contact_and_address to bootstrap

This commit is contained in:
ruthra kumar
2026-04-20 11:06:50 +05:30
parent e2b554e151
commit 7f021fb705
3 changed files with 32 additions and 48 deletions

View File

@@ -14,7 +14,7 @@ from erpnext.selling.doctype.customer.customer import (
get_customer_outstanding,
parse_full_name,
)
from erpnext.tests.utils import ERPNextTestSuite, create_test_contact_and_address
from erpnext.tests.utils import ERPNextTestSuite
class TestCustomer(ERPNextTestSuite):
@@ -71,8 +71,6 @@ class TestCustomer(ERPNextTestSuite):
"customer_name": "_Test Customer",
}
create_test_contact_and_address()
frappe.db.set_value(
"Contact", "_Test Contact for _Test Customer-_Test Customer", "is_primary_contact", 1
)

View File

@@ -10,7 +10,7 @@ from erpnext.stock.doctype.delivery_trip.delivery_trip import (
get_contact_and_address,
notify_customers,
)
from erpnext.tests.utils import ERPNextTestSuite, create_test_contact_and_address
from erpnext.tests.utils import ERPNextTestSuite
class TestDeliveryTrip(ERPNextTestSuite):
@@ -19,7 +19,6 @@ class TestDeliveryTrip(ERPNextTestSuite):
driver = create_driver()
create_vehicle()
create_delivery_notification()
create_test_contact_and_address()
address = create_address(driver)
self.delivery_trip = create_delivery_trip(driver, address, company="_Test Company")

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,
@@ -241,6 +198,7 @@ class BootStrapTestData:
self.make_sales_person()
self.make_activity_type()
self.make_address()
self.make_contact()
self.update_support_settings()
self.update_selling_settings()
self.update_stock_settings()
@@ -2859,9 +2817,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 = [
{