[Erp5-report] r43437 kazuhiko - in /erp5/trunk/products: ERP5/Document/ ERP5Type/tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Feb 17 16:34:38 CET 2011


Author: kazuhiko
Date: Thu Feb 17 16:34:38 2011
New Revision: 43437

URL: http://svn.erp5.org?rev=43437&view=rev
Log:
display a more useful message in case of missing dependencies.

Modified:
    erp5/trunk/products/ERP5/Document/BusinessTemplate.py
    erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py

Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=43437&r1=43436&r2=43437&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Thu Feb 17 16:34:38 2011
@@ -5230,9 +5230,17 @@ Business Template is a set of definition
        are installed. Raise an exception with the list of
        missing dependencies if some are missing
       """
+      missing_dep_list = self.getMissingDependencyList()
+      if len(missing_dep_list) != 0:
+        raise BusinessTemplateMissingDependency, 'Impossible to install, please install the following dependencies before: %s'%repr(missing_dep_list)
+
+    def getMissingDependencyList(self):
+      """
+      Retuns a list of missing dependencies.
+      """
       missing_dep_list = []
       dependency_list = self.getDependencyList()
-      if len(dependency_list)!=0:
+      if len(dependency_list) > 0:
         for dependency_couple in dependency_list:
           dependency_couple_list = dependency_couple.strip().split(' ', 1)
           dependency = dependency_couple_list[0]
@@ -5250,8 +5258,7 @@ Business Template is a set of definition
                   or (version_restriction not in (None, '') and
                      (not self.portal_templates.compareVersionStrings(installed_bt.getVersion(), version_restriction)))):
             missing_dep_list.append((dependency, version_restriction or ''))
-      if len(missing_dep_list) != 0:
-        raise BusinessTemplateMissingDependency, 'Impossible to install, please install the following dependencies before: %s'%repr(missing_dep_list)
+      return [' '.join([y for y in x if y]) for x in missing_dep_list]
 
     def diffObjectAsHTML(self, REQUEST, **kw):
       """

Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py?rev=43437&r1=43436&r2=43437&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] Thu Feb 17 16:34:38 2011
@@ -74,7 +74,6 @@ from zLOG import LOG, DEBUG
 
 from Products.ERP5Type.tests.backportUnittest import SetupSiteError
 from Products.ERP5Type.tests.utils import DummyMailHostMixin, parseListeningAddress
-from Products.ERP5.Document.BusinessTemplate import BusinessTemplateMissingDependency
 
 # Quiet messages when installing products
 install_product_quiet = 1
@@ -897,10 +896,9 @@ class ERP5TypeCommandLineTestCase(ERP5Ty
           ZopeTestCase._print('(imported in %.3fs) ' % (time.time() - start))
           # For unit test, we accept installing business templates with
           # missing a part of dependencies.
-          try:
-            bt.checkDependencies()
-          except BusinessTemplateMissingDependency:
-            ZopeTestCase._print('(some dependencies are missing) ')
+          missing_dep_list = bt.getMissingDependencyList()
+          if len(missing_dep_list) > 0:
+            ZopeTestCase._print('(missing dependencies : %r) ' % missing_dep_list)
         install_kw = None
         if get_install_kw:
           install_kw = {}



More information about the Erp5-report mailing list