[Erp5-report] r32765 luke - /erp5/trunk/products/ERP5OOo/tests/testOOoImport.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Feb 18 13:19:00 CET 2010


Author: luke
Date: Thu Feb 18 13:18:59 2010
New Revision: 32765

URL: http://svn.erp5.org?rev=32765&view=rev
Log:
 - refactor test and use Mixin to avoid code duplication
 - add class to test when erp5_web, which provides category_expiration_workflow, is installed
 - remove not needed login method, ERP5TypeTestCase provides very good one

Modified:
    erp5/trunk/products/ERP5OOo/tests/testOOoImport.py

Modified: erp5/trunk/products/ERP5OOo/tests/testOOoImport.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/testOOoImport.py?rev=32765&r1=32764&r2=32765&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/tests/testOOoImport.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/tests/testOOoImport.py [utf8] Thu Feb 18 13:18:59 2010
@@ -63,32 +63,9 @@
   path = makeFilePath(name)
   return FileUploadTest(path, name)
 
-class TestOOoImport(ERP5TypeTestCase):
-  """
-    ERP5  test import object list from OOo Document
-  """
-
-  # pseudo constants
-  RUN_ALL_TEST = 1
-  QUIET = 0
+class TestOOoImportMixin(object):
   gender_base_cat_id    = 'gender'
   function_base_cat_id  = 'function'
-
-  ##################################
-  ##  ZopeTestCase Skeleton
-  ##################################
-
-  def getTitle(self):
-    """
-      Return the title of the current test set.
-    """
-    return "ERP5 Site - OOo File importing"
-
-  def getBusinessTemplateList(self):
-    """
-      Return the list of required business templates.
-    """
-    return ('erp5_base', 'erp5_ooo_import')
 
   def afterSetUp(self):
     """
@@ -143,21 +120,29 @@
     transaction.commit()
     self.tic()
 
-
+class TestOOoImport(TestOOoImportMixin, ERP5TypeTestCase):
+  """
+    ERP5  test import object list from OOo Document
+  """
+
+  # pseudo constants
+  RUN_ALL_TEST = 1
+  QUIET = 0
   ##################################
-  ##  Useful methods
+  ##  ZopeTestCase Skeleton
   ##################################
 
-  def login(self):
-    """
-      Create a new manager user and login.
-    """
-    user_name = 'bartek'
-    user_folder = self.portal.acl_users
-    user_folder._doAddUser(user_name, '', ['Manager', 'Owner', 'Assignor',
-                                           'Associate', 'Auditor', 'Author'], [])
-    user = user_folder.getUserById(user_name).__of__(user_folder)
-    newSecurityManager(None, user)
+  def getTitle(self):
+    """
+      Return the title of the current test set.
+    """
+    return "ERP5 Site - OOo File importing"
+
+  def getBusinessTemplateList(self):
+    """
+      Return the list of required business templates.
+    """
+    return ('erp5_base', 'erp5_ooo_import')
 
   ##################################
   ##  Basic steps
@@ -1050,7 +1035,45 @@
     if not_ok:
       self.fail('Spreadsheet not read!')
 
+class TestOOoImportWeb(TestOOoImportMixin, ERP5TypeTestCase):
+  def getTitle(self):
+    """
+      Return the title of the current test set.
+    """
+    return "ERP5 Site - OOo File importing (with web)"
+
+  def getBusinessTemplateList(self):
+    """
+      Return the list of required business templates.
+    """
+    return ('erp5_base', 'erp5_web', 'erp5_ooo_import')
+
+  def test_CategoryTool_importCategoryFileExpirationSupport(self):
+    # tests simple use of CategoryTool_importCategoryFile script
+    region = self.portal.portal_categories.region
+    dummy_region = region.newContent(id='dummy_region')
+    transaction.commit()
+    self.tic()
+    self.portal.portal_categories.CategoryTool_importCategoryFile(
+        import_file=makeFileUpload('import_region_category.sxc'),
+        existing_category_list='expire')
+    transaction.commit()
+    self.tic()
+    self.assertEqual(3, len(region))
+    self.assertTrue('dummy_region' in region.objectIds())
+    self.assertEqual(region.dummy_region.getValidationState(), 'expired')
+    self.assertTrue('europe' in region.objectIds())
+    self.assertTrue('germany' in region.europe.objectIds())
+    self.assertTrue('france' in region.europe.objectIds())
+    france = region.europe.france
+    self.assertEquals('France', france.getTitle())
+    self.assertTrue(france.hasProperty('title'))
+    self.assertEquals('A Country', france.getDescription())
+    self.assertEquals('FR', france.getCodification())
+    self.assertEquals(1, france.getIntIndex())
+
 def test_suite():
   suite = unittest.TestSuite()
   suite.addTest(unittest.makeSuite(TestOOoImport))
+  suite.addTest(unittest.makeSuite(TestOOoImportWeb))
   return suite




More information about the Erp5-report mailing list