smartpush 1.0.2.2__py3-none-any.whl → 1.0.2.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/__init__.py CHANGED
@@ -1 +0,0 @@
1
- from smartpush.autotest import export
@@ -0,0 +1,3 @@
1
+ # -*- codeing = utf-8 -*-
2
+ # @Time :2025/1/16 23:31
3
+ # @Author :luzebin
@@ -0,0 +1,109 @@
1
+ import os
2
+ from io import BytesIO
3
+ import pandas as pd
4
+ import numpy as np
5
+ from requests import request
6
+
7
+
8
+ class ExcelExportChecke:
9
+ def read_excel_from_oss(method, url):
10
+ """读取oss的excel内容并写入到本地csv"""
11
+ try:
12
+ result = request(method=method, url=url)
13
+ excel_data = BytesIO(result.content)
14
+ print(f"成功读取oss文件内容: {url}")
15
+ return excel_data
16
+ except Exception as e:
17
+ print(f"读取oss报错 {url} 时出错:{e}")
18
+
19
+ def read_excel_and_write_to_dict(excel_data=None, file_name=None):
20
+ """excel内容并写入到内存dict中
21
+ :param excel_data:excel的io对象, 参数和file_name互斥
22
+ :file_name: excel文件名称,目前读取check_file目录下文件,参数和excel_data互斥
23
+ """
24
+ try:
25
+ if excel_data is not None and file_name is not None:
26
+ pass
27
+ elif file_name is not None:
28
+ excel_data = os.path.join(os.path.dirname(os.getcwd()) + "/check_file/" + file_name)
29
+ df = pd.read_excel(excel_data, engine="openpyxl")
30
+ # 将DataFrame转换为字典,以行为单位存储数据
31
+ row_dict = {} # 创建一个空字典来存储按行转换的数据
32
+ for index, row in df.iterrows(): # 遍历DataFrame中的每一行
33
+ row_dict[index] = row.to_dict() # 将每一行转换为字典并存储在row_dict中
34
+ return row_dict
35
+ except Exception as e:
36
+ print(f"excel写入dict时出错:{e}")
37
+
38
+ def read_excel_and_write_to_list(excel_data=None, file_name=None):
39
+ """excel内容并写入到内存list中
40
+ :param excel_data:excel的io对象, 参数和file_name互斥
41
+ :file_name: excel文件名称,目前读取check_file目录下文件,参数和excel_data互斥
42
+ """
43
+ try:
44
+ if excel_data is not None and file_name is not None:
45
+ pass
46
+ elif file_name is not None:
47
+ excel_data = os.path.join(os.path.dirname(os.getcwd()) + "/check_file/" + file_name)
48
+ df = pd.read_excel(excel_data, engine="openpyxl")
49
+ # 将DataFrame转换为字典,以行为单位存储数据
50
+ rows_list = df.values.tolist()
51
+ return rows_list
52
+ except Exception as e:
53
+ print(f"excel写入dict时出错:{e}")
54
+
55
+ def read_excel_and_write_to_csv(excel_data, file_name):
56
+ """excel内容并写入到csv中"""
57
+ try:
58
+ df = pd.read_excel(excel_data, engine="openpyxl")
59
+ local_csv_path = os.path.join(os.path.dirname(os.getcwd()) + "/temp_file/" + file_name)
60
+ df.to_csv(local_csv_path, index=False)
61
+ return local_csv_path
62
+ except Exception as e:
63
+ print(f"excel写入csv时出错:{e}")
64
+
65
+ def check_excel(actual, expected):
66
+ """对比两份excel内容
67
+ :param: actual: 实际值,list类型
68
+ :param: expected: 预期值,list类型
69
+ """
70
+ try:
71
+ if actual == expected:
72
+ return True
73
+ else:
74
+ errors = []
75
+ # 断言1:校验行数
76
+ actual_num = len(actual)
77
+ expected_num = len(expected)
78
+ check_row = actual_num - expected_num
79
+ if check_row == 0:
80
+ pass
81
+ else:
82
+ errors.append(
83
+ "行数和预期对比差" + check_row.__str__() + "行" + ", 实际:" + str(actual_num) + "预期: " + str(
84
+ expected_num))
85
+ # 断言不匹配行
86
+ if check_row >= 0:
87
+ num = len(expected)
88
+ else:
89
+ num = len(actual)
90
+ for i in range(num):
91
+ if actual[i] == expected[i]:
92
+ continue
93
+ else:
94
+ errors.append(
95
+ "第" + str(i + 1) + "行不匹配,预期为:" + str(expected[i]) + ", 实际为: " + str(actual[i]))
96
+ return False, errors
97
+ except Exception as e:
98
+ print(f"对比excel:{e}")
99
+
100
+ def del_temp_file(file_name=""):
101
+ """删除temp下临时文件"""
102
+ file_path = os.path.join(os.path.dirname(os.getcwd()) + "/temp_file/" + file_name)
103
+ try:
104
+ os.remove(file_path)
105
+ print(f"文件 {file_path} 已成功删除。")
106
+ except FileNotFoundError:
107
+ print(f"文件 {file_path} 不存在。")
108
+ except Exception as e:
109
+ print(f"删除文件 {file_path} 时出错:{e}")
@@ -0,0 +1,3 @@
1
+ # -*- codeing = utf-8 -*-
2
+ # @Time :2025/1/16 23:22
3
+ # @Author :luzebin
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpush
3
- Version: 1.0.2.2
3
+ Version: 1.0.2.4
4
4
  Summary: 用于smartpush自动化测试工具包
