Commit b8304ad7 authored by Łukasz Nowak's avatar Łukasz Nowak

- put document specific tests in document test


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45292 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 30d97aab
...@@ -3300,37 +3300,6 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor): ...@@ -3300,37 +3300,6 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
self.assertEquals( self.assertEquals(
99, skin_folder.getProperty('business_template_skin_layer_priority')) 99, skin_folder.getProperty('business_template_skin_layer_priority'))
def stepCreateDocument(self, sequence=None, **kw):
document_title = 'UnitTest'
document_data = """class UnitTest:
meta_type = 'ERP5 Unit Test'
portal_type = 'Unit Test'"""
cfg = getConfiguration()
file_path = os.path.join(cfg.instancehome, 'Document', document_title+'.py')
if os.path.exists(file_path):
os.remove(file_path)
f = file(file_path, 'w')
f.write(document_data)
f.close()
self.failUnless(os.path.exists(file_path))
sequence.edit(document_title=document_title, document_path=file_path,
document_data=document_data)
def stepAddDocumentToBusinessTemplate(self, sequence=None, **kw):
bt = sequence['current_bt']
bt.edit(template_document_id_list=[sequence['document_title']])
def stepRemoveDocument(self, sequence=None, **kw):
document_path = sequence['document_path']
os.remove(document_path)
self.failIf(os.path.exists(document_path))
def stepCheckDocumentExists(self, sequence=None, **kw):
self.failIf(not os.path.exists(sequence['document_path']))
def stepCheckDocumentRemoved(self, sequence=None, **kw):
self.failIf(os.path.exists(sequence['document_path']))
def stepCreateTest(self, sequence=None, **kw): def stepCreateTest(self, sequence=None, **kw):
test_title = 'UnitTest' test_title = 'UnitTest'
test_data = """class UnitTest: test_data = """class UnitTest:
...@@ -7048,53 +7017,159 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -7048,53 +7017,159 @@ class TestBusinessTemplate(BusinessTemplateMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def test_BusinessTemplateWithDocumentTestRemoved(self): class TestDocumentTemplateItem(BusinessTemplateMixin):
"""Checks that if Business Template defines Document and Test document_title = 'UnitTest'
Document is not removed""" document_data = """class UnitTest:
meta_type = 'ERP5 Unit Test'
portal_type = 'Unit Test'"""
document_data_updated = """class UnitTest:
meta_type = 'ERP5 Unit Test'
portal_type = 'Unit Test'
def updated(self):
pass"""
document_base_path = os.path.join(getConfiguration().instancehome, 'Document')
template_property = 'template_document_id_list'
def stepCreateDocument(self, sequence=None, **kw):
file_path = os.path.join(self.document_base_path, self.document_title+'.py')
if os.path.exists(file_path):
os.remove(file_path)
f = file(file_path, 'w')
f.write(self.document_data)
f.close()
self.failUnless(os.path.exists(file_path))
sequence.edit(document_title=self.document_title, document_path=file_path,
document_data=self.document_data)
def stepCreateUpdatedDocument(self, sequence=None, **kw):
file_path = os.path.join(self.document_base_path, self.document_title+'.py')
if os.path.exists(file_path):
os.remove(file_path)
f = file(file_path, 'w')
f.write(self.document_data_updated)
f.close()
self.failUnless(os.path.exists(file_path))
sequence.edit(document_title=self.document_title, document_path=file_path,
document_data_updated=self.document_data_updated)
def stepAddDocumentToBusinessTemplate(self, sequence=None, **kw):
bt = sequence['current_bt']
bt.edit(**{self.template_property: [sequence['document_title']]})
def stepRemoveDocument(self, sequence=None, **kw):
document_path = sequence['document_path']
os.remove(document_path)
self.failIf(os.path.exists(document_path))
def stepCheckDocumentExists(self, sequence=None, **kw):
self.failIf(not os.path.exists(sequence['document_path']))
self.assertEqual(file(sequence['document_path']).read(),
sequence['document_data'])
def stepCheckUpdatedDocumentExists(self, sequence=None, **kw):
self.failIf(not os.path.exists(sequence['document_path']))
self.assertEqual(file(sequence['document_path']).read(),
sequence['document_data_updated'])
def stepCheckDocumentRemoved(self, sequence=None, **kw):
self.failIf(os.path.exists(sequence['document_path']))
def test_BusinessTemplateWithDocument(self):
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = '\ sequence_string = '\
CreateDocument \ CreateDocument \
CreateTest \
CheckDocumentTestSameName \
CreateNewBusinessTemplate \ CreateNewBusinessTemplate \
UseExportBusinessTemplate \ UseExportBusinessTemplate \
AddDocumentToBusinessTemplate \ AddDocumentToBusinessTemplate \
AddTestToBusinessTemplate \
CheckModifiedBuildingState \ CheckModifiedBuildingState \
' + self.save_current_business_template_sequence_string + '\ CheckNotInstalledInstallationState \
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
RemoveDocument \ RemoveDocument \
RemoveTest \
RemoveBusinessTemplate \ RemoveBusinessTemplate \
RemoveAllTrashBins \ RemoveAllTrashBins \
ImportBusinessTemplate \ ImportBusinessTemplate \
UseImportBusinessTemplate \ UseImportBusinessTemplate \
CheckBuiltBuildingState \ CheckBuiltBuildingState \
CheckNotInstalledInstallationState \ CheckNotInstalledInstallationState \
InstallWithoutForceBusinessTemplate \ InstallBusinessTemplate \
Tic \ Tic \
CheckInstalledInstallationState \ CheckInstalledInstallationState \
CheckBuiltBuildingState \ CheckBuiltBuildingState \
CheckNoTrashBin \ CheckNoTrashBin \
CheckSkinsLayers \
CheckDocumentExists \ CheckDocumentExists \
CheckTestExists \ UninstallBusinessTemplate \
\ CheckBuiltBuildingState \
CopyBusinessTemplate \ CheckNotInstalledInstallationState \
Tic \ CheckDocumentRemoved \
\ '
RemoveTestFromBusinessTemplate \ sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_BusinessTemplateUpdateWithDocument(self):
sequence_list = SequenceList()
sequence_string = '\
CreateDocument \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddDocumentToBusinessTemplate \
CheckModifiedBuildingState \ CheckModifiedBuildingState \
' + self.save_current_business_template_sequence_string + '\ CheckNotInstalledInstallationState \
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
RemoveDocument \
RemoveBusinessTemplate \
RemoveAllTrashBins \
ImportBusinessTemplate \ ImportBusinessTemplate \
UseImportBusinessTemplate \ UseImportBusinessTemplate \
CheckBuiltBuildingState \ CheckBuiltBuildingState \
CheckNotInstalledInstallationState \ CheckNotInstalledInstallationState \
InstallWithoutForceBusinessTemplate \ InstallBusinessTemplate \
Tic \ Tic \
\
CheckInstalledInstallationState \ CheckInstalledInstallationState \
CheckBuiltBuildingState \ CheckBuiltBuildingState \
CheckTestRemoved \ CheckNoTrashBin \
CheckSkinsLayers \
CheckDocumentExists \ CheckDocumentExists \
RemoveDocument \
CreateUpdatedDocument \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddDocumentToBusinessTemplate \
CheckModifiedBuildingState \
CheckNotInstalledInstallationState \
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CreateDocument \
RemoveBusinessTemplate \
RemoveAllTrashBins \
ImportBusinessTemplate \
UseImportBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
InstallBusinessTemplate \
Tic \
CheckUpdatedDocumentExists \
UninstallBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckDocumentRemoved \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
...@@ -7161,120 +7236,66 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -7161,120 +7236,66 @@ class TestBusinessTemplate(BusinessTemplateMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
class TestDocumentTemplateItem(BusinessTemplateMixin): class TestConstraintTemplateItem(TestDocumentTemplateItem):
def test_BusinessTemplateWithDocument(self): def test(self):
raise NotImplemenetedError
class TestExtensionTemplateItem(TestDocumentTemplateItem):
def test(self):
raise NotImplemenetedError
class TestTestTemplateItem(TestDocumentTemplateItem):
def test_BusinessTemplateWithDocumentTestRemoved(self):
"""Checks that if Business Template defines Document and Test
Document is not removed"""
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = '\ sequence_string = '\
CreateDocument \ CreateDocument \
CreateTest \
CheckDocumentTestSameName \
CreateNewBusinessTemplate \ CreateNewBusinessTemplate \
UseExportBusinessTemplate \ UseExportBusinessTemplate \
AddDocumentToBusinessTemplate \ AddDocumentToBusinessTemplate \
AddTestToBusinessTemplate \
CheckModifiedBuildingState \ CheckModifiedBuildingState \
CheckNotInstalledInstallationState \ ' + self.save_current_business_template_sequence_string + '\
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
RemoveDocument \ RemoveDocument \
RemoveTest \
RemoveBusinessTemplate \ RemoveBusinessTemplate \
RemoveAllTrashBins \ RemoveAllTrashBins \
ImportBusinessTemplate \ ImportBusinessTemplate \
UseImportBusinessTemplate \ UseImportBusinessTemplate \
CheckBuiltBuildingState \ CheckBuiltBuildingState \
CheckNotInstalledInstallationState \ CheckNotInstalledInstallationState \
InstallBusinessTemplate \ InstallWithoutForceBusinessTemplate \
Tic \ Tic \
CheckInstalledInstallationState \ CheckInstalledInstallationState \
CheckBuiltBuildingState \ CheckBuiltBuildingState \
CheckNoTrashBin \ CheckNoTrashBin \
CheckSkinsLayers \
CheckDocumentExists \ CheckDocumentExists \
UninstallBusinessTemplate \ CheckTestExists \
CheckBuiltBuildingState \ \
CheckNotInstalledInstallationState \ CopyBusinessTemplate \
CheckDocumentRemoved \ Tic \
' \
sequence_list.addSequenceString(sequence_string) RemoveTestFromBusinessTemplate \
sequence_list.play(self)
def test_BusinessTemplateUpdateWithDocument(self):
sequence_list = SequenceList()
sequence_string = '\
CreateDocument \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddDocumentToBusinessTemplate \
CheckModifiedBuildingState \ CheckModifiedBuildingState \
CheckNotInstalledInstallationState \ ' + self.save_current_business_template_sequence_string + '\
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
RemoveDocument \
RemoveBusinessTemplate \
RemoveAllTrashBins \
ImportBusinessTemplate \ ImportBusinessTemplate \
UseImportBusinessTemplate \ UseImportBusinessTemplate \
CheckBuiltBuildingState \ CheckBuiltBuildingState \
CheckNotInstalledInstallationState \ CheckNotInstalledInstallationState \
InstallBusinessTemplate \ InstallWithoutForceBusinessTemplate \
Tic \ Tic \
\
CheckInstalledInstallationState \ CheckInstalledInstallationState \
CheckBuiltBuildingState \ CheckBuiltBuildingState \
CheckNoTrashBin \ CheckTestRemoved \
CheckSkinsLayers \
CheckDocumentExists \ CheckDocumentExists \
RemoveDocument \
CreateUpdatedDocument \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddDocumentToBusinessTemplate \
CheckModifiedBuildingState \
CheckNotInstalledInstallationState \
BuildBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
SaveBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CreateDocument \
RemoveBusinessTemplate \
RemoveAllTrashBins \
ImportBusinessTemplate \
UseImportBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
InstallBusinessTemplate \
Tic \
CheckUpdatedDocumentExists \
UninstallBusinessTemplate \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckDocumentRemoved \
CheckWorkflowChainRemoved \
' '
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
class TestConstraintTemplateItem(TestDocumentTemplateItem):
def test(self):
raise NotImplemenetedError
class TestExtensionTemplateItem(TestDocumentTemplateItem):
def test(self):
raise NotImplemenetedError
class TestTestTemplateItem(TestDocumentTemplateItem):
def test(self):
raise NotImplemenetedError
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestBusinessTemplate)) suite.addTest(unittest.makeSuite(TestBusinessTemplate))
......
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