[Erp5-report] r11679 - /erp5/trunk/products/ERP5/tests/testBusinessTemplate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Dec 12 11:32:28 CET 2006


Author: aurel
Date: Tue Dec 12 11:32:24 2006
New Revision: 11679

URL: http://svn.erp5.org?rev=11679&view=rev
Log:
add test for constraints

Modified:
    erp5/trunk/products/ERP5/tests/testBusinessTemplate.py

Modified: erp5/trunk/products/ERP5/tests/testBusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testBusinessTemplate.py?rev=11679&r1=11678&r2=11679&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBusinessTemplate.py (original)
+++ erp5/trunk/products/ERP5/tests/testBusinessTemplate.py Tue Dec 12 11:32:24 2006
@@ -1669,6 +1669,95 @@
     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):
     """
@@ -2700,6 +2789,117 @@
                        CheckBuiltBuildingState \
                        CheckNotInstalledInstallationState \
                        CheckPropertySheetRemoved \
+                       CheckWorkflowChainRemoved \
+                       '
+    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)




More information about the Erp5-report mailing list