From a9a99ab7e3873047bbf8904fecf47d19a6d841ea Mon Sep 17 00:00:00 2001 From: Nicolas Delaby <nicolas@nexedi.com> Date: Fri, 24 Dec 2010 16:01:56 +0000 Subject: [PATCH] Stick behaviour of acquisition_mask_value parameter of PropertySheets. mask_value == True, means local value take precedence over acquisition lookups. mask_value == False, means local value is displayed only if no relation is setted up OR if distant value is null (depends of Accessor type). Otherwise an acquired value is displayed over local_value. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41761 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/tests/testERP5Type.py | 97 ++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/product/ERP5Type/tests/testERP5Type.py b/product/ERP5Type/tests/testERP5Type.py index 6111e7828d..0d7d4bfccb 100644 --- a/product/ERP5Type/tests/testERP5Type.py +++ b/product/ERP5Type/tests/testERP5Type.py @@ -1279,6 +1279,103 @@ class TestPropertySheet: self.assertEquals(email.getDefaultAvailableLanguage(), 'ja') self.assertEquals(email.getAvailableLanguageList(), ('ja', 'fr', 'en')) + SUBORDINATION_ORGANISATION_REFERENCE = ''' + { 'id': 'subordination_organisation_reference', + 'type': 'string', + 'acquisition_base_category': ( 'subordination', ), + 'acquisition_portal_type' : ( 'Organisation', ), + 'acquisition_copy_value' : 0, + 'acquisition_mask_value' : 1, + 'acquisition_accessor_id' : 'getReference', + 'acquisition_depends' : None, + 'mode': 'rw', }''' + + def test_19c2_AcquiredStringAccessor(self): + """Tests an acquired string accessor. + We check in particular that getDefault[Property] and + setDefault[Property] are working correctly + This test focus on acquisition_mask_value parameter + """ + self._addProperty('Person', self.SUBORDINATION_ORGANISATION_REFERENCE) + + person = self.getPersonModule().newContent(portal_type='Person') + organisation = self.getOrganisationModule()\ + .newContent(portal_type='Organisation') + + person_reference = 'person_terry' + person.setSubordinationOrganisationReference(person_reference) + # Relation is not setted up, accessor must return + # local value + self.assertEquals(person.getSubordinationOrganisationReference(), + person_reference) + + person.setSubordinationValue(organisation) + transaction.commit() + self.tic() + + # mask_value is True, so local value take precedence + self.assertEquals(person.getSubordinationOrganisationReference(), + person_reference) + + organisation_reference = 'organisation_terry' + organisation.setReference(organisation_reference) + self.assertEquals(person.getSubordinationOrganisationReference(), + person_reference) + person.setSubordinationOrganisationReference(None) + self.assertEquals(person.getSubordinationOrganisationReference(), + organisation_reference) + + SUBORDINATION_ORGANISATION_SOURCE_REFERENCE = ''' + { 'id': 'subordination_organisation_source_reference', + 'type': 'string', + 'acquisition_base_category': ( 'subordination', ), + 'acquisition_portal_type' : ( 'Organisation', ), + 'acquisition_copy_value' : 0, + 'acquisition_mask_value' : 0, + 'acquisition_accessor_id' : 'getSourceReference', + 'acquisition_depends' : None, + 'mode': 'rw', }''' + + def test_19c3_AcquiredStringAccessor(self): + """Tests an acquired string accessor. + We check in particular that getDefault[Property] and + setDefault[Property] are working correctly + This test focus on acquisition_mask_value parameter + """ + self._addProperty('Person', + self.SUBORDINATION_ORGANISATION_SOURCE_REFERENCE) + + person = self.getPersonModule().newContent(portal_type='Person') + organisation = self.getOrganisationModule()\ + .newContent(portal_type='Organisation') + + person_reference = 'person_terry' + person.setSubordinationOrganisationSourceReference(person_reference) + # Relation is not setted up, accessor must return + # local value + self.assertEquals(person.getSubordinationOrganisationSourceReference(), + person_reference) + + person.setSubordinationValue(organisation) + transaction.commit() + self.tic() + + # mask_value is False, acquired value take precedence + # Because relation exists but distant document has no + # value, accessors fallback on local_value to display + # something to the user. + self.assertEquals(person.getSubordinationOrganisationSourceReference(), + person_reference) + + organisation_reference = 'organisation_terry' + organisation.setSourceReference(organisation_reference) + self.assertEquals(person.getSubordinationOrganisationSourceReference(), + organisation_reference) + person.setSubordinationOrganisationSourceReference(None) + self.assertEquals(person.getSubordinationOrganisationSourceReference(), + organisation_reference) + + NAME_INCLUDED_PROPERTY_PERSON = ''' { 'id': 'name_included_in_address', 'type': 'boolean', -- 2.30.9