Files
apiautotest/utils/requests_utils/case_dependence.py

48 lines
1.8 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 -*-
# @Time : 2023/12/18 9:16
# @Author : floraachy
# @File : case_denpence_handle
# @Software: PyCharm
# @Desc:
# 第三方库导入
import allure
from loguru import logger
# 本地应用/模块导入
from utils.requests_utils.api_workflow import get_api_data, api_work_flow
from config.path_config import INTERFACE_DIR
from config.global_vars import GLOBAL_VARS
def case_dependence_handle(case_dependence, source):
"""
处理用例依赖支持接口依赖和SQL依赖。关键字interface, sql
"""
if case_dependence is None:
logger.debug(f"case_dependence为空跳过用例依赖处理 --> case_dependence={case_dependence}")
return
if case_dependence.get("interface"):
interfaces = case_dependence["interface"]
if isinstance(interfaces, str):
with allure.step(f"依赖接口:{interfaces}"):
api_data = get_api_data(api_file_path=INTERFACE_DIR, key=interfaces)
result = api_work_flow(req_data=api_data, source=source)
GLOBAL_VARS.update(result)
elif isinstance(interfaces, list):
for interface in interfaces:
with allure.step(f"依赖接口:{interface}"):
api_data = get_api_data(api_file_path=INTERFACE_DIR, key=interface)
result = api_work_flow(req_data=api_data, source=source)
GLOBAL_VARS.update(result)
else:
logger.warning(f"依赖接口格式错误,跳过依赖接口处理~ --> interface 仅支持str和list格式")
else:
logger.warning(f"依赖接口为空,跳过依赖接口处理~")
# 依赖SQL处理
if case_dependence.get("sql"):
logger.warning(f"暂时不支持依赖sql处理后续更新")
pass