diff --git a/product/ERP5Form/tests/testFieldValueCache.py b/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.py similarity index 94% rename from product/ERP5Form/tests/testFieldValueCache.py rename to bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.py index a629bdd88c6a878b59477e77a972e7e8dccce478..41e2dff81c45bb177da5f1f99d70b3470ab34987 100644 --- a/product/ERP5Form/tests/testFieldValueCache.py +++ b/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.py @@ -66,16 +66,16 @@ class TestFieldValueCache(ERP5TypeTestCase): form() # Get form value field = form.my_first_name - id = 'title' + id_ = 'title' from Products.ERP5Form.Form import field_value_cache cache_id = ('ProxyField.get_value', field._p_oid, field._p_oid, - id) + id_) # Make sure cache has field self.assertTrue(field_value_cache.has_key(cache_id)) # Make sure cache and field are equal - self.assertEqual(field.get_value(id), field_value_cache[cache_id]) + self.assertEqual(field.get_value(id_), field_value_cache[cache_id]) # Call manage_renameObject form.manage_renameObject('my_first_name', 'my_first_name2') form.manage_renameObject('my_first_name2', 'my_first_name') @@ -86,4 +86,4 @@ class TestFieldValueCache(ERP5TypeTestCase): # Make sure cache has field self.assertTrue(field_value_cache.has_key(cache_id)) # Make sure cache and field are equal - self.assertEqual(field.get_value(id), field_value_cache[cache_id]) + self.assertEqual(field.get_value(id_), field_value_cache[cache_id]) diff --git a/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.xml b/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.xml new file mode 100644 index 0000000000000000000000000000000000000000..d5df644a1bc71c7c7ea458f53edf4add82d0c34b --- /dev/null +++ b/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.xml @@ -0,0 +1,110 @@ +<?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>testFieldValueCache</string> </value> + </item> + <item> + <key> <string>default_source_reference</string> </key> + <value> <string>Products.ERP5Form.tests.testFieldValueCache</string> </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>test.erp5.testFieldValueCache</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> diff --git a/product/ERP5Form/tests/testFields.py b/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.py similarity index 97% rename from product/ERP5Form/tests/testFields.py rename to bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.py index f0eec19feaba7289c1a8f41d5415dd2a57437fce..8329ac300b3215a19c3c6afd609cc03e24647b1f 100644 --- a/product/ERP5Form/tests/testFields.py +++ b/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.py @@ -34,13 +34,12 @@ import unittest # Initialize ERP5Form Product to load monkey patches -from Acquisition import aq_base from Products.Formulator.FieldRegistry import FieldRegistry from Products.Formulator.Validator import ValidationError from Products.Formulator.StandardFields import FloatField, StringField,\ DateTimeField, TextAreaField, CheckBoxField, ListField, LinesField, \ MultiListField, IntegerField -from Products.Formulator.MethodField import Method, BoundMethod +from Products.Formulator.MethodField import Method from Products.Formulator.TALESField import TALESMethod from Products.ERP5Type.Core.Folder import Folder @@ -61,7 +60,7 @@ class TestRenderViewAPI(ERP5TypeTestCase): return "{Field,Widget}.render_view" def test_signature(self): - for field in FieldRegistry.get_field_classes().itervalues(): + for field in FieldRegistry.get_field_classes().itervalues(): # pylint: disable=no-value-for-parameter self.assertEqual(('self', 'value', 'REQUEST', 'render_prefix'), field.render_view.im_func.func_code.co_varnames) if field is not ProxyField.ProxyField: @@ -643,9 +642,9 @@ class TestProxyField(ERP5TypeTestCase): _setUpDefaultTraversable() - def addField(self, form, id, title, field_type): - form.manage_addField(id, title, field_type) - field = getattr(form, id) + def addField(self, form, id_, title, field_type): + form.manage_addField(id_, title, field_type) + field = getattr(form, id_) field._p_oid = makeDummyOid() return field @@ -692,8 +691,8 @@ class TestProxyField(ERP5TypeTestCase): def test_get_value_default(self): # If the proxy field is named 'my_id', it will get 'id' # property on the context, regardless of the id of the proxified field - original_field = self.addField(self.container.Base_viewProxyFieldLibrary, - 'my_title', 'Title', 'StringField') + self.addField(self.container.Base_viewProxyFieldLibrary, + 'my_title', 'Title', 'StringField') proxy_field = self.addField(self.container.Base_view, 'my_id', 'ID', 'ProxyField') proxy_field.manage_edit_xmlrpc(dict(form_id='Base_viewProxyFieldLibrary', @@ -789,8 +788,8 @@ class TestProxyField(ERP5TypeTestCase): def test_manage_edit_surcharged_xmlrpc(self): # manage_edit_surcharged_xmlrpc is a method to edit proxyfields # programmatically - original_field = self.addField(self.container.Base_viewProxyFieldLibrary, - 'my_string', 'String', 'StringField') + self.addField(self.container.Base_viewProxyFieldLibrary, + 'my_string', 'String', 'StringField') proxy_field = self.addField(self.container.Base_view, 'my_String', '', 'ProxyField') proxy_field.manage_edit_xmlrpc(dict(form_id='Base_viewProxyFieldLibrary', @@ -809,8 +808,8 @@ class TestProxyField(ERP5TypeTestCase): """ Test a case that if proxy field id is same as template field id. """ - original_field = self.addField(self.container.Base_viewProxyFieldLibrary, - 'my_string', 'String', 'StringField') + self.addField(self.container.Base_viewProxyFieldLibrary, + 'my_string', 'String', 'StringField') # Use different id to the template field. proxy_field2 = self.addField(self.container.Base_view, 'my_another_string', '', 'ProxyField') @@ -842,8 +841,8 @@ class TestProxyField(ERP5TypeTestCase): not surcharged. """ # create a field - original_field = self.addField(self.container.Base_viewProxyFieldLibrary, - 'my_title', 'OrigTitle', 'StringField') + self.addField(self.container.Base_viewProxyFieldLibrary, + 'my_title', 'OrigTitle', 'StringField') field = self.addField(self.container.Base_view, 'my_dict_test', '', 'ProxyField') field.manage_edit_xmlrpc(dict(form_id='Base_viewProxyFieldLibrary', @@ -961,9 +960,9 @@ class TestFieldValueCache(ERP5TypeTestCase): def test_method_field(self): field = self.root.form.field - value, cacheable = getFieldValue(field, field, 'external_validator') + value, _ = getFieldValue(field, field, 'external_validator') self.assertEqual(False, value.value is field.values['external_validator']) - self.assertEqual(True, type(value.value) is Method) + self.assertEqual(True, isinstance(value.value, Method)) def _getCacheSize(self, cache_id): count = 0 diff --git a/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.xml b/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.xml new file mode 100644 index 0000000000000000000000000000000000000000..cf27be46311cc2d1b884eccd4931a97198b64e55 --- /dev/null +++ b/bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.xml @@ -0,0 +1,110 @@ +<?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>testFields</string> </value> + </item> + <item> + <key> <string>default_source_reference</string> </key> + <value> <string>Products.ERP5Form.tests.testFields</string> </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>test.erp5.testFields</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> diff --git a/bt5/erp5_core_test/bt/dependency_list b/bt5/erp5_core_test/bt/dependency_list index 4cb83ff5a92c7a15a6379507e00e57f6ddd2851f..899164e7f040e18ed860a01652abb5271c0cecad 100644 --- a/bt5/erp5_core_test/bt/dependency_list +++ b/bt5/erp5_core_test/bt/dependency_list @@ -1,3 +1,4 @@ erp5_full_text_mroonga_catalog erp5_base -erp5_csv_style \ No newline at end of file +erp5_csv_style +erp5_core_proxy_field_legacy \ No newline at end of file diff --git a/bt5/erp5_core_test/bt/template_test_id_list b/bt5/erp5_core_test/bt/template_test_id_list index b5c57c8cbd9c8c25fbcea367bdcf1eb569960a6a..277a6269302dae6fe8533360794e61693cba8c9a 100644 --- a/bt5/erp5_core_test/bt/template_test_id_list +++ b/bt5/erp5_core_test/bt/template_test_id_list @@ -17,6 +17,8 @@ test.erp5.testERP5Base test.erp5.testERP5Category test.erp5.testERP5Coordinate test.erp5.testERP5Core +test.erp5.testFieldValueCache +test.erp5.testFields test.erp5.testFolder test.erp5.testFolderMigration test.erp5.testGeographicalAddress