Files
smart-management-auto-test/base_framework/public_tools/__init__.py
qiaoxinjiu 6994b185a3 addproject
2026-01-22 19:10:37 +08:00

42 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding:utf-8 -*-
"""
Author: qiaoxinjiu
Create Data: 2020/9/21 18:39
"""
import json
def check_resp(is_check, resp):
if is_check:
assert resp["code"] == 200, "{}, exp code: {}".format(resp, 200)
assert resp["success"] is True, "{}, exp code: {}".format(resp, True)
assert resp["message"] == "", "{}, exp code: {}".format(resp, "")
assert resp["data"] != "", "{}, exp code: {}".format(resp, "")
def custom_check_resp(is_check, assert_list):
"""传参数例子asert_list = [(f"{resp}['code']", 0), (f"{resp}['message']", ""), (f"{resp}['success']", "True")]"""
if is_check:
for al in assert_list:
assert str(eval(al[0])) == str(al[1]), "{}, exp code: {}".format(eval(al[0]), al[1])
else:
pass
def convert_json(parames):
temp_json = json.dumps(parames)
temp_json1 = temp_json.replace("\"NULL\"", "null")
kwargs = json.loads(temp_json1)
return kwargs
def get_user(kwargs):
if kwargs.get("user", None):
user = kwargs.pop("user")
else:
user = None
return user, kwargs