smartpush 1.3.5__tar.gz → 1.3.8__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.
Files changed (22) hide show
  1. {smartpush-1.3.5 → smartpush-1.3.8}/PKG-INFO +1 -1
  2. {smartpush-1.3.5 → smartpush-1.3.8}/setup.py +1 -1
  3. smartpush-1.3.8/smartpush/flow/MockFlow.py +130 -0
  4. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush/get_jira_info.py +2 -2
  5. smartpush-1.3.8/smartpush/test.py +98 -0
  6. smartpush-1.3.8/smartpush/utils/ListDictUtils.py +29 -0
  7. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush.egg-info/PKG-INFO +1 -1
  8. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush.egg-info/SOURCES.txt +3 -0
  9. {smartpush-1.3.5 → smartpush-1.3.8}/README.md +0 -0
  10. {smartpush-1.3.5 → smartpush-1.3.8}/setup.cfg +0 -0
  11. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush/__init__.py +0 -0
  12. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush/export/__init__.py +0 -0
  13. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush/export/basic/ExcelExportChecker.py +0 -0
  14. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush/export/basic/GetOssUrl.py +0 -0
  15. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush/export/basic/ReadExcel.py +0 -0
  16. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush/export/basic/__init__.py +0 -0
  17. {smartpush-1.3.5/smartpush/utils → smartpush-1.3.8/smartpush/flow}/__init__.py +0 -0
  18. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush/utils/DataTypeUtils.py +0 -0
  19. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush/utils/StringUtils.py +0 -0
  20. /smartpush-1.3.5/smartpush/test.py → /smartpush-1.3.8/smartpush/utils/__init__.py +0 -0
  21. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush.egg-info/dependency_links.txt +0 -0
  22. {smartpush-1.3.5 → smartpush-1.3.8}/smartpush.egg-info/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpush
3
- Version: 1.3.5
3
+ Version: 1.3.8
4
4
  Summary: 用于smartpush自动化测试工具包
5
5
  Author: 卢泽彬、邵宇飞、周彦龙
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='smartpush',
5
- version='1.3.5',
5
+ version='1.3.8',
6
6
  description='用于smartpush自动化测试工具包',
7
7
  author='卢泽彬、邵宇飞、周彦龙',
8
8
  packages=find_packages(),
@@ -0,0 +1,130 @@
1
+ import json
2
+ import random
3
+ import time
4
+ import requests
5
+ from smartpush.utils import ListDictUtils
6
+
7
+
8
+ def get_current_flow(host_domain, cookies, flow_id):
9
+ # 提取flow所有节点数据
10
+ _url = host_domain + "/flow/getFlowDetail"
11
+ headers = {
12
+ "cookie": cookies
13
+ }
14
+ params = {
15
+ "flowId": flow_id,
16
+ "active": True,
17
+ "includeActivityDetail": True
18
+ }
19
+ result = json.loads(requests.request(method="get", url=_url, headers=headers, params=params).text)
20
+ # 按节点id存储
21
+ node_counts = []
22
+
23
+ def process_node(node):
24
+ node_counts.append({node["id"]: {"completedCount": node["data"]["completedCount"],
25
+ "skippedCount": node["data"]["skippedCount"],
26
+ "openUserCount": node["data"]["openUserCount"],
27
+ "clickUserCount": node["data"]["clickUserCount"],
28
+ "waitingCount": node["data"]["waitingCount"]
29
+ }
30
+ }
31
+ )
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
65
+
66
+
67
+ def start_flow(host_domain, cookies, flow_id, version):
68
+ # 开启flow
69
+ _url = host_domain + "/flow/publishFlow"
70
+ headers = {
71
+ "cookie": cookies,
72
+ "Content-Type": "application/json"
73
+ }
74
+ params = {
75
+ "flowId": flow_id,
76
+ "version": str(version)
77
+ }
78
+ result = requests.request(method="post", url=_url, headers=headers, json=params).text
79
+
80
+
81
+ def mock_pulsar(mock_domain, pulsar, limit=1):
82
+ """
83
+ # post请求
84
+ # times:为触发次数,默认1次即可
85
+ """
86
+ _url = mock_domain + "/flow/testEventMulti"
87
+ headers = {
88
+ "Content-Type": "application/json"
89
+ }
90
+ # 生成随机message_id
91
+ prefix = 179
92
+ pulsar["messageId"] = f"{prefix}{random.randint(10 ** 15, 10 ** 16 - 1)}"
93
+ params = {
94
+ "times": limit,
95
+ "mq": pulsar
96
+ }
97
+ result = requests.request(method="post", url=_url, headers=headers, json=params).text
98
+ return json.loads(result)
99
+
100
+
101
+ def check_flow(mock_domain, host_domain, cookies, **kwargs):
102
+ """
103
+ params
104
+ mock_domain:必填,触发接口域名
105
+ host_domain:必填,spflow接口域名
106
+ cookies:必填,sp登录态
107
+ flow_id:必填
108
+ pulsar:必填,模拟的触发数据
109
+ limit:非必填,默认为1 - mock_pulsar函数用于控制模拟触发的次数
110
+ num:非必填,默认为1 - compare_lists函数用于断言方法做差值计算
111
+ update_flow_params: 非必填,dict格式,需更新flow时传参,参数结构为sp的saveFlow接口内容
112
+ """
113
+ # 触发前提取flow数据,后续做对比
114
+ old_flow_counts, old_versions = get_current_flow(host_domain=host_domain, cookies=cookies,
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)
120
+ # 启动flow
121
+ start_flow(host_domain=host_domain, cookies=cookies, flow_id=kwargs["flow_id"], version=old_versions)
122
+ # 触发flow
123
+ mock_pulsar(mock_domain=mock_domain, pulsar=kwargs["pulsar"], limit=kwargs.get("limit", 1))
124
+ # 触发后提取flow数据,做断言
125
+ time.sleep(30)
126
+ new_flow_counts, new_versions = get_current_flow(host_domain=host_domain, cookies=cookies,
127
+ flow_id=kwargs["flow_id"])
128
+ # 断言
129
+ result = ListDictUtils.compare_lists(temp1=old_flow_counts, temp2=new_flow_counts, num=kwargs.get("num", 1))
130
+ return [True, "断言成功"] if len(result) == 0 else [False, result]
@@ -311,8 +311,8 @@ class JiraInfo:
311
311
  automation_saves_labor_time = value.get("自动化节省工时")
