smartpush 1.3.7__py3-none-any.whl → 1.3.8__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.
@@ -5,7 +5,7 @@ import requests
5
5
  from smartpush.utils import ListDictUtils
6
6
 
7
7
 
8
- def get_current_flow(host_domain, cookies, flow_id, oppor="forward"):
8
+ def get_current_flow(host_domain, cookies, flow_id):
9
9
  # 提取flow所有节点数据
10
10
  _url = host_domain + "/flow/getFlowDetail"
11
11
  headers = {
@@ -17,18 +17,51 @@ def get_current_flow(host_domain, cookies, flow_id, oppor="forward"):
17
17
  "includeActivityDetail": True
18
18
  }
19
19
  result = json.loads(requests.request(method="get", url=_url, headers=headers, params=params).text)
20
-
21
20
  # 按节点id存储
22
21
  node_counts = []
23
- for node in result["resultData"]["nodes"]:
22
+
23
+ def process_node(node):
24
24
  node_counts.append({node["id"]: {"completedCount": node["data"]["completedCount"],
25
25
  "skippedCount": node["data"]["skippedCount"],
26
26
  "openUserCount": node["data"]["openUserCount"],
27
27
  "clickUserCount": node["data"]["clickUserCount"],
28
- "waitingCount": node["data"]["waitingCount"]}
28
+ "waitingCount": node["data"]["waitingCount"]
29
+ }
29
30
  }
30
31
  )
31
- return {oppor: node_counts}, result["resultData"]["version"]
32
+ # 处理split节点
33
+ if "split" in node["data"].keys():
34
+ for branch_node in node['data']['split']['branches']["false"]:
35
+ process_node(branch_node)
36
+ for branch_node in node['data']['split']['branches']["true"]:
37
+ process_node(branch_node)
38
+ # 处理abTesting节点
39
+ elif "abTesting" in node["data"].keys():
40
+ for branch_node in node['data']['abTesting']['branches']["a"]:
41
+ process_node(branch_node)
42
+ for branch_node in node['data']['abTesting']['branches']["b"]:
43
+ process_node(branch_node)
44
+
45
+ # 处理所有顶层节点
46
+ for node in result['resultData']['nodes']:
47
+ process_node(node)
48
+ return node_counts, result["resultData"]["version"]
49
+
50
+
51
+ def update_flow(host_domain, cookies, **kwargs):
52
+ """
53
+ # 更新flow
54
+ update_flow_params: 必填,saveFlow接口所有参数,dict格式
55
+ version: 非必填,flow版本号
56
+ """
57
+ _url = host_domain + "/flow/saveFlow"
58
+ headers = {
59
+ "cookie": cookies,
60
+ "Content-Type": "application/json"
61
+ }
62
+ kwargs["update_flow_params"]["version"] = kwargs.get("version", kwargs["update_flow_params"]["version"])
63
+ params = kwargs["update_flow_params"]
64
+ result = requests.request(method="post", url=_url, headers=headers, json=params).text
32
65
 
33
66
 
34
67
  def start_flow(host_domain, cookies, flow_id, version):
@@ -46,18 +79,10 @@ def start_flow(host_domain, cookies, flow_id, version):
46
79
 
47
80
 
48
81
  def mock_pulsar(mock_domain, pulsar, limit=1):
82
+ """
49
83
  # post请求
50
84
  # times:为触发次数,默认1次即可
51
- # 第三步提取的content直接替换mq的值即可
52
- # 需参数化字段:
53
- # abandonedOrderId、checkoutId、controlObjectId取第一步control_object_id做参数化
54
- # platform为平台字段,枚举: 1:SF 2:ec1 4:ec2 8:domain
55
- # messageId:需更改,保证不是之前使用过的
56
- # userId:需参数化,兼容不同平台和环境
57
- # handle、storeId:兼容不同店铺
58
- #
59
- # 备注:
60
- # 可通过弃单id、userId字段测异常场景:如无联系人时,能触发但不发送,记录跳过数等;
85
+ """
61
86
  _url = mock_domain + "/flow/testEventMulti"
