Commit f84f4cdb authored by Julien Muchembled's avatar Julien Muchembled

tests: clean up code related to configuration of cloudooo/memcached connectors

- The conversion server is supposed to be configured in a system preference,
  so do this instead of using a normal preference.
- _getConversionServerDict -> _getConversionServerUrl, to make clear that
  cloudooo is now configured by a url, instead of a host/port couple.
- Refactoring: From the moment where setUpERP5Site() sets up things
  automatically, we don't the "same" duplicated code throughout many test to
  redo cloudooo configuration.
- In the promise file, the volatile/persistent memcached url were swapped.
parent 7d5aa17e
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerUrl
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Configurator.tests.ConfiguratorTestMixin import \ from Products.ERP5Configurator.tests.ConfiguratorTestMixin import \
TestLiveConfiguratorWorkflowMixin TestLiveConfiguratorWorkflowMixin
...@@ -184,10 +184,9 @@ class TestRunMyDocsConfiguratorWorkflowMixin(TestLiveConfiguratorWorkflowMixin): ...@@ -184,10 +184,9 @@ class TestRunMyDocsConfiguratorWorkflowMixin(TestLiveConfiguratorWorkflowMixin):
def stepCheckSystemPreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw): def stepCheckSystemPreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw):
""" Check System Preference""" """ Check System Preference"""
system_preference = self.portal.portal_catalog.getResultValue(portal_type="System Preference") system_preference = self.getDefaultSystemPreference()
conversion_dict = _getConversionServerDict()
self.assertEqual(system_preference.getPreferredDocumentConversionServerUrl(), self.assertEqual(system_preference.getPreferredDocumentConversionServerUrl(),
conversion_dict['url']) _getConversionServerUrl())
def _stepCheckKnowledgePadRole(self): def _stepCheckKnowledgePadRole(self):
""" Check if Knowledge Pad is configured correctly """ """ Check if Knowledge Pad is configured correctly """
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# #
############################################################################## ##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerUrl
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Configurator.tests.ConfiguratorTestMixin import \ from Products.ERP5Configurator.tests.ConfiguratorTestMixin import \
TestLiveConfiguratorWorkflowMixin TestLiveConfiguratorWorkflowMixin
...@@ -211,10 +211,9 @@ class TestUNGConfiguratorWorkflowMixin(TestLiveConfiguratorWorkflowMixin): ...@@ -211,10 +211,9 @@ class TestUNGConfiguratorWorkflowMixin(TestLiveConfiguratorWorkflowMixin):
def stepCheckSystemPreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw): def stepCheckSystemPreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw):
""" Check System Preference""" """ Check System Preference"""
system_preference = self.portal.portal_catalog.getResultValue(portal_type="System Preference") system_preference = self.getDefaultSystemPreference()
conversion_dict = _getConversionServerDict()
self.assertEqual(system_preference.getPreferredDocumentConversionServerUrl(), self.assertEqual(system_preference.getPreferredDocumentConversionServerUrl(),
conversion_dict['url']) _getConversionServerUrl())
def stepCheckSitePreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw): def stepCheckSitePreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw):
""" Check Site Preference""" """ Check Site Preference"""
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
############################################################################## ##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeLiveTestCase import ERP5TypeLiveTestCase from Products.ERP5Type.tests.ERP5TypeLiveTestCase import ERP5TypeLiveTestCase
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
import random import random
...@@ -73,14 +72,9 @@ class TestIngestion(ERP5TypeLiveTestCase): ...@@ -73,14 +72,9 @@ class TestIngestion(ERP5TypeLiveTestCase):
self.tic() self.tic()
def setSystemPreference(self): def setSystemPreference(self):
portal_preferences = getToolByName(self.portal, 'portal_preferences') default_pref = self.getDefaultSystemPreference()
default_pref = portal_preferences.default_site_preference default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredDocumentFileNameRegularExpression(FILE_NAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION) default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if default_pref.getPreferenceState() != 'global':
default_pref.enable()
def contributeFileWithUrl(self, script_id, filename=None): def contributeFileWithUrl(self, script_id, filename=None):
"""compute url and call portal_contributions.newContentFromUrl """compute url and call portal_contributions.newContentFromUrl
......
...@@ -5,9 +5,6 @@ subversion working copy paths and conversion server address. ...@@ -5,9 +5,6 @@ subversion working copy paths and conversion server address.
It's not meant to be called by zelenium tests directly. It's not meant to be called by zelenium tests directly.
""" """
if conversion_server_url is None:
raise TypeError("argument conversion_server_url should not be None")
pref = getattr(context.portal_preferences, "erp5_ui_test_preference", None) pref = getattr(context.portal_preferences, "erp5_ui_test_preference", None)
if pref is None: if pref is None:
pref = context.portal_preferences.newContent(id="erp5_ui_test_preference", pref = context.portal_preferences.newContent(id="erp5_ui_test_preference",
...@@ -17,17 +14,6 @@ if pref is None: ...@@ -17,17 +14,6 @@ if pref is None:
pref.setPreferredSubversionWorkingCopyList(tuple(working_copy_list.split(','))) pref.setPreferredSubversionWorkingCopyList(tuple(working_copy_list.split(',')))
pref.setPreferredHtmlStyleUnsavedFormWarning(False) pref.setPreferredHtmlStyleUnsavedFormWarning(False)
if pref.getPreferenceState() == 'disabled':
pref.enable()
pref = getattr(context.portal_preferences, "erp5_ui_test_system_preference", None)
if pref is None:
pref = context.portal_preferences.newContent(id="erp5_ui_test_system_preference",
portal_type="System Preference",
priority=1)
pref.setPreferredDocumentConversionServerUrl(conversion_server_url)
if pref.getPreferenceState() == 'disabled': if pref.getPreferenceState() == 'disabled':
pref.enable() pref.enable()
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>working_copy_list, conversion_server_url=None</string> </value> <value> <string>working_copy_list</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from DateTime import DateTime from DateTime import DateTime
import os.path import os.path
import Products.ERP5.tests import Products.ERP5.tests
...@@ -450,18 +449,10 @@ class TestUNG(ERP5TypeTestCase): ...@@ -450,18 +449,10 @@ class TestUNG(ERP5TypeTestCase):
""" Test if script load correctly the Web Page with data of one document """ Test if script load correctly the Web Page with data of one document
""" """
portal = self.portal portal = self.portal
portal_preferences = portal.portal_preferences
web_page_module = portal.web_page_module
portal_contributions = portal.portal_contributions
system_preference = portal_preferences.newContent(portal_type='System Preference')
conversion_dict = _getConversionServerDict()
system_preference.setPreferredDocumentConversionServerUrl(conversion_dict["url"])
system_preference.enable()
self.tic()
document_path, filename = self.getDocumentPath() document_path, filename = self.getDocumentPath()
file = FileUpload(document_path, filename) file = FileUpload(document_path, filename)
document = portal_contributions.newContent(file=file) document = portal.portal_contributions.newContent(file=file)
web_page = web_page_module.newContent(portal_type="Web Page") web_page = portal.web_page_module.newContent(portal_type="Web Page")
self.tic() self.tic()
self.changeSkin("UNGDoc") self.changeSkin("UNGDoc")
web_page.WebPage_updateWebDocument(document.getPath()) web_page.WebPage_updateWebDocument(document.getPath())
......
...@@ -33,8 +33,7 @@ import os ...@@ -33,8 +33,7 @@ import os
from unittest import skip from unittest import skip
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
_getConversionServerDict
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
...@@ -93,7 +92,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -93,7 +92,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
portal_catalog = self.getCatalogTool() portal_catalog = self.getCatalogTool()
#portal_catalog.manage_catalogClear() #portal_catalog.manage_catalogClear()
self.createCategories() self.createCategories()
self.setDefaultSitePreference()
#Overwrite immediateReindexObject() with a crashing method #Overwrite immediateReindexObject() with a crashing method
def crashingMethod(self): def crashingMethod(self):
...@@ -119,14 +117,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -119,14 +117,6 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
o = self.category_tool.group.newContent(portal_type='Category', o = self.category_tool.group.newContent(portal_type='Category',
id=category_id) id=category_id)
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
default_pref.enable()
return default_pref
def stepRemoveWorkflowsRelated(self, sequence=None, sequence_list=None, def stepRemoveWorkflowsRelated(self, sequence=None, sequence_list=None,
**kw): **kw):
""" """
......
...@@ -33,8 +33,7 @@ from unittest import expectedFailure ...@@ -33,8 +33,7 @@ from unittest import expectedFailure
from Products.CMFCore.WorkflowCore import WorkflowException from Products.CMFCore.WorkflowCore import WorkflowException
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
_getConversionServerDict
from Products.ERP5OOo.tests.testIngestion import FILENAME_REGULAR_EXPRESSION from Products.ERP5OOo.tests.testIngestion import FILENAME_REGULAR_EXPRESSION
from Products.ERP5OOo.tests.testIngestion import REFERENCE_REGULAR_EXPRESSION from Products.ERP5OOo.tests.testIngestion import REFERENCE_REGULAR_EXPRESSION
from email.header import decode_header from email.header import decode_header
...@@ -454,17 +453,11 @@ class TestCRM(BaseTestCRM): ...@@ -454,17 +453,11 @@ class TestCRM(BaseTestCRM):
id=i) id=i)
# create a person like a resource to declare it as a resource # create a person like a resource to declare it as a resource
person = self.portal.person_module.newContent(portal_type='Person') person = self.portal.person_module.newContent(portal_type='Person')
# Configure system preference.
portal_preferences = self.portal.portal_preferences
system_preference = portal_preferences.getActiveSystemPreference()
if system_preference is None:
system_preference = portal_preferences.newContent(
portal_type='System Preference')
system_preference.enable()
resource_list = [category.getRelativeUrl() \ resource_list = [category.getRelativeUrl() \
for category in resource.contentValues()] for category in resource.contentValues()]
resource_list.append(person.getRelativeUrl()) resource_list.append(person.getRelativeUrl())
# XXX this preference is obsolete, this is now based on use category # XXX this preference is obsolete, this is now based on use category
system_preference = self.getDefaultSystemPreference()
system_preference.setPreferredEventResourceList(resource_list) system_preference.setPreferredEventResourceList(resource_list)
self.tic() self.tic()
# Then create One event and play with it # Then create One event and play with it
...@@ -1052,13 +1045,9 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1052,13 +1045,9 @@ class TestCRMMailSend(BaseTestCRM):
default_email_text='me@erp5.org') default_email_text='me@erp5.org')
# set preference # set preference
default_pref = self.portal.portal_preferences.default_site_preference pref = self.getDefaultSystemPreference()
conversion_dict = _getConversionServerDict() pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url']) pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if default_pref.getPreferenceState() == 'disabled':
default_pref.enable()
# make sure customers are available to catalog # make sure customers are available to catalog
self.tic() self.tic()
......
...@@ -30,8 +30,7 @@ ...@@ -30,8 +30,7 @@
import unittest import unittest
import transaction import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
_getConversionServerDict
class TestERP5WebWithCRM(ERP5TypeTestCase): class TestERP5WebWithCRM(ERP5TypeTestCase):
...@@ -55,24 +54,9 @@ class TestERP5WebWithCRM(ERP5TypeTestCase): ...@@ -55,24 +54,9 @@ class TestERP5WebWithCRM(ERP5TypeTestCase):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
self.setSystemPreference()
user = self.createUser('robby') user = self.createUser('robby')
self.createUserAssignment(user, {}) 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.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
if self.portal.portal_workflow.isTransitionPossible(preference, 'enable'):
preference.enable()
def clearModule(self, module): def clearModule(self, module):
module.manage_delObjects(list(module.objectIds())) module.manage_delObjects(list(module.objectIds()))
self.tic() self.tic()
......
...@@ -40,8 +40,7 @@ import transaction ...@@ -40,8 +40,7 @@ import transaction
from AccessControl import Unauthorized from AccessControl import Unauthorized
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
_getConversionServerDict
from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript
from Products.ERP5.Document.Document import ConversionError from Products.ERP5.Document.Document import ConversionError
...@@ -145,19 +144,10 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -145,19 +144,10 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
self.setDefaultSitePreference()
self.web_page_module = self.portal.web_page_module self.web_page_module = self.portal.web_page_module
self.web_site_module = self.portal.web_site_module self.web_site_module = self.portal.web_site_module
self.portal_id = self.portal.getId() self.portal_id = self.portal.getId()
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
default_pref.enable()
return default_pref
def clearModule(self, module): def clearModule(self, module):
module.manage_delObjects(list(module.objectIds())) module.manage_delObjects(list(module.objectIds()))
self.tic() self.tic()
......
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
############################################################################## ##############################################################################
import unittest import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
_getConversionServerDict
import urlnorm # This library is imported to detect lack of import urlnorm # This library is imported to detect lack of
# urlnorm availibility in python environment # urlnorm availibility in python environment
...@@ -44,7 +43,6 @@ class TestWebCrawler(ERP5TypeTestCase): ...@@ -44,7 +43,6 @@ class TestWebCrawler(ERP5TypeTestCase):
""" """
_path_to_delete_list = [] _path_to_delete_list = []
system_pref_id = 'my_preference'
def getTitle(self): def getTitle(self):
""" """
...@@ -89,20 +87,9 @@ class TestWebCrawler(ERP5TypeTestCase): ...@@ -89,20 +87,9 @@ class TestWebCrawler(ERP5TypeTestCase):
self.tic() self.tic()
def setSystemPreference(self): def setSystemPreference(self):
portal_preferences = self.portal.portal_preferences pref = self.getDefaultSystemPreference()
system_preference = portal_preferences._getOb(self.system_pref_id, None) pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
if system_preference is None: pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
system_preference = portal_preferences.newContent(id=self.system_pref_id,
portal_type='System Preference')
conversion_dict = _getConversionServerDict()
system_preference.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
system_preference.setPreferredDocumentFilenameRegularExpression(
FILENAME_REGULAR_EXPRESSION)
system_preference.setPreferredDocumentReferenceRegularExpression(
REFERENCE_REGULAR_EXPRESSION)
if system_preference.getPreferenceState() != 'global':
system_preference.enable()
def bootstrapWebSite(self): def bootstrapWebSite(self):
"""Create 1 Website """Create 1 Website
...@@ -275,8 +262,7 @@ class TestWebCrawler(ERP5TypeTestCase): ...@@ -275,8 +262,7 @@ class TestWebCrawler(ERP5TypeTestCase):
self.assertFalse(len(new_web_crawler)) self.assertFalse(len(new_web_crawler))
# set another namespace on preference # set another namespace on preference
preference = self.portal.portal_preferences[self.system_pref_id] self.getDefaultSystemPreference().setPreferredIngestionNamespace('NEW')
preference.setPreferredIngestionNamespace('NEW')
self.tic() self.tic()
new_web_crawler.crawlContent() new_web_crawler.crawlContent()
self.tic() self.tic()
......
...@@ -32,7 +32,6 @@ from DateTime import DateTime ...@@ -32,7 +32,6 @@ from DateTime import DateTime
from AccessControl import Unauthorized from AccessControl import Unauthorized
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
...@@ -117,30 +116,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase): ...@@ -117,30 +116,8 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
# it is required by SecurityTestCase # it is required by SecurityTestCase
self.workflow_tool = self.portal.portal_workflow self.workflow_tool = self.portal.portal_workflow
self.setDefaultSitePreference()
self.setSystemPreference()
self.portal.portal_activities.unsubscribe() 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.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
if self.portal.portal_workflow.isTransitionPossible(preference, 'enable'):
preference.enable()
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
default_pref.enable()
return default_pref
def beforeTearDown(self): def beforeTearDown(self):
self.portal.portal_activities.subscribe() self.portal.portal_activities.subscribe()
ERP5TypeTestCase.beforeTearDown(self) ERP5TypeTestCase.beforeTearDown(self)
......
...@@ -86,18 +86,18 @@ class OOoServerProxy(ServerProxy): ...@@ -86,18 +86,18 @@ class OOoServerProxy(ServerProxy):
def __init__(self, context): def __init__(self, context):
preference_tool = getToolByName(context, 'portal_preferences') preference_tool = getToolByName(context, 'portal_preferences')
uri = getattr(preference_tool, "getPreferredDocumentConversionServerUrl", str)() uri = preference_tool.getPreferredDocumentConversionServerUrl()
if uri in ('', None): if not uri:
address = preference_tool.getPreferredOoodocServerAddress() address = preference_tool.getPreferredOoodocServerAddress()
port = preference_tool.getPreferredOoodocServerPortNumber() port = preference_tool.getPreferredOoodocServerPortNumber()
if address in ('', None) or port in ('', None) : if not (address and port):
raise ConversionError('OOoDocument: cannot proceed with conversion:' raise ConversionError('OOoDocument: cannot proceed with conversion:'
' conversion server url is not defined in preferences') ' conversion server url is not defined in preferences')
LOG('OOoDocument', WARNING, 'PreferredOoodocServer{Address,PortNumber}' + \ LOG('OOoDocument', WARNING, 'PreferredOoodocServer{Address,PortNumber}' + \
' are DEPRECATED please use PreferredDocumentServerUrl instead', error=True) ' are DEPRECATED please use PreferredDocumentServerUrl instead', error=True)
scheme = "http" scheme = "http"
uri = 'http://%s:%d' % (address, port) uri = '%s://%s:%s' % (scheme, address, port)
else: else:
if uri.startswith("http://"): if uri.startswith("http://"):
scheme = "http" scheme = "http"
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from StringIO import StringIO from StringIO import StringIO
...@@ -47,14 +46,6 @@ class TestFormPrintoutMixin(ERP5TypeTestCase): ...@@ -47,14 +46,6 @@ class TestFormPrintoutMixin(ERP5TypeTestCase):
user = uf.getUserById('zope').__of__(uf) user = uf.getUserById('zope').__of__(uf)
newSecurityManager(None, user) newSecurityManager(None, user)
def setSystemPreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
#default_pref.setPreferredConversionCacheFactory('document_cache_factory')
if default_pref.getPreferenceState() != 'global':
default_pref.enable()
def _validate(self, odf_file_data): def _validate(self, odf_file_data):
error_list = self.validator.validate(odf_file_data) error_list = self.validator.validate(odf_file_data)
if error_list: if error_list:
......
...@@ -54,7 +54,6 @@ from unittest import expectedFailure ...@@ -54,7 +54,6 @@ from unittest import expectedFailure
import ZPublisher.HTTPRequest import ZPublisher.HTTPRequest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase 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 FileUpload
from Products.ERP5Type.tests.utils import DummyLocalizer from Products.ERP5Type.tests.utils import DummyLocalizer
from Products.ERP5OOo.OOoUtils import OOoBuilder from Products.ERP5OOo.OOoUtils import OOoBuilder
...@@ -115,40 +114,27 @@ class TestDocumentMixin(ERP5TypeTestCase): ...@@ -115,40 +114,27 @@ class TestDocumentMixin(ERP5TypeTestCase):
def afterSetUp(self): def afterSetUp(self):
TestDocumentMixin.login(self) TestDocumentMixin.login(self)
self.setDefaultSitePreference()
self.setSystemPreference() self.setSystemPreference()
self.tic() self.tic()
self.login() self.login()
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
default_pref.enable()
return default_pref
def setSystemPreference(self): def setSystemPreference(self):
portal_type = 'System Preference' pref = self.getDefaultSystemPreference()
preference_list = self.portal.portal_preferences.contentValues( id = self.__class__.__name__
portal_type=portal_type) if pref.getPreferredConversionCacheFactory() != id:
if not preference_list: try:
# create a Cache Factory for tests self.portal.portal_caches[id]
cache_factory = self.portal.portal_caches.newContent(portal_type = 'Cache Factory') except KeyError:
self.setCacheFactory(
self.portal.portal_caches.newContent(id, 'Cache Factory'))
pref.setPreferredConversionCacheFactory(id)
pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
def setCacheFactory(self, cache_factory):
cache_factory.cache_duration = 36000 cache_factory.cache_duration = 36000
cache_plugin = cache_factory.newContent(portal_type='Ram Cache') cache_plugin = cache_factory.newContent(portal_type='Ram Cache')
cache_plugin.cache_expire_check_interval = 54000 cache_plugin.cache_expire_check_interval = 54000
preference = self.portal.portal_preferences.newContent(title="Default System Preference",
# use local RAM based cache as some tests need it
preferred_conversion_cache_factory = cache_factory.getId(),
portal_type=portal_type)
else:
preference = preference_list[0]
if self.portal.portal_workflow.isTransitionPossible(preference, 'enable'):
preference.enable()
return preference
def getDocumentModule(self): def getDocumentModule(self):
return getattr(self.getPortal(),'document_module') return getattr(self.getPortal(),'document_module')
......
...@@ -41,17 +41,13 @@ class TestDocumentWithFlare(TestDocument): ...@@ -41,17 +41,13 @@ class TestDocumentWithFlare(TestDocument):
def getTitle(self): def getTitle(self):
return "DMS with Flare" return "DMS with Flare"
def setSystemPreference(self): def setCacheFactory(self, cache_factory):
system_preference = TestDocument.setSystemPreference(self)
memcached = _getPersistentMemcachedServerDict() memcached = _getPersistentMemcachedServerDict()
# create a Cache Factory for tests
cache_factory = self.portal.portal_caches.newContent(portal_type = 'Cache Factory')
cache_factory.cache_duration = 15768000 cache_factory.cache_duration = 15768000
cache_plugin = cache_factory.newContent(portal_type='Distributed Ram Cache') plugin = self.portal.portal_memcached.persistent_memcached_plugin
system_preference.setPreferredConversionCacheFactory(cache_factory.getId()) plugin.setUrlString('%(hostname)s:%(port)s' % memcached)
persistent_memcached_plugin = self.portal.portal_memcached.persistent_memcached_plugin cache_factory.newContent(portal_type='Distributed Ram Cache',
persistent_memcached_plugin.setUrlString('%s:%s' %(memcached['hostname'], memcached['port'])) specialise_value=plugin)
cache_plugin.setSpecialiseValue(persistent_memcached_plugin)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
...@@ -55,7 +55,6 @@ class TestFormPrintoutAsODG(TestFormPrintoutMixin): ...@@ -55,7 +55,6 @@ class TestFormPrintoutAsODG(TestFormPrintoutMixin):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
self.setSystemPreference()
# XML validator # XML validator
v12schema_url = os.path.join(os.path.dirname(__file__), v12schema_url = os.path.join(os.path.dirname(__file__),
'OpenDocument-v1.2-os-schema.rng') 'OpenDocument-v1.2-os-schema.rng')
......
...@@ -51,7 +51,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin): ...@@ -51,7 +51,6 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
self.setSystemPreference()
# XML validator # XML validator
v12schema_url = os.path.join(os.path.dirname(__file__), v12schema_url = os.path.join(os.path.dirname(__file__),
'OpenDocument-v1.2-os-schema.rng') 'OpenDocument-v1.2-os-schema.rng')
......
...@@ -34,8 +34,8 @@ import os ...@@ -34,8 +34,8 @@ import os
from lxml import etree from lxml import etree
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.Utils import convertToUpperCase from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\ from Products.ERP5Type.tests.ERP5TypeTestCase import (
_getConversionServerDict ERP5TypeTestCase, _getConversionServerUrl)
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript
from Products.ERP5OOo.OOoUtils import OOoBuilder from Products.ERP5OOo.OOoUtils import OOoBuilder
...@@ -138,13 +138,9 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -138,13 +138,9 @@ class TestIngestion(ERP5TypeTestCase):
self.commit() self.commit()
def setSystemPreference(self): def setSystemPreference(self):
default_pref = self.portal.portal_preferences.default_site_preference default_pref = self.getDefaultSystemPreference()
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION) default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION) default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if default_pref.getPreferenceState() != 'global':
default_pref.enable()
def setSimulatedNotificationScript(self, sequence=None, sequence_list=None, **kw): def setSimulatedNotificationScript(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -1044,8 +1040,8 @@ class TestIngestion(ERP5TypeTestCase): ...@@ -1044,8 +1040,8 @@ class TestIngestion(ERP5TypeTestCase):
Make sure that preferences are set up properly and accessible Make sure that preferences are set up properly and accessible
""" """
preference_tool = self.portal.portal_preferences preference_tool = self.portal.portal_preferences
conversion_dict = _getConversionServerDict() self.assertEqual(preference_tool.getPreferredDocumentConversionServerUrl(),
self.assertEqual(preference_tool.getPreferredDocumentConversionServerUrl(), conversion_dict['url']) _getConversionServerUrl())
self.assertEqual(preference_tool.getPreferredDocumentFilenameRegularExpression(), FILENAME_REGULAR_EXPRESSION) self.assertEqual(preference_tool.getPreferredDocumentFilenameRegularExpression(), FILENAME_REGULAR_EXPRESSION)
self.assertEqual(preference_tool.getPreferredDocumentReferenceRegularExpression(), REFERENCE_REGULAR_EXPRESSION) self.assertEqual(preference_tool.getPreferredDocumentReferenceRegularExpression(), REFERENCE_REGULAR_EXPRESSION)
......
...@@ -54,6 +54,10 @@ class TestOoodResponse(ERP5TypeTestCase): ...@@ -54,6 +54,10 @@ class TestOoodResponse(ERP5TypeTestCase):
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
# disable pref that configures the conversion server
pref = self.getDefaultSystemPreference()
if pref.getPreferenceState() != 'disabled':
pref.disable()
portal_skins = self.getSkinsTool() portal_skins = self.getSkinsTool()
import_file_path = os.path.join(os.path.dirname(__file__), import_file_path = os.path.join(os.path.dirname(__file__),
'test_document', 'test_document',
......
...@@ -32,11 +32,9 @@ import os ...@@ -32,11 +32,9 @@ import os
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase 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 FileUpload
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5OOo.OOoUtils import OOoParser from Products.ERP5OOo.OOoUtils import OOoParser
from Products.ERP5Form.PreferenceTool import Priority
from DateTime import DateTime from DateTime import DateTime
def makeFilePath(name): def makeFilePath(name):
...@@ -55,13 +53,6 @@ class TestOOoImportMixin(ERP5TypeTestCase): ...@@ -55,13 +53,6 @@ class TestOOoImportMixin(ERP5TypeTestCase):
Initialize the ERP5 site. Initialize the ERP5 site.
""" """
self.login() self.login()
self.pref = self.portal.portal_preferences.newContent(
portal_type='System Preference')
conversion_dict = _getConversionServerDict()
self.pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
self.pref.setPriority(Priority.SITE)
self.pref.enable()
# create browser_id_manager # create browser_id_manager
if not "browser_id_manager" in self.portal.objectIds(): if not "browser_id_manager" in self.portal.objectIds():
self.portal.manage_addProduct['Sessions'].constructBrowserIdManager() self.portal.manage_addProduct['Sessions'].constructBrowserIdManager()
...@@ -100,8 +91,6 @@ class TestOOoImportMixin(ERP5TypeTestCase): ...@@ -100,8 +91,6 @@ class TestOOoImportMixin(ERP5TypeTestCase):
self.portal.portal_categories.region, self.portal.portal_categories.region,
]: ]:
parent.deleteContent(list(parent.objectIds())) parent.deleteContent(list(parent.objectIds()))
self.portal.portal_preferences.manage_delObjects([self.pref.getId()])
self.tic() self.tic()
class TestOOoImport(TestOOoImportMixin): class TestOOoImport(TestOOoImportMixin):
......
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
############################################################################## ##############################################################################
import unittest import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase, \ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
_getConversionServerDict
from Products.ERP5Type.tests.utils import DummyLocalizer from Products.ERP5Type.tests.utils import DummyLocalizer
from Products.ERP5Form.Selection import Selection from Products.ERP5Form.Selection import Selection
from Testing import ZopeTestCase from Testing import ZopeTestCase
...@@ -54,8 +53,6 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -54,8 +53,6 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
if not self.skin: if not self.skin:
raise NotImplementedError('Subclasses must define skin') raise NotImplementedError('Subclasses must define skin')
self.setDefaultSitePreference()
gender = self.portal.portal_categories.gender gender = self.portal.portal_categories.gender
if 'male' not in gender.objectIds(): if 'male' not in gender.objectIds():
gender.newContent(id='male') gender.newContent(id='male')
...@@ -86,14 +83,6 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -86,14 +83,6 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
name = 'person_module_selection' name = 'person_module_selection'
self.portal.portal_selections.setSelectionFor(name, Selection(name)) 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.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
default_pref.enable()
return default_pref
def publish(self, *args, **kw): def publish(self, *args, **kw):
kw['handle_errors'] = not debug kw['handle_errors'] = not debug
return super(TestOOoStyle, self).publish(*args, **kw) return super(TestOOoStyle, self).publish(*args, **kw)
......
...@@ -35,7 +35,6 @@ import unittest ...@@ -35,7 +35,6 @@ import unittest
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.runUnitTest import tests_home from Products.ERP5Type.tests.runUnitTest import tests_home
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5SyncML.Tool import SynchronizationTool from Products.ERP5SyncML.Tool import SynchronizationTool
from Products.ERP5SyncML.tests.testERP5SyncML import TestERP5SyncMLMixin from Products.ERP5SyncML.tests.testERP5SyncML import TestERP5SyncMLMixin
...@@ -149,8 +148,6 @@ class TestERP5DocumentSyncMLMixin(TestERP5SyncMLMixin): ...@@ -149,8 +148,6 @@ class TestERP5DocumentSyncMLMixin(TestERP5SyncMLMixin):
def setSystemPreferences(self): def setSystemPreferences(self):
default_pref = self.portal.portal_preferences.default_site_preference default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredDocumentFileNameRegularExpression(FILENAME_REGULAR_EXPRESSION) default_pref.setPreferredDocumentFileNameRegularExpression(FILENAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION) default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if default_pref.getPreferenceState() == 'disabled': if default_pref.getPreferenceState() == 'disabled':
......
...@@ -37,8 +37,7 @@ import shutil ...@@ -37,8 +37,7 @@ import shutil
import transaction import transaction
from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.HTTPResponse import HTTPResponse
from zExceptions.ExceptionFormatter import format_exception from zExceptions.ExceptionFormatter import format_exception
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase, \ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
_getConversionServerDict
from Products.ERP5Type.Utils import stopProcess, PR_SET_PDEATHSIG from Products.ERP5Type.Utils import stopProcess, PR_SET_PDEATHSIG
from lxml import etree from lxml import etree
from lxml.html import builder as E from lxml.html import builder as E
...@@ -250,13 +249,9 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase): ...@@ -250,13 +249,9 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
self.portal, self.run_only) self.portal, self.run_only)
def setSystemPreference(self): def setSystemPreference(self):
conversion_dict = _getConversionServerDict()
self.portal.Zuite_setPreference( self.portal.Zuite_setPreference(
working_copy_list=bt5_dir_list, working_copy_list=bt5_dir_list,
conversion_server_url=conversion_dict['url'],
) )
# XXX Memcached is missing
# XXX Persistent cache setup is missing
def _verboseErrorLog(self, size=10): def _verboseErrorLog(self, size=10):
for entry in self.portal.error_log.getLogEntries()[:size]: for entry in self.portal.error_log.getLogEntries()[:size]:
......
...@@ -60,6 +60,7 @@ from Testing.ZopeTestCase import PortalTestCase, user_name ...@@ -60,6 +60,7 @@ from Testing.ZopeTestCase import PortalTestCase, user_name
from Products.DCWorkflow.DCWorkflow import ValidationFailed from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.PythonScripts.PythonScript import PythonScript from Products.PythonScripts.PythonScript import PythonScript
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
from Products.ERP5Form.PreferenceTool import Priority
from zLOG import LOG, DEBUG from zLOG import LOG, DEBUG
from Products.ERP5Type.tests.backportUnittest import SetupSiteError from Products.ERP5Type.tests.backportUnittest import SetupSiteError
...@@ -127,17 +128,17 @@ def _getConnectionStringDict(): ...@@ -127,17 +128,17 @@ def _getConnectionStringDict():
os.environ.get(connection, '-' + connection_string) os.environ.get(connection, '-' + connection_string)
return connection_string_dict return connection_string_dict
def _getConversionServerDict(): def _getConversionServerUrl():
""" Returns a dict with url for Conversion Server (Oood) """ Return the url for Conversion Server (Cloudooo)
""" """
conversion_server_url = os.environ.get('conversion_server_url') url = os.environ.get('conversion_server_url')
conversion_server_hostname = os.environ.get('conversion_server_hostname', if not url: # BBB
'localhost') url = os.environ['conversion_server_url'] = 'http://%s:%s' % (
conversion_server_port = os.environ.get('conversion_server_port', os.environ.get('conversion_server_hostname', 'localhost'),
'8008') os.environ.get('conversion_server_port', 8008))
return dict(url=conversion_server_url, warn('conversion_server_hostname/conversion_server_port are deprecated.\n'
hostname=conversion_server_hostname, 'Using %s as conversion_server_url instead' % url, DeprecationWarning)
port=int(conversion_server_port)) return url
def _getVolatileMemcachedServerDict(): def _getVolatileMemcachedServerDict():
"""Returns a dict with hostname and port for volatile memcached Server """Returns a dict with hostname and port for volatile memcached Server
...@@ -157,10 +158,10 @@ def _getPersistentMemcachedServerDict(): ...@@ -157,10 +158,10 @@ def _getPersistentMemcachedServerDict():
def _createTestPromiseConfigurationFile(promise_path, bt5_repository_path_list=None): def _createTestPromiseConfigurationFile(promise_path, bt5_repository_path_list=None):
kumofs_url = "memcached://%(hostname)s:%(port)s/" % \ kumofs_url = "memcached://%(hostname)s:%(port)s/" % \
_getVolatileMemcachedServerDict()
memcached_url = "memcached://%(hostname)s:%(port)s/" % \
_getPersistentMemcachedServerDict() _getPersistentMemcachedServerDict()
cloudooo_url = _getConversionServerDict()['url'] memcached_url = "memcached://%(hostname)s:%(port)s/" % \
_getVolatileMemcachedServerDict()
cloudooo_url = _getConversionServerUrl()
promise_config = ConfigParser.RawConfigParser() promise_config = ConfigParser.RawConfigParser()
promise_config.add_section('external_service') promise_config.add_section('external_service')
...@@ -332,10 +333,16 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): ...@@ -332,10 +333,16 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
def unpinDateTime(self): def unpinDateTime(self):
self.pinDateTime(None) self.pinDateTime(None)
def getDefaultSitePreferenceId(self): def getDefaultSystemPreference(self):
"""Default id, usefull method to override id = 'default_system_preference'
""" tool = self.getPreferenceTool()
return "default_site_preference" try:
pref = tool[id]
except KeyError:
pref = tool.newContent(id, 'System Preference')
pref.setPriority(Priority.SITE)
pref.enable()
return pref
# Utility methods specific to ERP5Type # Utility methods specific to ERP5Type
def getTemplateTool(self): def getTemplateTool(self):
...@@ -907,12 +914,11 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin): ...@@ -907,12 +914,11 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
getattr(self.portal, connection_name).edit('', connection_string) getattr(self.portal, connection_name).edit('', connection_string)
def _updateConversionServerConfiguration(self): def _updateConversionServerConfiguration(self):
"""Update conversion server (Oood) at default site preferences. """Update conversion server (Cloudooo) at default site preferences.
""" """
conversion_dict = _getConversionServerDict() url = _getConversionServerUrl()
preference = self.portal.portal_preferences[ pref = self.getDefaultSystemPreference()
self.getDefaultSitePreferenceId()] pref._setPreferredDocumentConversionServerUrl(url)
preference._setPreferredDocumentConversionServerUrl(conversion_dict['url'])
def _updateMemcachedConfiguration(self): def _updateMemcachedConfiguration(self):
"""Update default memcached plugin configuration """Update default memcached plugin configuration
......
...@@ -10,7 +10,6 @@ import signal ...@@ -10,7 +10,6 @@ import signal
import shutil import shutil
import errno import errno
import random import random
from warnings import warn
import transaction import transaction
from glob import glob from glob import glob
try: try:
...@@ -739,9 +738,6 @@ def main(argument_list=None): ...@@ -739,9 +738,6 @@ def main(argument_list=None):
bt5_path_list = [] bt5_path_list = []
conversion_server_hostname = None
conversion_server_port = None
for opt, arg in opts: for opt, arg in opts:
if opt in ("-v", "--verbose"): if opt in ("-v", "--verbose"):
os.environ['VERBOSE'] = "1" os.environ['VERBOSE'] = "1"
...@@ -807,9 +803,9 @@ def main(argument_list=None): ...@@ -807,9 +803,9 @@ def main(argument_list=None):
elif opt == "--conversion_server_url": elif opt == "--conversion_server_url":
os.environ["conversion_server_url"] = arg os.environ["conversion_server_url"] = arg
elif opt == "--conversion_server_hostname": elif opt == "--conversion_server_hostname":
conversion_server_hostname = arg os.environ["conversion_server_hostname"] = arg
elif opt == "--conversion_server_port": elif opt == "--conversion_server_port":
conversion_server_port = arg os.environ["conversion_server_port"] = arg
elif opt == "--volatile_memcached_server_hostname": elif opt == "--volatile_memcached_server_hostname":
os.environ["volatile_memcached_server_hostname"] = arg os.environ["volatile_memcached_server_hostname"] = arg
elif opt == "--volatile_memcached_server_port": elif opt == "--volatile_memcached_server_port":
...@@ -844,17 +840,6 @@ def main(argument_list=None): ...@@ -844,17 +840,6 @@ def main(argument_list=None):
elif opt == "--instance_home": elif opt == "--instance_home":
instance_home = os.path.abspath(arg) instance_home = os.path.abspath(arg)
# BBB rewrite deprecated conversion_server_hostname / conversion_server_port into
# the equivalent conversion_server_url
if conversion_server_hostname and conversion_server_port and \
not os.environ.get('conversion_server_url'):
conversion_server_url = 'http://%s:%s' % (
conversion_server_hostname, conversion_server_port)
warn('conversion_server_hostname/conversion_server_port are deprecated.\n'
'Using %s as conversion_server_url instead' % conversion_server_url,
DeprecationWarning)
os.environ['conversion_server_url'] = conversion_server_url
bt5_path_list += filter(None, bt5_path_list += filter(None,
os.environ.get("erp5_tests_bt5_path", "").split(',')) os.environ.get("erp5_tests_bt5_path", "").split(','))
valid_path_list = [] valid_path_list = []
......
...@@ -31,6 +31,9 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase ...@@ -31,6 +31,9 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestERP5Promise(ERP5TypeTestCase): class TestERP5Promise(ERP5TypeTestCase):
def _updateConversionServerConfiguration(self):
pass
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
""" """
Return the list of business templates. Return the list of business templates.
...@@ -38,8 +41,7 @@ class TestERP5Promise(ERP5TypeTestCase): ...@@ -38,8 +41,7 @@ class TestERP5Promise(ERP5TypeTestCase):
return ("erp5_promise", "erp5_base") return ("erp5_promise", "erp5_base")
def _test_promise_alarm(self, alarm_id): def _test_promise_alarm(self, alarm_id):
alarm = getattr(self.portal.portal_alarms, alarm_id, None) alarm = self.portal.portal_alarms[alarm_id]
self.assertNotEquals(alarm, None, "Alarm %s not found" % alarm_id)
alarm.activeSense() alarm.activeSense()
self.tic() self.tic()
self.assertTrue(alarm.sense()) self.assertTrue(alarm.sense())
...@@ -56,6 +58,7 @@ class TestERP5Promise(ERP5TypeTestCase): ...@@ -56,6 +58,7 @@ class TestERP5Promise(ERP5TypeTestCase):
self._test_promise_alarm("promise_kumofs_server") self._test_promise_alarm("promise_kumofs_server")
def test_promise_memcached_server(self): def test_promise_memcached_server(self):
self.portal.portal_memcached.default_memcached_plugin.setUrlString(None)
self._test_promise_alarm("promise_memcached_server") self._test_promise_alarm("promise_memcached_server")
def test_promise_certificate_autority_tool(self): def test_promise_certificate_autority_tool(self):
......
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