Commit bf9cadf7 authored by Sebastien Robin's avatar Sebastien Robin

make template tool able to update all a site

* fix the state of bt (new, old, present)
* make resolveBusinessTemplateListDependency returning all
  dependencies, even installed ones
* add upgradeSite method to install everything from top level bt
* the code to check version restriction has been removed but
  it should be  moved to another method
parent 63c1f784
This diff is collapsed.
...@@ -50,14 +50,15 @@ class TestTemplateTool(ERP5TypeTestCase): ...@@ -50,14 +50,15 @@ class TestTemplateTool(ERP5TypeTestCase):
test_tool_id = 'test_portal_templates' test_tool_id = 'test_portal_templates'
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_csv_style') return ('erp5_core_proxy_field_legacy', 'erp5_base', 'erp5_csv_style')
def getTitle(self): def getTitle(self):
return "Template Tool" return "Template Tool"
def afterSetUp(self): def afterSetUp(self):
self.templates_tool = self.portal.portal_templates self.templates_tool = self.portal.portal_templates
self.setupAutomaticBusinessTemplateRepository() self.setupAutomaticBusinessTemplateRepository(
searchable_business_template_list=["erp5_core", "erp5_base"])
if getattr(self.portal, self.test_tool_id, None) is not None: if getattr(self.portal, self.test_tool_id, None) is not None:
self.portal.manage_delObjects(ids=[self.test_tool_id]) self.portal.manage_delObjects(ids=[self.test_tool_id])
self.portal.newContent(portal_type='Template Tool', self.portal.newContent(portal_type='Template Tool',
...@@ -408,38 +409,39 @@ class TestTemplateTool(ERP5TypeTestCase): ...@@ -408,38 +409,39 @@ class TestTemplateTool(ERP5TypeTestCase):
addRepositoryEntry(title='biz', dependency_list=()), addRepositoryEntry(title='biz', dependency_list=()),
addRepositoryEntry(title='ca1', provision_list=('sql',)), addRepositoryEntry(title='ca1', provision_list=('sql',)),
addRepositoryEntry(title='ca2', provision_list=('sql',)), addRepositoryEntry(title='ca2', provision_list=('sql',)),
addRepositoryEntry(title='end', dependency_list=('baz','sql')), addRepositoryEntry(title='a', dependency_list=()),
addRepositoryEntry(title='b', dependency_list=('a'), revision='5'),
addRepositoryEntry(title='end', dependency_list=('baz','sql', 'b')),
) )
# Simulate that we have some installed bt. # Simulate that we have some installed bt.
for bt_id in ('foo', 'ca1'): for bt_id in ('foo', 'ca1', 'b'):
bt = template_tool.newContent(portal_type='Business Template', bt = template_tool.newContent(portal_type='Business Template',
title=bt_id, revision='4', id=bt_id) title=bt_id, revision='4', id=bt_id)
bt.install() bt.install()
bt5_id_list = ['baz'] bt5_id_list = ['baz']
bt5_list = template_tool.resolveBusinessTemplateListDependency(bt5_id_list) bt5_list = template_tool.resolveBusinessTemplateListDependency(bt5_id_list)
self.assertEquals([(repository, 'bar.bt5'), self.assertEquals([(repository, 'foo.bt5'),
(repository, 'bar.bt5'),
(repository, 'baz.bt5')], bt5_list) (repository, 'baz.bt5')], bt5_list)
bt5_id_list = ['foo'] bt5_id_list = ['foo']
bt5_list = template_tool.resolveBusinessTemplateListDependency(bt5_id_list)
self.assertEquals([], bt5_list)
bt5_list = template_tool.resolveBusinessTemplateListDependency(bt5_id_list,
newest_only=True)
self.assertEquals([], bt5_list)
bt5_list = template_tool.resolveBusinessTemplateListDependency( bt5_list = template_tool.resolveBusinessTemplateListDependency(
bt5_id_list, False) bt5_id_list)
self.assertEquals([(repository, 'foo.bt5')], bt5_list) self.assertEquals([(repository, 'foo.bt5')], bt5_list)
bt5_id_list = ['biz', 'end'] bt5_id_list = ['biz', 'end']
bt5_list = template_tool.resolveBusinessTemplateListDependency(bt5_id_list) bt5_list = template_tool.resolveBusinessTemplateListDependency(bt5_id_list)
self.assertEquals([(repository, 'bar.bt5'), self.assertEquals([(repository, 'foo.bt5'),
(repository, 'a.bt5'),
(repository, 'bar.bt5'),
(repository, 'b.bt5'),
(repository, 'ca1.bt5'),
(repository, 'baz.bt5'), (repository, 'baz.bt5'),
(repository, 'biz.bt5'), (repository, 'end.bt5'),
(repository, 'end.bt5')], bt5_list) (repository, 'biz.bt5')], bt5_list)
# By removing ca1, we remove the choice for the "sql" provider. # By removing ca1, we remove the choice for the "sql" provider.
# Therefore template tool does not know any more what to take for "sql". # Therefore template tool does not know any more what to take for "sql".
...@@ -447,12 +449,12 @@ class TestTemplateTool(ERP5TypeTestCase): ...@@ -447,12 +449,12 @@ class TestTemplateTool(ERP5TypeTestCase):
self.assertRaises(BusinessTemplateMissingDependency, self.assertRaises(BusinessTemplateMissingDependency,
template_tool.resolveBusinessTemplateListDependency, template_tool.resolveBusinessTemplateListDependency,
bt5_id_list, False) bt5_id_list)
bt5_id_list = ['erp5_do_not_exist'] bt5_id_list = ['erp5_do_not_exist']
self.assertRaises(BusinessTemplateUnknownError, self.assertRaises(BusinessTemplateUnknownError,
template_tool.resolveBusinessTemplateListDependency, template_tool.resolveBusinessTemplateListDependency,
bt5_id_list, False) bt5_id_list)
def test_installBusinessTemplatesFromRepository_simple(self): def test_installBusinessTemplatesFromRepository_simple(self):
""" Simple test for portal_templates.installBusinessTemplatesFromRepository """ Simple test for portal_templates.installBusinessTemplatesFromRepository
...@@ -509,8 +511,7 @@ class TestTemplateTool(ERP5TypeTestCase): ...@@ -509,8 +511,7 @@ class TestTemplateTool(ERP5TypeTestCase):
bt5_name = 'erp5_odt_style' bt5_name = 'erp5_odt_style'
operation_log = template_tool.installBusinessTemplateListFromRepository([bt5_name], operation_log = template_tool.installBusinessTemplateListFromRepository([bt5_name],
only_newer=False, update_catalog=1) only_newer=False, update_catalog=1)
self.assertTrue("Installed %s with" % bt5_name in operation_log[-1])
self.assertTrue("Installed %s with" % bt5_name in operation_log[0])
bt = template_tool.getInstalledBusinessTemplate(bt5_name) bt = template_tool.getInstalledBusinessTemplate(bt5_name)
self.assertEquals(bt.getTitle(), bt5_name) self.assertEquals(bt.getTitle(), bt5_name)
self.commit() self.commit()
......
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