Commit 2043baea authored by Nicolas Wavrant's avatar Nicolas Wavrant

testTask: new test to check that simulation inheritance can overwrite default...

testTask: new test to check that simulation inheritance can overwrite default ledgers set on portal type
parent 6c960e56
...@@ -540,6 +540,40 @@ class TestTaskMixin: ...@@ -540,6 +540,40 @@ class TestTaskMixin:
self.assertEqual(task.contentValues()[0].getRequirement(), self.assertEqual(task.contentValues()[0].getRequirement(),
task_report_line.getRequirement()) task_report_line.getRequirement())
def stepSetUpLedgerCategory(self, sequence=None, sequence_list=None, **kw):
ledger = self.portal.portal_categories.ledger
if not ledger.get('favourite_ledger', None):
ledger.newContent(portal_type='Category', id='favourite_ledger')
if not ledger.get('default_task_report_ledger', None):
ledger.newContent(portal_type='Category',
id='default_task_report_ledger')
def stepSetDifferentDefaultLedgerForTaskandTaskReport(self, sequence=None,
sequence_list=None, **kw):
task_portal_type = self.portal.portal_types['Task']
task_report_portal_type = self.portal.portal_types['Task Report']
task_portal_type.edit(ledger='favourite_ledger')
task_report_portal_type.edit(ledger=['default_task_report_ledger',
'favourite_ledger'])
def stepCheckTaskReportLedgerIsSameAsTaskLedger(self, sequence=None,
sequence_list=None, **kw):
task = sequence.get('task')
task_report = sequence.get('task_report')
self.assertTrue(task.hasLedger())
self.assertTrue(task_report.hasLedger())
self.assertEqual(task.getLedger(), task_report.getLedger())
def stepCheckTaskReportLedgerIsDifferentFromItsDefaultLedger(self,
sequence=None, sequence_list=None, **kw):
task_report = sequence.get('task_report')
task_report_portal_type = self.portal.portal_types['Task Report']
self.assertNotEqual(task_report.getLedger(),
task_report_portal_type.getDefaultLedger())
class TestTask(TestTaskMixin, ERP5TypeTestCase): class TestTask(TestTaskMixin, ERP5TypeTestCase):
""" """
Test task behaviour. Test task behaviour.
...@@ -568,6 +602,11 @@ class TestTask(TestTaskMixin, ERP5TypeTestCase): ...@@ -568,6 +602,11 @@ class TestTask(TestTaskMixin, ERP5TypeTestCase):
""" """
return 1 return 1
def beforeTearDown(self):
# Removes default ledger on portal types if they exist
self.portal.portal_types['Task'].setLedger(None)
self.portal.portal_types['Task Report'].setLedger(None)
def test_01_testTaskBasicUseCase(self, quiet=0, run=run_all_test): def test_01_testTaskBasicUseCase(self, quiet=0, run=run_all_test):
""" """
Test creation of task and (automatic) task_report Test creation of task and (automatic) task_report
...@@ -787,6 +826,29 @@ class TestTask(TestTaskMixin, ERP5TypeTestCase): ...@@ -787,6 +826,29 @@ class TestTask(TestTaskMixin, ERP5TypeTestCase):
' priority=method_id!="_localBuild"') ' priority=method_id!="_localBuild"')
sequence("Tic SetTaskReport") sequence("Tic SetTaskReport")
def test_09_testTaskLedgerIsInheritedByTaskReport(self, quiet=0, run=run_all_test):
"""
Test that a task and its related task report generated by simulation have
the same ledger, even if the ledger set on the task is not the same as the
default one set on the "Task Report" portal type.
"""
if not run: return
sequence_list = SequenceList()
sequence_string = """
SetUpLedgerCategory
SetDifferentDefaultLedgerForTaskandTaskReport
"""
sequence_string += self.default_task_sequence
sequence_string += """
CheckTaskReportLedgerIsSameAsTaskLedger
CheckTaskReportLedgerIsDifferentFromItsDefaultLedger
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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