Commit 60fd0ae2 authored by Bartek Górny's avatar Bartek Górny

test up to date, with local roles check

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11789 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3f1c99f6
......@@ -54,9 +54,10 @@ from Acquisition import aq_base, aq_inner
from zLOG import LOG
import os
from Products.ERP5Type import product_path
from Products.ERP5OOo.Document.OOoDocument import ConversionError
# XXX set it to an appropriate value
erp5_port=80
erp5_port=9090
class TestDms(ERP5TypeTestCase):
"""
......@@ -70,6 +71,7 @@ class TestDms(ERP5TypeTestCase):
def afterSetUp(self, quiet=1, run=1):
self.createCategories()
self.createObjects()
self.login()
portal = self.getPortal()
......@@ -97,8 +99,20 @@ class TestDms(ERP5TypeTestCase):
else:
path = path[cat]
def getUserFolder(self):
return self.getPortal().acl_users
def createObjects(self):
p1=self.getPortal().person_module.newContent(portal_type='Person',id='1',first_name='John',last_name='McCartney')
if not hasattr(self.getPortal().person_module,'1'):
p1=self.getPortal().person_module.newContent(portal_type='Person',id='1',first_name='John',last_name='McCartney',reference='john',career_role='internal')
#self.getWorkflowTool().doActionFor(p1,'validate_action')
get_transaction().commit()
self.tic()
def getTestUser(self):
user = self.getUserFolder().getUserById('john')
self.failIf(user is None)
return user
def login(self, quiet=0, run=run_all_test):
uf = self.getPortal().acl_users
......@@ -116,13 +130,25 @@ class TestDms(ERP5TypeTestCase):
self.failUnless(self.getTypeTool()!=None)
self.failUnless(self.getSqlConnection()!=None)
self.failUnless(self.getCatalogTool()!=None)
self.failUnless(self.getWorkflowTool()!=None)
def _addRoleToDoc(self,doc):
role=doc.newContent(portal_type='Role Definition',id='1')
role=doc.newContent(portal_type='Role Definition')
role._edit(agent='person_module/1',role_name='Assignor')
def printAndCheck(self,doc):
self.assert_(u'Auditor' in doc.__ac_local_roles__.get('HQ',[]))
#def printAndCheck(self,doc):
#self.assert_(u'Auditor' in doc.__ac_local_roles__.get('HQ',[]))
def createTestDocument(self):
dm=self.getPortal().document_module
doctext=dm.newContent(portal_type='Text')
doctext._getServerCoordinate=lambda:('127.0.0.1',8080)
f=FileObject(os.getenv('INSTANCE_HOME')+'/../Products/ERP5OOo/tests/test.doc')
f.filename='test.doc'
doctext._edit(file=f)
f.close()
doctext.convert()
return doctext
def test_02_ObjectCreation(self,quiet=0,run=run_all_test):
if not quiet:
......@@ -130,57 +156,36 @@ class TestDms(ERP5TypeTestCase):
LOG('Testing... ',0,'test_02_ObjectCreation')
dm=self.getPortal().document_module
doctext=dm.newContent(portal_type='Text')
roletext=self._addRoleToDoc(doctext)
self.printAndCheck(doctext)
docspread=dm.newContent(portal_type='Spreadsheet')
rolespread=self._addRoleToDoc(docspread)
self.printAndCheck(docspread)
docpres=dm.newContent(portal_type='Presentation')
rolepres=self._addRoleToDoc(docpres)
self.printAndCheck(docpres)
docgraph=dm.newContent(portal_type='Graphic')
rolegraph=self._addRoleToDoc(docgraph)
self.printAndCheck(docgraph)
self._addRoleToDoc(doctext)
get_transaction().commit()
doctext.updateLocalRolesOnSecurityGroups()
self.tic()
u=self.getTestUser()
self.failUnless('Assignor' in u.getRolesInContext(doctext))
def test_03_BasicConversion(self,quiet=0,run=run_all_test):
if not quiet:
ZopeTestCase._print('\nTest Basic Conversion')
LOG('Testing... ',0,'test_03_BasicConversion')
dm=self.getPortal().document_module
doctext=dm.newContent(portal_type='Text',id='1')
doctext._getServerCoordinates=lambda:('127.0.0.1',8080)
doctext=dm.newContent(portal_type='Text')
doctext._getServerCoordinate=lambda:('127.0.0.1',8080)
f=FileObject(os.getenv('INSTANCE_HOME')+'/../Products/ERP5OOo/tests/test.doc')
f.filename='test.doc'
doctext._edit(file=f)
f.close()
self.assert_(doctext.isFileUploaded())
self.assert_(not doctext.hasOOfile())
self.assert_(not doctext.hasOOFile())
ZopeTestCase._print('\n originalloaded '+str(doctext.getSourceReference()))
ZopeTestCase._print('\n isFileUploaded '+str(doctext.isFileUploaded()))
ZopeTestCase._print('\n hasOOfile '+str(doctext.hasOOfile()))
ZopeTestCase._print('\n hasOOFile '+str(doctext.hasOOFile()))
doctext.convert()
self.assert_(not doctext.isFileUploaded())
self.assert_(doctext.hasOOfile())
ZopeTestCase._print('\n isFileUploaded '+str(doctext.isFileUploaded()))
ZopeTestCase._print('\n hasOOfile '+str(doctext.hasOOfile()))
self.assert_(doctext.hasOOFile())
ZopeTestCase._print('\n hasOOFile '+str(doctext.hasOOFile()))
tgts=doctext.getTargetFormatItemList()
tgtext=[t[1] for t in tgts]
self.assert_('pdf' in tgtext)
self.assertEquals('subject',doctext.getSubject())
self.assertEquals('keywords',doctext.getSubjectList()[0])
self.assert_(doctext.getSearchableText().find('adadadfa'))
def createTestDocument(self):
dm=self.getPortal().document_module
doctext=dm.newContent(portal_type='Text',id='1')
doctext._getServerCoordinates=lambda:('127.0.0.1',8080)
f=FileObject(os.getenv('INSTANCE_HOME')+'/../Products/ERP5OOo/tests/test.doc')
f.filename='test.doc'
doctext._edit(file=f)
f.close()
doctext.convert()
return doctext
def test_04_FileGeneration(self,quiet=0,run=run_all_test):
if not quiet:
ZopeTestCase._print('\nTest File Generation')
......@@ -188,29 +193,42 @@ class TestDms(ERP5TypeTestCase):
doctext=self.createTestDocument()
doctext.getTargetFile('pdf')
self.assert_(doctext.hasFileCache('pdf'))
doctext.getTargetFile('doc')
self.assert_(doctext.hasFileCache('doc'))
doctext.getTargetFile('txt')
self.assert_(doctext.hasFileCache('txt'))
doctext.getTargetFile('html-writer')
self.assert_(doctext.hasFileCache('html-writer'))
doctext.getTargetFile('rtf')
self.assert_(doctext.hasFileCache('rtf'))
self.failIf(doctext.hasSnapshot())
doctext.createSnapshot()
self.failUnless(doctext.hasSnapshot())
# XXX why this line fails???
# self.assertRaises(ConversionError,doctext.createSnapshot)
def test_05_OtherFunctions(self,quiet=0,run=run_all_test):
if not quiet:
ZopeTestCase._print('\nTest Other Functions')
LOG('Testing... ',0,'test_05_OtherFunctions')
doctext=self.createTestDocument()
ZopeTestCase._print('\n'+doctext.getCacheInfo())
#ZopeTestCase._print('\n'+doctext.getCacheInfo())
mtype=doctext.guessMimeType('file.doc')
self.assertEquals(mtype,'application/msword')
def test_06_ExternalDocument(self,quiet=0,run=run_all_test):
if not quiet:
ZopeTestCase._print('\nTest External Document')
LOG('Testing... ',0,'test_06_ExternalDocument')
dm=self.getPortal().document_module
doctext=dm.newContent(portal_type='External Document',id='ext1')
ZopeTestCase._print('\nTest External Web Page')
LOG('Testing... ',0,'test_06_ExternalWeb Page')
dm=self.getPortal().external_source_module
doctext=dm.newContent(portal_type='External Web Page')
self.assert_('http' in doctext.getProtocolList())
doctext.setUrlProtocol('http')
doctext.setUrlString('localhost:%i' % erp5_port)
doctext.setUrlString('localhost:%i/erp5' % erp5_port)
doctext.spiderSource()
if not quiet:
ZopeTestCase._print(doctext.getStatusMessage())
LOG('Testing External Document... ',0,doctext.getStatusMessage())
ZopeTestCase._print(doctext.getExternalProcessingStatusMessage())
LOG('Testing External Web Page... ',0,doctext.getExternalProcessingStatusMessage())
self.assert_(doctext.getTextContent().find('My language')>-1)
......
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