Commit de85c464 authored by Arnaud Fontaine's avatar Arnaud Fontaine

erp5_core_test: Migrate core tests ERP5/ERP5Type Products which have no external bt5 dependencies.

Not migrated:
  + testERP5Site: Checks Site creation and overrides setUp().
  + testERP5TypeInterfaces: Verifies that classes implements the Interfaces they claim to implement.
    => Should probably be integrated into coding style Unit Tests and done
       dynamically (MRO). Also, testERP5Interfaces imports code from that
       Unit Test and requires non-core bt5 to be installed.
  + testInvalidationBug: To-do (failing).
  + testPredicate: testDomainTool, inheriting from TestPredicateMixin, should be rewritten to not
    depend on erp5_apparel so that it can be moved to erp5_core_test.

Also, move manuallyInstallBusinessTemplate() and uninstallBusinessTemplate() from
ERP5TypeCommandLineTestCase to ERP5TypeTestCaseMixin as they are also used by
Live Unit Tests.
parent 1d5680fe
......@@ -30,14 +30,9 @@ import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestAccessTab(ERP5TypeTestCase):
def getTitle(self):
return "Access Tab Test"
def getBusinessTemplateList(self):
""" return business template list """
return ('erp5_base',)
def afterSetUp(self):
""" AfterSetup """
self.addPreferenceForAccessTab()
......@@ -53,7 +48,7 @@ class TestAccessTab(ERP5TypeTestCase):
portal_type="Preference")
preference.setPreferredHtmlStyleAccessTab(True)
if preference.getPreferenceState() != "enabled":
preference.enable()
preference.enable()
def configureBusinessApplication(self):
""" Configure business_application category on module property.
......@@ -61,7 +56,7 @@ class TestAccessTab(ERP5TypeTestCase):
business_application = self.portal.portal_categories.business_application
base = getattr(business_application, 'base', None)
if base is None:
base = self.portal.portal_categories.business_application.newContent(
base = self.portal.portal_categories.business_application.newContent(
portal_type='Category',
id='base',
title='base')
......@@ -114,8 +109,8 @@ class TestAccessTab(ERP5TypeTestCase):
self.assertEqual(len(person_menu), 2)
self.assertEqual(type(person_menu), tuple)
(organisation_label, organisation_url) = organisation_menu
(person_label, person_url) = person_menu
(organisation_label, _) = organisation_menu
(person_label, _) = person_menu
self.assertEqual(organisation_label, 'Organisations')
self.assertEqual(person_label, 'Persons')
......@@ -141,7 +136,7 @@ class TestAccessTab(ERP5TypeTestCase):
self.assertEqual(len(view_list[0]), 2)
base = view_list[0]
(label, menu_list) = base
(_, menu_list) = base
self.assertEqual(len(menu_list), 3)
currency_menu = menu_list[0]
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAccessTab</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAccessTab</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAccessTab</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -220,7 +220,6 @@ class TestAlarm(ERP5TypeTestCase):
right_second_date = DateTime(self.date_format % (2006,9,29,6,00,00))
right_third_date = DateTime(self.date_format % (2006,9,29,15,00,00))
right_fourth_date = DateTime(self.date_format % (2006,10,2,6,00,00))
right_fifth_date = DateTime(self.date_format % (2006,10,2,15,00,00))
alarm = self.newAlarm(enabled=True)
self.tic()
alarm.setPeriodicityStartDate(right_first_date)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAlarm</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAlarm</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAlarm</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testArrow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testArrow</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testArrow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -70,7 +70,6 @@ class TestAuoLogout(ERP5TypeTestCase):
Test auto logout feature of ERP5.
"""
portal = self.getPortal()
request = self.app.REQUEST
stdin = urllib.urlencode({
'__ac_name': self.manager_username,
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAutoLogout</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAutoLogout</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAutoLogout</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -87,9 +87,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
def afterSetUp(self):
self.login()
portal = self.getPortal()
self.category_tool = self.getCategoryTool()
portal_catalog = self.getCatalogTool()
#portal_catalog.manage_catalogClear()
self.createCategories()
......@@ -112,8 +110,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
category_list = ['testGroup1', 'testGroup2']
if 'testGroup1' not in self.category_tool.group.contentIds():
for category_id in category_list:
o = self.category_tool.group.newContent(portal_type='Category',
id=category_id)
self.category_tool.group.newContent(portal_type='Category',
id=category_id)
def stepRemoveWorkflowsRelated(self, sequence=None, sequence_list=None,
**kw):
......@@ -937,10 +935,10 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
cbt = pw._chains_by_type
props = {}
for id, wf_ids in cbt.iteritems():
if id == portal_type:
for id_, wf_ids in cbt.iteritems():
if id_ == portal_type:
wf_ids = list(wf_ids) + [dummy_worlflow_id]
props['chain_%s' % id] = ','.join(wf_ids)
props['chain_%s' % id_] = ','.join(wf_ids)
pw.manage_changeWorkflows('', props = props)
pw.manage_delObjects([dummy_worlflow_id])
......@@ -988,10 +986,10 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
dummy_validation_worlflow.variables.setStateVar('validation_state')
cbt = pw._chains_by_type
props = {}
for id, wf_ids in cbt.iteritems():
if id == portal_type:
for id_, wf_ids in cbt.iteritems():
if id_ == portal_type:
old_wf_ids = wf_ids
props['chain_%s' % id] = ','.join([dummy_validation_worlflow_id, dummy_simulation_worlflow_id])
props['chain_%s' % id_] = ','.join([dummy_validation_worlflow_id, dummy_simulation_worlflow_id])
pw.manage_changeWorkflows('', props=props)
permission_list = list(dummy_simulation_worlflow.permissions)
manager_has_permission = {}
......@@ -1065,6 +1063,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEqual(None, obj.getViewPermissionOwner())
def test_Member_Base_download(self):
import Products.ERP5Type
# tests that members can download files
class DummyFile(file):
def __init__(self, filename):
......@@ -1073,7 +1073,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
portal = self.getPortal()
organisation = portal.organisation_module.newContent(portal_type='Organisation')
file_document = organisation.newContent(portal_type='Embedded File',
file=DummyFile(__file__),
file=DummyFile(Products.ERP5Type.__file__),
content_type='text/plain')
# login as a member
......@@ -1089,7 +1089,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEqual(file_document.getData(), response.body)
self.assertEqual('text/plain',
response.getHeader('content-type').split(';')[0])
self.assertEqual('attachment; filename="%s"' % os.path.basename(__file__),
self.assertEqual('attachment; filename="%s"' % os.path.basename(Products.ERP5Type.__file__),
response.getHeader('content-disposition'))
def test_getTypeBasedMethod(self):
......@@ -1115,12 +1115,12 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
'scripts_params=None',
'# Script body\n'
'return context.getId()' )
copy_container_script = createZODBPythonScript(portal.portal_skins.custom,
createZODBPythonScript(portal.portal_skins.custom,
'CopyContainer_dummyFooMethod',
'scripts_params=None',
'# Script body\n'
'return context.getId()' )
cmfbtree_folder_script = createZODBPythonScript(portal.portal_skins.custom,
createZODBPythonScript(portal.portal_skins.custom,
'CMFBTreeFolder_dummyFoo2Method',
'scripts_params=None',
'# Script body\n'
......@@ -1143,7 +1143,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEqual(pers.getDummyTypeBaseMethod(), "Script Not Found")
person_dummy_script = createZODBPythonScript(portal.portal_skins.custom,
createZODBPythonScript(portal.portal_skins.custom,
'Person_getDummyTypeBaseMethod',
'scripts_params=None',
'# Script body\n'
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testBase</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testBase</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testBase</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>