case.Interface_is_tiaoshi = True case.Interface_tiaoshi_shifou = True db.session.commit() return jsonify({ 'code': 60, 'msg': u'用例测试失败,失败原因:{},请检查测试用例'.format(e) }) elif case.interface_type == 'dubbo': try: data = eval(case.Interface_pase) except Exception as e: case.Interface_is_tiaoshi = True case.Interface_tiaoshi_shifou = True db.session.commit() return jsonify({'code': 61, 'msg': '转化请求参数失败,原因:%s' % e}) dubboapi = DubboInterface(url=case.Interface_url, interface=case.Interface_pase, method=case.Interface_meth, param=case.Interface_headers, **(data)) dubboapireslu = dubboapi.getresult() if case.saveresult is True: new_testre = TestcaseResult(case_id=case.id) new_testre.result = str(dubboapireslu) new_testre.testevir = (url) db.session.add(new_testre) db.session.commit() if dubboapireslu['code'] == 0: assert_re = assert_in(asserqiwang=case.Interface_assert, fanhuijson=json.loads(dubboapireslu)) if assert_re == 'pass':
db.session.commit() return jsonify({'code': 102, 'msg': '测试返回异常,,请检查用例!'}) except Exception as e: case.Interface_is_tiaoshi = True case.Interface_tiaoshi_shifou = True db.session.commit() return jsonify({'code': 103, 'msg': u'用例测试失败,失败原因:{},请检查测试用例'.format(e)}) elif case.interface_type=='dubbo': try: data=eval(case.Interface_pase) except Exception as e: case.Interface_is_tiaoshi = True case.Interface_tiaoshi_shifou = True db.session.commit() return jsonify({'code': 159, 'msg': '转化请求参数失败,原因:%s' % e}) dubboapi = DubboInterface(url=case.Interface_url, interface=case.Interface_pase, method=case.Interface_meth, param=case.Interface_headers, **(data)) dubboapireslu = dubboapi.getresult() if case.saveresult is True: new_testre = TestcaseResult(case_id=case.id) new_testre.result = str(dubboapireslu) new_testre.testevir = (url) db.session.add(new_testre) db.session.commit() if dubboapireslu['code'] == 0: pass # assert_re = assert_in(asserqiwang=case.Interface_assert,fanhuijson=dubboapireslu) else: return jsonify({'code': 316, 'msg': '目前还不支持你所选择的类型的协议!'}) except Exception as e: case.Interface_is_tiaoshi = True