Commit 64b290ff authored by Jérome Perrin's avatar Jérome Perrin

remove unused import, wrap some long lines and use 'request' as a variable


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16076 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5b4e7a80
...@@ -27,15 +27,10 @@ ...@@ -27,15 +27,10 @@
############################################################################## ##############################################################################
import os import os
import sys import unittest
import Zope
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Testing import ZopeTestCase
from Products.PageTemplates.GlobalTranslationService import setGlobalTranslationService
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Testing.makerequest import makerequest
from Products.ERP5.Document.Document import ConversionError from Products.ERP5.Document.Document import ConversionError
from App.config import getConfiguration
class TestOoodResponse(ERP5TypeTestCase): class TestOoodResponse(ERP5TypeTestCase):
...@@ -47,7 +42,7 @@ class TestOoodResponse(ERP5TypeTestCase): ...@@ -47,7 +42,7 @@ class TestOoodResponse(ERP5TypeTestCase):
def getTitle(self): def getTitle(self):
return "TestOOoBatchMode" return "TestOOoBatchMode"
def login(self, quiet=0, run=run_all_test): def login(self):
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
uf._doAddUser(self.manager_username, self.manager_password, ['Manager'], []) uf._doAddUser(self.manager_username, self.manager_password, ['Manager'], [])
user = uf.getUserById(self.manager_username).__of__(uf) user = uf.getUserById(self.manager_username).__of__(uf)
...@@ -59,12 +54,14 @@ class TestOoodResponse(ERP5TypeTestCase): ...@@ -59,12 +54,14 @@ class TestOoodResponse(ERP5TypeTestCase):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
portal_skins = self.getSkinsTool() portal_skins = self.getSkinsTool()
portal_skins.custom.REQUEST.RESPONSE.setHeader('content-type', 'text/html') import_file_path = os.path.join(os.path.dirname(__file__),
import_file_path = os.path.join(os.path.dirname(__file__), 'PersonSpreadsheetStylesheet') 'PersonSpreadsheetStylesheet')
import_file = open(import_file_path, 'rb') import_file = open(import_file_path, 'rb')
addStyleSheet = portal_skins.custom.manage_addProduct['OFSP'].manage_addFile custom = portal_skins.custom
addStyleSheet(id='Base_getODTStyleSheet', file=import_file, title='', precondition='', content_type='application/vnd.oasis.opendocument.text') addStyleSheet = custom.manage_addProduct['OFSP'].manage_addFile
addOOoTemplate = portal_skins.custom.manage_addProduct['ERP5OOo'].addOOoTemplate addStyleSheet(id='Base_getODTStyleSheet', file=import_file, title='',
precondition='', content_type='application/vnd.oasis.opendocument.text')
addOOoTemplate = custom.manage_addProduct['ERP5OOo'].addOOoTemplate
addOOoTemplate(id='ERP5Site_viewNothingAsOdt', title='') addOOoTemplate(id='ERP5Site_viewNothingAsOdt', title='')
portal_skins.changeSkin(skinname=None) portal_skins.changeSkin(skinname=None)
ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt
...@@ -73,40 +70,42 @@ class TestOoodResponse(ERP5TypeTestCase): ...@@ -73,40 +70,42 @@ class TestOoodResponse(ERP5TypeTestCase):
ERP5Site_viewNothingAsOdt.pt_edit(text, content_type) ERP5Site_viewNothingAsOdt.pt_edit(text, content_type)
def test_01_noExcNoFormatNoBatchMode(self): def test_01_noExcNoFormatNoBatchMode(self):
portal_skins = self.getSkinsTool() request = self.portal.REQUEST
portal_skins.custom.REQUEST.RESPONSE.setHeader('content-type', 'text/html') request.RESPONSE.setHeader('content-type', 'text/html')
ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt
ERP5Site_viewNothingAsOdt(batch_mode=0) ERP5Site_viewNothingAsOdt(batch_mode=0)
self.assertEqual('application/vnd.oasis.opendocument.text', portal_skins.custom.REQUEST.RESPONSE.getHeader('content-type').split(';')[0]) self.assertEqual('application/vnd.oasis.opendocument.text',
self.assertEqual('inline;filename=ERP5Site_viewNothingAsOdt', portal_skins.custom.REQUEST.RESPONSE.getHeader('content-disposition')) request.RESPONSE.getHeader('content-type').split(';')[0])
self.assertEqual('inline;filename=ERP5Site_viewNothingAsOdt',
request.RESPONSE.getHeader('content-disposition'))
def test_02_noExcNoFormatBatchMode(self): def test_02_noExcNoFormatBatchMode(self):
portal_skins = self.getSkinsTool() request = self.portal.REQUEST
portal_skins.custom.REQUEST.RESPONSE.setHeader('content-type', 'text/html') request.RESPONSE.setHeader('content-type', 'text/html')
ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt
ERP5Site_viewNothingAsOdt(batch_mode=1) ERP5Site_viewNothingAsOdt(batch_mode=1)
self.assertEqual('text/html', portal_skins.custom.REQUEST.RESPONSE.getHeader('content-type').split(';')[0]) self.assertEqual('text/html',
request.RESPONSE.getHeader('content-type').split(';')[0])
def test_03_excPdfFormatNoBatchMode(self): def test_03_excPdfFormatNoBatchMode(self):
portal_skins = self.getSkinsTool() request = self.portal.REQUEST
portal_skins.custom.REQUEST.RESPONSE.setHeader('content-type', 'text/html') request.RESPONSE.setHeader('content-type', 'text/html')
ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt
self.assertRaises(ConversionError, ERP5Site_viewNothingAsOdt, batch_mode=0, format='pdf') self.assertRaises(ConversionError, ERP5Site_viewNothingAsOdt,
self.assertEqual('text/html', portal_skins.custom.REQUEST.RESPONSE.getHeader('content-type').split(';')[0]) batch_mode=0, format='pdf')
self.assertEqual('text/html',
request.RESPONSE.getHeader('content-type').split(';')[0])
def test_04_excPdfFormatBatchMode(self): def test_04_excPdfFormatBatchMode(self):
portal_skins = self.getSkinsTool() request = self.portal.REQUEST
portal_skins.custom.REQUEST.RESPONSE.setHeader('content-type', 'text/html') request.RESPONSE.setHeader('content-type', 'text/html')
ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt
self.assertRaises(ConversionError, ERP5Site_viewNothingAsOdt, batch_mode=1, format='pdf') self.assertRaises(ConversionError, ERP5Site_viewNothingAsOdt,
self.assertEqual('text/html', portal_skins.custom.REQUEST.RESPONSE.getHeader('content-type').split(';')[0]) batch_mode=1, format='pdf')
self.assertEqual('text/html', request.RESPONSE.getHeader('content-type').split(';')[0])
if __name__ == '__main__': def test_suite():
framework() suite = unittest.TestSuite()
else: suite.addTest(unittest.makeSuite(TestOoodResponse))
import unittest return suite
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestOoodResponse))
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