示例#1
0
    def insert(self, data):
        '''
        新增
        :param data: 新增数据
        :return:
        '''
        try:
            rqmt_id = newID().RQMT_ID()
            get_data = json.loads(data)
            rqmt_dever = get_data['rqmt_dever']
            rqmt_tester = get_data['rqmt_tester']
            rqmt_desc = get_data['rqmt_desc']
            group_id = getCode(get_data['group_id'])
            rqmt_end_date = get_data['rqmt_end_date']
            rqmt_begin_date = get_data['rqmt_begin_date']
            rqmt_status = get_data['rqmt_status']
            sql = 'INSERT INTO t_requirements_info (rqmt_dever, rqmt_tester, rqmt_desc, rqmt_end_date, rqmt_id,group_id,rqmt_begin_date,rqmt_status) VALUE(%s,%s,%s,%s,%s,%s,%s,%s)'
            params = (rqmt_dever, rqmt_tester, rqmt_desc, rqmt_end_date,
                      rqmt_id, group_id, rqmt_begin_date, rqmt_status)
            insert_result = DB_CONN().db_Insert(sql, params)
            # insert_result=insertToDatabase('t_requirements_info',get_data,rqmt_id=rqmt_id)
            return_data = respdata().sucessMessage(
                '', '新增成功,新增记录数为: ' + str(insert_result))

            return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
        except Exception as e:
            return_data = respdata().failMessage('',
                                                 '新增失败,请检查!错误信息为:' + str(e))
            return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
示例#2
0
 def insert(self, data):
     '''
     新增
     :param data: 新增数据
     :return:
     '''
     try:
         get_data = json.loads(data)
         rule_id = newID().RULE_ID()
         rule_import_desc = json.dumps(get_data['rule_import_desc'])
         rule_import_project = get_data['rule_import_project']
         # rule_import_project_a = dict()
         # for i in get_data['rule_import_desc']:
         #     rule_import_project_a[i] = ''
         # rule_import_project.append(rule_import_project_a)
         rule_import_project = json.dumps(rule_import_project)
         rule_checked = get_data['rule_checked']
         del get_data['rule_checked']
         del get_data['rule_import_desc']
         insert_result = insertToDatabase(
             't_rule_info',
             get_data,
             rule_id=rule_id,
             group_id=0,
             rule_import_desc=rule_import_desc,
             rule_import_project=rule_import_project,
             rule_checked=rule_checked)
         return_data = respdata().sucessMessage(
             '', '新增成功,新增记录数为: ' + str(insert_result))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
     except Exception as e:
         return_data = respdata().failMessage('',
                                              '新增失败,请检查!错误信息为:' + str(e))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
示例#3
0
 def coreInsert(self, data, **kwargs):
     '''
     新增
     :param data: 新增数据
     :return:
     '''
     try:
         get_data = json.loads(data)
         group_id_arr = get_data['group_id_arr']
         del get_data['group_id_arr']
         group_id_arr = json.dumps(group_id_arr)
         group_id = getCode(get_data['group_id'])
         get_data['group_id'] = group_id
         case_id = newID().CS_ID()
         get_data.update(kwargs)
         case_builder = self.username
         insert_result = insertToDatabase(self.table,
                                          get_data,
                                          case_id=case_id,
                                          group_id_arr=group_id_arr,
                                          case_builder=case_builder)
         return_data = respdata().sucessMessage(
             '', '新增成功,新增记录数为: ' + str(insert_result))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
     except Exception as e:
         return_data = respdata().failMessage('',
                                              '新增失败,请检查!错误信息为:' + str(e))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
