smartpush 1.2.8__py3-none-any.whl → 1.2.9__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/export/basic/ExcelExportChecker.py +36 -4
- smartpush/test.py +15 -14
- {smartpush-1.2.8.dist-info → smartpush-1.2.9.dist-info}/METADATA +1 -1
- {smartpush-1.2.8.dist-info → smartpush-1.2.9.dist-info}/RECORD +6 -6
- {smartpush-1.2.8.dist-info → smartpush-1.2.9.dist-info}/WHEEL +1 -1
- {smartpush-1.2.8.dist-info → smartpush-1.2.9.dist-info}/top_level.txt +0 -0
@@ -2,6 +2,7 @@ import copy
|
|
2
2
|
import json
|
3
3
|
from urllib.parse import unquote
|
4
4
|
from smartpush.export.basic.ReadExcel import *
|
5
|
+
from datetime import datetime
|
5
6
|
from smartpush.utils import DataTypeUtils
|
6
7
|
|
7
8
|
"""
|
@@ -96,14 +97,17 @@ def check_excel_content_form_dict(actual, expected, **kwargs):
|
|
96
97
|
return check_excel_content(actual, expected)
|
97
98
|
|
98
99
|
|
99
|
-
def check_excel_content_including_expected(actual, expected, **kwargs):
|
100
|
+
def check_excel_content_including_expected(actual, expected, expected_oss, **kwargs):
|
100
101
|
"""
|
101
102
|
通过 OSS URL 比较 Excel 内容,期望是包含的结果,actual传的是生成的oss
|
102
103
|
"""
|
103
104
|
actual, expected = read_excel_and_write_to_dict(actual, **kwargs), read_excel_and_write_to_dict(
|
104
105
|
expected, **kwargs)
|
105
106
|
# 判断是否存在差异
|
106
|
-
|
107
|
+
if kwargs.get("export_type") == "flow":
|
108
|
+
missing_items = assert_flow(expected, actual, expected_oss)
|
109
|
+
else:
|
110
|
+
missing_items = find_missing_elements(expected.values(), actual.values())
|
107
111
|
return (False, {"与期望结果存在差异": missing_items}) if missing_items else (True, "校验期望结果包含校验通过")
|
108
112
|
|
109
113
|
|
@@ -115,6 +119,33 @@ def find_missing_elements(list1, list2):
|
|
115
119
|
return missing
|
116
120
|
|
117
121
|
|
122
|
+
def assert_flow(expected, actual, expected_oss):
|
123
|
+
# 判断预期数据in实际导出的数据
|
124
|
+
ex_sheet0 = expected.get("sheet0", [])
|
125
|
+
ac_sheet0 = actual.get("sheet0", [])
|
126
|
+
ex_sheet1 = expected.get("Flow node data by sending time", [])
|
127
|
+
ac_sheet1 = actual.get("Flow node data by sending time", [])
|
128
|
+
differences = []
|
129
|
+
res=[]
|
130
|
+
ex_sheet1.append(ex_sheet0)
|
131
|
+
ac_sheet1.append(ac_sheet0)
|
132
|
+
for i in ac_sheet1:
|
133
|
+
if i not in ex_sheet1:
|
134
|
+
differences.append(i)
|
135
|
+
# 判断对应的列数据
|
136
|
+
for diff in differences:
|
137
|
+
if len(diff) != 24:
|
138
|
+
res.append("列预期不正确")
|
139
|
+
# 判断多出的行,获取今天的日期,与预期日期对比
|
140
|
+
ex_data = expected_oss.split("/")[4].split("-")
|
141
|
+
today = datetime.today()
|
142
|
+
target_date = datetime(int(ex_data[0]), int(ex_data[1]), int(ex_data[2]))
|
143
|
+
diff_days = (today - target_date).days
|
144
|
+
if len(differences) != diff_days:
|
145
|
+
res.append("日期预期不正确")
|
146
|
+
return res
|
147
|
+
|
148
|
+
|
118
149
|
def check_excel_content_form_list(actual, expected):
|
119
150
|
"""
|
120
151
|
通过 内容 比较 Excel 内容,不包含表头
|
@@ -135,7 +166,8 @@ def check_excel_all(actual_oss, expected_oss, check_type=None, **kwargs):
|
|
135
166
|
flag1, name_result = check_excel_name(actual_oss, expected_oss)
|
136
167
|
flag3, header_result = check_excel_header(actual_data_copy, expected_data_copy, type=file_type, **kwargs)
|
137
168
|
if check_type == "including":
|
138
|
-
flag2, content_result = check_excel_content_including_expected(actual, expected, type=file_type,
|
169
|
+
flag2, content_result = check_excel_content_including_expected(actual, expected, expected_oss, type=file_type,
|
170
|
+
**kwargs)
|
139
171
|
else:
|
140
172
|
flag2, content_result = check_excel_content_form_dict(actual, expected, type=file_type, **kwargs)
|
141
173
|
print(json.dumps(
|
@@ -357,5 +389,5 @@ def check_field_format(actual_oss, **kwargs):
|
|
357
389
|
errors.append(
|
358
390
|
f"{actual_dict_key[key]} 表, 第{num}行{filed_key}列{kwargs['fileds'][key][filed_key]}格式不符合规范, 值为:{row[filed_key]}")
|
359
391
|
num += 1
|
360
|
-
print(errors)
|
392
|
+
print(errors if len(errors) > 0 else "都校验成功")
|
361
393
|
return False if len(errors) > 0 else True
|
smartpush/test.py
CHANGED
@@ -3,23 +3,23 @@
|
|
3
3
|
# @Author :luzebin
|
4
4
|
import pandas as pd
|
5
5
|
|
6
|
-
from smartpush.export.basic import
|
6
|
+
from smartpush.export.basic.ExcelExportChecker import check_excel_all, read_excel_and_write_to_list, \
|
7
|
+
read_excel_from_oss, read_excel_csv_data, check_excel
|
7
8
|
from smartpush.export.basic.ReadExcel import read_excel_from_oss
|
8
9
|
from smartpush.export.basic.ReadExcel import read_excel_and_write_to_dict
|
9
10
|
from smartpush.export.basic.GetOssUrl import get_oss_address_with_retry
|
10
|
-
from smartpush.utils.DataTypeUtils import DataTypeUtils
|
11
11
|
|
12
12
|
if __name__ == '__main__':
|
13
|
-
oss1 = "https://cdn.smartpushedm.com/material_ec2/2025-02-
|
14
|
-
oss2 = "https://cdn.smartpushedm.com/material_ec2/2025-02-
|
13
|
+
oss1 = "https://cdn.smartpushedm.com/material_ec2/2025-02-25/58c4a3a885884741b22380c360ac2894/【自动化导出】营销活动URL点击与热图.xlsx"
|
14
|
+
oss2 = "https://cdn.smartpushedm.com/material_ec2/2025-02-27/a5e18e3b3a83432daca871953cb8471b/【自动化导出】营销活动URL点击与热图.xlsx"
|
15
15
|
# # print(check_excel_all(oss1, oss1))
|
16
|
-
oss3 = "https://cdn.smartpushedm.com/material_ec2/2025-02-
|
17
|
-
oss4 = "https://cdn.smartpushedm.com/material_ec2/2025-02-
|
16
|
+
oss3 = "https://cdn.smartpushedm.com/material_ec2/2025-02-25/58c4a3a885884741b22380c360ac2894/【自动化导出】营销活动URL点击与热图.xlsx"
|
17
|
+
oss4 = "https://cdn.smartpushedm.com/material_ec2/2025-02-26/58cee630b4c84eec9572b867af4ce692/%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%A8URL%E7%82%B9%E5%87%BB%E4%B8%8E%E7%83%AD%E5%9B%BE.xlsx"
|
18
18
|
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"
|
19
|
-
|
19
|
+
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"
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
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"
|
22
|
+
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"
|
23
23
|
|
24
24
|
# # #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}')
|
25
25
|
# # res=read_excel_and_write_to_dict(read_excel_from_oss(actual_oss))
|
@@ -27,10 +27,11 @@ if __name__ == '__main__':
|
|
27
27
|
# # print(read_excel_and_write_to_dict(read_excel_from_oss(oss1), type=".xlsx"))
|
28
28
|
# print(check_excel(check_type="all", actual_oss=actual_oss, expected_oss=expected_oss))
|
29
29
|
# print(check_excel_all(actual_oss=oss1, expected_oss=oss2,skiprows =1))
|
30
|
-
#
|
30
|
+
#print(check_excel_all(actual_oss=oss1, expected_oss=oss2, ignore_sort=0))
|
31
31
|
# print(check_excel_all(actual_oss=a_person_oss2, expected_oss=e_person_oss1, check_type="including"))
|
32
|
-
# print(check_excel_all(actual_oss=
|
32
|
+
# print(check_excel_all(actual_oss=e_person_oss1, expected_oss=a_person_oss2, check_type="person"))
|
33
33
|
# read_excel_csv_data(type=)
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
|
35
|
+
flow_ex="https://cdn.smartpushedm.com/material_ec2/2025-02-20/ad9e1534b8134dd098e96813f17d4b4d/%E6%B5%8B%E8%AF%95flow%E6%95%B0%E6%8D%AE%E6%8A%A5%E5%91%8A%E5%AF%BC%E5%87%BA%E5%8B%BF%E5%8A%A8%E6%95%B0%E6%8D%AE%E6%A6%82%E8%A7%88.xlsx"
|
36
|
+
flow_ac="https://cdn.smartpushedm.com/material_ec2/2025-03-04/0c8f919f28d4455f9908f905aada7efb/测试flow数据报告导出勿动数据概览.xlsx"
|
37
|
+
print(check_excel_all(actual_oss=flow_ac, expected_oss=flow_ex, check_type="including",export_type="flow",skiprows=1))
|
@@ -1,15 +1,15 @@
|
|
1
1
|
smartpush/__init__.py,sha256=XJrl1vhGATHSeSVqKmPXxYqxyseriUpvY5tLIXir3EE,24
|
2
2
|
smartpush/get_jira_info.py,sha256=dmCwkKa94xwyE2hegE1KBI3cV_LbrJ67P9osORUGPt4,2633
|
3
|
-
smartpush/test.py,sha256=
|
3
|
+
smartpush/test.py,sha256=pMXVJzsiQc7INFYmH_ZUPkHBbjl0xmFD8-9yKL8Wn1o,3564
|
4
4
|
smartpush/export/__init__.py,sha256=D9GbWcmwnetEndFDty5XbVienFK1WjqV2yYcQp3CM84,99
|
5
|
-
smartpush/export/basic/ExcelExportChecker.py,sha256=
|
5
|
+
smartpush/export/basic/ExcelExportChecker.py,sha256=BOcIEqYrZD9yhMSvHrqPFDOUj_5zKhm2_OyQSN7KOds,17718
|
6
6
|
smartpush/export/basic/GetOssUrl.py,sha256=zlExF_jy_TRV5lp0fws8Wed5MF_byp7JAEmvARVqlIg,3263
|
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
9
|
smartpush/utils/DataTypeUtils.py,sha256=BC7ioztO3vAfKd1EOoNvXdVuXYY8qjNskV1DP7LhW-M,1082
|
10
10
|
smartpush/utils/StringUtils.py,sha256=NXomJ4qmyBRAFnGj5hrFRWwQnRQMTcPzy20fk1dunSw,3980
|
11
11
|
smartpush/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
|
-
smartpush-1.2.
|
13
|
-
smartpush-1.2.
|
14
|
-
smartpush-1.2.
|
15
|
-
smartpush-1.2.
|
12
|
+
smartpush-1.2.9.dist-info/METADATA,sha256=NLRbHHvxDiBoF4HDuR8tV_7F61tySFBVumFx0Jcebew,145
|
13
|
+
smartpush-1.2.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
14
|
+
smartpush-1.2.9.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
|
15
|
+
smartpush-1.2.9.dist-info/RECORD,,
|
File without changes
|