예제 #1
0
    def remove_authority_record(self,
                                email_list,
                                password=None,
                                status=None,
                                company: list = None,
                                site: dict = None,
                                role: dict = None):
        print("At remove_authority_record \n " + str(locals()))

        if email_list is None:
            return
        email_list = list(set(email_list))
        authority = Authority()
        for email in email_list:
            authority.remove_authority(email,
                                       company=company,
                                       site=site,
                                       role=role)
        print("At remove_authority_record, to save to file: ")
        print(str(authority.df))
        authority.commit()
예제 #2
0
    def add_authority_record(self,
                             email_list,
                             password=None,
                             status=None,
                             company: list = None,
                             site: dict = None,
                             role: dict = None):
        #print("At add_authority_record \n " + str(locals()))

        if email_list is None:
            return
        email_list = list(set(email_list))
        authority = Authority()
        for email in email_list:
            authority.add_authority(email,
                                    password=password,
                                    status=status,
                                    company=company,
                                    site=site,
                                    role=role)
        #print(str(authority.df))
        authority.commit()
예제 #3
0
    def verify_companyadmin_password_email(self):

        self.start_test(locals())

        # get email_list
        authority = Authority()
        email_list = authority.get_email_list(bycolumn="role",
                                              value=ROLE_COMPANY_ADMIN)

        print("Start to check email and password for:  " + str(email_list))

        valuedict = self.verify_password_email(email_list)
        self.assert_true(
            valuedict != [],
            "Did not send email or password to: " + str(email_list))

        for item in valuedict:
            authority.add_authority(email=item["email"],
                                    password=item["password"])
        print(str(authority.df))
        authority.commit()

        self.end_test(self._testMethodName)
예제 #4
0
    def company_update(self, companyname, valuedict, expectation):

        self.start_test(locals())

        companyname, key, value, expectation = self.process_update_input(
            companyname, valuedict, expectation)

        self.login_sysadmin()

        found_company = self.company_search(companyname)
        if found_company == {}:
            self.assertTrue(False, "Cannot find company: " + companyname)

        found_correct = found_company["companyname"] == companyname \
                        and self.get_text(found_company["name_selector"]) == found_company["companyname"] \
                        and self.get_text(found_company["id_selector"]) == found_company["id"]
        print("Found info: \n" + str(found_company))
        self.assert_true(
            found_correct,
            "Found info doesn't match what show on user interface \n" +
            "Try to find: " + companyname + "\n But find " +
            str(found_company))

        edit_selector = str(found_company["edit_selector"])

        if True:
            self.company_update_start(edit_selector)
            authority = Authority()

            company = companyname
            if "companyname" in key:
                company = str(value["companyname"])
                self.company_create_update_set_companyname(company)
                email_list = authority.get_email_list(bycolumn="company",
                                                      value=companyname)
                for email in email_list:
                    authority.update_authority_list_value_column(
                        email=email,
                        column="company",
                        value=[companyname],
                        action="remove")
                    authority.update_authority_list_value_column(
                        email=email,
                        column="company",
                        value=[company],
                        action="add")

            if "status" in key:
                status = str(value["status"])
                self.company_create_update_set_status(status)
            else:
                status = None

            if "email" in key:
                email_list = str(value["email"])
                email_list = utilities.str_to_list(email_list)
                if expectation == "illegal_email_msg":
                    fail_msg = "The email address is invalid"
                else:
                    fail_msg = None
                self.company_create_update_set_email(email_list=email_list,
                                                     fail_msg=fail_msg,
                                                     expectation=expectation)

                # deal with user profile
                # email list connected with target company
                existing_connected_email_list = authority.get_email_list(
                    bycolumn="company", value=company)

                to_add_connection_email_list = [
                    i for i in email_list
                    if i not in existing_connected_email_list
                ]
                print("To_add_connection_email_list:   " +
                      str(to_add_connection_email_list))
                for email in to_add_connection_email_list:
                    authority.add_authority(email=email, company=[company])

                to_delete_email_list = [
                    i for i in existing_connected_email_list
                    if i not in email_list
                ]
                print("To_delete_email_list:   " +
                      str(to_delete_email_list))  #remove connection
                for email in to_delete_email_list:
                    authority.update_authority_list_value_column(
                        email=email,
                        column="company",
                        value=[company],
                        action="remove")
            else:
                email_list = None

            self.company_create_update_submit(expectation)

            if expectation == "pass":
                self.verify_company_info(company, status, email_list)
                print("start to update user profile with: \n" +
                      str(authority.df))
                authority.commit()

        self.logout()

        self.end_test(self._testMethodName)