示例#4
0
    def insert_to_casetable(self, online_timea, group_id):
        if self.table == 'rqmt_case_info':
            online_time = ''
            task_lists = self.transform_opt(rqmt_id=self.id)
        elif self.table == 'regress_case_info':
            online_time = online_timea
            task_lists = self.transform_opt(group_id=group_id)
        elif self.table == 'core_case_info':
            online_time = online_timea
            task_lists = self.transform_opt(group_id=group_id)
        if task_lists:
            groupdict = {}
            for i in task_lists:
                case_exe_plugin = i.get('case_exe_plugin')
                task_id = groupdict.get(str(case_exe_plugin))
                if not task_id:
                    task_id = newID().TK_ID()
                    groupdict[str(case_exe_plugin)] = task_id
                    self.insert_task_lists(task_id, case_exe_plugin,
                                           online_time, group_id)
                self.executor.submit(self.insert_case, task_id, i)

        # for key, val in task_lists.items():
        #     #listcase = task_lists.get(key)
        #     if len(val) == 0:
        #         pass
        #     else:
        #         task_id = newID().TK_ID()
        #         #time.sleep(1)
        #         for i in range(len(val)):
        #             #casedict = val[i]
        #             self.executor.submit(self.insert_case,task_id, val[i])
        #             #self.insert_case(task_id, val[i])
        #         if key == 'manual_lists':
        #             self.insert_task_lists(task_id, 100, online_time,group_id)
        #         elif key == 'API_platform_lists':
        #             self.insert_task_lists(task_id, 200, online_time,group_id)
        #         elif key == 'API_python_lists':
        #             self.insert_task_lists(task_id, 201, online_time,group_id)
        #         elif key == 'JMeter_lists':
        #             self.insert_task_lists(task_id, 202, online_time,group_id)
        #         elif key == 'Appium_lists':
        #             self.insert_task_lists(task_id, 401, online_time,group_id)
        #         elif key == 'PC_AT_lists':
        #             self.insert_task_lists(task_id, 301, online_time,group_id)
        #         elif key == 'UIAutomation_lists':
        #             self.insert_task_lists(task_id, 402, online_time,group_id)
        #         elif key == 'IOS_lists':
        #             self.insert_task_lists(task_id, 501, online_time,group_id)
        #         elif key == 'RTF_lists':
        #             self.insert_task_lists(task_id, 901, online_time,group_id)
        #         else:
        #             pass
        return_data = respdata().sucessMessage('', '任务转换完成,请查看!~')
        return json.dumps(return_data, ensure_ascii=False)
示例#5
0
 def timetaskInert(self, data):
     '''
     {"task_id":"TASK-20180711141704","timing_title":"测试调试","host_id":"ENV-2018100004","email_id":"41850","plugin_id":"P-1808160009","timing_data":{"timing_cycle":"hour","start_time":"2"},"timing_count":1,"is_run":"0-启动,1-停止"}
     :param data:
     :return:
     '''
     get_data = json.loads(data)
     time_id = newID().TIME_Id()
     result = insertToDatabase('t_time_task',
                               get_data,
                               time_id=time_id,
                               is_run=0)
     return_data = respdata().sucessMessage('', '保存成功!~')
     return json.dumps(return_data, ensure_ascii=False)
示例#6
0
 def case_rule_insert(self, data):
     '''
     用例模板新增
     :param data: 新增数据
     :return:
     '''
     try:
         get_data = json.loads(data)
         rule_case_id = newID().RULE_CASE_ID()
         insert_result = insertToDatabase('rule_case_info',
                                          get_data,
                                          rule_case_id=rule_case_id)
         return_data = respdata().sucessMessage(
             '', '新增成功,新增记录数为: ' + str(insert_result))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
     except Exception as e:
         return_data = respdata().failMessage('',
                                              '新增失败,请检查!错误信息为:' + str(e))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
示例#7
0
 def insert(self, data, **kwargs):
     '''
     添加环境组信息
     :return:
     '''
     try:
         get_data = json.loads(data)
         env_id = newID().envID()
         get_data.update(kwargs)
         insert_result = insertToDatabase(self.table,
                                          get_data,
                                          env_id=env_id)
         return_data = respdata().sucessMessage(
             '', '新增成功,新增记录数为: ' + str(insert_result))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
     except Exception as e:
         return_data = respdata().failMessage('',
                                              '新增失败,请检查!错误信息为:' + str(e))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
