Server IP : 127.0.0.2 / Your IP : 3.145.216.39 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/odoo/addons/hr_attendance/tests/ |
Upload File : |
# -*- coding: utf-8 -*- from odoo.tests.common import TransactionCase import time class TestHrAttendance(TransactionCase): """Tests for attendance date ranges validity""" def setUp(self): super(TestHrAttendance, self).setUp() self.attendance = self.env['hr.attendance'] self.test_employee = self.browse_ref('hr.employee_qdp') # demo data contains set up for self.test_employee def test_attendance_in_before_out(self): # Make sure check_out is before check_in with self.assertRaises(Exception): self.my_attend = self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 12:00'), 'check_out': time.strftime('%Y-%m-10 11:00'), }) def test_attendance_no_check_out(self): # Make sure no second attandance without check_out can be created self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 10:00'), }) with self.assertRaises(Exception): self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 11:00'), }) # 5 next tests : Make sure that when attendances overlap an error is raised def test_attendance_1(self): with self.assertRaises(Exception): self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 08:30'), 'check_out': time.strftime('%Y-%m-10 09:30'), }) def test_attendance_2(self): with self.assertRaises(Exception): self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 07:30'), 'check_out': time.strftime('%Y-%m-10 08:30'), }) def test_attendance_3(self): with self.assertRaises(Exception): self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 07:30'), 'check_out': time.strftime('%Y-%m-10 09:30'), }) def test_attendance_4(self): with self.assertRaises(Exception): self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 08:15'), 'check_out': time.strftime('%Y-%m-10 08:45'), }) def test_attendance_5(self): self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 10:00'), }) with self.assertRaises(Exception): self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 09:30'), 'check_out': time.strftime('%Y-%m-10 10:30'), }) def test_new_attendances(self): # Make sure attendance modification raises an error when it causes an overlap self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 11:00'), 'check_out': time.strftime('%Y-%m-10 12:00'), }) open_attendance = self.attendance.create({ 'employee_id': self.test_employee.id, 'check_in': time.strftime('%Y-%m-10 10:00'), }) with self.assertRaises(Exception): open_attendance.write({ 'check_out': time.strftime('%Y-%m-10 11:30'), })