Commit 3bd08172 authored by Łukasz Nowak's avatar Łukasz Nowak

- 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


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32765 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 737aa320
...@@ -63,33 +63,10 @@ def makeFileUpload(name): ...@@ -63,33 +63,10 @@ def makeFileUpload(name):
path = makeFilePath(name) path = makeFilePath(name)
return FileUploadTest(path, name) return FileUploadTest(path, name)
class TestOOoImport(ERP5TypeTestCase): class TestOOoImportMixin(object):
"""
ERP5 test import object list from OOo Document
"""
# pseudo constants
RUN_ALL_TEST = 1
QUIET = 0
gender_base_cat_id = 'gender' gender_base_cat_id = 'gender'
function_base_cat_id = 'function' 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): def afterSetUp(self):
""" """
Initialize the ERP5 site. Initialize the ERP5 site.
...@@ -143,21 +120,29 @@ class TestOOoImport(ERP5TypeTestCase): ...@@ -143,21 +120,29 @@ class TestOOoImport(ERP5TypeTestCase):
transaction.commit() transaction.commit()
self.tic() 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): def getTitle(self):
""" """
Create a new manager user and login. Return the title of the current test set.
""" """
user_name = 'bartek' return "ERP5 Site - OOo File importing"
user_folder = self.portal.acl_users
user_folder._doAddUser(user_name, '', ['Manager', 'Owner', 'Assignor', def getBusinessTemplateList(self):
'Associate', 'Auditor', 'Author'], []) """
user = user_folder.getUserById(user_name).__of__(user_folder) Return the list of required business templates.
newSecurityManager(None, user) """
return ('erp5_base', 'erp5_ooo_import')
################################## ##################################
## Basic steps ## Basic steps
...@@ -1050,7 +1035,45 @@ class TestOOoImport(ERP5TypeTestCase): ...@@ -1050,7 +1035,45 @@ class TestOOoImport(ERP5TypeTestCase):
if not_ok: if not_ok:
self.fail('Spreadsheet not read!') 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(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestOOoImport)) suite.addTest(unittest.makeSuite(TestOOoImport))
suite.addTest(unittest.makeSuite(TestOOoImportWeb))
return suite return suite
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