mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-25 14:11:45 +01:00
refactor(test): make timesheet deterministic
This commit is contained in:
@@ -14,15 +14,6 @@ from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestTimesheet(ERPNextTestSuite):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.make_projects()
|
||||
cls.make_activity_type()
|
||||
|
||||
def setUp(self):
|
||||
frappe.db.delete("Timesheet")
|
||||
|
||||
def test_timesheet_post_update(self):
|
||||
frappe.get_doc(
|
||||
{
|
||||
@@ -73,7 +64,7 @@ class TestTimesheet(ERPNextTestSuite):
|
||||
)
|
||||
|
||||
def test_timesheet_base_amount(self):
|
||||
emp = make_employee("test_employee_6@salary.com")
|
||||
emp = make_employee("test_employee_6@salary.com", company=self.companies[0].name)
|
||||
timesheet = make_timesheet(emp, simulate=True, is_billable=1)
|
||||
|
||||
self.assertEqual(timesheet.time_logs[0].base_billing_rate, 50)
|
||||
@@ -82,7 +73,7 @@ class TestTimesheet(ERPNextTestSuite):
|
||||
self.assertEqual(timesheet.time_logs[0].base_costing_amount, 40)
|
||||
|
||||
def test_timesheet_billing_amount(self):
|
||||
emp = make_employee("test_employee_6@salary.com")
|
||||
emp = make_employee("test_employee_6@salary.com", company=self.companies[0].name)
|
||||
timesheet = make_timesheet(emp, simulate=True, is_billable=1)
|
||||
|
||||
self.assertEqual(timesheet.total_hours, 2)
|
||||
@@ -92,7 +83,7 @@ class TestTimesheet(ERPNextTestSuite):
|
||||
self.assertEqual(timesheet.total_billable_amount, 100)
|
||||
|
||||
def test_timesheet_billing_amount_not_billable(self):
|
||||
emp = make_employee("test_employee_6@salary.com")
|
||||
emp = make_employee("test_employee_6@salary.com", company=self.companies[0].name)
|
||||
timesheet = make_timesheet(emp, simulate=True, is_billable=0)
|
||||
|
||||
self.assertEqual(timesheet.total_hours, 2)
|
||||
@@ -120,7 +111,7 @@ class TestTimesheet(ERPNextTestSuite):
|
||||
|
||||
@ERPNextTestSuite.change_settings("Projects Settings", {"fetch_timesheet_in_sales_invoice": 1})
|
||||
def test_timesheet_billing_based_on_project(self):
|
||||
emp = make_employee("test_employee_6@salary.com")
|
||||
emp = make_employee("test_employee_6@salary.com", company=self.companies[0].name)
|
||||
project = frappe.get_value("Project", {"project_name": "_Test Project"})
|
||||
|
||||
timesheet = make_timesheet(
|
||||
@@ -136,7 +127,7 @@ class TestTimesheet(ERPNextTestSuite):
|
||||
self.assertEqual(ts.time_logs[0].sales_invoice, sales_invoice.name)
|
||||
|
||||
def test_timesheet_time_overlap(self):
|
||||
emp = make_employee("test_employee_6@salary.com")
|
||||
emp = make_employee("test_employee_6@salary.com", company=self.companies[0].name)
|
||||
|
||||
settings = frappe.get_single("Projects Settings")
|
||||
initial_setting = settings.ignore_employee_time_overlap
|
||||
@@ -192,7 +183,7 @@ class TestTimesheet(ERPNextTestSuite):
|
||||
settings.save()
|
||||
|
||||
def test_timesheet_not_overlapping_with_continuous_timelogs(self):
|
||||
emp = make_employee("test_employee_6@salary.com")
|
||||
emp = make_employee("test_employee_6@salary.com", company=self.companies[0].name)
|
||||
|
||||
update_activity_type("_Test Activity Type")
|
||||
timesheet = frappe.new_doc("Timesheet")
|
||||
@@ -221,7 +212,7 @@ class TestTimesheet(ERPNextTestSuite):
|
||||
timesheet.save() # should not throw an error
|
||||
|
||||
def test_to_time(self):
|
||||
emp = make_employee("test_employee_6@salary.com")
|
||||
emp = make_employee("test_employee_6@salary.com", company=self.companies[0].name)
|
||||
from_time = now_datetime()
|
||||
|
||||
timesheet = frappe.new_doc("Timesheet")
|
||||
|
||||
Reference in New Issue
Block a user