示例#8
0
 def apiCopy(self, data):
     try:
         get_data = json.loads(data)
         api_id = get_data['api_id']
         sql = "select * from api_case_info where api_id = '{}'".format(
             api_id)
         result = getJsonFromDatabase(sql)[0]
         for k, v in result.items():
             if k == 'api_id':
                 result[k] = newID().apiId()
             if k == 'title':
                 result[k] = v + "___(复制)"
         del result['adddate']
         insertToDatabase('api_case_info', result)
         return_data = respdata().sucessMessage('', "复制成功!~")
         return json.dumps(return_data, ensure_ascii=False)
     except Exception as e:
         a = dict()
         a['response'] = '请求错误,错误信息为: ' + str(e)
         return json.dumps(resp(202, '请求失败', a), ensure_ascii=False)
示例#9
0
 def email_save(self, data):
     getdata = json.loads(data)
     email_id = newID().groupID()
     email_groupname = getdata['email_groupname']
     email_mainrecv = getdata['email_mainrecv']
     email_cc = getdata['email_cc']
     email_title = getdata['email_title']
     group_id = getCode(getdata['group_id'])
     group_id_arr = json.dumps(getdata['group_id_arr'])
     sql = 'insert into p_env_email_confg (email_id,email_groupname,email_mainrecv,email_cc,email_title,group_id,group_id_arr) VALUE (%s,%s,%s,%s,%s,%s,%s)'
     params = (email_id, email_groupname, email_mainrecv, email_cc,
               email_title, group_id, group_id_arr)
     try:
         dba = getJsonMysql()
         dba.exeUpdateByParamJson(sql, params)
         return_data = resp(200, '成功', '')
         return json.dumps(return_data, ensure_ascii=False)
     except Exception as e:
         a = dict()
         a['response'] = '请求错误,错误信息为: ' + str(e)
         return json.dumps(resp(201, '请求失败', a), ensure_ascii=False)
示例#10
0
 def insert(self, data, **kwargs):
     '''
     新增
     :param data: 新增数据
     :return:
     '''
     try:
         get_data = json.loads(data)
         get_data.update(kwargs)
         case_id = newID().CASE_ID()
         insert_result = insertToDatabase(
             self.table,
             get_data,
             case_id=case_id,
         )
         return_data = respdata().sucessMessage(
             '', '新增成功,新增记录数为: ' + str(insert_result))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
     except Exception as e:
         return_data = respdata().failMessage('',
                                              '新增失败,请检查!错误信息为:' + str(e))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
示例#11
0
 def env_insert(self, data, **kwargs):
     '''
             获取环境列表
             :return:
             '''
     try:
         get_data = json.loads(data)
         env_d_id = newID().ENV_ID_D()
         env_d_params = json.dumps(get_data['env_d_params'])
         del get_data['env_d_params']
         get_data.update(kwargs)
         insert_result = insertToDatabase(self.table,
                                          get_data,
                                          env_d_id=env_d_id,
                                          env_d_params=env_d_params)
         return_data = respdata().sucessMessage(
             '', '新增成功,新增记录数为: ' + str(insert_result))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
     except Exception as e:
         return_data = respdata().failMessage('',
                                              '新增失败,请检查!错误信息为:' + str(e))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
