mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-17 08:35:00 +00:00
refactor(test): make 'Activity Cost' idempotent
This commit is contained in:
@@ -9,13 +9,41 @@ from erpnext.projects.doctype.activity_cost.activity_cost import DuplicationErro
|
||||
|
||||
|
||||
class TestActivityCost(IntegrationTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.make_employees()
|
||||
|
||||
@classmethod
|
||||
def make_employees(cls):
|
||||
records = [
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"date_of_birth": "1980-01-01",
|
||||
"date_of_joining": "2010-01-01",
|
||||
"department": "_Test Department - _TC",
|
||||
"doctype": "Employee",
|
||||
"first_name": "_Test Employee",
|
||||
"gender": "Female",
|
||||
"naming_series": "_T-Employee-",
|
||||
"status": "Active",
|
||||
"user_id": "test@example.com",
|
||||
},
|
||||
]
|
||||
cls.employees = []
|
||||
for x in records:
|
||||
if not frappe.db.exists("Employee", {"first_name": x.get("first_name")}):
|
||||
cls.employees.append(frappe.get_doc(x).insert())
|
||||
else:
|
||||
cls.employees.append(frappe.get_doc("Employee", {"first_name": x.get("first_name")}))
|
||||
|
||||
def test_duplication(self):
|
||||
frappe.db.sql("delete from `tabActivity Cost`")
|
||||
activity_cost1 = frappe.new_doc("Activity Cost")
|
||||
activity_cost1.update(
|
||||
{
|
||||
"employee": "_T-Employee-00001",
|
||||
"employee_name": "_Test Employee",
|
||||
"employee": self.employees[0].name,
|
||||
"employee_name": self.employees[0].first_name,
|
||||
"activity_type": "_Test Activity Type 1",
|
||||
"billing_rate": 100,
|
||||
"costing_rate": 50,
|
||||
|
||||
Reference in New Issue
Block a user