예제 #1
0
                            % (interface_parm, headerdata, interface_parm))
            else:
                result = {'code': '1000', 'message': '请求类型错误', 'data': []}
        except Exception as e:
            # traceback.print_exc()
            MyLog.error(e)
        return result


if __name__ == '__main__':
    test_interface = RequestInterface()
    obj = OperationDbInterface(host_db='127.0.0.1', user_db='root', pwd_db='123456', name_db='test_interface',
                               port_db=3306,
                               link_type=0)
    sen_sql = "SELECT exe_mode,url_interface,header_interface,params_interface,code_expect from case_interface WHERE name_interface='getIpInfo.php' AND id=1; "
    parmams_interface = obj.select_one(sen_sql)

    print(parmams_interface)
    if parmams_interface.get('code') == '0000':
        # print(parmams_interface)
        url_interface = parmams_interface.get('data').get('url_interface')
        # print(url_interface)
        print(parmams_interface.get('data').get('header_interface'))
        headdata = ast.literal_eval(parmams_interface.get('data').get('header_interface'))  # 将unicode转换为字典
        type_interface = parmams_interface.get('data').get('exe_mode')
        # print((headdata))
        if url_interface != '' and headdata != '' and parmams_interface != '' and type_interface != '':
            print('yes')
            result = test_interface.http_request(url_interface, headdata,
                                                 parmams_interface.get('data').get('params_interface'), type_interface)
            print(result)
예제 #2
0
                                    else:
                                        print(
                                            '接口名称: %s|信息错误:获取用例数据失败|错误信息: %s\n'
                                            % (temp_name_interface,
                                               data_case_interface['message']))
                                        print(
                                            '#####################结束执行接口:%s#################### \n'
                                            % temp_name_interface)
                else:
                    print('错误信息:待执行接口获取失败|错误信息:%s' % module_execute['message'])

            elif value_input == '1':
                print('你输入的是:1|导出测试用例结果,请注意查看目录:%s' %
                      (config.src_path + '\\report'))
                name_export = base_db.select_one(
                    "SELECT value_config from config_total "
                    "WHERE `status` =1 AND key_config = 'name_export'"
                )  # 获取导出的接口数据元组
                print(name_export)
                if name_export['code'] == '0000' and len(
                        name_export['data']['value_config']) != 0:  #判断查询结果
                    temp_export = eval(
                        name_export['data']['value_config'])  #获取查询数据,并将其转化为字典
                    test_analyse_data = AnalyseData()
                    result_export = test_analyse_data.export2excel(
                        temp_export)  #导出测试结果
                    print(result_export['message'])
                    print("导出失败接口列表: %s\n" % result_export['data'])
                else:
                    print('请检查配置表数据正确性,当前值为:%s \n' % name_export['data'])
    except Exception as e:
        print('系统出现异常:%s ' % e)