Пример #1
0
    def test_a_modify_login_passwd(self, old, new1, new2, expect):
        self.modify_passwd.do_modify_login_passwd(old, new1, new2)
        username = login_user_info['username']
        sql = f'update system_user set pwd="B5B1C07C180FEFC77671906F382488F2" where name="{username}"'
        if '修改成功' in self.driver.find_element_by_css_selector(
                '#panel-password-success>div.modal-body.modal-warning>div>h4'
        ).text:
            actual = 'login: modify password pass'
            Utility.update_data(login_user_info, sql)
            self.driver.refresh()
        else:
            if Service.is_element_present(
                    self.driver, By.CSS_SELECTOR,
                    'body>div.bootbox.modal.fade.mydialog.in'
                    '>div>div>div.modal-body>div'):
                content = self.driver.find_element_by_css_selector(
                    'body>div.bootbox.modal.fade.mydialog.in'
                    '>div>div>div.modal-body>div').text

                if '新密码和原密码一致' in content:
                    actual = 'login:new vs old is same'
                elif '原密码错误' in content:
                    actual = 'login:old password is wrong'
                elif '请输入原密码' in content:
                    actual = 'login:old passeord is empty'
                elif '两次新密码输入不一致' in content:
                    actual = 'login:new_1st vs new_2st is not equal'
                elif '新密码格式不正确' in content:
                    actual = 'login:new password format is wrong'
                else:
                    actual = 'login:unknow error'
            else:
                actual = 'alert not appear'
            self.driver.refresh()
        self.assertEqual(expect, actual)
Пример #2
0
 def test_c_add_logs(self, s_time, e_time, hour, way, logs, expect):
     attr = self.teacher_duty.do_add_logs(s_time, e_time, hour, way, logs)
     attr_dict = attr.split('(')[1].split(')')[0]
     import json
     dict_attr = json.loads(attr_dict, encoding='utf-8')
     id = dict_attr['id']
     sql = f'update duty set log_status = "01" where id = {id}'
     ele_text = self.driver.find_element_by_css_selector(
         'body > div.bootbox.modal.fade.mydialog.in > div > div > '
         'div.modal-body > div').text
     if '日志填写成功' in ele_text:
         actual = 'test add duty logs pass'
         Utility.update_data(user_info, sql)
     else:
         actual = 'test add duty logs fail'
     self.driver.refresh()
     self.assertEqual(expect, actual)
Пример #3
0
 def test_c_undo_overtime_application(self, unkonw, expect):
     attr1, attr2 = self.overtime_application.do_undo_action()
     attr_dict = attr1.split('(')[1].split(')')[0]
     import json
     dict_attr = json.loads(attr_dict, encoding='utf-8')
     id = dict_attr['id']
     sql1 = f'select status from apply where id ={id}'
     db_result = Utility.query_one(user_info, sql1)
     time.sleep(2)
     status_text = self.overtime_application.get_line1_status()
     if '已撤销' in status_text and db_result[0] == '04' and attr2 == 'true':
         actual = 'test undo overtime application pass'
         sql2 = f"UPDATE apply SET status='03' WHERE (`id`='{id}')"
         Utility.update_data(user_info, sql2)
     else:
         actual = 'test undo overtime application fail'
     self.assertEqual(expect, actual)
    def test_today_morning_exam(cls, method, score, question, expect):
        import time
        local_time = time.strftime('%Y-%m-%d', time.localtime(time.time()))
        sql = f'select count(*) from morn_exam where create_time like "{local_time}%"'
        db_result1 = Utility.query_one(today_morning_exam_user_info, sql)
        cls.today_morning_exam.do_morning_exam(method, score, question)

        db_result2 = Utility.query_one(today_morning_exam_user_info, sql)
        num = db_result2[0] - db_result1[0]
        if num == 1:
            actual = 'test today morning exam pass'
            sql_del = 'delete from morn_exam order by morn_exam_id desc limit 1'
            Utility.update_data(today_morning_exam_user_info, sql_del)
        else:
            actual = 'test today morning exam fail'

        cls.assertEqual(expect, actual)