Skip to content

Commit d65aba3

Browse files
committed
refactor(test): hardcoded names over dynamic ones
Much faster bootstrap without those get_doc calls
1 parent efb3c80 commit d65aba3

26 files changed

Lines changed: 67 additions & 58 deletions

File tree

erpnext/accounts/doctype/process_deferred_accounting/test_process_deferred_accounting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_creation_of_ledger_entry_on_submit(self):
5252
start_date="2023-05-01",
5353
end_date="2023-06-30",
5454
type="Income",
55-
company=self.companies[0].name,
55+
company="_Test Company",
5656
)
5757

5858
process_deferred_accounting.insert()
@@ -83,7 +83,7 @@ def test_pda_submission_and_cancellation(self):
8383
start_date="2019-01-01",
8484
end_date="2019-01-31",
8585
type="Income",
86-
company=self.companies[0].name,
86+
company="_Test Company",
8787
)
8888
pda.submit()
8989
pda.cancel()

erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,7 +2272,7 @@ def test_repost_accounting_entries(self):
22722272

22732273
def test_create_purchase_invoice_without_mandatory(self):
22742274
pi = frappe.new_doc("Purchase Invoice")
2275-
pi.company = self.companies[0].name
2275+
pi.company = "_Test Company"
22762276
pi.flags.ignore_mandatory = True
22772277
pi.insert(ignore_permissions=True)
22782278

@@ -2401,7 +2401,7 @@ def test_purchase_invoice_with_use_serial_batch_field_for_rejected_qty(self):
24012401
"doctype": "Serial No",
24022402
"item_code": serial_item,
24032403
"serial_no": serial_no,
2404-
"company": self.companies[0].name,
2404+
"company": "_Test Company",
24052405
}
24062406
).insert()
24072407

erpnext/controllers/tests/test_mapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def make_quotation(self, item_list, customer):
3939
"order_type": "Sales",
4040
"transaction_date": nowdate(),
4141
"valid_till": add_months(nowdate(), 1),
42-
"company": self.companies[0].name,
42+
"company": "_Test Company",
4343
}
4444
)
4545
for item in item_list:

erpnext/controllers/tests/test_subcontracting_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ def test_incorrect_serial_no_components_based_on_material_transfer(self):
742742
"doctype": "Serial No",
743743
"item_code": "Subcontracted SRM Item 2",
744744
"serial_no": serial_no,
745-
"company": self.companies[0].name,
745+
"company": "_Test Company",
746746
}
747747
).insert()
748748

erpnext/crm/doctype/lead/test_lead.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_opportunity_from_lead(self):
120120
create_todo("followup", "Lead", lead.name)
121121

122122
opportunity = make_opportunity(lead.name)
123-
opportunity.company = self.companies[0].name
123+
opportunity.company = "_Test Company"
124124
opportunity.save()
125125

126126
self.assertEqual(opportunity.get("party_name"), lead.name)

erpnext/crm/doctype/opportunity/test_opportunity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_opportunity_status(self):
5454
self.assertEqual(doc.status, "Quotation")
5555

5656
def test_make_new_lead_if_required(self):
57-
opp_doc = make_opportunity_from_lead(self.companies[0].name)
57+
opp_doc = make_opportunity_from_lead("_Test Company")
5858

5959
self.assertTrue(opp_doc.party_name)
6060
self.assertEqual(opp_doc.opportunity_from, "Lead")

erpnext/crm/doctype/prospect/test_prospect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class TestProspect(ERPNextTestSuite):
1313
def test_add_lead_to_prospect_and_address_linking(self):
14-
company = self.companies[0].name
14+
company = "_Test Company"
1515
lead_doc = make_lead()
1616
address_doc = make_address(address_title=lead_doc.name)
1717
address_doc.append("links", {"link_doctype": lead_doc.doctype, "link_name": lead_doc.name})
@@ -37,7 +37,7 @@ def test_make_customer_from_prospect(self):
3737
"doctype": "Prospect",
3838
"company_name": "_Test Prospect",
3939
"customer_group": "_Test Customer Group",
40-
"company": self.companies[0].name,
40+
"company": "_Test Company",
4141
}
4242
)
4343
prospect.insert()

erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_new_transaction(self):
5555
}
5656

5757
bank = json.dumps(frappe.get_doc("Bank", "Citi").as_dict(), default=json_handler)
58-
company = self.companies[0].name
58+
company = "_Test Company"
5959

6060
add_bank_accounts(bank_accounts, bank, company)
6161

erpnext/manufacturing/doctype/bom/test_bom.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def test_bom_recursion_1st_level(self):
392392
item_code = make_item(properties={"is_stock_item": 1}).name
393393

394394
bom = frappe.new_doc("BOM")
395-
bom.company = self.companies[0].name
395+
bom.company = "_Test Company"
396396
bom.item = item_code
397397
bom.append("items", frappe._dict(item_code=item_code))
398398
bom.save()
@@ -406,13 +406,13 @@ def test_bom_recursion_transitive(self):
406406
item2 = make_item(properties={"is_stock_item": 1}).name
407407

408408
bom1 = frappe.new_doc("BOM")
409-
bom1.company = self.companies[0].name
409+
bom1.company = "_Test Company"
410410
bom1.item = item1
411411
bom1.append("items", frappe._dict(item_code=item2))
412412
bom1.save()
413413

414414
bom2 = frappe.new_doc("BOM")
415-
bom2.company = self.companies[0].name
415+
bom2.company = "_Test Company"
416416
bom2.item = item2
417417
bom2.append("items", frappe._dict(item_code=item1))
418418
bom2.save()
@@ -570,7 +570,7 @@ def test_bom_versioning(self):
570570
@timeout
571571
def test_clear_inpection_quality(self):
572572
bom = frappe.copy_doc(self.globalTestRecords["BOM"][2], ignore_no_copy=True)
573-
bom.company = self.companies[0].name
573+
bom.company = "_Test Company"
574574
bom.docstatus = 0
575575
bom.is_default = 0
576576
bom.quality_inspection_template = "_Test Quality Inspection Template"
@@ -616,7 +616,7 @@ def test_set_default_bom_for_item_having_single_bom(self):
616616

617617
# Step 1: Create BOM
618618
bom = frappe.new_doc("BOM")
619-
bom.company = self.companies[0].name
619+
bom.company = "_Test Company"
620620
bom.item = fg_item.item_code
621621
bom.quantity = 1
622622
bom.append(

erpnext/manufacturing/doctype/job_card/test_job_card.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_quality_inspection_mandatory_check(self):
8787
quantity=1,
8888
with_operations=1,
8989
track_semi_finished_goods=1,
90-
company=self.companies[9].name,
90+
company="_Test Company",
9191
)
9292
final_bom.append("items", {"item_code": raw.name, "qty": 1})
9393
final_bom.append(
@@ -122,7 +122,7 @@ def test_quality_inspection_mandatory_check(self):
122122
final_bom.insert()
123123
final_bom.submit()
124124
work_order = make_work_order(final_bom.name, final.name, 1, variant_items=[], use_multi_level_bom=0)
125-
work_order.company = self.companies[9].name
125+
work_order.company = "_Test Company"
126126
work_order.wip_warehouse = "Work In Progress - WP"
127127
work_order.fg_warehouse = "Finished Goods - WP"
128128
work_order.scrap_warehouse = "All Warehouses - WP"

0 commit comments

Comments
 (0)