Esempio n. 1
0
    def test_user_import_from_excel_file(self):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))

        # create a folder for covalent-members:
        members = helpers.create_memberfolder(self.portal)

        # extract members from file:
        excel_file_path = helpers.absolute_dir("assets/covalent_batch.xls")
        excel_file = open(excel_file_path, "r+b")
        filedata = mmap.mmap(excel_file.fileno(), 0)

        user_infos = member_import.extract_memberdata(filedata)

        filedata.close()
        excel_file.close()

        # add covalent-members:
        utilities.add_members(members, user_infos)

        # inspect our covalent-members:
        for properties in user_infos:
            memberId = properties['id']
            self.assertIn(memberId, members)
            member = members[memberId]
            self.assertEqual(member.title, properties['title'])
            self.assertEqual(member.emailAddress, properties['emailAddress'])
 def update(self):
     self.user_infos = \
         self.request.SESSION.get('batchuploadform_users', None)
     if not self.user_infos:
         return self.request.response.redirect(
             self.context.absolute_url() + '/import')
     if self.request.get('confirm'):
         utilities.add_members(self.context, self.user_infos)
         return self.request.response.redirect(
             self.context.absolute_url())
     if self.request.get('cancel'):
         return self.request.response.redirect(
             self.context.absolute_url() + '/import')