Пример #1
0
def save_new_test_case():
    log.log().logger.info(request)
    if request.method == 'GET':
        log.log().logger.info('post')
        return render_template("uitest/new_test_cases.html")
    if request.method == 'POST':
        info = request.form
        log.log().logger.info('info : %s' % info)
        name = viewutil.getInfoAttribute(info, 'name')
        module = viewutil.getInfoAttribute(info, 'module')
        description = viewutil.getInfoAttribute(info, 'description')
        steps = viewutil.getInfoAttribute(info, 'steps')
        log.log().logger.info("steps: %s" % steps)
        steps = steps.replace('"', "'")
        log.log().logger.info("steps: %s" % steps)
        type = viewutil.getInfoAttribute(info, 'type')
        if module == '' or name == '' or steps == '' or type == '':
            return '必填字段不得为空!'
        else:
            if type == '公共用例':
                isPublic = 1
            else:
                isPublic = 0
            test_case_manage.test_case_manage().new_test_case(
                module, name, steps, description, isPublic)
        # return render_template("test_cases.html")
        return redirect('test_cases')
Пример #2
0
def edit_test_case():
    log.log().logger.info(request)
    if request.method == 'GET':
        log.log().logger.info('post')
        info = request.values
        log.log().logger.info('info : %s' % info)
        id = viewutil.getInfoAttribute(info, 'id')
        log.log().logger.info('id: %s' % id)
        return render_template("uitest/edit_test_cases.html", id=id)
    if request.method == 'POST':
        info = request.form
        log.log().logger.info('info : %s' % info)
        id = viewutil.getInfoAttribute(info, 'id')
        name = viewutil.getInfoAttribute(info, 'name')
        module = viewutil.getInfoAttribute(info, 'module')
        description = viewutil.getInfoAttribute(info, 'description')
        steps = viewutil.getInfoAttribute(info, 'steps')
        log.log().logger.info("steps: %s" % steps)
        steps = steps.replace('"', "'")
        log.log().logger.info("steps: %s" % steps)
        type = viewutil.getInfoAttribute(info, 'type')
        if module == '' or name == '' or steps == '' or type == '':
            return '必填字段不得为空!'
        else:
            if type == '公共用例':
                isPublic = 1
            else:
                isPublic = 0
            test_case_manage.test_case_manage().update_test_case(
                id,
                ['module', 'name', 'steps', 'description', 'isPublicFunction'],
                [module, name, steps, description, isPublic])
            return render_template("uitest/test_batch2.html",
                                   id=id,
                                   type='test_suite')
Пример #3
0
def search_test_cases():
    if request.method == 'POST':
        log.log().logger.info('post')
    if request.method == 'GET':
        info = request.values
        log.log().logger.info('info : %s' % info)
        limit = info.get('limit', 10)  # 每页显示的条数
        offset = info.get('offset', 0)  # 分片数,(页码-1)*limit,它表示一段数据的起点
        log.log().logger.info('get %s' % limit)
        log.log().logger.info('get  offset %s' % offset)
        id = viewutil.getInfoAttribute(info, 'id')
        module = viewutil.getInfoAttribute(info, 'module')
        type = viewutil.getInfoAttribute(info, 'type')
        log.log().logger.info('module: %s' % module)
        module = module.split(',')
        log.log().logger.info(module)
        name = viewutil.getInfoAttribute(info, 'name')
        conditionList = ['name']
        valueList = [name]
        if type == 'unattach' and 'public' in module:
            module.remove('public')
        elif type != 'test_case':
            if len(module) != 0 and module[0] != 'All' and module[0] != '':
                conditionList.append('module')
                valueList.append(module)
            log.log().logger.info(
                'info content: id- %s, module - %s, name - %s, type - %s' %
                (id, module, name, type))
        else:
            conditionList = ['id']
            valueList = [id]
            log.log().logger.info(
                'info content: id- %s, module - %s, name - %s, type - %s' %
                (id, module, name, type))
        # else:
        fieldlist = []
        rows = 1000
        if type == 'unattach':
            caseList = test_case_manage.test_case_manage(
            ).show_test_cases_unattach(id, conditionList, valueList, fieldlist,
                                       rows)
        else:
            caseList = test_case_manage.test_case_manage().show_test_cases(
                conditionList, valueList, fieldlist, rows)
        log.log().logger.info(caseList)
        data = caseList
        if type == 'test_case':
            data1 = jsonify({'total': len(data), 'rows': data[0]})
        else:
            data1 = jsonify({
                'total': len(data),
                'rows': data[int(offset):int(offset) + int(limit)]
            })
        log.log().logger.info('data1: %s' % data1)
        return data1, {'Content-Type': 'application/json'}
