Commit ce9e92bf authored by Jérome Perrin's avatar Jérome Perrin

Set cloudoo on preferences in ERP5TypeTestCase

This has an impact on existing tests, because now the preference will always be
set, so tests won't have to handle cloudooo preference themselves.
parent 43ebcbd8
......@@ -488,9 +488,6 @@ class TestUNG(ERP5TypeTestCase):
self.logout()
self.assertEquals(json.loads(self.portal.Base_getPreferencePathList()), None)
self.login("ERP5TypeTestCase")
self.changeSkin("UNGDoc")
preference_dict = json.loads(self.portal.Base_getPreferencePathList())
self.assertEquals(preference_dict, {})
self.portal.portal_preferences.ung_preference.enable()
self.tic()
self.changeSkin("UNGDoc")
......
......@@ -61,8 +61,11 @@ class TestAuoLogout(ERP5TypeTestCase):
self.login(self.manager_username)
# setup short auto-logout period
portal.portal_preferences.default_site_preference.setPreferredMaxUserInactivityDuration(5)
portal.portal_preferences.default_site_preference.enable()
preference = self.portal.portal_preferences[
self.getDefaultSitePreferenceId()]
preference.setPreferredMaxUserInactivityDuration(5)
if self.portal.portal_workflow.isTransitionPossible(preference, 'enable'):
preference.enable()
self.tic()
def test_01_AutoLogout(self):
......
......@@ -33,10 +33,9 @@ import os
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl import getSecurityManager
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Utils import convertToUpperCase
......@@ -94,7 +93,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
portal_catalog = self.getCatalogTool()
#portal_catalog.manage_catalogClear()
self.createCategories()
self.setDefaultSitePreference()
#Overwrite immediateReindexObject() with a crashing method
def crashingMethod(self):
......@@ -120,15 +118,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
o = self.category_tool.group.newContent(portal_type='Category',
id=category_id)
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
default_pref.enable()
return default_pref
def stepRemoveWorkflowsRelated(self, sequence=None, sequence_list=None,
**kw):
"""
......
......@@ -29,10 +29,9 @@
import unittest
import os
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.CMFCore.WorkflowCore import WorkflowException
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5OOo.tests.testIngestion import FILENAME_REGULAR_EXPRESSION
from Products.ERP5OOo.tests.testIngestion import REFERENCE_REGULAR_EXPRESSION
from Products.ERP5Type.tests.backportUnittest import expectedFailure
......@@ -957,9 +956,6 @@ class TestCRMMailSend(BaseTestCRM):
# set preference
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if default_pref.getPreferenceState() == 'disabled':
......
......@@ -114,7 +114,6 @@ class TestERP5Coordinate(ERP5TypeTestCase):
pref = self.portal.portal_preferences.default_site_preference
pref.setPreferredTelephoneDefaultCountryNumber('33')
pref.setPreferredTelephoneDefaultAreaNumber('2')
pref.enable()
tel.fromText(coordinate_text='11111111')
self.assertEquals('+33(0)2-11111111',tel.asText())
......@@ -124,7 +123,6 @@ class TestERP5Coordinate(ERP5TypeTestCase):
pref = self.portal.portal_preferences.default_site_preference
pref.setPreferredTelephoneDefaultCountryNumber('')
pref.setPreferredTelephoneDefaultAreaNumber('')
pref.enable()
tel.fromText(coordinate_text='+11 1 11111111')
tel.fromText(coordinate_text='+22333445555')
self.assertEquals('+(0)-22333445555',tel.asText())
......@@ -317,7 +315,6 @@ class TestERP5Coordinate(ERP5TypeTestCase):
pref = self.portal.portal_preferences.default_site_preference
pref.setPreferredTelephoneDefaultCountryNumber('')
pref.setPreferredTelephoneDefaultAreaNumber('')
pref.enable()
tel.fromText(coordinate_text='12345678')
self.assertEquals('+(0)-12345678',tel.asText())
......
......@@ -29,9 +29,7 @@
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestERP5WebWithCRM(ERP5TypeTestCase):
......@@ -59,21 +57,6 @@ class TestERP5WebWithCRM(ERP5TypeTestCase):
user = self.createUser('robby')
self.createUserAssignment(user, {})
def setSystemPreference(self):
portal_type = 'System Preference'
preference_list = self.portal.portal_preferences.contentValues(
portal_type=portal_type)
if not preference_list:
preference = self.portal.portal_preferences.newContent(
portal_type=portal_type)
else:
preference = preference_list[0]
conversion_dict = _getConversionServerDict()
preference.setPreferredOoodocServerAddress(conversion_dict['hostname'])
preference.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(preference, 'enable'):
preference.enable()
def clearModule(self, module):
module.manage_delObjects(list(module.objectIds()))
self.tic()
......
......@@ -34,9 +34,8 @@ from lxml import etree
from AccessControl import Unauthorized
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript
from Products.ERP5.Document.Document import ConversionError
......@@ -109,20 +108,10 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
def afterSetUp(self):
self.login()
portal = self.getPortal()
self.setDefaultSitePreference()
self.web_page_module = self.portal.web_page_module
self.web_site_module = self.portal.web_site_module
self.portal_id = self.portal.getId()
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
default_pref.enable()
return default_pref
def clearModule(self, module):
module.manage_delObjects(list(module.objectIds()))
self.tic()
......
......@@ -84,8 +84,8 @@ class TestResource(ERP5TypeTestCase):
preference = portal_preferences.newContent(portal_type='System Preference',
title='Default Site Preference',
id='test_site_preference')
if preference.getPreferenceState() == 'disabled':
preference.enable()
if preference.getPreferenceState() == 'disabled':
preference.enable()
preference.setPreferredApparelModelVariationBaseCategoryList(('size', 'industrial_phase',))
preference.setPreferredApparelClothVariationBaseCategoryList(('size',))
......
......@@ -28,13 +28,11 @@
##############################################################################
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
import urlnorm # This library is imported to detect lack of
# urlnorm availibility in python environment
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
# test files' home
FILENAME_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})-(?P<language>[a-z]{2})-(?P<version>[0-9]{3})"
REFERENCE_REGULAR_EXPRESSION = "(?P<reference>[A-Z&é@{]{3,7})(-(?P<language>[a-z]{2}))?(-(?P<version>[0-9]{3}))?"
......@@ -94,11 +92,6 @@ class TestWebCrawler(ERP5TypeTestCase):
if system_preference is None:
system_preference = portal_preferences.newContent(id=self.system_pref_id,
portal_type='System Preference')
conversion_dict = _getConversionServerDict()
system_preference.\
setPreferredOoodocServerAddress(conversion_dict['hostname'])
system_preference.\
setPreferredOoodocServerPortNumber(conversion_dict['port'])
system_preference.setPreferredDocumentFilenameRegularExpression(
FILENAME_REGULAR_EXPRESSION)
system_preference.setPreferredDocumentReferenceRegularExpression(
......
......@@ -32,7 +32,6 @@ from DateTime import DateTime
from AccessControl import Unauthorized
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from AccessControl.SecurityManagement import newSecurityManager
class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
......@@ -118,23 +117,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
# it is required by SecurityTestCase
self.workflow_tool = self.portal.portal_workflow
self.setDefaultSitePreference()
self.setSystemPreference()
self.portal.portal_activities.unsubscribe()
def setSystemPreference(self):
portal_type = 'System Preference'
preference_list = self.portal.portal_preferences.contentValues(
portal_type=portal_type)
if not preference_list:
preference = self.portal.portal_preferences.newContent(
portal_type=portal_type)
else:
preference = preference_list[0]
conversion_dict = _getConversionServerDict()
preference.setPreferredOoodocServerAddress(conversion_dict['hostname'])
preference.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(preference, 'enable'):
preference.enable()
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
......
......@@ -31,7 +31,6 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from AccessControl.SecurityManagement import newSecurityManager
from StringIO import StringIO
......@@ -47,15 +46,6 @@ class TestFormPrintoutMixin(ERP5TypeTestCase):
user = uf.getUserById('zope').__of__(uf)
newSecurityManager(None, user)
def setSystemPreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
#default_pref.setPreferredConversionCacheFactory('document_cache_factory')
if default_pref.getPreferenceState() != 'global':
default_pref.enable()
def _validate(self, odf_file_data):
error_list = self.validator.validate(odf_file_data)
if error_list:
......
......@@ -54,7 +54,6 @@ from cgi import FieldStorage
import ZPublisher.HTTPRequest
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.utils import DummyLocalizer
from Products.ERP5OOo.OOoUtils import OOoBuilder
......@@ -127,9 +126,6 @@ class TestDocumentMixin(ERP5TypeTestCase):
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
......
......@@ -58,7 +58,6 @@ class TestFormPrintoutAsODG(TestFormPrintoutMixin):
def afterSetUp(self):
self.login()
self.setSystemPreference()
# XML validator
v12schema_url = os.path.join(os.path.dirname(__file__),
'OpenDocument-v1.2-os-schema.rng')
......
......@@ -52,7 +52,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
def afterSetUp(self):
self.login()
self.setSystemPreference()
# XML validator
v12schema_url = os.path.join(os.path.dirname(__file__),
'OpenDocument-v1.2-os-schema.rng')
......
......@@ -142,9 +142,6 @@ class TestIngestion(ERP5TypeTestCase):
def setSystemPreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if default_pref.getPreferenceState() != 'global':
......
......@@ -104,8 +104,10 @@ class TestOoodResponse(ERP5TypeTestCase):
request = self.portal.REQUEST
request.RESPONSE.setHeader('content-type', 'text/html')
ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt
# This assumes that a conversion error is raised because oood coordinates
# are not defined in preferences.
# Unset oood coordinates in preferences
preference = self.portal.portal_preferences[
self.getDefaultSitePreferenceId()]
preference.setPreferredOoodocServerAddress("")
self.assertRaises(ConversionError, ERP5Site_viewNothingAsOdt,
batch_mode=0, format='pdf')
self.assertEqual('text/html',
......@@ -115,8 +117,11 @@ class TestOoodResponse(ERP5TypeTestCase):
request = self.portal.REQUEST
request.RESPONSE.setHeader('content-type', 'text/html')
ERP5Site_viewNothingAsOdt = self.getPortal().ERP5Site_viewNothingAsOdt
# This assumes that a conversion error is raised because oood coordinates
# are not defined in preferences.
# Unset oood coordinates in preferences
preference = self.portal.portal_preferences[
self.getDefaultSitePreferenceId()]
preference.setPreferredOoodocServerAddress("")
self.assertRaises(ConversionError, ERP5Site_viewNothingAsOdt,
batch_mode=1, format='pdf')
self.assertEqual('text/html', request.RESPONSE.getHeader('content-type').split(';')[0])
......
......@@ -32,11 +32,9 @@ import os
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5OOo.OOoUtils import OOoParser
from Products.ERP5Form.PreferenceTool import Priority
from DateTime import DateTime
def makeFilePath(name):
......@@ -57,11 +55,6 @@ class TestOOoImportMixin(ERP5TypeTestCase):
self.login()
self.pref = self.portal.portal_preferences.newContent(
portal_type='System Preference')
conversion_dict = _getConversionServerDict()
self.pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
self.pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
self.pref.setPriority(Priority.SITE)
self.pref.enable()
# create browser_id_manager
if not "browser_id_manager" in self.portal.objectIds():
......
......@@ -28,10 +28,9 @@
##############################################################################
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase, \
_getConversionServerDict
from Products.ERP5Form.Selection import Selection
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5OOo.tests.utils import Validator
import httplib
......@@ -53,8 +52,6 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
if not self.skin:
raise NotImplementedError('Subclasses must define skin')
self.setDefaultSitePreference()
gender = self.portal.portal_categories.gender
if 'male' not in gender.objectIds():
gender.newContent(id='male')
......@@ -85,15 +82,6 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
name = 'person_module_selection'
self.portal.portal_selections.setSelectionFor(name, Selection(name))
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
default_pref.enable()
return default_pref
def publish(self, *args, **kw):
kw['handle_errors'] = not debug
return super(TestOOoStyle, self).publish(*args, **kw)
......
......@@ -34,7 +34,6 @@ import unittest
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.runUnitTest import tests_home
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5SyncML.Tool import SynchronizationTool
from Products.ERP5SyncML.tests.testERP5SyncML import TestERP5SyncMLMixin
......@@ -147,9 +146,6 @@ class TestERP5DocumentSyncMLMixin(TestERP5SyncMLMixin):
def setSystemPreferences(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
default_pref.setPreferredDocumentFileNameRegularExpression(FILENAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if default_pref.getPreferenceState() == 'disabled':
......
......@@ -889,6 +889,9 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
preference._setPreferredOoodocServerAddress(conversion_dict['hostname'])
preference._setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(preference, 'enable'):
preference.enable()
def _updateMemcachedConfiguration(self):
"""Update default memcached plugin configuration
"""
......
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