pytest-auto-api2-cli 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cli.py +9 -0
- common/__init__.py +0 -0
- common/setting.py +78 -0
- pytest_auto_api2/__init__.py +4 -0
- pytest_auto_api2/cli.py +900 -0
- pytest_auto_api2/runtime/__init__.py +1 -0
- pytest_auto_api2/runtime/api.py +10 -0
- pytest_auto_api2/runtime/loader.py +80 -0
- pytest_auto_api2_cli-0.2.0.dist-info/METADATA +945 -0
- pytest_auto_api2_cli-0.2.0.dist-info/RECORD +73 -0
- pytest_auto_api2_cli-0.2.0.dist-info/WHEEL +5 -0
- pytest_auto_api2_cli-0.2.0.dist-info/entry_points.txt +2 -0
- pytest_auto_api2_cli-0.2.0.dist-info/top_level.txt +6 -0
- run.py +85 -0
- test_case/Collect/test_collect_addtool.py +40 -0
- test_case/Collect/test_collect_delete_tool.py +40 -0
- test_case/Collect/test_collect_tool_list.py +40 -0
- test_case/Collect/test_collect_update_tool.py +40 -0
- test_case/Login/test_login.py +40 -0
- test_case/UserInfo/test_get_user_info.py +40 -0
- test_case/__init__.py +6 -0
- test_case/conftest.py +132 -0
- utils/__init__.py +9 -0
- utils/assertion/__init__.py +4 -0
- utils/assertion/assert_control.py +179 -0
- utils/assertion/assert_type.py +141 -0
- utils/cache_process/__init__.py +4 -0
- utils/cache_process/cache_control.py +89 -0
- utils/cache_process/redis_control.py +106 -0
- utils/logging_tool/__init__.py +4 -0
- utils/logging_tool/log_control.py +84 -0
- utils/logging_tool/log_decorator.py +48 -0
- utils/logging_tool/run_time_decorator.py +34 -0
- utils/mysql_tool/__init__.py +4 -0
- utils/mysql_tool/mysql_control.py +175 -0
- utils/notify/__init__.py +1 -0
- utils/notify/ding_talk.py +153 -0
- utils/notify/lark.py +181 -0
- utils/notify/send_mail.py +84 -0
- utils/notify/wechat_send.py +109 -0
- utils/other_tools/__init__.py +0 -0
- utils/other_tools/address_detection.py +73 -0
- utils/other_tools/allure_data/__init__.py +4 -0
- utils/other_tools/allure_data/allure_report_data.py +84 -0
- utils/other_tools/allure_data/allure_tools.py +54 -0
- utils/other_tools/allure_data/error_case_excel.py +316 -0
- utils/other_tools/exceptions.py +47 -0
- utils/other_tools/get_local_ip.py +27 -0
- utils/other_tools/install_tool/__init__.py +0 -0
- utils/other_tools/install_tool/install_requirements.py +91 -0
- utils/other_tools/jsonpath_date_replace.py +28 -0
- utils/other_tools/models.py +269 -0
- utils/other_tools/thread_tool.py +91 -0
- utils/read_files_tools/__init__.py +1 -0
- utils/read_files_tools/case_automatic_control.py +138 -0
- utils/read_files_tools/clean_files.py +19 -0
- utils/read_files_tools/excel_control.py +55 -0
- utils/read_files_tools/get_all_files_path.py +27 -0
- utils/read_files_tools/get_yaml_data_analysis.py +156 -0
- utils/read_files_tools/regular_control.py +209 -0
- utils/read_files_tools/swagger_for_yaml.py +145 -0
- utils/read_files_tools/testcase_template.py +103 -0
- utils/read_files_tools/yaml_control.py +86 -0
- utils/recording/__init__.py +0 -0
- utils/recording/mitmproxy_control.py +225 -0
- utils/requests_tool/__init__.py +0 -0
- utils/requests_tool/dependent_case.py +273 -0
- utils/requests_tool/encryption_algorithm_control.py +80 -0
- utils/requests_tool/request_control.py +443 -0
- utils/requests_tool/set_current_request_cache.py +73 -0
- utils/requests_tool/teardown_control.py +280 -0
- utils/times_tool/__init__.py +0 -0
- utils/times_tool/time_control.py +87 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Runtime bridge utilities for generated tests."""
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""Runtime import bridge used by generated testcase files."""
|
|
4
|
+
|
|
5
|
+
from utils.assertion.assert_control import Assert
|
|
6
|
+
from utils.read_files_tools.regular_control import regular
|
|
7
|
+
from utils.requests_tool.request_control import RequestControl
|
|
8
|
+
from utils.requests_tool.teardown_control import TearDownHandler
|
|
9
|
+
|
|
10
|
+
__all__ = ["Assert", "RequestControl", "TearDownHandler", "regular"]
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""Case cache loader for generated tests and dependency resolution."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Iterable, List, Optional
|
|
9
|
+
|
|
10
|
+
from common.setting import data_dir_path, resolve_project_path
|
|
11
|
+
from utils.cache_process.cache_control import CacheHandler, _cache_config
|
|
12
|
+
from utils.read_files_tools.get_yaml_data_analysis import CaseData
|
|
13
|
+
|
|
14
|
+
_CACHE_BUILT = False
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _iter_yaml_files(data_dir: Path) -> Iterable[Path]:
|
|
18
|
+
for pattern in ("*.yaml", "*.yml"):
|
|
19
|
+
for path in data_dir.rglob(pattern):
|
|
20
|
+
if path.is_file() and path.name != "proxy_data.yaml":
|
|
21
|
+
yield path
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def build_case_cache(data_dir: Optional[str] = None, *, force: bool = False) -> int:
|
|
25
|
+
"""Load all yaml case definitions into the in-memory cache."""
|
|
26
|
+
global _CACHE_BUILT
|
|
27
|
+
|
|
28
|
+
if _CACHE_BUILT and not force:
|
|
29
|
+
return len(_cache_config)
|
|
30
|
+
|
|
31
|
+
target = resolve_project_path(data_dir) if data_dir else data_dir_path()
|
|
32
|
+
data_root = Path(target)
|
|
33
|
+
if not data_root.exists():
|
|
34
|
+
raise FileNotFoundError(f"YAML data directory does not exist: {data_root}")
|
|
35
|
+
|
|
36
|
+
if force:
|
|
37
|
+
_cache_config.clear()
|
|
38
|
+
|
|
39
|
+
seen_case_ids = set(_cache_config.keys())
|
|
40
|
+
for yaml_path in _iter_yaml_files(data_root):
|
|
41
|
+
case_process = CaseData(str(yaml_path)).case_process(case_id_switch=True)
|
|
42
|
+
if not case_process:
|
|
43
|
+
continue
|
|
44
|
+
|
|
45
|
+
for case in case_process:
|
|
46
|
+
for case_id, case_data in case.items():
|
|
47
|
+
if case_id in seen_case_ids:
|
|
48
|
+
raise ValueError(
|
|
49
|
+
f"Duplicate case_id detected: {case_id}\nfile: {yaml_path}"
|
|
50
|
+
)
|
|
51
|
+
CacheHandler.update_cache(cache_name=case_id, value=case_data)
|
|
52
|
+
seen_case_ids.add(case_id)
|
|
53
|
+
|
|
54
|
+
_CACHE_BUILT = True
|
|
55
|
+
return len(seen_case_ids)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def load_cases_by_ids(case_ids: List[str], *, data_dir: Optional[str] = None) -> List[dict]:
|
|
59
|
+
"""Return parsed case data list in the same order as incoming ids."""
|
|
60
|
+
build_case_cache(data_dir=data_dir)
|
|
61
|
+
|
|
62
|
+
cases: List[dict] = []
|
|
63
|
+
missing = []
|
|
64
|
+
for case_id in case_ids:
|
|
65
|
+
if case_id not in _cache_config:
|
|
66
|
+
missing.append(case_id)
|
|
67
|
+
continue
|
|
68
|
+
cases.append(_cache_config[case_id])
|
|
69
|
+
|
|
70
|
+
if missing:
|
|
71
|
+
raise KeyError(f"Case ids not found in cache: {missing}")
|
|
72
|
+
|
|
73
|
+
return cases
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def clear_case_cache() -> None:
|
|
77
|
+
"""Clear in-memory cache and reset build flag."""
|
|
78
|
+
global _CACHE_BUILT
|
|
79
|
+
_cache_config.clear()
|
|
80
|
+
_CACHE_BUILT = False
|