smartpush 1.4.2__py3-none-any.whl → 1.4.4__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.
- smartpush/flow/MockFlow.py +20 -20
- smartpush/test.py +26 -19
- smartpush/utils/ListDictUtils.py +3 -3
- {smartpush-1.4.2.dist-info → smartpush-1.4.4.dist-info}/METADATA +1 -1
- {smartpush-1.4.2.dist-info → smartpush-1.4.4.dist-info}/RECORD +7 -7
- {smartpush-1.4.2.dist-info → smartpush-1.4.4.dist-info}/WHEEL +0 -0
- {smartpush-1.4.2.dist-info → smartpush-1.4.4.dist-info}/top_level.txt +0 -0
smartpush/flow/MockFlow.py
CHANGED
@@ -25,16 +25,13 @@ def get_current_flow(host_domain, cookies, flow_id, splits=None, **kwargs):
|
|
25
25
|
get_email_content = kwargs.get("get_email_content", False)
|
26
26
|
email_contents = []
|
27
27
|
|
28
|
-
def process_node(node, split_num
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
"clickUserCount": node["data"]["clickUserCount"],
|
34
|
-
"waitingCount": node["data"]["waitingCount"]
|
28
|
+
def process_node(node, split_num=0, index_type="completedCount"):
|
29
|
+
# 如当前分支为拆分节点,根据走yes还是no分支取对应字段
|
30
|
+
if "split" == node["type"] and splits is not None and len(splits) > split_num:
|
31
|
+
index_type = "completedCount" if splits[split_num] == "true" else "skippedCount"
|
32
|
+
node_counts.append({node["id"]: {index_type: node["data"][index_type]
|
35
33
|
}
|
36
|
-
}
|
37
|
-
)
|
34
|
+
})
|
38
35
|
# 提取邮件内容
|
39
36
|
if get_email_content and node["type"] == "sendLetter":
|
40
37
|
email_contents.append({node["data"]["sendLetter"]["emailName"]: {
|
@@ -42,11 +39,11 @@ def get_current_flow(host_domain, cookies, flow_id, splits=None, **kwargs):
|
|
42
39
|
"sender": node["data"]["sendLetter"]["sender"],
|
43
40
|
}})
|
44
41
|
# 处理split节点
|
45
|
-
if "split"
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
if "split" == node["type"] and splits is not None and len(splits) > split_num:
|
43
|
+
split_branch = node['data']['split']['branches'][splits[split_num]]
|
44
|
+
split_num += 1
|
45
|
+
for branch_node in split_branch:
|
46
|
+
process_node(branch_node, split_num)
|
50
47
|
# # 处理abTesting节点
|
51
48
|
# elif "abTesting" in node["data"].keys():
|
52
49
|
# for branch_node in node['data']['abTesting']['branches']["a"]:
|
@@ -107,6 +104,7 @@ def mock_pulsar(mock_domain, pulsar, limit=1):
|
|
107
104
|
"times": limit,
|
108
105
|
"mq": pulsar
|
109
106
|
}
|
107
|
+
print(params)
|
110
108
|
result = requests.request(method="post", url=_url, headers=headers, json=params).text
|
111
109
|
return json.loads(result)
|
112
110
|
|
@@ -132,6 +130,7 @@ def check_flow(host_domain, cookies, mock_domain="", **kwargs):
|
|
132
130
|
all_key: 非必填,bool,默认false,输入true时,检查指标节点常用5个字段
|
133
131
|
check_key: 非必填, 默认只有completedCount, list格式,传入需检查节点的指标key,如:completedCount、skippedCount、openRate等
|
134
132
|
split_node: list,有拆分节点时需填,结构:如: ["false", "true"],即走到拆分节点限制不满足分支再走满足分支
|
133
|
+
get_email_content: bool,默认false, 提取邮件内容,用于断言邮箱内是否送达
|
135
134
|
"""
|
136
135
|
# todo: 还差邮件校验部分,后续补充
|
137
136
|
is_split_steps = kwargs.get("split_steps", "all")
|
@@ -139,8 +138,8 @@ def check_flow(host_domain, cookies, mock_domain="", **kwargs):
|
|
139
138
|
if is_split_steps == "one" or is_split_steps == "all":
|
140
139
|
# 触发前提取flow数据,后续做对比
|
141
140
|
old_flow_counts, old_versions, _ = get_current_flow(host_domain=host_domain, cookies=cookies,
|
142
|
-
|
143
|
-
|
141
|
+
flow_id=kwargs["flow_id"],
|
142
|
+
splits=kwargs.get("split_node", None))
|
144
143
|
kwargs["old_flow_counts"] = old_flow_counts
|
145
144
|
# 更新flow
|
146
145
|
if kwargs.get("update_flow_params", False):
|
@@ -159,12 +158,13 @@ def check_flow(host_domain, cookies, mock_domain="", **kwargs):
|
|
159
158
|
time.sleep(kwargs.get("sleep_time", 60))
|
160
159
|
# 触发后提取flow数据,做断言
|
161
160
|
new_flow_counts, new_versions, email_contents = get_current_flow(host_domain=host_domain, cookies=cookies,
|
162
|
-
|
163
|
-
|
164
|
-
|
161
|
+
flow_id=kwargs["flow_id"],
|
162
|
+
splits=kwargs.get("split_node", None),
|
163
|
+
get_email_content=kwargs.get(
|
164
|
+
"get_email_content", False))
|
165
165
|
# 断言
|
166
166
|
result = ListDictUtils.compare_lists(temp1=kwargs.get("old_flow_counts"),
|
167
167
|
temp2=new_flow_counts, num=kwargs.get("num", 1),
|
168
|
-
check_key=kwargs.get("check_key", ["completedCount"]),
|
168
|
+
check_key=kwargs.get("check_key", ["completedCount", "skippedCount"]),
|
169
169
|
all_key=kwargs.get("all_key", False))
|
170
170
|
return [True, "断言成功"] if len(result) == 0 else [False, result], email_contents
|
smartpush/test.py
CHANGED
@@ -13,7 +13,7 @@ from smartpush.export.basic.ReadExcel import read_excel_and_write_to_dict
|
|
13
13
|
from smartpush.export.basic.GetOssUrl import get_oss_address_with_retry
|
14
14
|
from smartpush.utils.DataTypeUtils import DataTypeUtils
|
15
15
|
from smartpush.flow import MockFlow
|
16
|
-
from smartpush.utils import EmailUtlis
|
16
|
+
from smartpush.utils import EmailUtlis, ListDictUtils
|
17
17
|
|
18
18
|
if __name__ == '__main__':
|
19
19
|
# 导出流程
|
@@ -46,7 +46,7 @@ if __name__ == '__main__':
|
|
46
46
|
# flow触发流程 ------------------------------------------------------------------------------------------------------------------------
|
47
47
|
_url = "http://sp-go-flow-test.inshopline.com"
|
48
48
|
host_domain = "https://test.smartpushedm.com/api-em-ec2"
|
49
|
-
cookies = "_ga=GA1.1.88071637.1717860341; _ga_NE61JB8ZM6=GS1.1.1718954972.32.1.1718954972.0.0.0; _ga_Z8N3C69PPP=GS1.1.1723104149.2.0.1723104149.0.0.0; _ga_D2KXR23WN3=GS1.1.1735096783.3.1.1735096812.0.0.0; osudb_lang=; osudb_oar=#01#
|
49
|
+
cookies = "_ga=GA1.1.88071637.1717860341; _ga_NE61JB8ZM6=GS1.1.1718954972.32.1.1718954972.0.0.0; _ga_Z8N3C69PPP=GS1.1.1723104149.2.0.1723104149.0.0.0; _ga_D2KXR23WN3=GS1.1.1735096783.3.1.1735096812.0.0.0; osudb_lang=; a_lang=zh-hans-cn; osudb_uid=4213785247; osudb_oar=#01#SID0000128BA0RSWIkgaJoBiROHmmY9zaWt+yNT/cLZpKsGBxkFK4G4Fi+YE+5zicSeFaJmg/+zbnZjt543htvh4TVJOox971SEqJXBJuZu1bKK41UleDRJkw1ufT+wR8zbZw/w1VkSProXPqvU3SXTkEAA6ho; osudb_appid=SMARTPUSH; osudb_subappid=1; ecom_http_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTAzMjY4NDgsImp0aSI6IjE1ZjU1ZDUwLTgwMzgtNDFkMS05YzA4LTAwNTUyYTZjYzc0MSIsInVzZXJJbmZvIjp7ImlkIjowLCJ1c2VySWQiOiI0MjEzNzg1MjQ3IiwidXNlcm5hbWUiOiIiLCJlbWFpbCI6ImZlbGl4LnNoYW9Ac2hvcGxpbmVhcHAuY29tIiwidXNlclJvbGUiOiJvd25lciIsInBsYXRmb3JtVHlwZSI6Nywic3ViUGxhdGZvcm0iOjEsInBob25lIjoiIiwibGFuZ3VhZ2UiOiJ6aC1oYW5zLWNuIiwiYXV0aFR5cGUiOiIiLCJhdHRyaWJ1dGVzIjp7ImNvdW50cnlDb2RlIjoiQ04iLCJjdXJyZW5jeSI6IkpQWSIsImN1cnJlbmN5U3ltYm9sIjoiSlDCpSIsImRvbWFpbiI6InNtYXJ0cHVzaDQubXlzaG9wbGluZXN0Zy5jb20iLCJsYW5ndWFnZSI6ImVuIiwibWVyY2hhbnRFbWFpbCI6ImZlbGl4LnNoYW9Ac2hvcGxpbmUuY29tIiwibWVyY2hhbnROYW1lIjoiU21hcnRQdXNoNF9lYzJf6Ieq5Yqo5YyW5bqX6ZO6IiwicGhvbmUiOiIiLCJzY29wZUNoYW5nZWQiOmZhbHNlLCJzdGFmZkxhbmd1YWdlIjoiemgtaGFucy1jbiIsInN0YXR1cyI6MCwidGltZXpvbmUiOiJBc2lhL01hY2FvIn0sInN0b3JlSWQiOiIxNjQ0Mzk1OTIwNDQ0IiwiaGFuZGxlIjoic21hcnRwdXNoNCIsImVudiI6IkNOIiwic3RlIjoiIiwidmVyaWZ5IjoiIn0sImxvZ2luVGltZSI6MTc0NzczNDg0ODc0Miwic2NvcGUiOlsiZW1haWwtbWFya2V0IiwiY29va2llIiwic2wtZWNvbS1lbWFpbC1tYXJrZXQtbmV3LXRlc3QiLCJlbWFpbC1tYXJrZXQtbmV3LWRldi1mcyIsImFwaS11Yy1lYzIiLCJhcGktc3UtZWMyIiwiYXBpLWVtLWVjMiIsImZsb3ctcGx1Z2luIiwiYXBpLXNwLW1hcmtldC1lYzIiXSwiY2xpZW50X2lkIjoiZW1haWwtbWFya2V0In0.O3HQgqEvqb2nxm_6EkYX797j_qqeQ21M1ohIWOJu8Uo; JSESSIONID=57D8A7D13DD34650E0FF72DDB3435515"
|
50
50
|
|
51
51
|
params = {
|
52
52
|
"abandonedOrderId": "c2c4a695a36373f56899b370d0f1b6f2",
|
@@ -148,37 +148,44 @@ if __name__ == '__main__':
|
|
148
148
|
|
149
149
|
# old_flow_counts, old_versions, email_contents = MockFlow.get_current_flow(host_domain=host_domain, cookies=cookies,
|
150
150
|
# flow_id="FLOW6966717528141252274",
|
151
|
-
# splits=["false", "
|
151
|
+
# splits=["false", "true", "true"],
|
152
|
+
# get_email_content=True)
|
152
153
|
# print(old_flow_counts, old_versions, email_contents)
|
153
154
|
mock_pulsar_step1, _ = MockFlow.check_flow(mock_domain=_url, host_domain=host_domain, cookies=cookies,
|
154
155
|
flow_id="FLOW6966717528141252274", pulsar=params,
|
155
|
-
split_steps="one", split_node=["true"])
|
156
|
+
split_steps="one", split_node=["false", "true", "true"])
|
157
|
+
print(mock_pulsar_step1)
|
156
158
|
# time.sleep(60)
|
157
159
|
mock_pulsar_step2, email_contents = MockFlow.check_flow(mock_domain=_url, host_domain=host_domain, cookies=cookies,
|
158
160
|
flow_id="FLOW6966717528141252274",
|
159
161
|
old_flow_counts=mock_pulsar_step1,
|
160
|
-
split_steps="two", split_node=["true"],
|
162
|
+
split_steps="two", split_node=["false", "true", "true"],
|
161
163
|
get_email_content=True)
|
162
|
-
print(mock_pulsar_step1)
|
163
164
|
print(mock_pulsar_step2)
|
164
165
|
print(email_contents)
|
165
166
|
|
166
|
-
|
167
|
-
#
|
167
|
+
# split_steps="two")
|
168
|
+
# node_counts, versions = MockFlow.get_current_flow(host_domain=host_domain, cookies=cookies,
|
168
169
|
# flow_id="FLOW6749144046546626518")
|
169
170
|
|
170
171
|
# 调试
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
|
177
|
-
# b = [
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
172
|
+
# a = [{'049fd321-5a22-4f92-9692-a3da9507ee4b': {'completedCount': 44}},
|
173
|
+
# {'09ff19db-33a3-41d8-88e9-12e6017ddfd3': {'completedCount': 44}},
|
174
|
+
# {'31941d3a-910b-48fa-b302-0f3cf7790401': {'skippedCount': 7}},
|
175
|
+
# {'01e7c21d-ab57-4f89-98ad-1a437bca1138': {'completedCount': 5}},
|
176
|
+
# {'f3af15d5-848e-43d3-9ad3-d8f5172df6e0': {'completedCount': 5}},
|
177
|
+
# {'15630c25-75fa-4456-a6ee-a2bd1e3e64a1': {'completedCount': 42}}]
|
178
|
+
# b = [{'049fd321-5a22-4f92-9692-a3da9507ee4b': {'completedCount': 44}},
|
179
|
+
# {'09ff19db-33a3-41d8-88e9-12e6017ddfd3': {'completedCount': 44}},
|
180
|
+
# {'31941d3a-910b-48fa-b302-0f3cf7790401': {'skippedCount': 7}},
|
181
|
+
# {'01e7c21d-ab57-4f89-98ad-1a437bca1138': {'completedCount': 5}},
|
182
|
+
# {'f3af15d5-848e-43d3-9ad3-d8f5172df6e0': {'completedCount': 5}},
|
183
|
+
# {'15630c25-75fa-4456-a6ee-a2bd1e3e64a1': {'completedCount': 42}}]
|
184
|
+
# result = ListDictUtils.compare_lists(temp1=a,
|
185
|
+
# temp2=b, num=1,
|
186
|
+
# check_key=["completedCount", "skippedCount"],
|
187
|
+
# all_key=False)
|
188
|
+
# print(result)
|
182
189
|
|
183
190
|
# 断言邮件
|
184
191
|
loginEmail, password = 'lulu9600000@gmail.com', 'evvurakhttndwspx'
|
smartpush/utils/ListDictUtils.py
CHANGED
@@ -14,14 +14,14 @@ def compare_lists(temp1, temp2, check_key=["completedCount"], all_key=False, num
|
|
14
14
|
# 获取内层字典
|
15
15
|
inner_dict_a = temp1_a[outer_key]
|
16
16
|
inner_dict_b = temp2_b[outer_key]
|
17
|
+
# 提取内层字典key并存入list中
|
17
18
|
inner_dict_a_keys = list(inner_dict_a)
|
18
|
-
inner_dict_b_keys = list(inner_dict_b)
|
19
19
|
if all_key is False:
|
20
|
-
inner_dict_a_keys =
|
20
|
+
inner_dict_a_keys = check_key
|
21
21
|
# 遍历内层字典的键
|
22
22
|
for inner_key in inner_dict_a_keys:
|
23
23
|
# 确保 temp2 对应的内层字典中也有相同的键
|
24
|
-
if inner_key in
|
24
|
+
if inner_key in inner_dict_a.keys():
|
25
25
|
# 检查是否满足条件
|
26
26
|
if inner_dict_a[inner_key] + num != inner_dict_b[inner_key]:
|
27
27
|
error.append({
|
@@ -1,19 +1,19 @@
|
|
1
1
|
smartpush/__init__.py,sha256=XJrl1vhGATHSeSVqKmPXxYqxyseriUpvY5tLIXir3EE,24
|
2
2
|
smartpush/get_jira_info.py,sha256=Ej2JRlO_Kct6Koju57b27ySy_B4q43f0I2bFcS_fmaw,17801
|
3
|
-
smartpush/test.py,sha256=
|
3
|
+
smartpush/test.py,sha256=N2m5-MJvlKgTNk-kWq3eREzjBbirOiLJTMS9grVZu2Y,36723
|
4
4
|
smartpush/export/__init__.py,sha256=D9GbWcmwnetEndFDty5XbVienFK1WjqV2yYcQp3CM84,99
|
5
5
|
smartpush/export/basic/ExcelExportChecker.py,sha256=R_1gFy69vE2V5pY20zFsnhqWgJ42Vtf35zBtOPfhUpU,17590
|
6
6
|
smartpush/export/basic/GetOssUrl.py,sha256=LeF1y1_uJaYXth1KvO6mEDS29ezb9tliBv5SrbqYkXc,6136
|
7
7
|
smartpush/export/basic/ReadExcel.py,sha256=ZnG2mtYqLY-xuYx9SyulbdYUP_0E5jIeKDewfakAsTw,7342
|
8
8
|
smartpush/export/basic/__init__.py,sha256=6tcrS-2NSlsJo-UwEsnGUmwCf7jgOsh_UEbM0FD-gYE,70
|
9
|
-
smartpush/flow/MockFlow.py,sha256=
|
9
|
+
smartpush/flow/MockFlow.py,sha256=T8tZuJ9FLF0arbdu0PvbwXk-Ca-wjH46P-HCEW5aq2Y,8124
|
10
10
|
smartpush/flow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
smartpush/utils/DataTypeUtils.py,sha256=BC7ioztO3vAfKd1EOoNvXdVuXYY8qjNskV1DP7LhW-M,1082
|
12
12
|
smartpush/utils/EmailUtlis.py,sha256=DAHd73bJ8hiJCLEXtD0xcwxPD7SOPSmBB7Jvlf6gN6s,11201
|
13
|
-
smartpush/utils/ListDictUtils.py,sha256=
|
13
|
+
smartpush/utils/ListDictUtils.py,sha256=Fm5_d7UyY6xB8gySMPdl5jIFSRhXZcYXdYW-_L1alcE,1640
|
14
14
|
smartpush/utils/StringUtils.py,sha256=n8mo9k0JQN63MReImgv-66JxmmymOGknR8pH2fkQrAo,4139
|
15
15
|
smartpush/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
smartpush-1.4.
|
17
|
-
smartpush-1.4.
|
18
|
-
smartpush-1.4.
|
19
|
-
smartpush-1.4.
|
16
|
+
smartpush-1.4.4.dist-info/METADATA,sha256=y2Y8f7qQqrwC-a9JiZmj0TSUDODHSY6bLZXV4z0nnhA,131
|
17
|
+
smartpush-1.4.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
18
|
+
smartpush-1.4.4.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
|
19
|
+
smartpush-1.4.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|