Commit 7162af93 authored by Romain Courteaud's avatar Romain Courteaud

Added test for Setter.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3752 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9b3385d2
...@@ -101,12 +101,17 @@ class TestBase(ERP5TypeTestCase): ...@@ -101,12 +101,17 @@ class TestBase(ERP5TypeTestCase):
Light install create only base categories, so we create Light install create only base categories, so we create
some categories for testing them some categories for testing them
""" """
pass category_list = ['testGroup1', 'testGroup2']
if len(self.category_tool.group.contentValues()) == 0 :
for category_id in category_list:
o = self.category_tool.group.newContent(portal_type='Category',
id=category_id)
def stepTic(self,**kw): def stepTic(self,**kw):
self.tic() self.tic()
def stepRemoveWorkflowsRelated(self, sequence=None, sequence_list=None, **kw): def stepRemoveWorkflowsRelated(self, sequence=None, sequence_list=None,
**kw):
""" """
Remove workflow related to the portal type Remove workflow related to the portal type
""" """
...@@ -131,7 +136,8 @@ class TestBase(ERP5TypeTestCase): ...@@ -131,7 +136,8 @@ class TestBase(ERP5TypeTestCase):
object = module.newContent(portal_type=self.object_portal_type) object = module.newContent(portal_type=self.object_portal_type)
sequence.edit( sequence.edit(
object=object, object=object,
current_title='' current_title='',
current_group_value=None
) )
def stepCheckTitleValue(self, sequence=None, sequence_list=None, **kw): def stepCheckTitleValue(self, sequence=None, sequence_list=None, **kw):
...@@ -142,8 +148,8 @@ class TestBase(ERP5TypeTestCase): ...@@ -142,8 +148,8 @@ class TestBase(ERP5TypeTestCase):
current_title = sequence.get('current_title') current_title = sequence.get('current_title')
self.assertEquals(object.getTitle(), current_title) self.assertEquals(object.getTitle(), current_title)
def stepSetDifferentTitleValue(self, sequence=None, sequence_list=None, def stepSetDifferentTitleValueWithEdit(self, sequence=None,
**kw): sequence_list=None, **kw):
""" """
Set a different title value Set a different title value
""" """
...@@ -172,7 +178,8 @@ class TestBase(ERP5TypeTestCase): ...@@ -172,7 +178,8 @@ class TestBase(ERP5TypeTestCase):
self.failUnless(method_id in ["immediateReindexObject", self.failUnless(method_id in ["immediateReindexObject",
"recursiveImmediateReindexObject"]) "recursiveImmediateReindexObject"])
def stepSetSameTitleValue(self, sequence=None, sequence_list=None, **kw): def stepSetSameTitleValueWithEdit(self, sequence=None, sequence_list=None,
**kw):
""" """
Set a different title value Set a different title value
""" """
...@@ -188,8 +195,8 @@ class TestBase(ERP5TypeTestCase): ...@@ -188,8 +195,8 @@ class TestBase(ERP5TypeTestCase):
message_list = portal.portal_activities.getMessageList() message_list = portal.portal_activities.getMessageList()
self.assertEquals(len(message_list), 0) self.assertEquals(len(message_list), 0)
def test_01_areActivitiesWellLaunchedBySetter(self, quiet=0, def test_01_areActivitiesWellLaunchedByPropertyEdit(self, quiet=0,
run=run_all_test): run=run_all_test):
""" """
Test if setter does not call a activity if the attribute Test if setter does not call a activity if the attribute
value is not changed. value is not changed.
...@@ -200,15 +207,16 @@ class TestBase(ERP5TypeTestCase): ...@@ -200,15 +207,16 @@ class TestBase(ERP5TypeTestCase):
sequence_string = '\ sequence_string = '\
RemoveWorkflowsRelated \ RemoveWorkflowsRelated \
CreateObject \ CreateObject \
Tic \
CheckTitleValue \ CheckTitleValue \
SetDifferentTitleValue \ SetDifferentTitleValueWithEdit \
CheckIfActivitiesAreCreated \ CheckIfActivitiesAreCreated \
CheckTitleValue \ CheckTitleValue \
Tic \ Tic \
CheckIfMessageQueueIsEmpty \ CheckIfMessageQueueIsEmpty \
SetSameTitleValue \ SetSameTitleValueWithEdit \
CheckIfMessageQueueIsEmpty \ CheckIfMessageQueueIsEmpty \
SetDifferentTitleValue \ SetDifferentTitleValueWithEdit \
CheckIfActivitiesAreCreated \ CheckIfActivitiesAreCreated \
CheckTitleValue \ CheckTitleValue \
Tic \ Tic \
...@@ -219,15 +227,16 @@ class TestBase(ERP5TypeTestCase): ...@@ -219,15 +227,16 @@ class TestBase(ERP5TypeTestCase):
sequence_string = '\ sequence_string = '\
AssociateWorkflows \ AssociateWorkflows \
CreateObject \ CreateObject \
Tic \
CheckTitleValue \ CheckTitleValue \
SetDifferentTitleValue \ SetDifferentTitleValueWithEdit \
CheckIfActivitiesAreCreated \ CheckIfActivitiesAreCreated \
CheckTitleValue \ CheckTitleValue \
Tic \ Tic \
CheckIfMessageQueueIsEmpty \ CheckIfMessageQueueIsEmpty \
SetSameTitleValue \ SetSameTitleValueWithEdit \
CheckIfMessageQueueIsEmpty \ CheckIfMessageQueueIsEmpty \
SetDifferentTitleValue \ SetDifferentTitleValueWithEdit \
CheckIfActivitiesAreCreated \ CheckIfActivitiesAreCreated \
CheckTitleValue \ CheckTitleValue \
Tic \ Tic \
...@@ -236,6 +245,242 @@ class TestBase(ERP5TypeTestCase): ...@@ -236,6 +245,242 @@ class TestBase(ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepCheckGroupValue(self, sequence=None, sequence_list=None, **kw):
"""
Check if getTitle return a correect value
"""
object = sequence.get('object')
current_group_value = sequence.get('current_group_value')
self.assertEquals(object.getGroupValue(), current_group_value)
def stepSetDifferentGroupValueWithEdit(self, sequence=None,
sequence_list=None, **kw):
"""
Set a different title value
"""
object = sequence.get('object')
current_group_value = sequence.get('current_group_value')
group1 = object.portal_categories.restrictedTraverse('group/testGroup1')
group2 = object.portal_categories.restrictedTraverse('group/testGroup2')
if (current_group_value is None) or \
(current_group_value == group2) :
new_group_value = group1
else:
new_group_value = group2
# new_group_value = '%s_a' % current_title
object.edit(group_value=new_group_value)
sequence.edit(
current_group_value=new_group_value
)
def stepSetSameGroupValueWithEdit(self, sequence=None, sequence_list=None,
**kw):
"""
Set a different title value
"""
object = sequence.get('object')
object.edit(group_value=object.getGroupValue())
def test_02_areActivitiesWellLaunchedByCategoryEdit(self, quiet=0,
run=run_all_test):
"""
Test if setter does not call a activity if the attribute
value is not changed.
"""
if not run: return
sequence_list = SequenceList()
# Test without workflows associated to the portal type
sequence_string = '\
RemoveWorkflowsRelated \
CreateObject \
Tic \
CheckGroupValue \
SetDifferentGroupValueWithEdit \
CheckIfActivitiesAreCreated \
CheckGroupValue \
Tic \
CheckIfMessageQueueIsEmpty \
SetSameGroupValueWithEdit \
CheckIfMessageQueueIsEmpty \
SetDifferentGroupValueWithEdit \
CheckIfActivitiesAreCreated \
CheckGroupValue \
Tic \
CheckIfMessageQueueIsEmpty \
'
sequence_list.addSequenceString(sequence_string)
# Test with workflows associated to the portal type
sequence_string = '\
AssociateWorkflows \
CreateObject \
Tic \
CheckGroupValue \
SetDifferentGroupValueWithEdit \
CheckIfActivitiesAreCreated \
CheckGroupValue \
Tic \
CheckIfMessageQueueIsEmpty \
SetSameGroupValueWithEdit \
CheckIfMessageQueueIsEmpty \
SetDifferentGroupValueWithEdit \
CheckIfActivitiesAreCreated \
CheckGroupValue \
Tic \
CheckIfMessageQueueIsEmpty \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepSetDifferentTitleValueWithSetter(self, sequence=None,
sequence_list=None, **kw):
"""
Set a different title value
"""
object = sequence.get('object')
current_title = sequence.get('current_title')
new_title_value = '%s_a' % current_title
object.setTitle(new_title_value)
sequence.edit(
current_title=new_title_value
)
def stepSetSameTitleValueWithSetter(self, sequence=None,
sequence_list=None, **kw):
"""
Set a different title value
"""
object = sequence.get('object')
object.setTitle(object.getTitle())
def test_03_areActivitiesWellLaunchedByPropertySetter(self, quiet=0,
run=run_all_test):
"""
Test if setter does not call a activity if the attribute
value is not changed.
"""
if not run: return
sequence_list = SequenceList()
# Test without workflows associated to the portal type
sequence_string = '\
RemoveWorkflowsRelated \
CreateObject \
Tic \
CheckTitleValue \
SetDifferentTitleValueWithSetter \
CheckIfActivitiesAreCreated \
CheckTitleValue \
Tic \
CheckIfMessageQueueIsEmpty \
SetSameTitleValueWithSetter \
CheckIfMessageQueueIsEmpty \
SetDifferentTitleValueWithSetter \
CheckIfActivitiesAreCreated \
CheckTitleValue \
Tic \
CheckIfMessageQueueIsEmpty \
'
sequence_list.addSequenceString(sequence_string)
# Test with workflows associated to the portal type
sequence_string = '\
AssociateWorkflows \
CreateObject \
Tic \
CheckTitleValue \
SetDifferentTitleValueWithSetter \
CheckIfActivitiesAreCreated \
CheckTitleValue \
Tic \
CheckIfMessageQueueIsEmpty \
SetSameTitleValueWithSetter \
CheckIfMessageQueueIsEmpty \
SetDifferentTitleValueWithSetter \
CheckIfActivitiesAreCreated \
CheckTitleValue \
Tic \
CheckIfMessageQueueIsEmpty \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def stepSetDifferentGroupValueWithSetter(self, sequence=None,
sequence_list=None, **kw):
"""
Set a different title value
"""
object = sequence.get('object')
current_group_value = sequence.get('current_group_value')
group1 = object.portal_categories.restrictedTraverse('group/testGroup1')
group2 = object.portal_categories.restrictedTraverse('group/testGroup2')
if (current_group_value is None) or \
(current_group_value == group2) :
new_group_value = group1
else:
new_group_value = group2
# new_group_value = '%s_a' % current_title
object.setGroupValue(new_group_value)
sequence.edit(
current_group_value=new_group_value
)
def stepSetSameGroupValueWithSetter(self, sequence=None,
sequence_list=None, **kw):
"""
Set a different title value
"""
object = sequence.get('object')
object.setGroupValue(object.getGroupValue())
def test_04_areActivitiesWellLaunchedByCategorySetter(self, quiet=0,
run=run_all_test):
"""
Test if setter does not call a activity if the attribute
value is not changed.
"""
if not run: return
sequence_list = SequenceList()
# Test without workflows associated to the portal type
sequence_string = '\
RemoveWorkflowsRelated \
CreateObject \
Tic \
CheckGroupValue \
SetDifferentGroupValueWithSetter \
CheckIfActivitiesAreCreated \
CheckGroupValue \
Tic \
CheckIfMessageQueueIsEmpty \
SetSameGroupValueWithSetter \
CheckIfMessageQueueIsEmpty \
SetDifferentGroupValueWithSetter \
CheckIfActivitiesAreCreated \
CheckGroupValue \
Tic \
CheckIfMessageQueueIsEmpty \
'
sequence_list.addSequenceString(sequence_string)
# Test with workflows associated to the portal type
sequence_string = '\
AssociateWorkflows \
CreateObject \
Tic \
CheckGroupValue \
SetDifferentGroupValueWithSetter \
CheckIfActivitiesAreCreated \
CheckGroupValue \
Tic \
CheckIfMessageQueueIsEmpty \
SetSameGroupValueWithSetter \
CheckIfMessageQueueIsEmpty \
SetDifferentGroupValueWithSetter \
CheckIfActivitiesAreCreated \
CheckGroupValue \
Tic \
CheckIfMessageQueueIsEmpty \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
if __name__ == '__main__': if __name__ == '__main__':
framework() framework()
else: else:
......
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