Commit 77c1c67e authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

testERP5Core: also test the tools registration when testing the site manager migration

parent f7445044
...@@ -576,7 +576,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -576,7 +576,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
if i.getId() not in ('portal_uidhandler',) and if i.getId() not in ('portal_uidhandler',) and
0 != i.getUid() != i.getProperty('uid')]) 0 != i.getUid() != i.getProperty('uid')])
def test_site_manager_and_translation_migration(self): def test_04_site_manager_and_translation_migration(self):
from zope.site.hooks import getSite, setSite from zope.site.hooks import getSite, setSite
from zope.component import queryUtility from zope.component import queryUtility
from zope.i18n.interfaces import ITranslationDomain from zope.i18n.interfaces import ITranslationDomain
...@@ -594,25 +594,26 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -594,25 +594,26 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEqual(queryUtility(ITranslationDomain, 'ui'), None) self.assertEqual(queryUtility(ITranslationDomain, 'ui'), None)
# now let's simulate a site just migrated from Zope 2.8 that's being # now let's simulate a site just migrated from Zope 2.8 that's being
# accessed for the first time: # accessed for the first time:
old_site = getSite() from Products.ERP5 import ERP5Site
try: setSite()
setSite() # Sites from Zope2.8 don't have a site_manager yet.
# Sites from Zope2.8 don't have a site_manager yet. del self.portal._components
del self.portal._components self.assertIsNotNone(ERP5Site._missing_tools_registered)
# check that we can't get any translation utility ERP5Site._missing_tools_registered = None
self.assertEqual(queryUtility(ITranslationDomain, 'erp5_ui'), None) self.commit()
# Now simulate first access. Default behaviour from # check that we can't get any translation utility
# ObjectManager is to raise a ComponentLookupError here: self.assertEqual(queryUtility(ITranslationDomain, 'erp5_ui'), None)
setSite(self.portal) # Now simulate first access. Default behaviour from
# This should have automatically reconstructed the i18n utility # ObjectManager is to raise a ComponentLookupError here:
# registrations:
self.assertEqual(queryUtility(ITranslationDomain, 'erp5_ui'), setSite(self.portal)
erp5_ui_catalog) self.commit()
self.assertEqual(queryUtility(ITranslationDomain, 'ui'), erp5_ui_catalog) self.assertIsNotNone(ERP5Site._missing_tools_registered)
finally: # This should have automatically reconstructed the i18n utility
# clean everything up, we don't want to mess the test environment # registrations:
self.abort() self.assertEqual(queryUtility(ITranslationDomain, 'erp5_ui'),
setSite(old_site) erp5_ui_catalog)
self.assertEqual(queryUtility(ITranslationDomain, 'ui'), erp5_ui_catalog)
def test_BasicAuthenticateDesactivated(self): def test_BasicAuthenticateDesactivated(self):
"""Make sure Unauthorized error does not lead to Basic auth popup in browser""" """Make sure Unauthorized error does not lead to Basic auth popup in browser"""
......
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