Commit 3b58bad4 authored by Aurel's avatar Aurel

add test for constraints

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11679 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent eeb1ce9b
......@@ -1669,6 +1669,95 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
data = f.read()
self.assertEqual(data, ps_data)
# Test Constraint
def stepCreateConstraint(self, sequence=None, sequence_list=None, **kw):
"""
Create a Constraint
"""
ct_title = 'UnitTest'
ct_data = ' \nclass UnitTest: \n """ \n Fake constraint for unit test \n \
""" \n _properties = ( \n ) \n _categories = ( \n ) \n\n'
cfg = getConfiguration()
file_path = os.path.join(cfg.instancehome, 'Constraint', ct_title+'.py')
if os.path.exists(file_path):
os.remove(file_path)
f = file(file_path, 'w')
f.write(ct_data)
f.close()
self.failUnless(os.path.exists(file_path))
sequence.edit(ct_title=ct_title, ct_path=file_path, ct_data=ct_data)
def stepAddConstraintToBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
"""
Add Constraint to Business Template
"""
bt = sequence.get('current_bt', None)
self.failUnless(bt is not None)
ct_title = sequence.get('ct_title', None)
self.failUnless(ct_title is not None)
bt.edit(template_constraint_id_list=[ct_title])
def stepRemoveConstraint(self, sequence=None, sequencer_list=None, **kw):
"""
Remove Constraint
"""
ct_path = sequence.get('ct_path', None)
self.failUnless(ct_path is not None)
self.failUnless(os.path.exists(ct_path))
os.remove(ct_path)
self.failIf(os.path.exists(ct_path))
def stepCheckConstraintExists(self, sequence=None, sequencer_list=None, **kw):
"""
Check presence of Constraint
"""
ct_path = sequence.get('ct_path', None)
ct_data = sequence.get('ct_data', None)
self.failUnless(ct_path is not None)
self.failUnless(os.path.exists(ct_path))
# check data in property sheet
f = file(ct_path, 'r')
data = f.read()
self.assertEqual(data, ct_data)
def stepCheckConstraintRemoved(self, sequence=None, sequencer_list=None, **kw):
"""
Check presence of Constraint
"""
ct_path = sequence.get('ct_path', None)
self.failUnless(ct_path is not None)
self.failIf(os.path.exists(ct_path))
def stepCreateUpdatedConstraint(self, sequence=None, sequence_list=None, **kw):
"""
Create a Constraint
"""
ct_title = 'UnitTest'
ct_data = ' \nclass UnitTest2: \n """ \n Second Fake constraint for unit test \n \
""" \n _properties = ( \n ) \n _categories = ( \n ) \n\n'
cfg = getConfiguration()
file_path = os.path.join(cfg.instancehome, 'Constraint', ct_title+'.py')
if os.path.exists(file_path):
os.remove(file_path)
f = file(file_path, 'w')
f.write(ct_data)
f.close()
self.failUnless(os.path.exists(file_path))
sequence.edit(ct_data_u=ct_data)
def stepCheckUpdatedConstraintExists(self, sequence=None, sequencer_list=None, **kw):
"""
Check presence of Constraint
"""
ct_path = sequence.get('ct_path', None)
ct_data = sequence.get('ct_data_u', None)
self.failUnless(ct_path is not None)
self.failUnless(os.path.exists(ct_path))
# check data in property sheet
f = file(ct_path, 'r')
data = f.read()
self.assertEqual(data, ct_data)
# Busines templates
def stepImportBusinessTemplate(self, sequence=None, sequence_list=None, **kw):
"""
......@@ -2705,6 +2794,117 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def test_156_BusinessTemplateWithConstraint(self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
message = 'Test Business Template With Constraint'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList()
sequence_string = '\
CreateConstraint \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddConstraintToBusinessTemplate \
CheckModifiedBuildingState \
CheckNotInstalledInstallationState \
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
RemoveConstraint \
RemoveBusinessTemplate \
RemoveAllTrashBins \
ImportBusinessTemplate \
UseImportBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
InstallBusinessTemplate \
Tic \
CheckInstalledInstallationState \
CheckBuiltBuildingState \
CheckNoTrashBin \
CheckSkinsLayers \
CheckConstraintExists \
UninstallBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckConstraintRemoved \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def test_157_BusinessTemplateUpdateWithConstraint(self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
message = 'Test Business Template With Constraint'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList()
sequence_string = '\
CreateConstraint \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddConstraintToBusinessTemplate \
CheckModifiedBuildingState \
CheckNotInstalledInstallationState \
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
RemoveConstraint \
RemoveBusinessTemplate \
RemoveAllTrashBins \
ImportBusinessTemplate \
UseImportBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
InstallBusinessTemplate \
Tic \
CheckInstalledInstallationState \
CheckBuiltBuildingState \
CheckNoTrashBin \
CheckSkinsLayers \
CheckConstraintExists \
RemoveConstraint \
CreateUpdatedConstraint \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddConstraintToBusinessTemplate \
CheckModifiedBuildingState \
CheckNotInstalledInstallationState \
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CreateConstraint \
RemoveBusinessTemplate \
RemoveAllTrashBins \
ImportBusinessTemplate \
UseImportBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
InstallBusinessTemplate \
Tic \
CheckUpdatedConstraintExists \
UninstallBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckConstraintRemoved \
CheckWorkflowChainRemoved \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def test_16_BusinessTemplateWithAllItems(self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
......
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