Пример #4
0
def copy_test_case():
    log.log().logger.info(request)
    log.log().logger.info(request.method)
    # log.log().logger.info(request.value)
    if request.method == 'GET':
        log.log().logger.info('post')
        result = jsonify({'code': 500, 'msg': 'should be get!'})
        return result
    if request.method == 'POST':
        info = request.form
        log.log().logger.info('info :  %s' % info)
        id = viewutil.getInfoAttribute(info, 'id')
        log.log().logger.info(id)
        if id == '':
            result = jsonify({'code': 500, 'msg': 'test case is not found!'})
        else:
            result0 = test_case_manage.test_case_manage().copy_test_case(id)
            if result0:
                result = jsonify({'code': 200, 'msg': 'copy success!'})
            else:
                result = jsonify({
                    'code': 500,
                    'msg': 'test case is not found!'
                })
        return result
Пример #5
0
def test_case_runhistory_report2():
    REMOTE_HOST = "https://pyecharts.github.io/assets/js"
    bar = pyecharts.Pie()
    bar.add("Sports",
            ["Football", "Basketball", "Baseball", "Tennis", "Swimming"],
            [23, 34, 45, 56, 67],
            is_more_utils=True)

    log.log().logger.info(request)
    if request.method == 'GET':
        log.log().logger.info('post')
        info = request.values
        log.log().logger.info('info :  %s' % info)
        id = viewutil.getInfoAttribute(info, 'id')
        log.log().logger.info('id: %s' % id)
        if len(test_case_manage.test_case_manage().show_test_cases(['id'],
                                                                   [id], [],
                                                                   2)) == 1:
            return render_template("uitest/test_batch_result.html",
                                   id=id,
                                   type='test_case',
                                   test_suite_id='',
                                   myechart=bar.render_embed(),
                                   host=REMOTE_HOST,
                                   script_list=bar.get_js_dependencies())
        else:
            return render_template("uitest/test_cases.html")
    else:
        return render_template("uitest/test_cases.html")
Пример #6
0
 def batch_new_testcase(self,
                        test_suite_id,
                        test_case_id_list,
                        browser_type_list=['']):
     support_browser = ['Chrome', 'Firefox', '']
     run_type = test_suite_manage.test_suite_manage().search_test_suite(
         test_suite_id, 'run_type')
     if run_type == 'Chrome':
         test_case_id_list = self.remove_android(test_case_id_list)
     log.log().logger.info('%s, %s' %
                           (test_case_id_list, len(test_case_id_list)))
     if len(test_case_id_list) == 0:
         result = 0
     else:
         for test_case_id in test_case_id_list:
             steps = test_case_manage.test_case_manage().search_test_case(
                 [test_case_id], ['name', 'steps'])
             log.log().logger.info('%s, %s, %s' %
                                   (steps, steps[0][0], steps[0][1]))
             if len(steps):
                 for browser_type in browser_type_list:
                     if browser_type not in support_browser:
                         log.log().logger.info(
                             '%s browser is not support!' % browser_type)
                     else:
                         self.new_test_batch(test_suite_id,
                                             test_case_id,
                                             steps[0][0],
                                             steps[0][1],
                                             browser_type=browser_type)
             else:
                 log.log().logger.info('test case not exist!')
             result = 1
     return result
Пример #7
0
 def batch_new_testcase_IP(self, test_suite_id, test_case_id_list, ip):
     run_type = test_suite_manage.test_suite_manage().search_test_suite(
         test_suite_id, 'run_type')
     if run_type == 'Chrome':
         test_case_id_list = self.remove_android(test_case_id_list)
     log.log().logger.info('%s, %s' %
                           (test_case_id_list, len(test_case_id_list)))
     if len(test_case_id_list) == 0:
         result = 0
     else:
         for test_case_id in test_case_id_list:
             steps = test_case_manage.test_case_manage().search_test_case(
                 [test_case_id], ['name', 'steps'])
             log.log().logger.info('%s, %s,%s' %
                                   (steps, steps[0][0], steps[0][1]))
             if len(steps):
                 self.new_test_batch_IP(test_suite_id,
                                        test_case_id,
                                        steps[0][0],
                                        steps[0][1],
                                        ip,
                                        status='0')
             else:
                 log.log().logger.info('test case not exist!')
             result = 1
     return result
