Commit 7e3281f5 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Various


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@242 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 705ffbbb
......@@ -45,9 +45,9 @@ ZopeTestCase.installProduct('TranslationService')
# ERP5
ZopeTestCase.installProduct('ERP5Catalog')
ZopeTestCase.installProduct('CMFCategory')
ZopeTestCase.installProduct('CMFActivity')
ZopeTestCase.installProduct('ERP5Type')
ZopeTestCase.installProduct('ERP5Form') # Not required by ERP5Type but required by ERP5Form
ZopeTestCase.installProduct('CMFActivity')
ZopeTestCase.installProduct('ERP5SyncML')
ZopeTestCase.installProduct('ERP5') # Not needed by ERP5Type
......@@ -88,13 +88,18 @@ class ERP5TypeTestCase(PortalTestCase):
"""
pass
def getBusinessTemplateList(self):
"""
"""
return ('erp5_common', )
def setupERP5Site(app, id='portal', quiet=0):
'''Creates a ERP5 site.'''
if not hasattr(aq_base(app), id):
_start = time.time()
# Add user and log in
if not quiet: ZopeTestCase._print('Adding ERP5TypeTestCase user ... ')
if not quiet: ZopeTestCase._print('Adding ERP5TypeTestCase user ... \n')
uf = app.acl_users
uf._doAddUser('ERP5TypeTestCase', '', ['Manager'], [])
user = uf.getUserById('ERP5TypeTestCase').__of__(uf)
......@@ -102,11 +107,18 @@ def setupERP5Site(app, id='portal', quiet=0):
# Add ERP5 Site
#factory = app.manage_addProduct['CMFDefault']
#factory.manage_addCMFSite(id)
if not quiet: ZopeTestCase._print('Adding ERP5 Site ... ')
if not quiet: ZopeTestCase._print('Adding ERP5 Site ... \n')
factory = app.manage_addProduct['ERP5'] # Not needed by ERP5Type
factory.manage_addERP5Site(id)
portal=app[id]
# VERY IMPORTANT: Add some business templates
business_template_list = ('erp5_common', )
for id in business_template_list:
ZopeTestCase._print('Adding %s business template ... \n' % id)
portal.portal_templates.download('%s.zexp' % id, id=id)
portal.portal_templates[id].install()
# Log out
if not quiet: ZopeTestCase._print('Logout ... ')
if not quiet: ZopeTestCase._print('Logout ... \n')
noSecurityManager()
get_transaction().commit()
if not quiet: ZopeTestCase._print('done (%.3fs)\n' % (time.time()-_start,))
......
......@@ -2,6 +2,8 @@
# Skeleton ZopeTestCase
#
from random import randint
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
......@@ -11,12 +13,63 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestERP5Type(ERP5TypeTestCase):
# Some helper methods
#def afterSetUp(self):
# pass
def testSetInt(self):
# Test something
self.failUnless(1==1)
def getRandomString(self):
return str(randint(-10000000,100000000))
def getTemplateTool(self):
return getattr(self.getPortal(), 'portal_templates', None)
def getCategoryTool(self):
return getattr(self.getPortal(), 'portal_categories', None)
def getTypeTool(self):
return getattr(self.getPortal(), 'portal_types', None)
# Here are the tests
def testHasTemplateTool(self):
# Test if portal_templates was created
self.failUnless(self.getTemplateTool()!=None)
def testHasCategoryTool(self):
# Test if portal_categories was created
self.failUnless(self.getCategoryTool()!=None)
def testTemplateToolHasGetId(self):
# Test if portal_templates has getId method (RAD)
self.failUnless(self.getTemplateTool().getId() == 'portal_templates')
def testTemplateToolHasGetId(self):
# Test if portal_categories has getId method (RAD)
self.failUnless(self.getCategoryTool().getId() == 'portal_categories')
# erp5_common tests
def testCommonHasParentBaseCategory(self):
# Test if erp5_common parent base category was imported successfully
self.failUnless(getattr(self.getCategoryTool(), 'parent', None) != None)
def testCommonHasImageType(self):
# Test if erp5_common parent base category was imported successfully
self.failUnless(getattr(self.getTypeTool(), 'Image', None) != None)
# Business Template Tests
def testBusinessTemplate(self):
# Create a business template and test if portal_type matches
# Make a extension tests on basic accessors
from Products.ERP5.Document import addBusinessTemplate
portal_templates = self.getTemplateTool()
new_id = portal_templates.generateNewId()
#bt = self.getTemplateTool().newContent(portal_type="Business Template") # Fails Why ?
addBusinessTemplate(portal_templates, new_id)
business_template = getattr(portal_templates, new_id)
self.failUnless(business_template.getPortalType() == 'Business Template')
# Test simple string accessor
test_string = self.getRandomString()
business_template.setTitle(test_string)
self.failUnless(business_template.getTitle()==test_string)
if __name__ == '__main__':
......
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