Commit 36f719f0 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_hr_test: add position opportunity tests

parent 622e8567
......@@ -128,3 +128,87 @@ class testPosition(ERP5TypeTestCase):
pdf = position_application.getFollowUpRelatedValue(portal_type='PDF')
self.assertTrue('Resume/CV, Generated by Writer' in pdf.getDescription())
def test_positionOpportunityFastInput(self):
portal = self.getPortalObject()
if not portal.service_module.has_key('test_position_opportunity'):
portal.service_module.newContent(
portal_type='Service',
id='test_position_opportunity',
reference='test_position_opportunity',
title='test position opportunity')
service = portal.service_module.test_position_opportunity
if not portal.service_module.has_key('test_position_opportunity_2'):
portal.service_module.newContent(
portal_type='Service',
id='test_position_opportunity_2',
reference='test_position_opportunity_2',
title='test position opportunity 2')
service_2 = portal.service_module.test_position_opportunity_2
position_opportunity = portal.position_opportunity_module.newContent(portal_type='Position Opportunity')
position_requirement = position_opportunity.newContent(portal_type='Position Requirement')
for item in [position_opportunity, position_requirement]:
position_requirement_dict = item.PositionOpporunity_addFastInputLineList(
listbox=({'listbox_key': '1', 'price': 123, 'resource_relative_url': service.getRelativeUrl(), 'reference': service.getReference(), 'title': service.getTitle()},),
batch=1)
self.assertEqual(len(position_requirement_dict.keys()), 1)
self.assertTrue(service.getRelativeUrl() in position_requirement_dict)
position_requirement = position_requirement_dict[service.getRelativeUrl()]
self.assertEqual(position_requirement.getTitle(), service.getTitle())
self.assertEqual(position_requirement.getReference(), service.getReference())
self.assertEqual(position_requirement.getPrice(), 123)
# only one for same service
position_requirement_dict = item.PositionOpporunity_addFastInputLineList(
listbox=({'listbox_key': '1', 'price': 123, 'resource_relative_url': service.getRelativeUrl(), 'reference': service.getReference(), 'title': service.getTitle()},
{'listbox_key': '2', 'price': 456, 'resource_relative_url': service.getRelativeUrl(), 'reference': service.getReference(), 'title': service.getTitle()}),
batch=1)
self.assertEqual(len(position_requirement_dict.keys()), 1)
self.assertTrue(service.getRelativeUrl() in position_requirement_dict)
position_requirement = position_requirement_dict[service.getRelativeUrl()]
self.assertEqual(position_requirement.getTitle(), service.getTitle())
self.assertEqual(position_requirement.getReference(), service.getReference())
self.assertEqual(position_requirement.getPrice(), 123)
position_requirement_dict = item.PositionOpporunity_addFastInputLineList(
listbox=({'listbox_key': '1', 'price': 123, 'resource_relative_url': service.getRelativeUrl(), 'reference': service.getReference(), 'title': service.getTitle()},
{'listbox_key': '2', 'price': 123, 'resource_relative_url': service_2.getRelativeUrl(), 'reference': service_2.getReference(), 'title': service_2.getTitle()}),
batch=1)
self.assertEqual(len(position_requirement_dict.keys()), 2)
for i in [service, service_2]:
self.assertTrue(i.getRelativeUrl() in position_requirement_dict)
position_requirement = position_requirement_dict[i.getRelativeUrl()]
self.assertEqual(position_requirement.getTitle(), i.getTitle())
self.assertEqual(position_requirement.getReference(), i.getReference())
self.assertEqual(position_requirement.getPrice(), 123)
def test_positionOpportunityGetFastInputLine(self):
portal = self.getPortalObject()
position_opportunity = portal.position_opportunity_module.newContent(portal_type='Position Opportunity')
lines_num = 5
result_list = position_opportunity.PositionOpportunity_getFastInputLineList(lines_num)
self.assertEqual(len(result_list), lines_num)
portal.REQUEST.form['field_listbox_title_new_1']='service_1'
result_list = position_opportunity.PositionOpportunity_getFastInputLineList(lines_num)
self.assertEqual(len(result_list), lines_num+1)
self.assertEqual(result_list[0].resource_title, 'service_1')
def test_positionOpportunityUpdateFastInputLine(self):
portal = self.getPortalObject()
position_opportunity = portal.position_opportunity_module.newContent(portal_type='Position Opportunity')
if not portal.service_module.has_key('test_position_opportunity'):
portal.service_module.newContent(
portal_type='Service',
id='test_position_opportunity',
reference='test_position_opportunity',
title='test position opportunity')
service = portal.service_module.test_position_opportunity
listbox=({'listbox_key': '1', 'price': 123, 'resource_relative_url': '', 'reference': service.getReference(), 'title': service.getTitle()},)
output_listbox = position_opportunity.PositionOpporunity_updateFastInputLineList(listbox, batch=1)
listbox[0]['resource_relative_url'] = service.getReference()
self.assertEqual(output_listbox, listbox)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment