Commit f2a8c7c58c2c3cea3a113af9b8da70f2799c0351
1 parent
35b3317e
支持方法跟新
Showing
9 changed files
with
240 additions
and
0 deletions
commons/clientSession.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | ||
2 | + | ||
3 | +# @Time : 2021/7/16 10:23 | ||
4 | +# @Author : Ljq | ||
5 | +# @File : clientSession.py | ||
6 | +# @Software: PyCharm | ||
7 | + | ||
8 | +""" | ||
9 | + | ||
10 | +""" | ||
11 | + | ||
12 | +import requests | ||
13 | +import json | ||
14 | +from commons.readConf import readConfig | ||
15 | + | ||
16 | +class cliSession(object): | ||
17 | + def __init__(self): | ||
18 | + rConf = readConfig() | ||
19 | + | ||
20 | + def __init__(self): | ||
21 | + rC = readConfig() | ||
22 | + self.userName = rC.returnOptionsItems("loginInfo","userName") | ||
23 | + self.password = rC.returnOptionsItems("loginInfo","password") | ||
24 | + self.loginUrl = rC.returnOptionsItems("host","uapHost")+"/api/authenticationApi/loginWeb" | ||
25 | + self.loginData = {"userName":self.userName,"password":self.password} | ||
26 | + self.webHeaders = {"X-Requested-With":"XMLHttpRequest", | ||
27 | + "Content-Type":"application/x-www-form-urlencoded", | ||
28 | + "Cookie":"UAP_accessToken=${UAP_accessToken}; UAP_refreshToken=${UAP_refreshToken};UAP_firmId=${UAP_firmId}"} | ||
29 | + | ||
30 | + self.clientHeaders={"UAP_accessToken":"${UAP_accessToken}", | ||
31 | + "UAP_refreshToken":"${UAP_refreshToken}", | ||
32 | + "UAP_firmId":"${UAP_firmId}", | ||
33 | + "Cookie":"UAP_accessToken=${UAP_accessToken}; UAP_refreshToken=${UAP_refreshToken}", | ||
34 | + "Content-Type":"application/json"} | ||
35 | + | ||
36 | + def loginUser(self): | ||
37 | + """ | ||
38 | + | ||
39 | + :return: | ||
40 | + """ | ||
41 | + # 返回登录信息,以及可用headers,clientHeaders用户客户端操作header,webHeaders用于web页面使用headers | ||
42 | + res = requests.post(url=self.loginUrl,data=json.dumps(self.loginData)) | ||
43 | + print(res.json()) | ||
44 | + UAP_accessToken,UAP_refreshToken,UAP_firmId=res.json()["data"]["accessToken"],res.json()["data"]["refreshToken"],res.json()["data"]["user"]["firmId"] | ||
45 | + webHeadersCookie = "UAP_accessToken="+UAP_accessToken+"; UAP_refreshToken="+UAP_refreshToken+";UAP_firmId="+str(UAP_firmId) | ||
46 | + clientHeadersCookie = "UAP_accessToken="+UAP_accessToken+"; UAP_refreshToken="+UAP_refreshToken | ||
47 | + self.webHeaders["Cookie"] = webHeadersCookie | ||
48 | + self.clientHeaders["UAP_accessToken"] = UAP_accessToken | ||
49 | + self.clientHeaders["UAP_refreshToken"]= UAP_refreshToken | ||
50 | + self.clientHeaders["UAP_firmId"] = str(UAP_firmId) | ||
51 | + self.clientHeaders["Cookie"] = clientHeadersCookie | ||
52 | + return self.webHeaders,self.clientHeaders,res.json() |
commons/readConf.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | ||
2 | + | ||
3 | +# @Time : 2021/7/16 10:36 | ||
4 | +# @Author : Ljq | ||
5 | +# @File : readConf.py | ||
6 | +# @Software: PyCharm | ||
7 | + | ||
8 | +""" | ||
9 | +配置文件读取 | ||
10 | +""" | ||
11 | + | ||
12 | +import configparser | ||
13 | +import os | ||
14 | + | ||
15 | +class readConfig(object): | ||
16 | + ROBOT_LIBRARY_SCOPE = 'TEST CASE' | ||
17 | + ROBOT_LIBRARY_VERSION = '0.1' | ||
18 | + | ||
19 | + def __init__(self): | ||
20 | + self.conf = configparser.ConfigParser() | ||
21 | + self.evn_name = os.name | ||
22 | + self.file_name = r'test_config_hg' | ||
23 | + if self.evn_name == 'nt': | ||
24 | + self.relative_path = r'/config/marketConfig/' | ||
25 | + # # 本地调试路径 | ||
26 | + # self.file_path = os.path.abspath(os.path.join(os.getcwd(), "../..")) + self.relative_path+self.file_name | ||
27 | + # 本地main方法执行路径 | ||
28 | + self.file_path = os.path.abspath(os.path.join(os.getcwd(), "../")) + self.relative_path + self.file_name | ||
29 | + elif self.evn_name == 'posix': | ||
30 | + self.relative_path = r'/config/marketConfig/' | ||
31 | + self.file_path = os.path.abspath(os.path.join(os.getcwd())) + self.relative_path + self.file_name | ||
32 | + # self.file_path = os.getcwd() | ||
33 | + print(self.file_path) | ||
34 | + self.conf.read(self.file_path,encoding="utf-8") | ||
35 | + | ||
36 | + def returnSections(self): | ||
37 | + sections = self.conf.sections() | ||
38 | + print(sections) | ||
39 | + return sections | ||
40 | + | ||
41 | + def returnOptions(self,options): | ||
42 | + options = self.conf.options(options) | ||
43 | + print(options) | ||
44 | + return options | ||
45 | + | ||
46 | + def returnOptionsInfo(self,items): | ||
47 | + items = self.conf.items(items) | ||
48 | + print(items) | ||
49 | + | ||
50 | + def returnOptionsItems(self,options,items): | ||
51 | + value = self.conf.get(options,items) | ||
52 | + print(value) | ||
53 | + return value | ||
54 | + | ||
55 | + def ReturnFilePath(self): | ||
56 | + print(self.file_path) | ||
57 | + return self.file_path | ||
58 | + | ||
59 | +# readConfig().returnOptionsItems("loginInfo","userName") | ||
0 | \ No newline at end of file | 60 | \ No newline at end of file |
commons/scripts/__init__.py
0 → 100644
commons/scripts/createIdNum.py
0 → 100644
1 | +#coding=utf-8 | ||
2 | + | ||
3 | +# @Time : 2021/5/26 11:19 | ||
4 | +# @Author : Ljq | ||
5 | +# @File : createIdNum.py | ||
6 | +# @Software: PyCharm | ||
7 | + | ||
8 | + | ||
9 | +""" | ||
10 | + 生成身份证号 | ||
11 | +""" | ||
12 | + | ||
13 | +import time | ||
14 | +import random | ||
15 | + | ||
16 | + | ||
17 | +def cIN(): | ||
18 | + """ | ||
19 | + 身份证号生成 | ||
20 | + :return: | ||
21 | + """ | ||
22 | + # 拼接备用身份证号 | ||
23 | + area,birthday,policeStationCode,sex = 110101,time.strftime("%Y%m%d", time.localtime()),random.randint(10,99),random.randint(0,9) | ||
24 | + idNum_str = f"{area}{birthday}{policeStationCode}{sex}" | ||
25 | + basecCode = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] | ||
26 | + checkCode = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"] | ||
27 | + num = 0 | ||
28 | + for i in range(17): | ||
29 | + num = num + basecCode[i] * int(idNum_str[i]) | ||
30 | + return f"{idNum_str}{checkCode[num % 11]}" | ||
31 | +# | ||
32 | +# print(cIN()) | ||
0 | \ No newline at end of file | 33 | \ No newline at end of file |
commons/scripts/dealContentType.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | ||
2 | + | ||
3 | +# @Time : 2021/7/16 14:51 | ||
4 | +# @Author : Ljq | ||
5 | +# @File : dealContentType.py | ||
6 | +# @Software: PyCharm | ||
7 | + | ||
8 | +""" | ||
9 | + 用于hearders中Content-Type格式处理 | ||
10 | +""" | ||
11 | + | ||
12 | +def jsonCT(headers=None): | ||
13 | + headers["Content-Type"] = "application/json; charset=UTF-8" | ||
14 | + return headers | ||
15 | + | ||
16 | +def urlCode(headers=None): | ||
17 | + headers["Content-Type"] = "application/x-www-form-urlencoded" | ||
18 | + return headers | ||
0 | \ No newline at end of file | 19 | \ No newline at end of file |
commons/scripts/delReport.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | ||
2 | + | ||
3 | +# @Time : 2021/7/19 14:35 | ||
4 | +# @Author : Ljq | ||
5 | +# @File : delectReport.py | ||
6 | +# @Software: PyCharm | ||
7 | + | ||
8 | +""" | ||
9 | +用于删除多余的报告文件 | ||
10 | +""" | ||
11 | + | ||
12 | +import os,sys | ||
13 | + | ||
14 | +def delReport(path,delNum=5): | ||
15 | + # print("path",path) | ||
16 | + if os.name == "nt": | ||
17 | + report_route = os.path.abspath(os.path.join(path, "../")) | ||
18 | + else: | ||
19 | + report_route = os.path.abspath(os.path.join(path)) | ||
20 | + file_list = os.listdir(report_route + "/report/") | ||
21 | + # print("delReport file_lis --- ", file_list) | ||
22 | + if len(file_list) > delNum: | ||
23 | + file_list = file_list[:0-delNum] | ||
24 | + # print("if file_lis --- ",file_list) | ||
25 | + for i in file_list: | ||
26 | + if os.path.isfile(report_route + "/report/" + i) and ".log" not in i: | ||
27 | + os.remove(report_route + "/report/" + i) | ||
28 | + print(f"删除报告 {i} 成功") | ||
29 | + # 文件已删除 | ||
30 | + print("多余的报告文件已删除") | ||
31 | + else: | ||
32 | + print("没有需要删除的文件") | ||
0 | \ No newline at end of file | 33 | \ No newline at end of file |
config/marketConfig/__init__.py
0 → 100644
config/marketConfig/put_market_config_info_here
0 → 100644
config/marketConfig/test_config_hg
0 → 100644
1 | +#沈阳市场信息 | ||
2 | +[loginInfo] | ||
3 | +userName=scgy | ||
4 | +password=DYdgRcAyx2bPboAmu0tgIYBM1kMxFAuDty7IQk4162Zh+8KKa8jtu6xIjG9W4yauTfPiuP1sqxDatskXFqCOz76ea14AqRCYEBz53xVr+vLfcz9zOB2d1T3aIlJbEk8yi2c21pd/MFkBw+Fhd0tky/6eN8kJA8mtsj3uDwSb9qo= | ||
5 | + | ||
6 | +[testInfo] | ||
7 | +#已添加的身份证号 | ||
8 | +cCNum=11010119990307865X | ||
9 | +cCNumB=110101199903077593 | ||
10 | +#入库未开卡的卡号 | ||
11 | +cardNum=210607113166 | ||
12 | +#已开卡的卡号 | ||
13 | +cardNumRe=888800001207 | ||
14 | +#密码设置 | ||
15 | +loginPwd=111111 | ||
16 | + | ||
17 | +[host] | ||
18 | +cardHost=http://test.card.diligrp.com:8386 | ||
19 | +uapHost=http://test.uap.diligrp.com | ||
20 | +gatewayHost=http://test.gateway.diligrp.com:8285 | ||
0 | \ No newline at end of file | 21 | \ No newline at end of file |