Пример #8
0
def test_case_runhistory():
    log.log().logger.info(request)
    if request.method == 'GET':
        log.log().logger.info('post')
        info = request.values
        log.log().logger.info('info :  %s' %info)
        id = viewutil.getInfoAttribute(info, 'id')
        log.log().logger.info('id: %s' %id)
        if len(test_case_manage.test_case_manage().show_test_cases(['id'], [id], [], 2))==1:
            return render_template("uitest/test_batch2.html",id=id,type='test_case',test_suite_id='')
        else:
            return render_template("uitest/test_cases.html")
    else:
        return render_template("uitest/test_cases.html")
Пример #9
0
def delete_test_case():
    log.log().logger.info(request)
    if request.method == 'GET':
        log.log().logger.info('post')
        info = request.values
        log.log().logger.info('info : %s' %info)
        id = viewutil.getInfoAttribute(info, 'id')
        log.log().logger.info('id: %s' %id)
        return render_template("uitest/test_cases.html")
    if request.method == 'POST':
        info = request.form
        log.log().logger.info('info : %s' %info)
        id = viewutil.getInfoAttribute(info, 'id')
        act = viewutil.getInfoAttribute(info, 'act')
        if act == 'del':
            test_case_manage.test_case_manage().update_test_case(id, ['status'], [0])
            code = 200
            message = 'delete success!'
        else:
            code=500
            message = 'act is not del!'
        result = jsonify({'code': code, 'msg': message})
        return result,{'Content-Type': 'application/json'}
Пример #10
0
def test_public_test_cases():
    if request.method == 'POST':
        log.log().logger.info('post')
    if request.method == 'GET':
        info = request.values
        log.log().logger.info('info : %s' % info)

        conditionList = ['id']
        valueList = [id]
        fieldlist = []
        rows = 1000
        caseList = test_case_manage.test_case_manage().show_test_public_cases()
        log.log().logger.info(caseList)
        data = caseList
        data1 = jsonify({'total': len(data), 'rows': data})
        log.log().logger.info('data1: %s' % data1)
        return data1, {'Content-Type': 'application/json'}
Пример #11
0
def search_test_batch():
    if request.method == 'POST':
        log.log().logger.info('post')
    if request.method == 'GET':
        info = request.values
        log.log().logger.info('info : %s' % info)
        limit = info.get('limit', 10)  # 每页显示的条数
        offset = info.get('offset', 0)  # 分片数,(页码-1)*limit,它表示一段数据的起点
        log.log().logger.info('get %s' % limit)
        log.log().logger.info('get  offset %s' % offset)
        id = viewutil.getInfoAttribute(info, 'id')
        name = viewutil.getInfoAttribute(info, 'name')
        status = viewutil.getInfoAttribute(info, 'status')
        module = viewutil.getInfoAttribute(info, 'module')
        ipVal = viewutil.getInfoAttribute(info, 'ipVal')
        browser_type = viewutil.getInfoAttribute(info, 'browser_type')
        type = viewutil.getInfoAttribute(info, 'type')
        log.log().logger.info('module: %s' % module)
        log.log().logger.info('ipVal %s' % ipVal)
        module = module.split(',')
        log.log().logger.info(module)
        valueList = []
        conditionList = []
        if id == '':
            data1 = jsonify({'total': 0, 'rows': []})
        else:
            if name != '':
                conditionList.append('name')
                valueList.append(name)
            if status != '':
                conditionList.append('status')
                valueList.append(status)
            if len(module) != 0 and module[0] != 'All' and module[0] != '':
                conditionList.append('module')
                valueList.append(module)
            ipList = ipVal.split(',')
            for j in range(len(ipList)):
                if ipList[j] != '':
                    conditionList.append('ip')
                    valueList.append(ipList[j])
            fieldlist = []
            rows = 1000
            if type == "" or type == 'test_suite':
                conditionList.append('test_suite_id')
                valueList.append(id)
                caseList = test_batch_manage.test_batch_manage(
                ).show_test_batch(conditionList, valueList, fieldlist, rows)
                log.log().logger.info("caseList %s" % caseList)
                data = caseList
            elif type == 'test_case':
                conditionList.append('test_case_id')
                valueList.append(id)
                caseList = test_batch_manage.test_batch_manage(
                ).show_test_batch(conditionList, valueList, fieldlist, rows)
                log.log().logger.info(caseList)
                data = caseList
            else:
                caseList = test_case_manage.test_case_manage(
                ).show_test_cases_unattach(id, conditionList, valueList,
                                           fieldlist, rows)
                log.log().logger.info(caseList)
                data = caseList
            data1 = jsonify({
                'total': len(data),
                'rows': data[int(offset):int(offset) + int(limit)]
            })
            log.log().logger.info('data1: %s' % data1)
        return data1, {'Content-Type': 'application/json'}