Commit a4cb237e authored by Fabien Morin's avatar Fabien Morin

change the copy subobject test to use it on a paysheet, not on a model


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18324 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fe193247
...@@ -968,7 +968,9 @@ class TestPayroll(TestPayrollMixin): ...@@ -968,7 +968,9 @@ class TestPayroll(TestPayrollMixin):
# that's make 11 ! # that's make 11 !
# check the model number # check the model number
self.assertEqual(len(model_reference_dict), 6) self.assertEqual(len(model_reference_dict), 5) # (6-1 because model_b
# haven't any subobject not
# yet added)
self.assertEqual(model_reference_dict[model_employee.getRelativeUrl()], self.assertEqual(model_reference_dict[model_employee.getRelativeUrl()],
['1', 'over_time_duration']) ['1', 'over_time_duration'])
self.assertEqual(model_reference_dict[model_company.getRelativeUrl()], self.assertEqual(model_reference_dict[model_company.getRelativeUrl()],
...@@ -976,25 +978,44 @@ class TestPayroll(TestPayrollMixin): ...@@ -976,25 +978,44 @@ class TestPayroll(TestPayrollMixin):
self.assertEqual(model_reference_dict[model_a.getRelativeUrl()], ['5',]) self.assertEqual(model_reference_dict[model_a.getRelativeUrl()], ['5',])
self.assertEqual(model_reference_dict[model_c.getRelativeUrl()], self.assertEqual(model_reference_dict[model_c.getRelativeUrl()],
['6', '7', '8']) ['6', '7', '8'])
self.assertEqual(model_reference_dict[model_b.getRelativeUrl()], [])
self.assertEqual(model_reference_dict[model_country.getRelativeUrl()], self.assertEqual(model_reference_dict[model_country.getRelativeUrl()],
['3','4', 'social_insurance']) ['3','4', 'social_insurance'])
# copy sub object from all inhéritance models into the base model # copy sub object from all inhéritance models into the a paysheet
nb_subobject_before = len(model_employee.contentValues(\
portal_type=portal_type_list))
model_employee.copyInheritanceSubObjects(model_reference_dict)
nb_subobject_after = len(model_employee.contentValues(\
portal_type=portal_type_list))
# check there are all here: # create a paysheet
nb_added_sub_objects = nb_subobject_after - nb_subobject_before id = 'inheritance_paysheet'
paysheet_module = self.portal.getDefaultModule(\
portal_type=self.paysheet_transaction_portal_type)
if hasattr(paysheet_module, id):
paysheet_module.manage_delObjects([id])
paysheet = paysheet_module.newContent(\
portal_type = self.paysheet_transaction_portal_type,
id = id,
title = id,
specialise_value = model_employee)
# inherite model
#paysheet.setSpecialiseValue(model_employee)
# check heneritance works
self.assertEqual(paysheet.getSpecialiseValue(), model_employee)
# copy sub objects
nb_subobject_before = len(paysheet.contentValues(\
portal_type=portal_type_list))
paysheet.copyInheritanceSubObjects(model_reference_dict)
get_transaction().commit() get_transaction().commit()
self.paysheet_model_module.reindexObject() self.paysheet_model_module.reindexObject()
self.tic() self.tic()
nb_subobject_after = len(paysheet.contentValues(\
portal_type=portal_type_list))
# check there are all here:
nb_added_sub_objects = nb_subobject_after - nb_subobject_before
self.assertEqual(nb_added_sub_objects, 11) self.assertEqual(nb_added_sub_objects, 11)
import unittest import unittest
...@@ -1002,4 +1023,3 @@ def test_suite(): ...@@ -1002,4 +1023,3 @@ def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPayroll)) suite.addTest(unittest.makeSuite(TestPayroll))
return suite return suite
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