From 7a0e17b1041de119e4e51193f8feb0c53d6ead91 Mon Sep 17 00:00:00 2001 From: aaronchenyongzhi <262667641@qq.com> Date: Thu, 14 Sep 2023 04:01:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=A5=E8=AF=A2=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E4=B8=BA=E7=A9=BA=E5=AD=97=E7=AC=A6=E6=97=B6?= =?UTF-8?q?=E5=BC=95=E5=8F=91=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OutPut/reports/report.html | 397 ++++++----------- common/bif_functions/bif_other.py | 2 +- common/core/action.py | 4 +- common/data_analysis/dependent_parameter.py | 1 + common/http_client/http_client.py | 172 ++++---- common/parsing/parsing_postman.py | 4 +- config/config.py | 3 +- excel_converter.py | 10 +- src/cases/test_cases.xlsx | Bin 19285 -> 29656 bytes src/cases/test_openapi_cases.xlsx | Bin 0 -> 18537 bytes src/temporary_file/bookShopApi.json | 457 ++++++++++++++++++++ 11 files changed, 688 insertions(+), 362 deletions(-) create mode 100644 src/cases/test_openapi_cases.xlsx create mode 100644 src/temporary_file/bookShopApi.json diff --git a/OutPut/reports/report.html b/OutPut/reports/report.html index aee4558..666fc67 100644 --- a/OutPut/reports/report.html +++ b/OutPut/reports/report.html @@ -220,7 +220,7 @@
| 请求地址 --> https://api.shop.eduwork.cn/api/auth/register
+| 请求方法 --> POST
+| 请求头 --> {'Content-Length': '106', 'Content-Type': 'application/json'}
+| 请求 body --> b'{"name": "69209", "email": "xiulanjiang@example.net", "password": 123456, "password_confirmation": 123456}'
+| 接口状态--> 201
+| 接口耗时--> 0:00:00.283209
+| 接口响应-->
+| 断言结果-->[{'检查项': '201', '期望值': '201', '实际值': '201', '断言方法': 'eq:实际值与期望值相等', '断言结果': '通过'}]
+
+--------------------------------------------------我是分割线--------------------------------------------------
+test_api_001_postman (test_executor.TestProjectApi)执行——>【通过】
+
+
+
+ | 请求地址 --> https://api.shop.eduwork.cn/api/auth/login
+| 请求方法 --> POST
+| 请求头 --> {'Content-Length': '56', 'Content-Type': 'application/json'}
+| 请求 body --> b'{"email": "xiulanjiang@example.net", "password": 123456}'
+| 接口状态--> 200
+| 接口耗时--> 0:00:00.143225
+| 接口响应--> {"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2FwaS5zaG9wLmVkdXdvcmsuY24vYXBpL2F1dGgvbG9naW4iLCJpYXQiOjE2OTQ2MzUwNTAsImV4cCI6MTY5NDk5NTA1MCwibmJmIjoxNjk0NjM1MDUwLCJqdGkiOiJtTFlxbEY0dHc3STNPbjFYIiwic3ViIjoiMTcyMjAiLCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.HoiAdlA7a_AQ1yEGHSUbN6j8cH9JxwSDssy9ZWM4F0Y","token_type":"Bearer","expires_in":360000}
+| 断言结果-->[{'检查项': '200', '期望值': '200', '实际值': '200', '断言方法': 'eq:实际值与期望值相等', '断言结果': '通过'}]
+
+--------------------------------------------------我是分割线--------------------------------------------------
+test_api_002_postman (test_executor.TestProjectApi)执行——>【通过】
+
+
+
+ 这个测试用例听说泡面比较好吃,所以放弃执行了!!+ + +
| 执行 sql 成功--> {'select_one': [{'name': 'kira', 'age': 18}]}
-pm----------------> {'Url': '/api/register', 'Headers': '{"Content-Type": "application/json"}', 'HeadersCrypto': None, 'QueryString': None, 'RequestDataType': 'json', 'RequestData': '{"email": "{{email}}", "password": "{{password}}"}', 'RequestDataCrypto': None, 'Response': '', 'Assertion': '', 'ErrorLog': '', None: None}
-前置脚本请求对象= {'Url': '/api/register', 'Headers': '{"Content-Type": "application/json"}', 'HeadersCrypto': None, 'QueryString': None, 'RequestDataType': 'json', 'RequestData': '{"email": "{{email}}", "password": "{{password}}"}', 'RequestDataCrypto': None, 'Response': '', 'Assertion': '', 'ErrorLog': '', None: None}
-获取请求URL: /api/register
-获取请求Header: {'Content-Type': 'application/json'}
-获取请求数据: {'email': '{{email}}', 'password': '{{password}}'}
----->获取环境变量=这个是你想要的值
-| 第1次请求参数=【(Action(), 'https://reqres.in', '/api/register', 'post')__{'json': '{"email": "eve.holt@reqres.in", "password": "pistol"}', 'headers': '{"Content-Type": "application/json"}', 'params': None}】
-| 请求地址 --> https://reqres.in/api/register
-| 请求方法 --> POST
-| 请求头 --> {'Content-Type': 'application/json', 'Content-Length': '53'}
-| 请求 body --> b'{"email": "eve.holt@reqres.in", "password": "pistol"}'
-| 接口状态--> 200
-| 接口耗时--> 0:00:00.811371
-| 接口响应--> {"id":4,"token":"QpwL5tke4Pnpja7X4"}
-后置脚本响应对象= (Response [200])
-响应对象转json: {'id': 4, 'token': 'QpwL5tke4Pnpja7X4'}
-响应对象转text: {"id":4,"token":"QpwL5tke4Pnpja7X4"}
-获取环境变量={'id': 4, 'token': 'QpwL5tke4Pnpja7X4'}
-| 断言结果-->[{'检查项': '200', '期望值': '200', '实际值': '200', '断言方法': 'eq:实际值与期望值相等', '断言结果': '通过'}]
-
---------------------------------------------------我是分割线--------------------------------------------------
-test_api_002_注册 (test_executor.TestProjectApi)执行——>【通过】
-
-
-
- | 请求地址 --> https://reqres.in/api/login
-| 请求方法 --> POST
-| 请求头 --> {'Content-Type': 'application/json', 'Content-Length': '53'}
-| 请求 body --> b'{"email": "eve.holt@reqres.in", "password": "pistol"}'
-| 接口状态--> 200
-| 接口耗时--> 0:00:00.463100
-| 接口响应--> {"token":"QpwL5tke4Pnpja7X4"}
-请求地址 --> https://reqres.in/api/login
-请求头 --> {'Content-Type': 'application/json', 'Content-Length': '53'}
-请求 body --> b'{"email": "eve.holt@reqres.in", "password": "pistol"}'
-接口状态--> 200
-接口耗时--> 0:00:00.463100
-接口响应--> {"token":"QpwL5tke4Pnpja7X4"}
-| 断言结果-->[{'检查项': '200', '期望值': '200', '实际值': '200', '断言方法': 'eq:实际值与期望值相等', '断言结果': '通过'}, {'检查项': 463.1, '期望值': 300, '实际值': 463.1, '断言方法': 'gte:实际值大于或等于期望值', '断言结果': '通过'}]
-
---------------------------------------------------我是分割线--------------------------------------------------
-test_api_003_登录 (test_executor.TestProjectApi)执行——>【通过】
-
-
-
- 开始执行md5_sign加密,待加密参数={'Content-Type': 'application/json;charset=utf-8', 'token': 'QpwL5tke4Pnpja7X4'}
-| 请求地址 --> https://reqres.in/api/users?page=1
-| 请求方法 --> GET
-| 请求头 --> {'Content-Type': 'application/json;charset=utf-8', 'token': 'QpwL5tke4Pnpja7X4', 'sign': '14f25b9fed8dac0feba78ea42acf8b35'}
-| 请求 body --> None
-| 接口状态--> 200
-| 接口耗时--> 0:00:00.160911
-| 接口响应--> {"page":1,"per_page":6,"total":12,"total_pages":2,"data":[{"id":1,"email":"george.bluth@reqres.in","first_name":"George","last_name":"Bluth","avatar":"https://reqres.in/img/faces/1-image.jpg"},{"id":2,"email":"janet.weaver@reqres.in","first_name":"Janet","last_name":"Weaver","avatar":"https://reqres.in/img/faces/2-image.jpg"},{"id":3,"email":"emma.wong@reqres.in","first_name":"Emma","last_name":"Wong","avatar":"https://reqres.in/img/faces/3-image.jpg"},{"id":4,"email":"eve.holt@reqres.in","first_name":"Eve","last_name":"Holt","avatar":"https://reqres.in/img/faces/4-image.jpg"},{"id":5,"email":"charles.morris@reqres.in","first_name":"Charles","last_name":"Morris","avatar":"https://reqres.in/img/faces/5-image.jpg"},{"id":6,"email":"tracey.ramos@reqres.in","first_name":"Tracey","last_name":"Ramos","avatar":"https://reqres.in/img/faces/6-image.jpg"}],"support":{"url":"https://reqres.in/#support-heading","text":"To keep ReqRes free, contributions towards server costs are appreciated!"}}
-| 断言结果-->[{'检查项': '200', '期望值': 200, '实际值': '200', '断言方法': 'eq:实际值与期望值相等', '断言结果': '失败'}]
-
---------------------------------------------------我是分割线--------------------------------------------------
-test_api_004_用户列表 (test_executor.TestProjectApi)执行——>【失败】
-
-
- Traceback (most recent call last): -- -
File "d:\python3.9\lib\unittest\case.py", line 59, in testPartExecutor - yield -- -
File "d:\python3.9\lib\unittest\case.py", line 593, in run - self._callTestMethod(testMethod) -- -
File "d:\python3.9\lib\unittest\case.py", line 550, in _callTestMethod - method() -- -
File "E:\production\apitest\common\core\dataDriver.py", line 43, in wrapper - return func(self, params, *args, **kwargs) -- -
File "E:\production\apitest\test_script\test_executor.py", line 50, in test_api - self.action.execute_validation(excel, sheet, iid, name, desc, expected) -- -
File "E:\production\apitest\common\core\action.py", line 96, in execute_validation - raise e -- -
File "E:\production\apitest\common\core\action.py", line 86, in execute_validation - res = self.run_validate(expected, self.response_json) -- -
File "E:\production\apitest\common\validation\validator.py", line 116, in run_validate - self.validate(resp) -- -
File "E:\production\apitest\common\validation\validator.py", line 87, in validate - raise e -- -
File "E:\production\apitest\common\validation\validator.py", line 83, in validate - fun(actual_value=actual_value, expect_value=expect_value) -- -
File "E:\production\apitest\common\validation\comparators.py", line 30, in eq - assert actual_value == expect_value, p_string(actual_value, expect_value) -- -
AssertionError: 预期:200 -> (class 'str'), 实际:200 -> (class 'int')
-
-
-
- | 请求地址 --> https://reqres.in/api/users/4
-| 请求方法 --> GET
-| 请求头 --> {'Content-Type': 'application/json;charset=utf-8', 'token': 'QpwL5tke4Pnpja7X4'}
-| 请求 body --> None
-| 接口状态--> 200
-| 接口耗时--> 0:00:00.165761
-| 接口响应--> {"data":{"id":4,"email":"eve.holt@reqres.in","first_name":"Eve","last_name":"Holt","avatar":"https://reqres.in/img/faces/4-image.jpg"},"support":{"url":"https://reqres.in/#support-heading","text":"To keep ReqRes free, contributions towards server costs are appreciated!"}}
-| 断言结果-->[{'检查项': '$.data.id', '期望值': 4, '实际值': 4, '断言方法': 'eq:实际值与期望值相等', '断言结果': '通过'}, {'检查项': '$.data.email', '期望值': 'eve.holt@reqres.in', '实际值': 'eve.holt@reqres.in', '断言方法': 'eq:实际值与期望值相等', '断言结果': '通过'}, {'检查项': '200', '期望值': '200', '实际值': '200', '断言方法': 'eq:实际值与期望值相等', '断言结果': '通过'}]
-
---------------------------------------------------我是分割线--------------------------------------------------
-test_api_005_用户列表 (test_executor.TestProjectApi)执行——>【通过】
-
+ 这个测试用例听说泡面比较好吃,所以放弃执行了!!
| 请求地址 --> https://bimdc.bzlrobot.com/bsp/pre/user/ugs/ibs/api/ibs-file/file-upload/upload-image
-| 请求方法 --> POST
-| 请求头 --> {'BSP_TOKEN': '7c7d70bfb079d72182156d9b80d7911c', 'USER_ENV_ID': '1320970534539886592', 'USER_ID': '60629040', 'USER_TENANT': '1320970534539886592', 'Content-Length': '170', 'Content-Type': 'multipart/form-data; boundary=9a150998ef4ddb384b9b3fc8300097bc'}
-| 请求 body --> b'--9a150998ef4ddb384b9b3fc8300097bc\r\nContent-Disposition: form-data; name="file"; filename="test.txt"\r\nContent-Type: text/plain\r\n\r\n\r\n--9a150998ef4ddb384b9b3fc8300097bc--\r\n'
-| 接口状态--> 503
-| 接口耗时--> 0:00:00.079066
-| 接口响应--> {"code":503,"data":null,"message":"Failed to handle request [POST https://ibs-gateway.ibs-pre/ibs-file/file-upload/upload-image]: 503 SERVICE_UNAVAILABLE \"Unable to find instance for APP-API\""}
-| 断言结果-->未填写断言信息,默认执行断言请求返回的状态码!!!
-
---------------------------------------------------我是分割线--------------------------------------------------
-test_api_007_文件上传 (test_executor.TestProjectApi)执行——>【失败】
-
-
- Traceback (most recent call last): -- -
File "d:\python3.9\lib\unittest\case.py", line 59, in testPartExecutor - yield -- -
File "d:\python3.9\lib\unittest\case.py", line 593, in run - self._callTestMethod(testMethod) -- -
File "d:\python3.9\lib\unittest\case.py", line 550, in _callTestMethod - method() -- -
File "E:\production\apitest\common\core\dataDriver.py", line 43, in wrapper - return func(self, params, *args, **kwargs) -- -
File "E:\production\apitest\test_script\test_executor.py", line 50, in test_api - self.action.execute_validation(excel, sheet, iid, name, desc, expected) -- -
File "E:\production\apitest\common\core\action.py", line 96, in execute_validation - raise e -- -
File "E:\production\apitest\common\core\action.py", line 90, in execute_validation - eq(200, self.response.status_code) -- -
File "E:\production\apitest\common\validation\comparators.py", line 30, in eq - assert actual_value == expect_value, p_string(actual_value, expect_value) -- -
AssertionError: 预期:200 -> (class 'int'), 实际:503 -> (class 'int')
-
+ 这个测试用例听说泡面比较好吃,所以放弃执行了!!