Commit 2cf95f9e authored by Jérome Perrin's avatar Jérome Perrin Committed by Julien Muchembled

configure cloudooo by URL in default preference

Since !306 we have configured system preference to use cloudoo from the Slapos SR, but this configuration was still old style configuration setting host / port.

It caused a test to fail 
```
======================================================================
FAIL: test_01_PreferenceSetup (testIngestion.TestIngestion)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/srv/slapgrid/slappart7/srv/testnode/aai/soft/f030becfa6e3878c62ccb9bccc43a291/parts/erp5/Products/ERP5OOo/tests/testIngestion.py", line 1048, in test_01_PreferenceSetup
    self.assertEqual(preference_tool.getPreferredOoodocServerAddress(), conversion_dict['hostname'])
AssertionError: 'erp5-cloudooo' != 'localhost'
```

and that was a problem with the test, we don't have to care about `getPreferredOoodocServerAddress`, as only URL matters now (it was just working because both were set to localhost).

/reviewed-on !315
parents e705e5d0 f84f4cdb
......@@ -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.ERP5Configurator.tests.ConfiguratorTestMixin import \
TestLiveConfiguratorWorkflowMixin
......@@ -184,10 +184,9 @@ class TestRunMyDocsConfiguratorWorkflowMixin(TestLiveConfiguratorWorkflowMixin):
def stepCheckSystemPreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw):
""" Check System Preference"""
system_preference = self.portal.portal_catalog.getResultValue(portal_type="System Preference")
conversion_dict = _getConversionServerDict()
system_preference = self.getDefaultSystemPreference()
self.assertEqual(system_preference.getPreferredDocumentConversionServerUrl(),
conversion_dict['url'])
_getConversionServerUrl())
def _stepCheckKnowledgePadRole(self):
""" Check if Knowledge Pad is configured correctly """
......
......@@ -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.ERP5Configurator.tests.ConfiguratorTestMixin import \
TestLiveConfiguratorWorkflowMixin
......@@ -211,10 +211,9 @@ class TestUNGConfiguratorWorkflowMixin(TestLiveConfiguratorWorkflowMixin):
def stepCheckSystemPreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw):
""" Check System Preference"""
system_preference = self.portal.portal_catalog.getResultValue(portal_type="System Preference")
conversion_dict = _getConversionServerDict()
system_preference = self.getDefaultSystemPreference()
self.assertEqual(system_preference.getPreferredDocumentConversionServerUrl(),
conversion_dict['url'])
_getConversionServerUrl())
def stepCheckSitePreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw):
""" Check Site Preference"""
......
......@@ -28,7 +28,6 @@
##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeLiveTestCase import ERP5TypeLiveTestCase
from Products.CMFCore.utils import getToolByName
import random
......@@ -73,14 +72,9 @@ class TestIngestion(ERP5TypeLiveTestCase):
self.tic()
def setSystemPreference(self):
portal_preferences = getToolByName(self.portal, 'portal_preferences')
default_pref = portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredDocumentFileNameRegularExpression(FILE_NAME_REGULAR_EXPRESSION)
default_pref = self.getDefaultSystemPreference()
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if default_pref.getPreferenceState() != 'global':
default_pref.enable()
def contributeFileWithUrl(self, script_id, filename=None):
"""compute url and call portal_contributions.newContentFromUrl
......
......@@ -5,9 +5,6 @@ subversion working copy paths and conversion server address.
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)
if pref is None:
pref = context.portal_preferences.newContent(id="erp5_ui_test_preference",
......@@ -17,17 +14,6 @@ if pref is None:
pref.setPreferredSubversionWorkingCopyList(tuple(working_copy_list.split(',')))
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':
pref.enable()
......
......@@ -50,7 +50,7 @@
</item>
<item>
<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>
<key> <string>id</string> </key>
......
......@@ -28,7 +28,6 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.ERP5TypeTestCase import _getConversionServerDict
from DateTime import DateTime
import os.path
import Products.ERP5.tests
......@@ -450,18 +449,10 @@ class TestUNG(ERP5TypeTestCase):
""" Test if script load correctly the Web Page with data of one document
"""
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()
file = FileUpload(document_path, filename)
document = portal_contributions.newContent(file=file)
web_page = web_page_module.newContent(portal_type="Web Page")
document = portal.portal_contributions.newContent(file=file)
web_page = portal.web_page_module.newContent(portal_type="Web Page")
self.tic()
self.changeSkin("UNGDoc")
web_page.WebPage_updateWebDocument(document.getPath())
......
......@@ -323,12 +323,8 @@ It\'s the lowest priority one; ie. managers can create higher priority preferenc
<value> <int>10</int> </value>
</item>
<item>
<key> <string>preferred_ooodoc_server_address</string> </key>
<value> <string>erp5-cloudooo</string> </value>
</item>
<item>
<key> <string>preferred_ooodoc_server_port_number</string> </key>
<value> <int>2020</int> </value>
<key> <string>preferred_document_conversion_server_url</string> </key>
<value> <string>http://erp5-cloudooo:2020</string> </value>
</item>
<item>
<key> <string>preferred_quantity_field_width</string> </key>
......
......@@ -33,8 +33,7 @@ import os
from unittest import skip
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl import getSecurityManager
from Products.ERP5Type.tests.Sequence import SequenceList
......@@ -93,7 +92,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):
......@@ -119,14 +117,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.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,
**kw):
"""
......
......@@ -33,8 +33,7 @@ from unittest import expectedFailure
from Products.CMFCore.WorkflowCore import WorkflowException
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5OOo.tests.testIngestion import FILENAME_REGULAR_EXPRESSION
from Products.ERP5OOo.tests.testIngestion import REFERENCE_REGULAR_EXPRESSION
from email.header import decode_header
......@@ -454,17 +453,11 @@ class TestCRM(BaseTestCRM):
id=i)
# create a person like a resource to declare it as a resource
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() \
for category in resource.contentValues()]
resource_list.append(person.getRelativeUrl())
# XXX this preference is obsolete, this is now based on use category
system_preference = self.getDefaultSystemPreference()
system_preference.setPreferredEventResourceList(resource_list)
self.tic()
# Then create One event and play with it
......@@ -1052,13 +1045,9 @@ class TestCRMMailSend(BaseTestCRM):
default_email_text='me@erp5.org')
# set 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.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
if default_pref.getPreferenceState() == 'disabled':
default_pref.enable()
pref = self.getDefaultSystemPreference()
pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
# make sure customers are available to catalog
self.tic()
......
......@@ -30,8 +30,7 @@
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestERP5WebWithCRM(ERP5TypeTestCase):
......@@ -55,24 +54,9 @@ class TestERP5WebWithCRM(ERP5TypeTestCase):
def afterSetUp(self):
self.login()
self.setSystemPreference()
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.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
if self.portal.portal_workflow.isTransitionPossible(preference, 'enable'):
preference.enable()
def clearModule(self, module):
module.manage_delObjects(list(module.objectIds()))
self.tic()
......
......@@ -40,8 +40,7 @@ import transaction
from AccessControl import Unauthorized
from AccessControl.SecurityManagement import newSecurityManager
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript
from Products.ERP5.Document.Document import ConversionError
......@@ -145,19 +144,10 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
def afterSetUp(self):
self.login()
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.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
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()
......
......@@ -28,8 +28,7 @@
##############################################################################
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
import urlnorm # This library is imported to detect lack of
# urlnorm availibility in python environment
......@@ -44,7 +43,6 @@ class TestWebCrawler(ERP5TypeTestCase):
"""
_path_to_delete_list = []
system_pref_id = 'my_preference'
def getTitle(self):
"""
......@@ -89,20 +87,9 @@ class TestWebCrawler(ERP5TypeTestCase):
self.tic()
def setSystemPreference(self):
portal_preferences = self.portal.portal_preferences
system_preference = portal_preferences._getOb(self.system_pref_id, None)
if system_preference is None:
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()
pref = self.getDefaultSystemPreference()
pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
def bootstrapWebSite(self):
"""Create 1 Website
......@@ -275,8 +262,7 @@ class TestWebCrawler(ERP5TypeTestCase):
self.assertFalse(len(new_web_crawler))
# set another namespace on preference
preference = self.portal.portal_preferences[self.system_pref_id]
preference.setPreferredIngestionNamespace('NEW')
self.getDefaultSystemPreference().setPreferredIngestionNamespace('NEW')
self.tic()
new_web_crawler.crawlContent()
self.tic()
......
......@@ -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):
......@@ -117,30 +116,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.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):
self.portal.portal_activities.subscribe()
ERP5TypeTestCase.beforeTearDown(self)
......
......@@ -86,18 +86,18 @@ class OOoServerProxy(ServerProxy):
def __init__(self, context):
preference_tool = getToolByName(context, 'portal_preferences')
uri = getattr(preference_tool, "getPreferredDocumentConversionServerUrl", str)()
if uri in ('', None):
uri = preference_tool.getPreferredDocumentConversionServerUrl()
if not uri:
address = preference_tool.getPreferredOoodocServerAddress()
port = preference_tool.getPreferredOoodocServerPortNumber()
if address in ('', None) or port in ('', None) :
if not (address and port):
raise ConversionError('OOoDocument: cannot proceed with conversion:'
' conversion server url is not defined in preferences')
LOG('OOoDocument', WARNING, 'PreferredOoodocServer{Address,PortNumber}' + \
' are DEPRECATED please use PreferredDocumentServerUrl instead', error=True)
scheme = "http"
uri = 'http://%s:%d' % (address, port)
uri = '%s://%s:%s' % (scheme, address, port)
else:
if uri.startswith("http://"):
scheme = "http"
......
......@@ -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,14 +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.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
#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 unittest import expectedFailure
import ZPublisher.HTTPRequest
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
......@@ -115,40 +114,27 @@ class TestDocumentMixin(ERP5TypeTestCase):
def afterSetUp(self):
TestDocumentMixin.login(self)
self.setDefaultSitePreference()
self.setSystemPreference()
self.tic()
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):
portal_type = 'System Preference'
preference_list = self.portal.portal_preferences.contentValues(
portal_type=portal_type)
if not preference_list:
# create a Cache Factory for tests
cache_factory = self.portal.portal_caches.newContent(portal_type = 'Cache Factory')
cache_factory.cache_duration = 36000
cache_plugin = cache_factory.newContent(portal_type='Ram Cache')
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
pref = self.getDefaultSystemPreference()
id = self.__class__.__name__
if pref.getPreferredConversionCacheFactory() != id:
try:
self.portal.portal_caches[id]
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_plugin = cache_factory.newContent(portal_type='Ram Cache')
cache_plugin.cache_expire_check_interval = 54000
def getDocumentModule(self):
return getattr(self.getPortal(),'document_module')
......
......@@ -41,17 +41,13 @@ class TestDocumentWithFlare(TestDocument):
def getTitle(self):
return "DMS with Flare"
def setSystemPreference(self):
system_preference = TestDocument.setSystemPreference(self)
def setCacheFactory(self, cache_factory):
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_plugin = cache_factory.newContent(portal_type='Distributed Ram Cache')
system_preference.setPreferredConversionCacheFactory(cache_factory.getId())
persistent_memcached_plugin = self.portal.portal_memcached.persistent_memcached_plugin
persistent_memcached_plugin.setUrlString('%s:%s' %(memcached['hostname'], memcached['port']))
cache_plugin.setSpecialiseValue(persistent_memcached_plugin)
plugin = self.portal.portal_memcached.persistent_memcached_plugin
plugin.setUrlString('%(hostname)s:%(port)s' % memcached)
cache_factory.newContent(portal_type='Distributed Ram Cache',
specialise_value=plugin)
def test_suite():
suite = unittest.TestSuite()
......
......@@ -55,7 +55,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')
......
......@@ -51,7 +51,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')
......
......@@ -34,8 +34,8 @@ import os
from lxml import etree
from DateTime import DateTime
from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeTestCase import (
ERP5TypeTestCase, _getConversionServerUrl)
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import FileUpload, createZODBPythonScript
from Products.ERP5OOo.OOoUtils import OOoBuilder
......@@ -138,13 +138,9 @@ class TestIngestion(ERP5TypeTestCase):
self.commit()
def setSystemPreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref = self.getDefaultSystemPreference()
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_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):
"""
......@@ -1044,10 +1040,8 @@ class TestIngestion(ERP5TypeTestCase):
Make sure that preferences are set up properly and accessible
"""
preference_tool = self.portal.portal_preferences
conversion_dict = _getConversionServerDict()
self.assertEqual(preference_tool.getPreferredOoodocServerAddress(), conversion_dict['hostname'])
self.assertEqual(preference_tool.getPreferredOoodocServerPortNumber(), conversion_dict['port'])
self.assertEqual(preference_tool.getPreferredDocumentConversionServerUrl(), conversion_dict['url'])
self.assertEqual(preference_tool.getPreferredDocumentConversionServerUrl(),
_getConversionServerUrl())
self.assertEqual(preference_tool.getPreferredDocumentFilenameRegularExpression(), FILENAME_REGULAR_EXPRESSION)
self.assertEqual(preference_tool.getPreferredDocumentReferenceRegularExpression(), REFERENCE_REGULAR_EXPRESSION)
......
......@@ -54,6 +54,10 @@ class TestOoodResponse(ERP5TypeTestCase):
def afterSetUp(self):
self.login()
# disable pref that configures the conversion server
pref = self.getDefaultSystemPreference()
if pref.getPreferenceState() != 'disabled':
pref.disable()
portal_skins = self.getSkinsTool()
import_file_path = os.path.join(os.path.dirname(__file__),
'test_document',
......
......@@ -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):
......@@ -55,13 +53,6 @@ class TestOOoImportMixin(ERP5TypeTestCase):
Initialize the ERP5 site.
"""
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
if not "browser_id_manager" in self.portal.objectIds():
self.portal.manage_addProduct['Sessions'].constructBrowserIdManager()
......@@ -100,8 +91,6 @@ class TestOOoImportMixin(ERP5TypeTestCase):
self.portal.portal_categories.region,
]:
parent.deleteContent(list(parent.objectIds()))
self.portal.portal_preferences.manage_delObjects([self.pref.getId()])
self.tic()
class TestOOoImport(TestOOoImportMixin):
......
......@@ -28,8 +28,7 @@
##############################################################################
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase, \
_getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import DummyLocalizer
from Products.ERP5Form.Selection import Selection
from Testing import ZopeTestCase
......@@ -54,8 +53,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')
......@@ -86,14 +83,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.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
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)
......
......@@ -35,7 +35,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
......@@ -149,8 +148,6 @@ class TestERP5DocumentSyncMLMixin(TestERP5SyncMLMixin):
def setSystemPreferences(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 default_pref.getPreferenceState() == 'disabled':
......
......@@ -37,8 +37,7 @@ import shutil
import transaction
from ZPublisher.HTTPResponse import HTTPResponse
from zExceptions.ExceptionFormatter import format_exception
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase, \
_getConversionServerDict
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.Utils import stopProcess, PR_SET_PDEATHSIG
from lxml import etree
from lxml.html import builder as E
......@@ -250,13 +249,9 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
self.portal, self.run_only)
def setSystemPreference(self):
conversion_dict = _getConversionServerDict()
self.portal.Zuite_setPreference(
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):
for entry in self.portal.error_log.getLogEntries()[:size]:
......
......@@ -60,6 +60,7 @@ from Testing.ZopeTestCase import PortalTestCase, user_name
from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.PythonScripts.PythonScript import PythonScript
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
from Products.ERP5Form.PreferenceTool import Priority
from zLOG import LOG, DEBUG
from Products.ERP5Type.tests.backportUnittest import SetupSiteError
......@@ -127,17 +128,17 @@ def _getConnectionStringDict():
os.environ.get(connection, '-' + connection_string)
return connection_string_dict
def _getConversionServerDict():
""" Returns a dict with url for Conversion Server (Oood)
def _getConversionServerUrl():
""" Return the url for Conversion Server (Cloudooo)
"""
conversion_server_url = os.environ.get('conversion_server_url')
conversion_server_hostname = os.environ.get('conversion_server_hostname',
'localhost')
conversion_server_port = os.environ.get('conversion_server_port',
'8008')
return dict(url=conversion_server_url,
hostname=conversion_server_hostname,
port=int(conversion_server_port))
url = os.environ.get('conversion_server_url')
if not url: # BBB
url = os.environ['conversion_server_url'] = 'http://%s:%s' % (
os.environ.get('conversion_server_hostname', 'localhost'),
os.environ.get('conversion_server_port', 8008))
warn('conversion_server_hostname/conversion_server_port are deprecated.\n'
'Using %s as conversion_server_url instead' % url, DeprecationWarning)
return url
def _getVolatileMemcachedServerDict():
"""Returns a dict with hostname and port for volatile memcached Server
......@@ -157,10 +158,10 @@ def _getPersistentMemcachedServerDict():
def _createTestPromiseConfigurationFile(promise_path, bt5_repository_path_list=None):
kumofs_url = "memcached://%(hostname)s:%(port)s/" % \
_getVolatileMemcachedServerDict()
memcached_url = "memcached://%(hostname)s:%(port)s/" % \
_getPersistentMemcachedServerDict()
cloudooo_url = _getConversionServerDict()['url']
memcached_url = "memcached://%(hostname)s:%(port)s/" % \
_getVolatileMemcachedServerDict()
cloudooo_url = _getConversionServerUrl()
promise_config = ConfigParser.RawConfigParser()
promise_config.add_section('external_service')
......@@ -332,10 +333,16 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
def unpinDateTime(self):
self.pinDateTime(None)
def getDefaultSitePreferenceId(self):
"""Default id, usefull method to override
"""
return "default_site_preference"
def getDefaultSystemPreference(self):
id = 'default_system_preference'
tool = self.getPreferenceTool()
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
def getTemplateTool(self):
......@@ -907,12 +914,11 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
getattr(self.portal, connection_name).edit('', connection_string)
def _updateConversionServerConfiguration(self):
"""Update conversion server (Oood) at default site preferences.
"""Update conversion server (Cloudooo) at default site preferences.
"""
conversion_dict = _getConversionServerDict()
preference = self.portal.portal_preferences[
self.getDefaultSitePreferenceId()]
preference._setPreferredDocumentConversionServerUrl(conversion_dict['url'])
url = _getConversionServerUrl()
pref = self.getDefaultSystemPreference()
pref._setPreferredDocumentConversionServerUrl(url)
def _updateMemcachedConfiguration(self):
"""Update default memcached plugin configuration
......
......@@ -10,7 +10,6 @@ import signal
import shutil
import errno
import random
from warnings import warn
import transaction
from glob import glob
try:
......@@ -739,9 +738,6 @@ def main(argument_list=None):
bt5_path_list = []
conversion_server_hostname = None
conversion_server_port = None
for opt, arg in opts:
if opt in ("-v", "--verbose"):
os.environ['VERBOSE'] = "1"
......@@ -807,9 +803,9 @@ def main(argument_list=None):
elif opt == "--conversion_server_url":
os.environ["conversion_server_url"] = arg
elif opt == "--conversion_server_hostname":
conversion_server_hostname = arg
os.environ["conversion_server_hostname"] = arg
elif opt == "--conversion_server_port":
conversion_server_port = arg
os.environ["conversion_server_port"] = arg
elif opt == "--volatile_memcached_server_hostname":
os.environ["volatile_memcached_server_hostname"] = arg
elif opt == "--volatile_memcached_server_port":
......@@ -844,17 +840,6 @@ def main(argument_list=None):
elif opt == "--instance_home":
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,
os.environ.get("erp5_tests_bt5_path", "").split(','))
valid_path_list = []
......
......@@ -31,6 +31,9 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestERP5Promise(ERP5TypeTestCase):
def _updateConversionServerConfiguration(self):
pass
def getBusinessTemplateList(self):
"""
Return the list of business templates.
......@@ -38,8 +41,7 @@ class TestERP5Promise(ERP5TypeTestCase):
return ("erp5_promise", "erp5_base")
def _test_promise_alarm(self, alarm_id):
alarm = getattr(self.portal.portal_alarms, alarm_id, None)
self.assertNotEquals(alarm, None, "Alarm %s not found" % alarm_id)
alarm = self.portal.portal_alarms[alarm_id]
alarm.activeSense()
self.tic()
self.assertTrue(alarm.sense())
......@@ -56,6 +58,7 @@ class TestERP5Promise(ERP5TypeTestCase):
self._test_promise_alarm("promise_kumofs_server")
def test_promise_memcached_server(self):
self.portal.portal_memcached.default_memcached_plugin.setUrlString(None)
self._test_promise_alarm("promise_memcached_server")
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