3535
3636class TestAttendance (HRMSTestSuite ):
3737 def setUp (self ):
38- from hrms .payroll .doctype .salary_slip .test_salary_slip import make_holiday_list
39-
40- from_date = get_year_start (add_months (getdate (), - 1 ))
41- to_date = get_year_ending (getdate ())
42- self .holiday_list = make_holiday_list (from_date = from_date , to_date = to_date )
43- frappe .db .delete ("Attendance" )
44- frappe .db .delete ("Employee Checkin" )
38+ self .holiday_list = "Salary Slip Test Holiday List"
4539
4640 def test_duplicate_attendance (self ):
4741 employee = make_employee ("test_duplicate_attendance@example.com" , company = "_Test Company" )
@@ -144,7 +138,7 @@ def test_allow_attendance_with_different_shifts(self):
144138 ).insert ()
145139
146140 def test_mark_absent (self ):
147- employee = make_employee ("test_mark_absent@example.com" )
141+ employee = make_employee ("test_mark_absent@example.com" , company = "_Test Company" )
148142 date = nowdate ()
149143
150144 attendance = mark_attendance (employee , date , "Absent" )
@@ -158,7 +152,9 @@ def test_unmarked_days(self):
158152 attendance_date = add_days (first_sunday , 1 )
159153
160154 employee = make_employee (
161- "test_unmarked_days@example.com" , date_of_joining = add_days (attendance_date , - 1 )
155+ "test_unmarked_days@example.com" ,
156+ date_of_joining = add_days (attendance_date , - 1 ),
157+ company = "_Test Company" ,
162158 )
163159 frappe .db .set_value ("Employee" , employee , "holiday_list" , self .holiday_list )
164160
@@ -182,7 +178,9 @@ def test_unmarked_days_excluding_holidays(self):
182178 attendance_date = add_days (first_sunday , 1 )
183179
184180 employee = make_employee (
185- "test_unmarked_days@example.com" , date_of_joining = add_days (attendance_date , - 1 )
181+ "test_unmarked_days@example.com" ,
182+ date_of_joining = add_days (attendance_date , - 1 ),
183+ company = "_Test Company" ,
186184 )
187185
188186 mark_attendance (employee , attendance_date , "Present" )
@@ -228,7 +226,10 @@ def test_unmarked_days_as_per_joining_and_relieving_dates(self):
228226 doj = add_days (date , 1 )
229227 relieving_date = add_days (date , 5 )
230228 employee = make_employee (
231- "test_unmarked_days_as_per_doj@example.com" , date_of_joining = doj , relieving_date = relieving_date
229+ "test_unmarked_days_as_per_doj@example.com" ,
230+ date_of_joining = doj ,
231+ relieving_date = relieving_date ,
232+ company = "_Test Company" ,
232233 )
233234
234235 frappe .db .set_value ("Employee" , employee , "holiday_list" , self .holiday_list )
@@ -270,14 +271,14 @@ def test_duplicate_attendance_when_created_from_checkins_and_tool(self):
270271 self .assertEqual (len (attendances ), 1 )
271272
272273 def test_get_events_returns_attendance (self ):
273- employee = make_employee ( "calendar.user@example.com " , company = " _Test Company" )
274+ employee = frappe . get_doc ( "Employee " , { "first_name" : " _Test Employee" } )
274275
275- attendance_name = mark_attendance (employee , getdate (), status = "Present" )
276+ attendance_name = mark_attendance (employee . name , getdate (), status = "Present" )
276277 attendance = frappe .get_value ("Attendance" , attendance_name , "status" )
277278
278279 self .assertEqual (attendance , "Present" )
279280
280- frappe .set_user ("calendar.user@example.com" )
281+ frappe .set_user (employee . user_id )
281282 try :
282283 events = get_events (start = getdate (), end = getdate ())
283284 finally :
@@ -289,9 +290,6 @@ def test_get_events_returns_attendance(self):
289290 self .assertEqual (attendance_events [0 ].get ("status" ), "Present" )
290291 self .assertEqual (
291292 attendance_events [0 ].get ("employee_name" ),
292- frappe .db .get_value ("Employee" , employee , "employee_name" ),
293+ frappe .db .get_value ("Employee" , employee . name , "employee_name" ),
293294 )
294295 self .assertEqual (attendance_events [0 ].get ("attendance_date" ), getdate ())
295-
296- def tearDown (self ):
297- frappe .db .rollback ()
0 commit comments