示例#12
0
 def warningInsert(self, data, **kwargs):
     '''
     新增
     :param data: 新增数据
     :return:
     '''
     try:
         get_data = json.loads(data)
         warning_id = newID().WN_ID()
         warning_email_id = json.dumps(get_data["warning_email_id"])
         warning_desc = get_data["warning_desc"]
         warning_info = json.dumps(get_data["warning_info"])
         warning_type = get_data['warning_type']
         warning_sql = "INSERT INTO w_warning_info ( warning_id,warning_email_id,warning_desc,warning_info,warning_type ) VALUE (%s,%s,%s,%s,%s)"
         params = (warning_id, warning_email_id, warning_desc, warning_info,
                   warning_type)
         insert_result = DB_CONN().db_Insert(warning_sql, params)
         return_data = respdata().sucessMessage(
             '', '新增成功,新增记录数为: ' + str(insert_result))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
     except Exception as e:
         return_data = respdata().failMessage('',
                                              '新增失败,请检查!错误信息为:' + str(e))
         return json.dumps(return_data, cls=MyEncoder, ensure_ascii=False)
示例#13
0
def empty_api(ws, j, groupid, db):
    api_uri = ws[j + 1][1].value
    if api_uri != None:
        print("测试一下")
        case_desc = ws[j + 1][2].value
        method = ws[j + 1][3].value
        data = ws[j + 1][4].value
        headers = ws[j + 1][5].value
        return1 = ws[j + 1][6].value
        return2 = ws[j + 1][7].value
        api_type = ws[j + 1][8].value
        api_path = ws[j + 1][12].value

        # 接口類型
        if api_type is None:
            api_type = None
        elif "查" in api_type:
            api_type = 1
        elif "新" in api_type:
            api_type = 2
        elif "改" in api_type:
            api_type = 3
        elif "刪" in api_type:
            api_type = 4

        # 接口登錄態
        api_need_login = ws[j + 1][9].value
        if api_need_login is None:
            api_need_login = api_need_login
        elif "否" in api_need_login:
            api_need_login = 0
        elif "是" in api_need_login:
            api_need_login = 1

        # 接口是否重構
        api_is_remold = ws[j + 1][10].value
        if api_is_remold is None:
            api_is_remold = None
        elif "否" in api_is_remold:
            api_is_remold = 0
        elif "是" in api_is_remold:
            api_is_remold = 1

        # 接口狀態
        api_status = ws[j + 1][11].value
        if api_status is None:
            api_status = None
        elif "无" in api_status:
            api_status = 0
        elif "有" in api_status:
            api_status = 1
        elif '改' in api_status:
            api_status = 2
        id = newID().apiId()
        group_id = groupid
        if data != None:
            init_pa = changRaw(json.loads(data), 'api')
            sql = 'insert into api_case_info (api_id,uri,method,title,headers,params,init_data,group_id,api_type,api_need_login,api_is_remold,api_status,api_path) VALUE (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'
            aparams = (id, api_uri, method, case_desc, headers, data,
                       json.dumps(init_pa), group_id, api_type, api_need_login,
                       api_is_remold, api_status, api_path)
        else:
            sql = 'insert into api_case_info (api_id,uri,method,title,headers,params,group_id,api_type,api_need_login,api_is_remold,api_status,api_path) VALUE (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'
            aparams = (id, api_uri, method, case_desc, headers, data, group_id,
                       api_type, api_need_login, api_is_remold, api_status,
                       api_path)

        db.exeUpdateByParamJson(sql, aparams)
        return_data = respdata().sucessMessage('', '插入成功')
        print(return_data)
        return json.dumps(return_data, ensure_ascii=False)
