Exemplo n.º 1
0
def install_mock_pas_plugin():
    out = io.BytesIO()
    pp = ZODBMutablePropertyProvider(TESTING_PLUGIN_ID,
                                     'Mock LDAP',
                                     schema=(('email', 'string', NO_VALUE), ))
    pp.meta_type = 'Mock External PAS Users'
    acl_users = api.portal.get_tool('acl_users')
    acl_users[TESTING_PLUGIN_ID] = pp
    activatePluginInterfaces(api.portal.get(), TESTING_PLUGIN_ID, out)
Exemplo n.º 2
0
    def test_schema_for_mutable_property_provider(self):
        """Add a schema to a ZODBMutablePropertyProvider.
        """

        # Schema is list of tuples with name, type (string), value.
        # From the types it seems only 'lines' is handled differently.
        address_schema = [
            ('addresses', 'lines', ['Here', 'There']),
            ('city', 'str', 'Somewhere'),
            ('telephone', 'int', 1234567),
        ]

        # This used to give a ValueError, so we just check that it
        # does not.
        provider = ZODBMutablePropertyProvider('address_plugin',
                                               "Address Plugin",
                                               schema=address_schema)

        # When this test passes, we are happy already, but let's add a
        # few more basic tests.

        # Create a new Member
        mt = getToolByName(self.portal, 'portal_membership')
        mt.addMember('user1', 'u1', ['Member'], [], {
            'email': '*****@*****.**',
            'fullname': 'User #1'
        })
        member = mt.getMemberById('user1')
        sheet = provider.getPropertiesForUser(member)
        self.assertEqual(sheet.propertyIds(),
                         ['addresses', 'city', 'telephone'])
        self.assertEqual(sheet.propertyInfo('city'), {
            'type': 'str',
            'id': 'city',
            'mode': ''
        })
        self.assertEqual(sheet.getProperty('addresses'), ('Here', 'There'))