Esempio n. 1
0
 def get_user_info(self):
     user_info = []
     for j in self.test_register():
         search_result = do_mysql.sql_search(
             sql=('SELECT Id,RegName,MobilePhone,Pwd FROM member WHERE MobilePhone=%s'),
             virtue=j)
         user_info.append(search_result)
     return user_info
Esempio n. 2
0
 def test_recharge(self, case_list):
     self.my_HandleExcel = HandleExcel(DATA_COMMON_FILE_PATH, 'recharge')
     if case_list['check_sql']:
         before_sql_data = do_mysql.sql_search(
             case_list['check_sql'],
             virtue=eval(case_list['data'])['mobilephone'])
         self.before_leaveamount = float(before_sql_data['LeaveAmount'])
     request_result = do_request.send_request(
         case_list['method'],
         do_config.get_value('request', 'default_address') +
         case_list['url_path'], case_list['data'])
     actual = int(request_result.json().get('code'))
     result = case_list['expected']
     msg = case_list['title']
     try:
         self.assertEqual(result, actual, msg)
         if case_list['check_sql']:
             after_sql_data = do_mysql.sql_search(
                 case_list['check_sql'],
                 virtue=eval(case_list['data'])['mobilephone'])
             after_leaveamount = float(after_sql_data['LeaveAmount'])
             true_results = after_leaveamount - self.before_leaveamount
             self.assertEqual(
                 eval(case_list['data'])['amount'], round(true_results, 2),
                 msg)
         print('{},执行结果为:{}'.format(msg, true_result))
         self.my_HandleExcel.write_result(case_list['case_id'] + 1, actual,
                                          true_result)
         do_logger.error("{}, 执行结果为: {}".format(msg, true_result))
     except AssertionError as e:
         print('具体异常为{}'.format(e))
         self.my_HandleExcel.write_result(case_list['case_id'] + 1, actual,
                                          fail_result)
         do_logger.error("{}, 执行结果为: {},具体异常为{}".format(
             msg, fail_result, e))
         raise e
Esempio n. 3
0
 def test_invest(self, case_list):
     case_list_str = str(case_list)
     context_data = HandleContext.manager_user_tel(case_list_str)
     context_data = HandleContext.manager_user_pwd(context_data)
     context_data = HandleContext.borrower_user_id(context_data)
     context_data = HandleContext.loan_id(context_data)
     context_data = HandleContext.investors_user_tel(context_data)
     context_data = HandleContext.investors_user_id(context_data)
     context_data = HandleContext.investors_user_pwd(context_data)
     context_data = HandleContext.not_existed_user_id(context_data)
     context_data = HandleContext.not_exitsed_loan_id(context_data)
     case_list_dict = eval(context_data)
     request_data = case_list_dict['data']
     method = case_list_dict['method']
     url = do_config.get_value(
         'request', 'default_address') + case_list_dict['url_path']
     res = do_request.send_request(method, url, data=request_data)
     add_success_msg = do_config.get_value('request', 'add_success_msg')
     actual = res.text
     if add_success_msg in actual:
         check_sql = case_list_dict['check_sql']
         if check_sql:
             loan_id_sql = do_mysql.sql_search(check_sql)
             loan_id_value = loan_id_sql['Id']
             setattr(HandleContext, 'loan_idw', loan_id_value)
     result = str(case_list_dict['expected'])
     msg = case_list_dict['title']
     true_result = do_config.get_value('msg', 'true_result')
     fail_result = do_config.get_value('msg', 'fail_result')
     try:
         self.assertIn(result, actual, msg)
         print('{},执行结果为:{}'.format(msg, true_result))
         my_excel.write_result(case_list_dict['case_id'] + 1, actual,
                               true_result)
         do_logger.error("{}, 执行结果为: {}".format(msg, true_result))
     except AssertionError as e:
         print('具体异常为{}'.format(e))
         my_excel.write_result(case_list_dict['case_id'] + 1, actual,
                               fail_result)
         do_logger.error("{}, 执行结果为: {},具体异常为{}".format(
             msg, fail_result, e))
         raise e