pytest-api-framework-alpha 0.3.2__tar.gz → 0.3.4__tar.gz
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.
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/PKG-INFO +1 -1
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/base_class.py +11 -1
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/conftest.py +3 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/script.py +6 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/mock_util.py +47 -2
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/pytest_api_framework_alpha.egg-info/PKG-INFO +1 -1
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/setup.py +1 -1
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/__init__.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/db/__init__.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/db/mysql_db.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/db/redis_db.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/exceptions.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/exit_code.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/extract.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/global_attribute.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/http_client.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/render_data.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/report.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/startapp.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/__init__.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/common.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/date_util.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/encrypt.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/log_util.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/yaml_util.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/validate.py +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/pytest_api_framework_alpha.egg-info/SOURCES.txt +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/pytest_api_framework_alpha.egg-info/dependency_links.txt +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/pytest_api_framework_alpha.egg-info/requires.txt +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/pytest_api_framework_alpha.egg-info/top_level.txt +0 -0
- {pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/setup.cfg +0 -0
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/base_class.py
RENAMED
|
@@ -18,7 +18,8 @@ from framework.utils.date_util import DateUtil
|
|
|
18
18
|
from framework.utils.common import snake_to_pascal, SingletonFaker
|
|
19
19
|
from framework.global_attribute import GlobalAttribute, _FRAMEWORK_CONTEXT, CONTEXT
|
|
20
20
|
from framework.exceptions import ValidateException, RenderException, RequestException, GetAccountError, GetAppHttpError
|
|
21
|
-
from framework.utils.mock_util import get_customized_kytmock, set_customized_kytmock, PaymentType, RiskLevel, IsDelayed
|
|
21
|
+
from framework.utils.mock_util import get_customized_kytmock, set_customized_kytmock, PaymentType, RiskLevel, IsDelayed, \
|
|
22
|
+
mock_mq
|
|
22
23
|
|
|
23
24
|
from handlers.extend_base_test_case_attr import ExtendBaseTestCase
|
|
24
25
|
from config.settings import UNAUTHORIZED_CODE, FAKER_LANGUAGE
|
|
@@ -190,3 +191,12 @@ class BaseTestCase(ExtendBaseTestCase):
|
|
|
190
191
|
|
|
191
192
|
"""
|
|
192
193
|
return set_customized_kytmock(self.context.get("env"), request_id, payment_type, risk_level, is_delayed)
|
|
194
|
+
|
|
195
|
+
def mock_mq_message(self,target_exchange,exchange_type,message,routing_key:str=None):
|
|
196
|
+
"""
|
|
197
|
+
target_exchange:目标交换机名称
|
|
198
|
+
exchange_type:交换机类型,枚举:fanout,direct,topic,header
|
|
199
|
+
message:消息体,json格式
|
|
200
|
+
routing_key: 路由关键字,默认为null
|
|
201
|
+
"""
|
|
202
|
+
return mock_mq(self.context.get("env"),target_exchange,exchange_type,message,routing_key)
|
|
@@ -365,6 +365,7 @@ def pytest_generate_tests(metafunc):
|
|
|
365
365
|
if mark_obj.name not in ["skip", "skipif", "xfail", "usefixtures", "filterwarnings",
|
|
366
366
|
"parametrize", "order", "timeout", "django_db", "asyncio"] and not mark_obj.args:
|
|
367
367
|
marks.append(mark_obj.name)
|
|
368
|
+
marks = [item.lower() for item in marks]
|
|
368
369
|
# 校验标签
|
|
369
370
|
is_subset, diff = subset_and_diff(set(marks), set(MARK_LIST))
|
|
370
371
|
|
|
@@ -614,6 +615,8 @@ def sort(case_items):
|
|
|
614
615
|
def pytest_collection_finish(session):
|
|
615
616
|
"""获取最终排序后的 items 列表"""
|
|
616
617
|
logger.info(f"共收集到 {len(session.items)} 个测试用例")
|
|
618
|
+
if not session.items:
|
|
619
|
+
pytest.exit("未收集到用例")
|
|
617
620
|
# 过滤掉item名称是test_setup或test_teardown的
|
|
618
621
|
session.items = [item for item in session.items if item.name not in ["test_setup", "test_teardown"]]
|
|
619
622
|
|
|
@@ -16,3 +16,9 @@ class BaseScript(__BaseScript):
|
|
|
16
16
|
|
|
17
17
|
def default_app(self, app):
|
|
18
18
|
return app or self.app
|
|
19
|
+
|
|
20
|
+
def context_set(self, key, value):
|
|
21
|
+
self.context.set(app=self.app, key=key, value=value)
|
|
22
|
+
|
|
23
|
+
def context_get(self, key):
|
|
24
|
+
return self.context.get(app=self.app, key=key)
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/mock_util.py
RENAMED
|
@@ -136,6 +136,45 @@ def get_customized_kytmock(env,request_id):
|
|
|
136
136
|
|
|
137
137
|
return None
|
|
138
138
|
|
|
139
|
+
def mock_mq(env,target_exchange,exchange_type,message,routing_key):
|
|
140
|
+
# 获取环境配置
|
|
141
|
+
env_config = get_environment_config(env)
|
|
142
|
+
method = "mock_mq"
|
|
143
|
+
url = get_full_api_url(env,method)
|
|
144
|
+
# 参数验证
|
|
145
|
+
if not isinstance(target_exchange, str) or not target_exchange:
|
|
146
|
+
raise ValueError("target_exchange必须是非空字符串")
|
|
147
|
+
if not isinstance(exchange_type,str ) or not exchange_type:
|
|
148
|
+
raise ValueError("exchange_type 必须是非空字符串")
|
|
149
|
+
if not isinstance(message,str ) or not message:
|
|
150
|
+
raise ValueError("message 必须是非空字符串")
|
|
151
|
+
# 构建请求参数
|
|
152
|
+
payload = {
|
|
153
|
+
"targetExchange": target_exchange,
|
|
154
|
+
"targetExchangeType": exchange_type,
|
|
155
|
+
"message": message,
|
|
156
|
+
"targetRoutingKey": routing_key
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
try:
|
|
160
|
+
# 使用环境配置中的超时时间
|
|
161
|
+
response = requests.post(
|
|
162
|
+
url,
|
|
163
|
+
json=payload,
|
|
164
|
+
timeout=env_config["timeout"]
|
|
165
|
+
)
|
|
166
|
+
response.raise_for_status()
|
|
167
|
+
|
|
168
|
+
return response.json()
|
|
169
|
+
except requests.exceptions.HTTPError as e:
|
|
170
|
+
print(f"HTTP错误 [{env}]: {e}")
|
|
171
|
+
except requests.exceptions.RequestException as e:
|
|
172
|
+
print(f"请求异常 [{env}]: {e}")
|
|
173
|
+
except ValueError:
|
|
174
|
+
print(f"响应解析失败 [{env}]")
|
|
175
|
+
|
|
176
|
+
return None
|
|
177
|
+
|
|
139
178
|
if __name__ == "__main__":
|
|
140
179
|
# # 1. 调用测试环境的入金接口
|
|
141
180
|
# test_deposit = set_customized_kytmock(
|
|
@@ -155,5 +194,11 @@ if __name__ == "__main__":
|
|
|
155
194
|
# )
|
|
156
195
|
# print(f"开发环境出金响应: {dev_withdrawal}")
|
|
157
196
|
|
|
158
|
-
get_content = get_customized_kytmock("dev","A0101585")
|
|
159
|
-
print(f"查询结果:{get_content}")
|
|
197
|
+
# get_content = get_customized_kytmock("dev","A0101585")
|
|
198
|
+
# print(f"查询结果:{get_content}")
|
|
199
|
+
exchange_name = "camp.gateway.backbone.mock.ex.order-status"
|
|
200
|
+
exchange_type = "fanout"
|
|
201
|
+
message = "{ \"avgFillPrice\": 440.23, \"filled\": 11.0000000000000000, \"orderId\": 409, \"remaining\": 0.0000000000000000, \"status\": \"Filled\" }"
|
|
202
|
+
result = mock_mq("dev",exchange_name,exchange_type,message)
|
|
203
|
+
print(result)
|
|
204
|
+
|
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/db/__init__.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/db/mysql_db.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/db/redis_db.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/exceptions.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/exit_code.py
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/global_attribute.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/http_client.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/render_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/__init__.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/common.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/date_util.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/encrypt.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/log_util.py
RENAMED
|
File without changes
|
{pytest_api_framework_alpha-0.3.2 → pytest_api_framework_alpha-0.3.4}/framework/utils/yaml_util.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|