5
5
  Home-page: UNKNOWN
6
6
  Author: 卢泽彬、邵宇飞、周彦龙
@@ -0,0 +1,9 @@
1
+ smartpush/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ smartpush/get_jira_info.py,sha256=zXp5OB9fVY5e0RbYcqlcq3ClqwLBAEvAVPZ1A_PrdMg,2416
3
+ smartpush/export/__init__.py,sha256=gyPv80Ib3xZxujSGuUk5NVWb_J3qOwJjB5JFlsLWuLI,70
4
+ smartpush/export/basic/ExcelExportChecker.py,sha256=xvYsmzdq-nULf4uGv2ZTcxHhelM-kGHtKAwtWzR_jQ8,4700
5
+ smartpush/export/basic/__init__.py,sha256=6tcrS-2NSlsJo-UwEsnGUmwCf7jgOsh_UEbM0FD-gYE,70
6
+ smartpush-1.0.2.4.dist-info/METADATA,sha256=YJ77pBjSvl9SzgmsK6D3kqfLmk0Z2NlOlZlWqav0QSI,210
7
+ smartpush-1.0.2.4.dist-info/WHEEL,sha256=OqRkF0eY5GHssMorFjlbTIq072vpHpF60fIQA6lS9xA,92
8
+ smartpush-1.0.2.4.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
9
+ smartpush-1.0.2.4.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- smartpush/__init__.py,sha256=ep8lBshfHhKtcmiPKVOEjS_ODMy9jq7bsiLZzfXryec,37
2
- smartpush/get_jira_info.py,sha256=zXp5OB9fVY5e0RbYcqlcq3ClqwLBAEvAVPZ1A_PrdMg,2416
3
- smartpush-1.0.2.2.dist-info/METADATA,sha256=ZYC3sE91s_COMmuEdRTkW2yfEauA8u-cHGrCI-_1WaY,210
4
- smartpush-1.0.2.2.dist-info/WHEEL,sha256=OqRkF0eY5GHssMorFjlbTIq072vpHpF60fIQA6lS9xA,92
5
- smartpush-1.0.2.2.dist-info/top_level.txt,sha256=5_CXqu08EfbPaKLjuSAOAqCmGU6shiatwDU_ViBGCmg,10
6
- smartpush-1.0.2.2.dist-info/RECORD,,