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.
Files changed (73) hide show
  1. cli.py +9 -0
  2. common/__init__.py +0 -0
  3. common/setting.py +78 -0
  4. pytest_auto_api2/__init__.py +4 -0
  5. pytest_auto_api2/cli.py +900 -0
  6. pytest_auto_api2/runtime/__init__.py +1 -0
  7. pytest_auto_api2/runtime/api.py +10 -0
  8. pytest_auto_api2/runtime/loader.py +80 -0
  9. pytest_auto_api2_cli-0.2.0.dist-info/METADATA +945 -0
  10. pytest_auto_api2_cli-0.2.0.dist-info/RECORD +73 -0
  11. pytest_auto_api2_cli-0.2.0.dist-info/WHEEL +5 -0
  12. pytest_auto_api2_cli-0.2.0.dist-info/entry_points.txt +2 -0
  13. pytest_auto_api2_cli-0.2.0.dist-info/top_level.txt +6 -0
  14. run.py +85 -0
  15. test_case/Collect/test_collect_addtool.py +40 -0
  16. test_case/Collect/test_collect_delete_tool.py +40 -0
  17. test_case/Collect/test_collect_tool_list.py +40 -0
  18. test_case/Collect/test_collect_update_tool.py +40 -0
  19. test_case/Login/test_login.py +40 -0
  20. test_case/UserInfo/test_get_user_info.py +40 -0
  21. test_case/__init__.py +6 -0
  22. test_case/conftest.py +132 -0
  23. utils/__init__.py +9 -0
  24. utils/assertion/__init__.py +4 -0
  25. utils/assertion/assert_control.py +179 -0
  26. utils/assertion/assert_type.py +141 -0
  27. utils/cache_process/__init__.py +4 -0
  28. utils/cache_process/cache_control.py +89 -0
  29. utils/cache_process/redis_control.py +106 -0
  30. utils/logging_tool/__init__.py +4 -0
  31. utils/logging_tool/log_control.py +84 -0
  32. utils/logging_tool/log_decorator.py +48 -0
  33. utils/logging_tool/run_time_decorator.py +34 -0
  34. utils/mysql_tool/__init__.py +4 -0
  35. utils/mysql_tool/mysql_control.py +175 -0
  36. utils/notify/__init__.py +1 -0
  37. utils/notify/ding_talk.py +153 -0
  38. utils/notify/lark.py +181 -0
  39. utils/notify/send_mail.py +84 -0
  40. utils/notify/wechat_send.py +109 -0
  41. utils/other_tools/__init__.py +0 -0
  42. utils/other_tools/address_detection.py +73 -0
  43. utils/other_tools/allure_data/__init__.py +4 -0
  44. utils/other_tools/allure_data/allure_report_data.py +84 -0
  45. utils/other_tools/allure_data/allure_tools.py +54 -0
  46. utils/other_tools/allure_data/error_case_excel.py +316 -0
  47. utils/other_tools/exceptions.py +47 -0
  48. utils/other_tools/get_local_ip.py +27 -0
  49. utils/other_tools/install_tool/__init__.py +0 -0
  50. utils/other_tools/install_tool/install_requirements.py +91 -0
  51. utils/other_tools/jsonpath_date_replace.py +28 -0
  52. utils/other_tools/models.py +269 -0
  53. utils/other_tools/thread_tool.py +91 -0
  54. utils/read_files_tools/__init__.py +1 -0
  55. utils/read_files_tools/case_automatic_control.py +138 -0
  56. utils/read_files_tools/clean_files.py +19 -0
  57. utils/read_files_tools/excel_control.py +55 -0
  58. utils/read_files_tools/get_all_files_path.py +27 -0
  59. utils/read_files_tools/get_yaml_data_analysis.py +156 -0
  60. utils/read_files_tools/regular_control.py +209 -0
  61. utils/read_files_tools/swagger_for_yaml.py +145 -0
  62. utils/read_files_tools/testcase_template.py +103 -0
  63. utils/read_files_tools/yaml_control.py +86 -0
  64. utils/recording/__init__.py +0 -0
  65. utils/recording/mitmproxy_control.py +225 -0
  66. utils/requests_tool/__init__.py +0 -0
  67. utils/requests_tool/dependent_case.py +273 -0
  68. utils/requests_tool/encryption_algorithm_control.py +80 -0
  69. utils/requests_tool/request_control.py +443 -0
  70. utils/requests_tool/set_current_request_cache.py +73 -0
  71. utils/requests_tool/teardown_control.py +280 -0
  72. utils/times_tool/__init__.py +0 -0
  73. 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