Commit 294fda6e authored by Fabien Morin's avatar Fabien Morin

add two tests method

- the first to test required fields
- the second to test read only fields (editable)
This two tests are made on StringFields and DateTimeFields. They check that the
property is present on ERP5 fields if scribus file have this property, and alos
that they don't have it if is not present.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20394 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 585c43f1
...@@ -32,7 +32,6 @@ from Testing import ZopeTestCase ...@@ -32,7 +32,6 @@ from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload from Products.ERP5Type.tests.utils import FileUpload
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from zLOG import LOG
class TestScribusUtils(ERP5TypeTestCase): class TestScribusUtils(ERP5TypeTestCase):
'''Unit test for SribusUtils API''' '''Unit test for SribusUtils API'''
...@@ -191,6 +190,104 @@ class TestScribusUtils(ERP5TypeTestCase): ...@@ -191,6 +190,104 @@ class TestScribusUtils(ERP5TypeTestCase):
self.assertEquals(getattr(self.portal.portal_skins.erp5_test.Dummy_view, self.assertEquals(getattr(self.portal.portal_skins.erp5_test.Dummy_view,
'text_1', None), None) 'text_1', None), None)
def test_05_requiredFields(self):
''' Set required property on a scribus field. After creating module with
scribus, the ERP5 field should have the required property set on.'''
# module creation using scribus file containing fields with requied
# property set:
self.portal.ERP5Site_createModuleScribus(
module_id="dummy_module",
module_portal_type="Dummy Module",
module_title="Dummy Module Title",
import_pdf_file=self.makeFileUpload('test_field_properties.pdf'),
import_scribus_file=self.makeFileUpload('test_field_properties.sla'),
portal_skins_folder="erp5_test",
object_title="Dummy",
object_portal_type="Dummy")
self.assertNotEqual(self.portal._getOb('dummy_module', None), None)
self.assertNotEqual(
self.portal.portal_skins._getOb("erp5_test", None), None)
self.assertEquals("Dummy Module Title",
self.portal.dummy_module.getTitle())
self.assertNotEqual(self.portal.portal_types.getTypeInfo("Dummy Module"),
None)
self.assertNotEqual(self.portal.portal_types.getTypeInfo("Dummy"), None)
# define some field lists
required_field_name_list = ['my_required_string_field',
'my_required_date']
not_required_field_name_list = [ 'my_simple_string_field',
'my_simple_date']
all_field_name_list = required_field_name_list + \
not_required_field_name_list
# check the that fields prensent in the sla file have been created in the
# erp5 form
form = self.portal.portal_skins.erp5_test.Dummy_view
for field_name in all_field_name_list:
self.assertNotEquals(getattr(form, field_name, None), None)
# check the required fields are required :
for field_name in required_field_name_list:
field = getattr(form, field_name, None)
self.assertEquals(field.values['required'], 1)
# check fields not required are not :
for field_name in not_required_field_name_list:
field = getattr(form, field_name, None)
self.assertNotEquals(field.values['required'], 1)
def test_06_readOnlyFields(self):
''' Set read only property on a scribus field. After creating module with
scribus, it should not be possible to edit it.'''
# module creation using scribus file containing fields with read only
# property set:
self.portal.ERP5Site_createModuleScribus(
module_id="dummy_module",
module_portal_type="Dummy Module",
module_title="Dummy Module Title",
import_pdf_file=self.makeFileUpload('test_field_properties.pdf'),
import_scribus_file=self.makeFileUpload('test_field_properties.sla'),
portal_skins_folder="erp5_test",
object_title="Dummy",
object_portal_type="Dummy")
self.assertNotEqual(self.portal._getOb('dummy_module', None), None)
self.assertNotEqual(
self.portal.portal_skins._getOb("erp5_test", None), None)
self.assertEquals("Dummy Module Title",
self.portal.dummy_module.getTitle())
self.assertNotEqual(self.portal.portal_types.getTypeInfo("Dummy Module"),
None)
self.assertNotEqual(self.portal.portal_types.getTypeInfo("Dummy"), None)
# define some field lists
read_only_field_name_list = ['my_read_only_string_field',
'my_read_only_date']
not_read_only_field_name_list = [ 'my_simple_string_field',
'my_simple_date']
all_field_name_list = read_only_field_name_list + \
not_read_only_field_name_list
# check the that fields prensent in the sla file have been created in the
# erp5 form
form = self.portal.portal_skins.erp5_test.Dummy_view
for field_name in all_field_name_list:
self.assertNotEquals(getattr(form, field_name, None), None)
# check the read_only fields are read_only :
for field_name in read_only_field_name_list:
field = getattr(form, field_name, None)
self.assertEquals(field.values['editable'], 1)
# check fields not read_only are not :
for field_name in not_read_only_field_name_list:
field = getattr(form, field_name, None)
self.assertNotEquals(field.values['editable'], 1)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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