62
87
  headers = {
63
88
  "Content-Type": "application/json"
@@ -83,10 +108,15 @@ def check_flow(mock_domain, host_domain, cookies, **kwargs):
83
108
  pulsar:必填,模拟的触发数据
84
109
  limit:非必填,默认为1 - mock_pulsar函数用于控制模拟触发的次数
85
110
  num:非必填,默认为1 - compare_lists函数用于断言方法做差值计算
111
+ update_flow_params: 非必填,dict格式,需更新flow时传参,参数结构为sp的saveFlow接口内容
86
112
  """
87
113
  # 触发前提取flow数据,后续做对比
88
114
  old_flow_counts, old_versions = get_current_flow(host_domain=host_domain, cookies=cookies,
89
115
  flow_id=kwargs["flow_id"])
116
+ # 更新flow
117
+ if kwargs.get("update_flow_params", False):
118
+ update_flow(host_domain=host_domain, cookies=cookies, update_flow_params=kwargs.get("update_flow_params"),
119
+ version=old_versions)
90
120
  # 启动flow
91
121
  start_flow(host_domain=host_domain, cookies=cookies, flow_id=kwargs["flow_id"], version=old_versions)
92
122
  # 触发flow
@@ -97,4 +127,4 @@ def check_flow(mock_domain, host_domain, cookies, **kwargs):
97
127
  flow_id=kwargs["flow_id"])
98
128
  # 断言
99
129
  result = ListDictUtils.compare_lists(temp1=old_flow_counts, temp2=new_flow_counts, num=kwargs.get("num", 1))
100
- return [True, "断言成功"] if len(result) == 0 else [False, result]
130
+ return [True, "断言成功"] if len(result) == 0 else [False, result]
smartpush/test.py CHANGED
@@ -31,13 +31,17 @@ if __name__ == '__main__':
31
31
  # print(check_excel_all(actual_oss=oss1, expected_oss=oss2,skiprows =1))
32
32
  # print(check_excel_all(actual_oss=oss1, expected_oss=oss2,ignore_sort=True))
33
33
  # print(check_excel_all(actual_oss=a_person_oss2, expected_oss=e_person_oss1, check_type="including"))
34
- print(ExcelExportChecker.check_excel_all(actual_oss=oss3, expected_oss=oss4, check_type="including"))
34
+ # print(ExcelExportChecker.check_excel_all(actual_oss=oss3, expected_oss=oss4, check_type="including"))
35
35
  # read_excel_csv_data(type=)
36
36
  # print(DataTypeUtils().check_email_format())
37
37
  # errors = ExcelExportChecker.check_field_format(actual_oss=oss1, fileds={0: {5: "time"}}, skiprows=1)
38
38
  # ExcelExportChecker.check_excel_name(actual_oss=oss1, expected_oss=url)
39
39
 
40
40
  _url = "http://sp-go-flow-test.inshopline.com"
41
+ host_domain = "https://test.smartpushedm.com/api-em-ec2"
42
+ 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=4213785218; osudb_oar=#01#SID0000126BGKWZjG4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TQyMzI2NTM0LCJzY29wZSI6WyJlbWFpbC1tYXJrZXQiLCJjb29raWUiLCJzbC1lY29tLWVtYWlsLW1hcmtldC1uZXctdGVzdCIsImVtYWlsLW1hcmtldC1uZXctZGV2LWZzIiwiYXBpLXVjLWVjMiIsImFwaS1zdS1lYzIiLCJhcGktZW0tZWMyIiwiZmxvdy1wbHVnaW4iLCJhcGktc3AtbWFya2V0LWVjMiJdLCJjbGllbnRfaWQiOiJlbWFpbC1tYXJrZXQifQ.rBrzepA8U8ghqLcNGGF4N6s6PXA6v6tJaKVOe5jQdaw; JSESSIONID=0228F95DD250A037C91E0E2927EE2FC7"
43
+
44
+
41
45
  params = {
42
46
  "abandonedOrderId": "c2c4a695a36373f56899b370d0f1b6f2",
43
47
  "areaCode": "",
@@ -87,4 +91,8 @@ if __name__ == '__main__':
87
91
  "uid": "4603296300",
88
92
  "userId": "1911625831177650177"
89
93
  }
90
- mock_pulsar = MockFlow.mock_pulsar(_url, params)
94
+ mock_pulsar = MockFlow.check_flow(mock_domain=_url, host_domain=host_domain, cookies=cookies,
95
+ flow_id="FLOW6749144046546626518", pulsar=params)
96
+ # node_counts, versions = MockFlow.get_current_flow(host_domain=host_domain, cookies=cookies,
97
+ # flow_id="FLOW6749144046546626518")
98
+ print(mock_pulsar)
@@ -22,7 +22,6 @@ def compare_lists(temp1, temp2, num=1):
22
22
  if inner_dict_a[inner_key] + num != inner_dict_b[inner_key]:
23
23
  error.append({
24
24
  outer_key: {
25
-
26
25
  f"{inner_key}_in_a": inner_dict_a[inner_key],
27
26
  f"{inner_key}_in_b": inner_dict_b[inner_key]
28
27
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpush
3
- Version: 1.3.7
3
+ Version: 1.3.8
4
4
  Summary: 用于smartpush自动化测试工具包
5
5
  Author: 卢泽彬、邵宇飞、周彦龙
6
6
 
@@ -1,18 +1,18 @@
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=BIzo668m0cD8OTtMF6Gt4Ph0WcrFvBt287FzMU2hR-8,5502
3
+ smartpush/test.py,sha256=gOZE1am6-6ZPcfKLfh2KblHXhL5YY-LncPZhji4THYI,7648
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=5uv09Wfc1i4mqjx5FuuH1-31775gr4UmXQv5rbAoN1Y,3991
9
+ smartpush/flow/MockFlow.py,sha256=I9EKR9-rQ6H-fI4dzYZ_WRrHqxVdIcxaPKGKzG_3e3I,5083
10
10
  smartpush/flow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  smartpush/utils/DataTypeUtils.py,sha256=BC7ioztO3vAfKd1EOoNvXdVuXYY8qjNskV1DP7LhW-M,1082
12
- smartpush/utils/ListDictUtils.py,sha256=zhRCwPsvGCECHZWPUmm3fMRUCipg_fFVpBtX4PFNPzE,1386
12
+ smartpush/utils/ListDictUtils.py,sha256=OsmNzMA3nCAUJaRw53uyUkZI0t95VBlfxYwD4FFtjz8,1385
13
13
  smartpush/utils/StringUtils.py,sha256=n8mo9k0JQN63MReImgv-66JxmmymOGknR8pH2fkQrAo,4139
14
14
  smartpush/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- smartpush-1.3.7.dist-info/METADATA,sha256=CnE9qGsxwJ_KlOxXUMOL408udG8bMWkCjTRWT0u-Vss,145
16
- smartpush-1.3.7.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
17
- smartpush-1.3.7.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
18
- smartpush-1.3.7.dist-info/RECORD,,
15
+ smartpush-1.3.8.dist-info/METADATA,sha256=8_OjDrX1Go1UcCFJO-VlEzcBHOlnIpVVmvxRiiRKCCs,145
16
+ smartpush-1.3.8.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
17
+ smartpush-1.3.8.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
18
+ smartpush-1.3.8.dist-info/RECORD,,