312
312
  fixVersions = value.get("fixVersions")
313
313
  content += f"> [{key + '-' + summary}]({url}) \n状态:{status}\n实际上线时间:{actually_online_time}\n自动化测试工作量:{automated_testing_workload}\n自动节省工时:{automation_saves_labor_time}\n" \
314
- f"测试:{tester_user_id} \n\n "
315
- content = f"### <font color=\"warning\"> 版本{fixVersions}需求已上线,请更新jira数据,进行版本收尾</font> \n" + content
314
+ f"测试:{tester_user_id}\n版本号:{fixVersions} \n\n "
315
+ content = f"### <font color=\"warning\"> 本周版本需求已上线,请检查并更新jira数据,进行版本收尾</font> \n" + content
316
316
  self.send_wecom_robot_message(webhook, content)
317
317
 
318
318
  def get_tester_wecom_userid(self, tester, user_data):
@@ -0,0 +1,98 @@
1
+ # -*- codeing = utf-8 -*-
2
+ # @Time :2025/2/20 00:27
3
+ # @Author :luzebin
4
+ import pandas as pd
5
+
6
+ from smartpush.export.basic import ExcelExportChecker
7
+ from smartpush.export.basic.ReadExcel import read_excel_from_oss
8
+ from smartpush.export.basic.ReadExcel import read_excel_and_write_to_dict
9
+ from smartpush.export.basic.GetOssUrl import get_oss_address_with_retry
10
+ from smartpush.utils.DataTypeUtils import DataTypeUtils
11
+ from smartpush.flow import MockFlow
12
+
13
+ if __name__ == '__main__':
14
+ oss1 = "https://cdn.smartpushedm.com/material_ec2/2025-02-26/31c1a577af244c65ab9f9a984c64f3d9/ab%E5%BC%B9%E7%AA%97%E6%B5%8B%E8%AF%952.10%E5%88%9B%E5%BB%BA-%E6%9C%89%E5%85%A8%E9%83%A8%E6%95%B0%E6%8D%AE%E9%94%80%E5%94%AE%E9%A2%9D%E6%98%8E%E7%BB%86%E6%95%B0%E6%8D%AE.xlsx"
15
+ oss2 = "https://cdn.smartpushedm.com/material_ec2/2025-02-26/31c1a577af244c65ab9f9a984c64f3d9/ab%E5%BC%B9%E7%AA%97%E6%B5%8B%E8%AF%952.10%E5%88%9B%E5%BB%BA-%E6%9C%89%E5%85%A8%E9%83%A8%E6%95%B0%E6%8D%AE%E9%94%80%E5%94%AE%E9%A2%9D%E6%98%8E%E7%BB%86%E6%95%B0%E6%8D%AE.xlsx"
16
+ # # print(check_excel_all(oss1, oss1))
17
+ oss3 = "https://cdn.smartpushedm.com/material_ec2/2025-03-07/dca03e35cb074ac2a46935c85de9f510/导出全部客户.csv"
18
+ oss4 = "https://cdn.smartpushedm.com/material_ec2/2025-03-07/c5fa0cc24d05416e93579266910fbd3e/%E5%AF%BC%E5%87%BA%E5%85%A8%E9%83%A8%E5%AE%A2%E6%88%B7.csv"
19
+ expected_oss = "https://cdn.smartpushedm.com/material_ec2/2025-02-26/757df7e77ce544e193257c0da35a4983/%E3%80%90%E8%87%AA%E5%8A%A8%E5%8C%96%E5%AF%BC%E5%87%BA%E3%80%91%E8%90%A5%E9%94%80%E6%B4%BB%E5%8A%A8%E6%95%B0%E6%8D%AE%E6%A6%82%E8%A7%88.xlsx"
20
+ # actual_oss = "https://cdn.smartpushedm.com/material_ec2/2025-02-26/757df7e77ce544e193257c0da35a4983/%E3%80%90%E8%87%AA%E5%8A%A8%E5%8C%96%E5%AF%BC%E5%87%BA%E3%80%91%E8%90%A5%E9%94%80%E6%B4%BB%E5%8A%A8%E6%95%B0%E6%8D%AE%E6%A6%82%E8%A7%88.xlsx"
21
+ url = "https://cdn.smartpushedm.com/material_ec2_prod/2025-03-06/fe6f042f50884466979155c5ef825736/copy%20of%202025-01-16%20%E5%88%9B%E5%BB%BA%E7%9A%84%20A%2FB%20%E6%B5%8B%E8%AF%95%20copy%20of%202025-01-16%20app-%E6%99%AE%E9%80%9A%E6%A8%A1%E6%9D%BF%201%E6%95%B0%E6%8D%AE%E6%80%BB%E8%A7%88.xlsx"
22
+
23
+ # e_person_oss1 = "https://cdn.smartpushedm.com/material_ec2/2025-02-27/b48f34b3e88045d189631ec1f0f23d51/%E5%AF%BC%E5%87%BA%E5%85%A8%E9%83%A8%E5%AE%A2%E6%88%B7.csv"
24
+ # a_person_oss2 = "https://cdn.smartpushedm.com/material_ec2/2025-02-27/c50519d803c04e3b9b52d9f625fed413/%E5%AF%BC%E5%87%BA%E5%85%A8%E9%83%A8%E5%AE%A2%E6%88%B7.csv"
25
+
26
+ # # #actual_oss= get_oss_address_with_retry("23161","https://cdn.smartpushedm.com/material_ec2_prod/2025-02-20/dae941ec20964ca5b106407858676f89/%E7%BE%A4%E7%BB%84%E6%95%B0%E6%8D%AE%E6%A6%82%E8%A7%88.xlsx","",'{"page":1,"pageSize":10,"type":null,"status":null,"startTime":null,"endTime":null}')
27
+ # # res=read_excel_and_write_to_dict(read_excel_from_oss(actual_oss))
28
+ # # print(res)
29
+ # # print(read_excel_and_write_to_dict(read_excel_from_oss(oss1), type=".xlsx"))
30
+ # print(check_excel(check_type="all", actual_oss=actual_oss, expected_oss=expected_oss))
31
+ # print(check_excel_all(actual_oss=oss1, expected_oss=oss2,skiprows =1))
32
+ # print(check_excel_all(actual_oss=oss1, expected_oss=oss2,ignore_sort=True))
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"))
35
+ # read_excel_csv_data(type=)
36
+ # print(DataTypeUtils().check_email_format())
37
+ # errors = ExcelExportChecker.check_field_format(actual_oss=oss1, fileds={0: {5: "time"}}, skiprows=1)
38
+ # ExcelExportChecker.check_excel_name(actual_oss=oss1, expected_oss=url)
39
+
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#SID0000126BGKWZjG4n42Q2CwFh4CS1WDoQZHTsZddVzHm5AvTJYrgIBGBQYLWO+XpYs47JMugUA6ZpHRvCdRTXw0OLXxpvdGnuT8GZ5qgcuWxiOIUHwdOCKPO9aEBTTB6NWeShMEFpZlU9lLxzcYL6HLlPBHe; osudb_appid=SMARTPUSH; osudb_subappid=1; ecom_http_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDc1MzQzMjYsImp0aSI6IjVlMTMyOWU3LTAwMzItNDIyNS1hY2NmLWFlNDY4ZTUxZDgxMiIsInVzZXJJbmZvIjp7ImlkIjowLCJ1c2VySWQiOiI0MjEzNzg1MjE4IiwidXNlcm5hbWUiOi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derId": "c2c4a695a36373f56899b370d0f1b6f2",
47
+ "areaCode": "",
48
+ "context": {
49
+ "order": {
50
+ "buyerSubscribeEmail": True,
51
+ "checkoutId": "c2c4a695a36373f56899b370d0f1b6f2",
52
+ "discountCodes": [],
53
+ "orderAmountSet": {
54
+ "amount": 3,
55
+ "currency": "JPY"
56
+ },
57
+ "orderDetails": [
58
+ {
59
+ "productId": "16060724900402692190790343",
60
+ "title": "测试2.0-商品同步AutoSync-2023-08-17 20:52:00",
61
+ "titleTranslations": []
62
+ }
63
+ ],
64
+ "receiverCountryCode": "HK"
65
+ },
66
+ "user": {
67
+ "addresses": [],
68
+ "areaCode": "",
69
+ "email": "testsmart200+10@gmail.com",
70
+ "firstName": "testsmart200+10",
71
+ "gender": "others",
72
+ "id": "1911625831177650177",
73
+ "lastName": "",
74
+ "phone": "",
75
+ "tags": [],
76
+ "uid": "4603296300",
77
+ "userName": "testsmart200+10"
78
+ }
79
+ },
80
+ "controlObjectId": "c2c4a695a36373f56899b370d0f1b6f2",
81
+ "controlObjectType": 4,
82
+ "email": "testsmart200+10@gmail.com",
83
+ "handle": "smartpush4",
84
+ "language": "en",
85
+ "messageId": "1911625832100397058",
86
+ "phone": "",
87
+ "platform": 4,
88
+ "storeId": "1644395920444",
89
+ "timezone": "Asia/Macao",
90
+ "triggerId": "c1001",
91
+ "uid": "4603296300",
92
+ "userId": "1911625831177650177"
93
+ }
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)
@@ -0,0 +1,29 @@
1
+ def compare_lists(temp1, temp2, num=1):
2
+ """对比两个list中字典,a中字典对应的键值+num等于b字典中键值
3
+ ab值示例:
4
+ a = [{"123": {"a": 1, "b": 2}}, {"456": {"a": 5, "b": 6}}]
5
+ b = [{"123": {"a": 2, "b": 2}}, {"456": {"a": 6, "b": 6}}]
6
+ """
7
+ error = []
8
+ # 同时遍历两个列表中的字典
9
+ for temp1_a, temp2_b in zip(temp1, temp2):
10
+ # 遍历每个字典的键
11
+ for outer_key in temp1_a:
12
+ # 确保 temp2 对应的字典中也有相同的外层键
13
+ if outer_key in temp2_b:
14
+ # 获取内层字典
15
+ inner_dict_a = temp1_a[outer_key]
16
+ inner_dict_b = temp2_b[outer_key]
17
+ # 遍历内层字典的键
18
+ for inner_key in inner_dict_a:
19
+ # 确保 temp2 对应的内层字典中也有相同的键
20
+ if inner_key in inner_dict_b:
21
+ # 检查是否满足条件
22
+ if inner_dict_a[inner_key] + num != inner_dict_b[inner_key]:
23
+ error.append({
24
+ outer_key: {
25
+ f"{inner_key}_in_a": inner_dict_a[inner_key],
26
+ f"{inner_key}_in_b": inner_dict_b[inner_key]
27
+ }
28
+ })
29
+ return error
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpush
3
- Version: 1.3.5
3
+ Version: 1.3.8
4
4
  Summary: 用于smartpush自动化测试工具包
5
5
  Author: 卢泽彬、邵宇飞、周彦龙
@@ -12,6 +12,9 @@ smartpush/export/basic/ExcelExportChecker.py
12
12
  smartpush/export/basic/GetOssUrl.py
13
13
  smartpush/export/basic/ReadExcel.py
14
14
  smartpush/export/basic/__init__.py
15
+ smartpush/flow/MockFlow.py
16
+ smartpush/flow/__init__.py
15
17
  smartpush/utils/DataTypeUtils.py
18
+ smartpush/utils/ListDictUtils.py
16
19
  smartpush/utils/StringUtils.py
17
20
  smartpush/utils/__init__.py
File without changes
File without changes