Commit ce483b26 authored by Gabriel Monnerat's avatar Gabriel Monnerat Committed by Julien Muchembled

Add test to simulate the issue with the method...

Add test to simulate the issue with the method TemplateTool.installBusinessTemplateListFromRepository

Using the method try to install Business Templates that are already
installed, the Business Templates is uploaded on ERP5 but not used. It
creates a lot of garbage because in the end you have many bt5s not
installed.

(cherry picked from commit 28e0f0a2)
parent b8e0957c
master allow_login_change allow_login_change_differentiate_id_and_login allow_login_change_wip arnau arnau-kns arnau-kns-without-property-mapping auto_extend_select_list autoflake backup_erp5_workflow bk_erp5ish_actions_tool bk_sqlcatalog catalog_fulltext catalog_fulltext_old cedriclen-eos cherry-pick-4a8e045d clean_up_upgrader compact_title_no_reference datetimefield douglas_forum dream_distributor eos-dev erp5-component erp5-data-notebook erp5-forum erp5-preference erp5-release erp5-slapos-upgrade erp5-vifib erp5-vifib-cleanup erp5_free_subscription erp5_workflow fix/accounting_period_constraint_vs_acquired_node fix/change_state_priority fix/login_validate_check_consistency for_testrunner_1 for_testrunner_2 formbox gabriel-fix-rounding-in-accounting-generation gabriel-fix-rounding-in-accounting-generation2 gadget-json-value improve_default_caching_policy_manager isDeletable item_tracking_graph_editor jerome-test jerome_graph_editor_renderjs jerome_user_preference_time_zone jm/form-action-guard joblib-activity jupyter-jio-erp5 jupyter-notebook-storage kns master_calendar_wip_patches master_calendar_wip_patches_extend_security master_no_guard_on_workflow_transition master_no_guard_on_workflow_transition_plus_calendar_wip_patchs nexedi-erp5-jp no_longer_simulated_state officejs officejs_clean portal_callables portal_solver_process_security_configuration reindex_calendar_after_change_calendar_exception renderjs-extension romain-fulltext shop-box sms_more_than_140_characters strict_catalog testnode_software_link timezones tristan tristan-merge view-aggregated-amounts vivekpab_erp5webrenderjs_layoutconfig vivekpab_jabberclient vivekpab_renderjs_interfaces wenjie wenjie_branch xiaowu_newui erp5.util-0.4.46 erp5.util-0.4.44 erp5.util-0.4.43
No related merge requests found
......@@ -1211,9 +1211,15 @@ class TemplateTool (BaseTool):
"Impossible to install, please install the following dependencies before: %s" \
% [x[1] for x in missing_dependency_list]
template_url_dict = self._getBusinessTemplateUrlDict()
activate_kw = dict(activity="SQLQueue", tag="start_%s" % (time.time()))
for repository, bt_id in resolved_template_list:
bt = template_url_dict.get(bt_id)
if bt is not None and bt_id in installed_bt5_set:
revision = int(bt['revision'])
installed_bt5 = self.getInstalledBusinessTemplate(bt_id)
if int(installed_bt5.getRevision()) <= revision and only_newer:
continue
bt_url = '%s/%s' % (repository, bt_id)
param_dict = dict(download_url=bt_url, only_newer=only_newer)
if update_catalog is not _MARKER:
......
......@@ -627,6 +627,21 @@ class TestTemplateTool(ERP5TypeTestCase):
self.assertNotEquals(bt, None)
transaction.abort()
def test_installBusinessTemplateListFromRepository_ignore_when_installed(self):
"""Check that install one business template, this method does not download
many business templates that are already installed
"""
template_tool = self.portal.portal_templates
# Delete not installed bt5 to check easily if more not installed was
# created
for bt5 in template_tool.getBuiltBusinessTemplateList():
bt5.delete()
bt5_name_list = ['erp5_calendar']
template_tool.installBusinessTemplateListFromRepository(bt5_name_list,
install_dependency=True)
self.tic()
self.assertEquals(template_tool.getBuiltBusinessTemplateList(), [])
def test_sortBusinessTemplateList(self):
"""Check sorting of a list of business template by their dependencies
"""
......
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