Пример #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 test_user_import_from_excel_file_acceptance(self):
        driver = self.driver

        # create a folder for covalent-members:
        pat.setRoles(self.portal, pat.TEST_USER_ID, ('Manager',))
        members = helpers.create_memberfolder(self.portal)

        # log in as a manager:
        login(driver, self.portal, username=testing.MANAGER,
            password=testing.PASSWORD)

        open(driver, members.absolute_url() + "/import")

        fileUpload = driver.find_element_by_name("form.widgets.file")
        filename = helpers.absolute_dir("assets/covalent_batch.xls")
        fileUpload.send_keys(filename)
        driver.find_element_by_id("form-buttons-save").click()

        # TODO: assert

        driver.find_element_by_name("confirm").click()