Commit 3f383450 authored by Jérome Perrin's avatar Jérome Perrin

CodingStyleTest: review business template installation

We were installing erp5_upgrader with its test dependencies, so it was
installing erp5_full_text_mroonga_catalog. We were also installing
erp5_full_text_myisam_catalog, so we ended up with two full text
business template installed (and the order of this installation was not
deterministic).
This was problematic, because we were installing all the test dependencies
of erp5_upgrader, but we don't really need them here and one goal of
CodingStyleTest is to install only the dependencies of tested business
templates, as a way to verify that dependencies are correctly specified.

This new approach hooks at another level, to install a full text business
template only if the tested business template has a dependency to the
virutal "erp5_full_text_catalog" bt, but no dependency to a concrete bt
(which happens for example in erp5_base) and to install erp5_upgrader
without its test dependencies.

As a result, we also run without erp5_base unless it's an explicit
dependency.

This also reverts commit ab44309f (
full_text_myisam_catalog: skip coding style test) that is no longer
needed with this new approach.
parent 8e477621
......@@ -32,6 +32,7 @@ import unittest
from glob import glob
from Products.ERP5.tests import testXHTML
from Products.ERP5.Document.BusinessTemplate import BusinessTemplateMissingDependency
from Products.ERP5Type.tests.utils import addUserToDeveloperRole
from Products.ERP5Type.tests.CodingStyleTestCase import CodingStyleTestCase
......@@ -43,23 +44,19 @@ class CodingStyleTest(CodingStyleTestCase, testXHTML.TestXHTMLMixin):
"""
def getBusinessTemplateList(self):
# install erp5_upgrader for CodingStyleTestCase.test_run_upgrader
# XXX also install erp5_full_text_myisam_catalog to workaround missing test
# dependencies and the fact that test dependencies are not checked
# recursively.
return (
'erp5_upgrader',
'erp5_full_text_myisam_catalog',
self.tested_business_template)
# note: more business templates will be installed by
# _installBusinessTemplateList
return (self.tested_business_template, )
def _installBusinessTemplateList(self,
bt_list,
update_repository_bt_list=True,
*args,
**kwargs):
"""Install depencencies automatically
"""Install dependencies automatically and also install erp5_upgrader,
which is needed for CodingStyleTestCase.test_run_upgrader
taken from runUnitTest._ZodbTestComponentBootstrapOnly.
the resolution approach is taken from runUnitTest._ZodbTestComponentBootstrapOnly.
"""
template_tool = self.portal.portal_templates
......@@ -74,11 +71,36 @@ class CodingStyleTest(CodingStyleTestCase, testXHTML.TestXHTMLMixin):
template_tool.updateRepositoryBusinessTemplateList(bt5_path_list)
bt_to_install_title_set = set(x[1] for x in bt_list)
bt_to_install_title_set.add('erp5_core')
# Install the tested business template.
try:
url_bt_tuple_list = [
('%s/%s' % (repository, bt_title), bt_title) for repository, bt_title in
template_tool.resolveBusinessTemplateListDependency(
[x[1] for x in bt_list],
bt_to_install_title_set,
with_test_dependency_list=True)]
except BusinessTemplateMissingDependency as e:
# it may have a virtual dependency on erp5_full_text_catalog, if that's
# the case, we choose erp5_full_text_mroonga_catalog
if str(e).startswith('Unable to resolve dependencies for erp5_full_text_catalog,'):
url_bt_tuple_list = [
('%s/%s' % (repository, bt_title), bt_title) for repository, bt_title in
template_tool.resolveBusinessTemplateListDependency(
bt_to_install_title_set | set(('erp5_full_text_mroonga_catalog',)),
with_test_dependency_list=True)]
if 'erp5_upgrader' not in bt_to_install_title_set:
upgrader_url_bt_tuple_list = [
('%s/%s' % (repository, bt_title), bt_title) for repository, bt_title in
template_tool.resolveBusinessTemplateListDependency(
['erp5_upgrader'],
# We don't actually run erp5_upgrader test, so we don't want to install
# erp5_upgrader test dependencies
with_test_dependency_list=False)]
for url, bt in upgrader_url_bt_tuple_list:
if bt not in bt_to_install_title_set:
url_bt_tuple_list.append((url, bt))
return super(CodingStyleTest,
self)._installBusinessTemplateList(url_bt_tuple_list,
......
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