refactor(test): hardcoded names over dynamic

This commit is contained in:
ruthra kumar
2026-03-02 11:05:32 +05:30
parent 7cad642a11
commit 21b25ce96c
4 changed files with 22 additions and 12 deletions

View File

@@ -84,6 +84,8 @@ class TestQueries(ERPNextTestSuite):
self.assertGreaterEqual(frappe.db.count("UOM", {"enabled": 1}), 10)
def test_employee_query_with_user_permissions(self):
employee = frappe.db.get_all("Employee", {"first_name": "_Test Employee"})[0].name
# party field is a dynamic link field in Payment Entry doctype with ignore_user_permissions=0
ps = make_property_setter(
doctype="Payment Entry",
@@ -98,7 +100,7 @@ class TestQueries(ERPNextTestSuite):
{
"user": user.name,
"doctype": "Employee",
"docname": "_Test Employee",
"docname": employee,
"is_default": 1,
"apply_to_all_doctypes": 1,
"applicable_doctypes": [],

View File

@@ -13,11 +13,13 @@ class TestLead(ERPNextTestSuite):
def test_make_customer(self):
from erpnext.crm.doctype.lead.lead import make_customer
lead = frappe.db.get_all("Lead", {"lead_name": "_Test Lead"})[0].name
frappe.delete_doc_if_exists("Customer", "_Test Lead")
customer = make_customer("_Test Lead")
customer = make_customer(lead)
self.assertEqual(customer.doctype, "Customer")
self.assertEqual(customer.lead_name, "_Test Lead")
self.assertEqual(customer.lead_name, lead)
customer.company = "_Test Company"
customer.customer_group = "_Test Customer Group"
@@ -41,9 +43,10 @@ class TestLead(ERPNextTestSuite):
def test_make_customer_from_organization(self):
from erpnext.crm.doctype.lead.lead import make_customer
customer = make_customer("_Test Lead 1")
lead = frappe.db.get_all("Lead", {"lead_name": "_Test Lead 1"})[0].name
customer = make_customer(lead)
self.assertEqual(customer.doctype, "Customer")
self.assertEqual(customer.lead_name, "_Test Lead 1")
self.assertEqual(customer.lead_name, lead)
customer.company = "_Test Company"
customer.customer_group = "_Test Customer Group"

View File

@@ -122,9 +122,9 @@ class TestJobCard(ERPNextTestSuite):
final_bom.submit()
work_order = make_work_order(final_bom.name, final.name, 1, variant_items=[], use_multi_level_bom=0)
work_order.company = "_Test Company"
work_order.wip_warehouse = "Work In Progress - WP"
work_order.fg_warehouse = "Finished Goods - WP"
work_order.scrap_warehouse = "All Warehouses - WP"
work_order.wip_warehouse = "Work In Progress - _TC"
work_order.fg_warehouse = "Finished Goods - _TC"
work_order.scrap_warehouse = "All Warehouses - _TC"
for operation in work_order.operations:
operation.time_in_mins = 60
@@ -187,7 +187,7 @@ class TestJobCard(ERPNextTestSuite):
jc1 = frappe.get_last_doc("Job Card", {"work_order": self.work_order.name})
jc2 = frappe.get_last_doc("Job Card", {"work_order": wo2.name})
employee = "_Test Employee"
employee = frappe.db.get_all("Employee", {"first_name": "_Test Employee"})[0].name
jc1.append(
"time_logs",

View File

@@ -9,13 +9,18 @@ from erpnext.tests.utils import ERPNextTestSuite
class TestActivityCost(ERPNextTestSuite):
def test_duplication(self):
employee = frappe.db.get_all("Employee", filters={"first_name": "_Test Employee"})[0].name
activity_type = frappe.db.get_all(
"Activity Type", filters={"activity_type": "_Test Activity Type 1"}
)[0].name
frappe.db.sql("delete from `tabActivity Cost`")
activity_cost1 = frappe.new_doc("Activity Cost")
activity_cost1.update(
{
"employee": "_Test Employee",
"employee_name": self.employees[0].first_name,
"activity_type": self.activity_type[1].name,
"employee": employee,
"employee_name": employee,
"activity_type": activity_type,
"billing_rate": 100,
"costing_rate": 50,
}