odoo/addons/hr_attendance/test/attendance_process.yml

100 lines
3.2 KiB
YAML

-
Create a user as 'HR Attendance Officer'
-
!record {model: res.users, id: res_users_attendance_officer, view: False}:
company_id: base.main_company
name: HR Officer
login: ao
-
I added groups for HR Attendance Officer.
-
!record {model: res.users, id: res_users_attendance_officer}:
groups_id:
- base.group_hr_user
-
Give the access rights of Hr Officer to test attendance process.
-
!context
uid: 'res_users_attendance_officer'
-
In order to test attendance process in OpenERP, I entry of SignIn of employee.
-
!python {model: hr.employee}: |
self.attendance_action_change(cr, uid, [ref("hr.employee_al")], context=context)
-
I check that Employee is "Present".
-
!assert {model: hr.employee, id: hr.employee_al, severity: error, string: Employee should be in present state}:
- state == 'present'
-
After few seconds, employee sign's out.
-
!python {model: hr.employee}: |
import time
time.sleep(2)
self.attendance_action_change(cr, uid, [ref("hr.employee_al")], context=context)
-
I check that Employee is "Absent".
-
!assert {model: hr.employee, id: hr.employee_al, severity: error, string: Employee should be in absent state}:
- state == 'absent'
-
In order to check that first attendance must be Sign In.
-
!python {model: hr.attendance}: |
import time
try:
self.create(cr, uid, {'employee_id': ref('hr.employee_niv'), 'name': time.strftime('%Y-%m-%d 09:59:25'), 'action': 'sign_out'}, None)
except Exception, e:
assert e[0]=='ValidateError', e
-
First of all, Employee Sign's In.
-
!record {model: hr.attendance, id: hr_attendance_0}:
employee_id: hr.employee_niv
name: !eval time.strftime('%Y-%m-%d 09:59:25')
action: 'sign_in'
-
Now Employee is going to Sign In prior to First Sign In.
-
!python {model: hr.attendance}: |
import time
try:
self.create(cr, uid, {'employee_id': ref('hr.employee_niv'), 'name': time.strftime('%Y-%m-%d 08:59:25'), 'action': 'sign_in'}, None)
except Exception, e:
assert e[0]=='ValidateError', e
-
After that Employee is going to Sign In after First Sign In.
-
!python {model: hr.attendance}: |
import time
try:
self.create(cr, uid, {'employee_id': ref('hr.employee_niv'), 'name': time.strftime('%Y-%m-%d 10:59:25'), 'action': 'sign_in'}, None)
except Exception, e:
assert e[0]=='ValidateError', e
-
After two hours, Employee Sign's Out.
-
!record {model: hr.attendance, id: hr_attendance_1}:
employee_id: hr.employee_niv
name: !eval time.strftime('%Y-%m-%d 11:59:25')
action: 'sign_out'
-
Now Employee is going to Sign Out prior to First Sign Out.
-
!python {model: hr.attendance}: |
import time
try:
self.create(cr, uid, {'employee_id': ref('hr.employee_niv'), 'name': time.strftime('%Y-%m-%d 10:59:25'), 'action': 'sign_out'}, None)
except Exception, e:
assert e[0]=='ValidateError', e
-
After that Employee is going to Sign Out After First Sign Out.
-
!python {model: hr.attendance}: |
import time
try:
self.create(cr, uid, {'employee_id': ref('hr.employee_niv'), 'name': time.strftime('%Y-%m-%d 12:59:25'), 'action': 'sign_out'}, None)
except Exception, e:
assert e[0]=='ValidateError', e