[IMP] hr_recruitment: Convert yml into python test case

This commit is contained in:
Axay Javiya
2017-06-13 15:38:50 +02:00
committed by Yannick Tivisse
parent 2e6c675dd6
commit 4fe90a4fb4
5 changed files with 46 additions and 50 deletions
-1
View File
@@ -38,7 +38,6 @@ You can define the different phases of interviews and easily rate the applicant
'demo': [
'data/hr_recruitment_demo.xml',
],
'test': ['test/recruitment_process.yml'],
'installable': True,
'auto_install': False,
'application': True,
@@ -1,49 +0,0 @@
-
Create a user as 'HR Recruitment Officer'
-
!record {model: res.users, id: res_users_hr_recruitment_officer, view: False}:
company_id: base.main_company
name: HR Recruitment Officer
login: hrro
email: hrofcr@yourcompany.com
-
I added groups for HR Recruitment Officer.
-
!record {model: res.users, id: res_users_hr_recruitment_officer}:
groups_id:
- hr_recruitment.group_hr_recruitment_user
-
In Order to test process of Recruitment so giving HR officer's rights,
-
!context
uid: 'res_users_hr_recruitment_officer'
-
An applicant is interested in the job position. So he sends a resume by email.
-
!python {model: mail.thread, id: False}: |
import odoo
request_file = open(odoo.modules.module.get_module_resource('hr_recruitment','test', 'resume.eml'),'rb')
job_id = self.env.ref('hr.job_developer').id
request_message = request_file.read()
self.message_process('hr.applicant', request_message, custom_values={"job_id": job_id})
-
After getting the mail, I check the details of the new applicant.
-
!python {model: hr.applicant, id: False}: |
applicant = self.search([('email_from','=', 'Mr. Richard Anderson <Richard_Anderson@yahoo.com>')], limit=1)
assert applicant, "Applicant is not created after getting the mail"
resume_ids = self.env['ir.attachment'].search([('datas_fname','=','resume.pdf'),('res_model','=',self._name),('res_id','=',applicant.id)])
assert applicant.name == "Application for the post of Jr.application Programmer.", "Applicant name does not match."
assert applicant.stage_id.id == ref('hr_recruitment.stage_job1'), "Stage should be 'Initial qualification' and is '%s'." % (applicant.stage_id.name)
assert applicant.stage_id.sequence == 1, "Applicant stage sequence should be 1."
assert len(resume_ids), "Resume is not attached."
-
I assign the Job position to the applicant
-
!python {model: hr.applicant, id: hr_case_programmer}: |
self.write({'job_id':ref('hr.job_developer')})
-
I schedule meeting with applicant for interview.
-
!python {model: hr.applicant, id: hr_case_programmer}: |
self.action_makeMeeting()
+1
View File
@@ -0,0 +1 @@
from . import test_recruitment_process
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import common
from odoo.modules.module import get_module_resource
class TestRecruitmentProcess(common.TransactionCase):
def test_00_recruitment_process(self):
""" Test recruitment process """
# Create a new HR Recruitment Officer
self.res_users_hr_recruitment_officer = self.env['res.users'].create({
'company_id': self.env.ref('base.main_company').id,
'name': 'HR Recruitment Officer',
'login': "hrro",
'email': "hrofcr@yourcompany.com",
'groups_id': [(6, 0, [self.env.ref('hr_recruitment.group_hr_recruitment_user').id])]
})
# An applicant is interested in the job position. So he sends a resume by email.
# In Order to test process of Recruitment so giving HR officer's rights
with open(get_module_resource('hr_recruitment', 'tests', 'resume.eml'), 'rb') as request_file:
request_message = request_file.read()
self.env['mail.thread'].sudo(self.res_users_hr_recruitment_officer.id).message_process(
'hr.applicant', request_message, custom_values={"job_id": self.env.ref('hr.job_developer').id})
# After getting the mail, I check the details of the new applicant.
applicant = self.env['hr.applicant'].search([('email_from', '=', 'Mr. Richard Anderson <Richard_Anderson@yahoo.com>')], limit=1)
self.assertTrue(applicant, "Applicant is not created after getting the mail")
resume_ids = self.env['ir.attachment'].search([
('datas_fname', '=', 'resume.pdf'),
('res_model', '=', self.env['hr.applicant']._name),
('res_id', '=', applicant.id)])
self.assertEquals(applicant.name, 'Application for the post of Jr.application Programmer.', 'Applicant name does not match.')
self.assertEquals(applicant.stage_id, self.env.ref('hr_recruitment.stage_job1'),
"Stage should be 'Initial qualification' and is '%s'." % (applicant.stage_id.name))
self.assertTrue(resume_ids, 'Resume is not attached.')
# I assign the Job position to the applicant
applicant.write({'job_id': self.env.ref('hr.job_developer').id})
# I schedule meeting with applicant for interview.
applicant_meeting = applicant.action_makeMeeting()
self.assertEquals(applicant_meeting['context']['default_name'], 'Application for the post of Jr.application Programmer.',
'Applicant name does not match.')