diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 7d97100..b3e1506 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -12,8 +12,8 @@ - - + + diff --git a/OutPut/Reports/history.json b/OutPut/Reports/history.json index 4d117a6..87f56ab 100644 --- a/OutPut/Reports/history.json +++ b/OutPut/Reports/history.json @@ -1 +1 @@ -[{"success": 4, "all": 7, "fail": 1, "skip": 0, "error": 2, "runtime": "0.45 S", "begin_time": "2023-04-21 12:10:31", "pass_rate": "57.14"}, {"success": 0, "all": 1, "fail": 0, "skip": 0, "error": 1, "runtime": "0.01 S", "begin_time": "2023-04-21 12:11:52", "pass_rate": "0.00"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.33 S", "begin_time": "2023-04-21 12:12:54", "pass_rate": "83.33"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.30 S", "begin_time": "2023-04-21 12:13:32", "pass_rate": "83.33"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.28 S", "begin_time": "2023-04-21 14:47:43", "pass_rate": "83.33"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.27 S", "begin_time": "2023-04-21 15:01:06", "pass_rate": "83.33"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.24 S", "begin_time": "2023-04-21 15:03:53", "pass_rate": "83.33"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.23 S", "begin_time": "2023-04-21 15:06:10", "pass_rate": "83.33"}, {"success": 6, "all": 7, "fail": 0, "skip": 0, "error": 1, "runtime": "3.00 S", "begin_time": "2023-05-14 23:58:13", "pass_rate": "85.71"}, {"success": 0, "all": 2, "fail": 0, "skip": 0, "error": 2, "runtime": "0.02 S", "begin_time": "2023-05-15 11:52:27", "pass_rate": "0.00"}, {"success": 0, "all": 2, "fail": 0, "skip": 0, "error": 2, "runtime": "0.00 S", "begin_time": "2023-05-15 11:57:23", "pass_rate": "0.00"}, {"success": 6, "all": 7, "fail": 0, "skip": 0, "error": 1, "runtime": "1.38 S", "begin_time": "2023-05-15 11:59:30", "pass_rate": "85.71"}] \ No newline at end of file +[{"success": 4, "all": 7, "fail": 1, "skip": 0, "error": 2, "runtime": "0.45 S", "begin_time": "2023-04-21 12:10:31", "pass_rate": "57.14"}, {"success": 0, "all": 1, "fail": 0, "skip": 0, "error": 1, "runtime": "0.01 S", "begin_time": "2023-04-21 12:11:52", "pass_rate": "0.00"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.33 S", "begin_time": "2023-04-21 12:12:54", "pass_rate": "83.33"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.30 S", "begin_time": "2023-04-21 12:13:32", "pass_rate": "83.33"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.28 S", "begin_time": "2023-04-21 14:47:43", "pass_rate": "83.33"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.27 S", "begin_time": "2023-04-21 15:01:06", "pass_rate": "83.33"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.24 S", "begin_time": "2023-04-21 15:03:53", "pass_rate": "83.33"}, {"success": 5, "all": 6, "fail": 1, "skip": 0, "error": 0, "runtime": "0.23 S", "begin_time": "2023-04-21 15:06:10", "pass_rate": "83.33"}, {"success": 6, "all": 7, "fail": 0, "skip": 0, "error": 1, "runtime": "3.00 S", "begin_time": "2023-05-14 23:58:13", "pass_rate": "85.71"}, {"success": 0, "all": 2, "fail": 0, "skip": 0, "error": 2, "runtime": "0.02 S", "begin_time": "2023-05-15 11:52:27", "pass_rate": "0.00"}, {"success": 0, "all": 2, "fail": 0, "skip": 0, "error": 2, "runtime": "0.00 S", "begin_time": "2023-05-15 11:57:23", "pass_rate": "0.00"}, {"success": 6, "all": 7, "fail": 0, "skip": 0, "error": 1, "runtime": "1.38 S", "begin_time": "2023-05-15 11:59:30", "pass_rate": "85.71"}, {"success": 6, "all": 7, "fail": 0, "skip": 0, "error": 1, "runtime": "1.44 S", "begin_time": "2023-05-16 15:11:50", "pass_rate": "85.71"}] \ No newline at end of file diff --git a/README.md b/README.md index 26b7522..618b112 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ * 钉钉、企业微信通知: 支持多种通知场景,执行成功之后,可选择发送钉钉、或者企业微信、邮箱通知 * 内置实现了一部分随意函数及自定义常用函数:如:随机字符串、任意日期时间、随机gps、随机用户身份证、地址、邮箱、企业信息等等 * 自定义拓展函数: 如用例中需要自己实习一些函数使用,可以随时写上函数,通过 {{func()}} 随时调用 +* 支持导入postman的json文件自动处理成测试用例,然后修改一下参数即可使用 ## 遇到问题 diff --git a/common/base_datas.py b/common/base_datas.py index 95a0fb3..bbd7e48 100644 --- a/common/base_datas.py +++ b/common/base_datas.py @@ -9,7 +9,8 @@ class BaseDates: # ***************************************************************** # 测试数据所在路径 # ***************************************************************** - test_api = os.path.join(base_path, "data", "moduleA", "test_api.xlsx") + templates = os.path.join(base_path, "data", "templates", "template.xlsx") + test_api = os.path.join(base_path, "data", "test_cases", "test_api.xlsx") # ***************************************************************** # 测试用例脚本目录 @@ -23,8 +24,6 @@ class BaseDates: log_path = os.path.join(base_path, "OutPut", "Log") - - if __name__ == '__main__': test = BaseDates() print(test.base_path) diff --git a/common/files_tools/excel.py b/common/files_tools/excel.py index dbd2665..6a0fb34 100644 --- a/common/files_tools/excel.py +++ b/common/files_tools/excel.py @@ -121,6 +121,15 @@ class DoExcel: row_data.append(cell_value) return row_data + def create_sheet(self, title): + return self.wb.create_sheet(title=title) + + def copy_sheet(self, source_sheet, destination_sheet): + source = self.wb[source_sheet] + destination = self.wb[destination_sheet] + for row in source.iter_rows(values_only=True): + destination.append(row) + def save(self, filename=None): """ 获取文件名 @@ -142,12 +151,20 @@ class DoExcel: if self.get_max_row(): pass - def do_main(self, filename, *d): + def do_main(self, filename, *d, output_filename=None, copy_sheets=True): """ 动态保存列表嵌套字典的数据到 excel 中 :param:*d(list):传入的数据列表 + :param copy_sheets: 是否复制源文件的其他 sheet,默认为 True + :param *d: 传入的数据列表 :return:bool """ + # 复制源文件的其他 sheet 到新的 Excel 文件 + if copy_sheets: + for sheet_name in self.wb.sheetnames: + if sheet_name != self.wb.active.title: + self.create_sheet(sheet_name) + self.copy_sheet(sheet_name, sheet_name) for i, val in enumerate(d): c = 0 @@ -157,6 +174,9 @@ class DoExcel: # value 作为每一条数据写入 self.set_value_by_cell(i + 2, c + 1, v) c += 1 + if output_filename: + self.save(output_filename) + return self.save(filename) diff --git a/common/tools/parsing_postman.py b/common/tools/parsing_postman.py index 22a1dfc..892c27c 100644 --- a/common/tools/parsing_postman.py +++ b/common/tools/parsing_postman.py @@ -21,7 +21,6 @@ def parsing_postman(path): api = {} if isinstance(content, list): for item in content: - print(item.get('name')) _parse_api(content=item) elif isinstance(content, dict): if 'item' in content.keys(): @@ -30,12 +29,12 @@ def parsing_postman(path): api['name'] = 'postman' api['description'] = content.get('name') request = content.get('request') + api['Run'] = 'yes' if request: # api请求方法 api['Method'] = request.get('method', 'GET').upper() header = request.get('header') header = {item.get('key'): item.get('value') for item in header} if header else {} - auth = request.get('auth') if auth: auth_type = auth.get('type') @@ -43,8 +42,6 @@ def parsing_postman(path): auth_value = {item.get('key'): item.get('value') for item in auth.get(auth_type) if (item and item.get('key'))} header.update(auth_value) - # api请求头 - api['Headers'] = json.dumps(header, ensure_ascii=False) # api 请求地址 url = request.get('url') if url: @@ -57,6 +54,9 @@ def parsing_postman(path): # # api查询参数 # api['Request Data'] = '&'.join( # [item.get('key') + '=' + (item.get('value') or '') for item in url.get('query') if item]) + # api请求头 + api['Headers'] = json.dumps(header, ensure_ascii=False) + api['Headers是否加密'] = '' body = request.get('body') if body: # api接口请求参数类型 @@ -67,19 +67,23 @@ def parsing_postman(path): api['request_data_type'] = 'data' elif 'urlencoded' == request_mode: api['request_data_type'] = 'data' - else: - api['request_data_type'] = 'json' + # api接口请求参数 request_data = body.get(request_mode) + api['Request Data'] = {} if request_data and 'raw' == request_mode: - api['Request Data'] = request_data.replace('\t', '').replace('\n', '') + api['Request Data'].update( + json.loads(request_data.replace('\t', '').replace('\n', '').replace('\r', ''))) elif request_data and 'formdata' == request_mode: if isinstance(request_data, list): - api['Request Data'] = json.dumps({item.get('key'): '' for item in request_data}, - ensure_ascii=False) - else: - api['Request Data'] = '' - api['参数加密方式'] = '' + for item in request_data: + if item.get("type") == "text": + api['Request Data'].update({item.get('key'): item.get("value", "")}) + elif item.get("type") == "file": + api["Request Data"].update({item.get('key'): item.get("src", "")}) + api["request_data_type"] = "files" + api["Request Data"] = json.dumps(api["Request Data"], ensure_ascii=False) + api['请求参数是否加密'] = '' api['提取请求参数'] = '' api['Jsonpath'] = '' api['正则表达式'] = '' @@ -87,7 +91,6 @@ def parsing_postman(path): api['绝对路径表达式'] = '' api['SQL'] = '' api['sql变量'] = '' - api['响应类型'] = '' api['预期结果'] = '' api['响应结果'] = '' api['断言结果'] = '' @@ -101,7 +104,7 @@ def parsing_postman(path): if __name__ == '__main__': - pat = r'postman.json' + pat = r'D:\apk_api\api-test-project\temp\postman.json' res = parsing_postman(pat) print('结果:', res) print("类型", type(res)) diff --git a/data/moduleA/test_api.xlsx b/data/moduleA/test_api.xlsx deleted file mode 100644 index 9ad0247..0000000 Binary files a/data/moduleA/test_api.xlsx and /dev/null differ diff --git a/data/other/Snipaste_2020-11-06_17-47-55.png b/data/templates/Snipaste_2020-11-06_17-47-55.png similarity index 100% rename from data/other/Snipaste_2020-11-06_17-47-55.png rename to data/templates/Snipaste_2020-11-06_17-47-55.png diff --git a/data/templates/template.xlsx b/data/templates/template.xlsx new file mode 100644 index 0000000..2241fce Binary files /dev/null and b/data/templates/template.xlsx differ diff --git a/data/test_cases/test_api.xlsx b/data/test_cases/test_api.xlsx new file mode 100644 index 0000000..3aaaeb9 Binary files /dev/null and b/data/test_cases/test_api.xlsx differ diff --git a/data/test_cases/test_postman_case.xlsx b/data/test_cases/test_postman_case.xlsx new file mode 100644 index 0000000..b7f8b5c Binary files /dev/null and b/data/test_cases/test_postman_case.xlsx differ diff --git a/data/test_cases/test_postman_cases.xlsx b/data/test_cases/test_postman_cases.xlsx new file mode 100644 index 0000000..9f7299b Binary files /dev/null and b/data/test_cases/test_postman_cases.xlsx differ diff --git a/postman_to_excel.py b/postman_to_excel.py new file mode 100644 index 0000000..99ca83d --- /dev/null +++ b/postman_to_excel.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# encoding: utf-8 +""" +@author: kira +@contact: 262667641@qq.com +@file: postman_to_excel.py +@time: 2023/5/16 16:35 +@desc: +""" +import os.path + +from common.base_datas import BaseDates +from common.files_tools.excel import DoExcel +from common.tools.parsing_postman import parsing_postman + + +def main(postman_filename, output_filename): + """将postman导出的json文件转为excel测试用例""" + postman_to_excel = parsing_postman(postman_filename) + test_postman_case = BaseDates.templates # 使用标准模板 + excel = DoExcel() + excel.do_main(test_postman_case, *postman_to_excel, output_filename=output_filename) + + +if __name__ == '__main__': + postman_to_json = r'D:\apk_api\api-test-project\temp\postman.json' # postman导出的json文件 + out_file = os.path.join(BaseDates.base_path, 'data', 'test_cases', 'test_postman_cases.xlsx') # 转化后的文件保存的位置 + main(postman_to_json, out_file) diff --git a/temp/postman.json b/temp/postman.json index 835f151..830fe5e 100644 --- a/temp/postman.json +++ b/temp/postman.json @@ -183,22 +183,75 @@ "response": [] }, { - "name": "获取请购详情 Copy", + "name": "文件上传", "request": { "method": "POST", "header": [ { - "key": "BSP_TOKEN", - "value": "aba920e63584c3b1fef3cb4c498bca44", - "type": "text" + "key": "Accept", + "value": "*/*" + }, + { + "key": "Accept-Language", + "value": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6" + }, + { + "key": "Connection", + "value": "keep-alive" + }, + { + "key": "Cookie", + "value": "sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%221876a7f1e0f1368-09fbff283e5df9-4c657b58-2073600-1876a7f1e10e86%22%2C%22first_id%22%3A%22%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E5%BC%95%E8%8D%90%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Flogin.countrygarden.com.cn%2F%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTg3NmE3ZjFlMGYxMzY4LTA5ZmJmZjI4M2U1ZGY5LTRjNjU3YjU4LTIwNzM2MDAtMTg3NmE3ZjFlMTBlODYifQ%3D%3D%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%22%2C%22value%22%3A%22%22%7D%2C%22%24device_id%22%3A%221876a7f1e0f1368-09fbff283e5df9-4c657b58-2073600-1876a7f1e10e86%22%7D; x-access-token=9f576f5f914c6e29584f82e5c5fe9c92" + }, + { + "key": "Origin", + "value": "https://bimdc.bzlrobot.com" + }, + { + "key": "Sec-Fetch-Dest", + "value": "empty" + }, + { + "key": "Sec-Fetch-Mode", + "value": "cors" + }, + { + "key": "Sec-Fetch-Site", + "value": "same-origin" + }, + { + "key": "User-Agent", + "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.0.0" + }, + { + "key": "app_token", + "value": "A4C419A561A3404A86A33628A3F681C3" + }, + { + "key": "sec-ch-ua", + "value": "\"Not/A)Brand\";v=\"99\", \"Microsoft Edge\";v=\"115\", \"Chromium\";v=\"115\"" + }, + { + "key": "sec-ch-ua-mobile", + "value": "?0" + }, + { + "key": "sec-ch-ua-platform", + "value": "\"Windows\"" } ], "body": { - "mode": "urlencoded", - "urlencoded": [] + "mode": "formdata", + "formdata": [ + { + "key": "file", + "type": "file", + "src": "test.jpeg" + } + ] }, "url": { - "raw": "https://bimdc.bzlrobot.com/bsp/test/user/ugs/ibs/api/ibs-material/material/jobRequire/detail?t=&isEdit=&requireId=5804&projectId=", + "raw": "https://bimdc.bzlrobot.com/bsp/opi/document/v1/document/fileStore/uploadFile", "protocol": "https", "host": [ "bimdc", @@ -207,46 +260,226 @@ ], "path": [ "bsp", - "test", - "user", - "ugs", - "ibs", - "api", - "ibs-material", - "material", - "jobRequire", - "detail" - ], - "query": [ - { - "key": "t", - "value": "" - }, - { - "key": "isEdit", - "value": "" - }, - { - "key": "requireId", - "value": "5804" - }, - { - "key": "projectId", - "value": "" - } + "opi", + "document", + "v1", + "document", + "fileStore", + "uploadFile" ] } }, "response": [] }, { - "name": "获取请购详情 Copy 2", + "name": "https://bimdc.bzlrobot.com/bsp/opi/document/v1/document/fileStore/uploadFile", "request": { "method": "POST", "header": [ { - "key": "BSP_TOKEN", - "value": "aba920e63584c3b1fef3cb4c498bca44", + "key": "Accept", + "value": "*/*" + }, + { + "key": "Accept-Language", + "value": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6" + }, + { + "key": "Connection", + "value": "keep-alive" + }, + { + "key": "Cookie", + "value": "sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%221876a7f1e0f1368-09fbff283e5df9-4c657b58-2073600-1876a7f1e10e86%22%2C%22first_id%22%3A%22%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E5%BC%95%E8%8D%90%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Flogin.countrygarden.com.cn%2F%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTg3NmE3ZjFlMGYxMzY4LTA5ZmJmZjI4M2U1ZGY5LTRjNjU3YjU4LTIwNzM2MDAtMTg3NmE3ZjFlMTBlODYifQ%3D%3D%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%22%2C%22value%22%3A%22%22%7D%2C%22%24device_id%22%3A%221876a7f1e0f1368-09fbff283e5df9-4c657b58-2073600-1876a7f1e10e86%22%7D; x-access-token=9f576f5f914c6e29584f82e5c5fe9c92" + }, + { + "key": "Origin", + "value": "https://bimdc.bzlrobot.com" + }, + { + "key": "Sec-Fetch-Dest", + "value": "empty" + }, + { + "key": "Sec-Fetch-Mode", + "value": "cors" + }, + { + "key": "Sec-Fetch-Site", + "value": "same-origin" + }, + { + "key": "User-Agent", + "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.0.0" + }, + { + "key": "app_token", + "value": "A4C419A561A3404A86A33628A3F681C3" + }, + { + "key": "sec-ch-ua", + "value": "\"Not/A)Brand\";v=\"99\", \"Microsoft Edge\";v=\"115\", \"Chromium\";v=\"115\"" + }, + { + "key": "sec-ch-ua-mobile", + "value": "?0" + }, + { + "key": "sec-ch-ua-platform", + "value": "\"Windows\"" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "file", + "type": "file", + "src": "/C:/Users/chenyongzhi11/Desktop/微信图片_20221025174254.jpg" + } + ] + }, + "url": { + "raw": "https://bimdc.bzlrobot.com/bsp/opi/document/v1/document/fileStore/uploadFile", + "protocol": "https", + "host": [ + "bimdc", + "bzlrobot", + "com" + ], + "path": [ + "bsp", + "opi", + "document", + "v1", + "document", + "fileStore", + "uploadFile" + ] + } + }, + "response": [] + }, + { + "name": "平台登录", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "username", + "value": "admin", + "type": "text" + }, + { + "key": "password", + "value": "3306", + "type": "text" + }, + { + "key": "csrfmiddlewaretoken", + "value": "av1VLobtvmrqvvoDRygqIqBr8QOa2ExxzcB1zVpHRKXXvOtoDzhmuLapxdP8uJj7", + "type": "text" + } + ] + }, + "url": { + "raw": "http://127.0.0.1:8000/index/", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "index", + "" + ] + } + }, + "response": [] + }, + { + "name": "新增项目", + "request": { + "method": "POST", + "header": [ + { + "key": "Cookie", + "value": "sessionid=zjs3ytyud4hh952ongttt6vvx3fihlqv", + "type": "text" + } + ], + "body": { + "mode": "urlencoded", + "urlencoded": [] + }, + "url": { + "raw": "http://127.0.0.1:8000/project/create_project/", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "project", + "create_project", + "" + ] + } + }, + "response": [] + }, + { + "name": "查询项目列表信息", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://127.0.0.1:8000/project/get_projects/", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" + ], + "port": "8000", + "path": [ + "project", + "get_projects", + "" + ] + } + }, + "response": [] + }, + { + "name": "新增模块", + "request": { + "method": "POST", + "header": [ + { + "key": "Cookie", + "value": "sessionid=zjs3ytyud4hh952ongttt6vvx3fihlqv", "type": "text" } ], @@ -260,42 +493,43 @@ } }, "url": { - "raw": "https://bimdc.bzlrobot.com/bsp/test/user/ugs/ibs/api/ibs-material/material/jobRequire/detail?t=&isEdit=&requireId=5804&projectId=", - "protocol": "https", + "raw": "http://127.0.0.1:8000/module/create_modul/", + "protocol": "http", "host": [ - "bimdc", - "bzlrobot", - "com" + "127", + "0", + "0", + "1" ], + "port": "8000", "path": [ - "bsp", - "test", - "user", - "ugs", - "ibs", - "api", - "ibs-material", - "material", - "jobRequire", - "detail" + "module", + "create_modul", + "" + ] + } + }, + "response": [] + }, + { + "name": "查询模块列表", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://127.0.0.1:8000/module/get_module/", + "protocol": "http", + "host": [ + "127", + "0", + "0", + "1" ], - "query": [ - { - "key": "t", - "value": "" - }, - { - "key": "isEdit", - "value": "" - }, - { - "key": "requireId", - "value": "5804" - }, - { - "key": "projectId", - "value": "" - } + "port": "8000", + "path": [ + "module", + "get_module", + "" ] } }, diff --git a/test_script/script/baseclass.py b/test_script/script/baseclass.py index b182e67..84f23b3 100644 --- a/test_script/script/baseclass.py +++ b/test_script/script/baseclass.py @@ -78,7 +78,7 @@ class BaseClass(unittest.TestCase): self.headers = self._case.get("Headers", {}) self.parameters = self._case.get("Request Data") self.parameters_key = self._case.get("提取请求参数") - self.encryption = self._case.get("参数加密方式") + self.encryption = self._case.get("请求参数是否加密") self.regex = self._case.get("正则表达式") self.keys = self._case.get("正则变量") self.deps = self._case.get("绝对路径表达式") diff --git a/test_script/test_script/test_standard.py b/test_script/test_script/test_api_script.py similarity index 93% rename from test_script/test_script/test_standard.py rename to test_script/test_script/test_api_script.py index e4ba69a..4e1a075 100644 --- a/test_script/test_script/test_standard.py +++ b/test_script/test_script/test_api_script.py @@ -56,7 +56,8 @@ class TestProjectApi(unittest.TestCase): item_headers = item.get("Headers", {}) request_data = item.get("Request Data") parameters_key = item.get("提取请求参数") - encryption = item.get("参数加密方式") + is_request_data_encryption = item.get("请求参数是否加密") + is_headers_encryption = item.get("Headers是否加密") regex = item.get("正则表达式") keys = item.get("正则变量") deps = item.get("绝对路径表达式") @@ -98,8 +99,11 @@ class TestProjectApi(unittest.TestCase): # 提取请求参数信息 DataExtractor(request_data).substitute_data(jp_dict=parameters_key) # 判断是否执行加密 - if encryption: - request_data = do_encrypt(encryption, request_data) # 数据加密:MD5 or sha1 + if is_headers_encryption: + headers = do_encrypt(is_headers_encryption, headers) # 请求头参数加密:md5,sha1,sha256... + + if is_request_data_encryption: + request_data = do_encrypt(is_request_data_encryption, request_data) # 请求参数加密:md5,sha1,sha256... logger.my_log(f"当前用例所在的 sheet --> {sheet}", "info") logger.my_log(f"执行 SQL 语句 --> {sql}", "info") logger.my_log(f"预期结果 --> {expected}", "info") diff --git a/upload_server/__init__.py b/upload_server/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/upload_server/templates/index.html b/upload_server/templates/index.html deleted file mode 100644 index e3a784b..0000000 --- a/upload_server/templates/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - index - - - -上传图片 -
- - - -
- - - \ No newline at end of file diff --git a/upload_server/upload.py b/upload_server/upload.py deleted file mode 100644 index 41d4def..0000000 --- a/upload_server/upload.py +++ /dev/null @@ -1,34 +0,0 @@ -import os -import time -from flask import Flask, request, render_template - -app = Flask(__name__) -print(app.instance_path) -print(app.root_path) -print(app.static_folder) - - -@app.route("/") -def index(): - return render_template('index.html') - - -@app.route("/uploads/", methods=['POST']) -def upload(): - # 获取文件 - file = request.files.get("pic") - if not file: - return render_template('index.html') - # file_name = time.strftime("%Y-%m-%d-%H-%M-%S") + file.filename - file_name = file.filename - file_url = f'/static/{file_name}' - file.save(os.path.join( - app.root_path, - app.static_folder, - file_name - )) - return file_url - - -if __name__ == '__main__': - app.run(debug=True)