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

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Mar 29 16:57:19 CEST 2011


Author: luke
Date: Tue Mar 29 16:57:19 2011
New Revision: 44733

URL: http://svn.erp5.org?rev=44733&view=rev
Log:
 - add a test to cover lack of casting to int while comparing revision of Business Templates

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=44733&r1=44732&r2=44733&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testBusinessTemplate.py [utf8] Tue Mar 29 16:57:19 2011
@@ -5825,6 +5825,48 @@ class TestBusinessTemplate(ERP5TypeTestC
     self.assertEquals(bt.getChangeLog(), 'MODIFIED')
     self.assertEquals(portal.getTitle(), 'MODIFIED')
 
+  def test_updateBusinessTemplateFromUrl_stringCastingBug(self):
+    pt = self.getTemplateTool()
+    template = pt.newContent(portal_type='Business Template')
+    self.failUnless(template.getBuildingState() == 'draft')
+    self.failUnless(template.getInstallationState() == 'not_installed')
+    title = 'install_casting_to_int_bug_check'
+    template.edit(title=title,
+                  version='1.0',
+                  description='bt for unit_test')
+    transaction.commit()
+
+    template.build()
+    transaction.commit()
+
+    cfg = getConfiguration()
+    template_path = os.path.join(cfg.instancehome, 'tests', '%s' % (title,))
+    # remove previous version of bt it exists
+    if os.path.exists(template_path):
+      shutil.rmtree(template_path)
+    template.export(path=template_path, local=1)
+    self.failUnless(os.path.exists(template_path))
+
+    # setup version '9'
+    first_revision = '9'
+    open(os.path.join(template_path, 'bt', 'revision'), 'w').write(first_revision)
+    pt.updateBusinessTemplateFromUrl(template_path)
+    new_bt = pt.getInstalledBusinessTemplate(title)
+    
+    self.assertEqual(new_bt.getRevision(), first_revision)
+
+    # setup revision '11', becasue: '11' < '9' (string comp), but 11 > 9 (int comp)
+    second_revision = '11'
+    self.assertTrue(second_revision < first_revision)
+    self.assertTrue(int(second_revision) > int(first_revision))
+
+    open(os.path.join(template_path, 'bt', 'revision'), 'w').write(second_revision)
+    pt.updateBusinessTemplateFromUrl(template_path)
+    newer_bt = pt.getInstalledBusinessTemplate(title)
+
+    self.assertNotEqual(new_bt, newer_bt)
+    self.assertEqual(newer_bt.getRevision(), second_revision)
+
   def stepCreateCustomWorkflow(self, sequence=None, sequence_list=None, **kw):
     """
     Create a custom workflow



More information about the Erp5-report mailing list