示例#14
0
    def write(self):
        """
        写入Excel文件
        :return:
        """
        self.parse_all()
        param = []
        for k, v in self.all_case.items():
            exeLog("用例" + str(v))
            plugin = ENUM_OPT("case_exe_plugin").get_items()
            pluginList = []
            for i in plugin:
                pluginList.append(i[0])
            if len(v) == 12 and v[-1] in pluginList:
                v.insert(0, newID().CS_ID())
                v.insert(3, self.rqmt_id)
                v.append(self.group_id)
                # print(v)
                v[7] = ENUM_OPT("case_type").get_val(v[7])
                v[8] = ENUM_OPT("case_exe_status").get_val(v[8])
                v[9] = ENUM_OPT("case_level").get_val(v[9])
                # v[10] = ENUM_OPT("case_exe_env").get_val(v[11])
                v[11] = ENUM_OPT("case_exe_env").get_val(v[11])
                v[12] = ENUM_OPT("case_exe_type").get_val(v[12])
                v[13] = ENUM_OPT("case_exe_plugin").get_val(v[13])
                param.append(tuple(v))
            elif len(v) < 12 and v[-1] in pluginList:
                v.insert(0, newID().CS_ID())
                v.insert(3, self.rqmt_id)
                v.append(self.group_id)
                v.insert(5, "")
                # print(v)
                v[7] = ENUM_OPT("case_type").get_val(v[7])
                v[8] = ENUM_OPT("case_exe_status").get_val(v[8])
                v[9] = ENUM_OPT("case_level").get_val(v[9])
                # v[10] = ENUM_OPT("case_exe_env").get_val(v[11])
                v[11] = ENUM_OPT("case_exe_env").get_val(v[11])
                v[12] = ENUM_OPT("case_exe_type").get_val(v[12])
                v[13] = ENUM_OPT("case_exe_plugin").get_val(v[13])
                param.append(tuple(v))
            if len(v) == 12 and v[2] in pluginList:
                newV = [newID().CS_ID()]
                newV.append(v[0])
                newV.append(v[1])
                newV.append(self.rqmt_id)
                # newV.append(v[12])
                newV.append(v[11])
                newV.append(v[10])
                newV.append(v[9])
                newV.append(v[8])
                newV.append(v[7])
                newV.append(v[6])
                newV.append(v[5])
                newV.append(v[4])
                newV.append(v[3])
                newV.append(v[2])
                newV.append(self.group_id)
                newV[7] = ENUM_OPT("case_type").get_val(newV[7])
                newV[8] = ENUM_OPT("case_exe_status").get_val(newV[8])
                newV[9] = ENUM_OPT("case_level").get_val(newV[9])
                newV[11] = ENUM_OPT("case_exe_env").get_val(newV[11])
                newV[12] = ENUM_OPT("case_exe_type").get_val(newV[12])
                newV[13] = ENUM_OPT("case_exe_plugin").get_val(newV[13])
                param.append(tuple(newV))

            elif len(v) < 12 and v[2] in pluginList:
                newV = [newID().CS_ID()]
                newV.append(v[0])
                newV.append(v[1])
                # newV.append("")
                newV.append(self.rqmt_id)
                newV.append("")
                newV.append(v[10])
                newV.append(v[9])
                newV.append(v[8])
                newV.append(v[7])
                newV.append(v[6])
                newV.append(v[5])
                newV.append(v[4])
                newV.append(v[3])
                newV.append(v[2])
                newV.append(self.group_id)
                newV[7] = ENUM_OPT("case_type").get_val(newV[7])
                newV[8] = ENUM_OPT("case_exe_status").get_val(newV[8])
                newV[9] = ENUM_OPT("case_level").get_val(newV[9])
                newV[11] = ENUM_OPT("case_exe_env").get_val(newV[11])
                newV[12] = ENUM_OPT("case_exe_type").get_val(newV[12])
                newV[13] = ENUM_OPT("case_exe_plugin").get_val(newV[13])
                param.append(tuple(newV))
        param = eval((str(param).replace('[Blank]', "")))
        print(param)
        # param = [("测试工程师","[8, 9, 10, 1]","2018-08-14 18:22:36","11")]
        sql = "INSERT INTO {} ( case_id,case_path,case_desc,rqmt_id,case_init,case_step,case_prev_data,case_type,case_exe_status,case_level,case_builder,case_exe_env,case_exe_type,case_exe_plugin,group_id)" \
" VALUE (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)".format(self.table)
        print(sql)
        DB_CONN().db_Batch(sql, param)