Commit eec2ab68c93a9df6662533f5ad891f6a044da66d

Authored by lixi
1 parent e2cd7368

更新demo

commons/ConfigDB.py
... ... @@ -2,11 +2,9 @@
2 2 # -*- coding: UTF-8 -*-
3 3 import pymysql
4 4 import time
5   -import commons.common as ca
6 5 import json
7   -from commons.Logging import Logger
8   -# import chardet
9   -log=Logger()
  6 +import commons.common as ca
  7 +from commons.Logging import log
10 8  
11 9  
12 10 dbhost=ca.get_global_config('global_data','Database','dbhost')
... ...
commons/Faker.py
1   -#!/usr/bin/python
2   -# -*- coding: UTF-8 -*-
3   -import random
4   -from faker import Factory
5   -
6   -class random_data():
7   -
8   - def __init__(self, type='zh_CN'):
9   - self.type = type
10   - self.fake = Factory().create(self.type)
11   -
12   - def date(self):
13   - "随机时间"
14   - return self.fake.date(pattern="%Y-%m-%d")
15   -
16   - def name(self):
17   - "随机姓名"
18   - return self.fake.name()
19   -
20   - def identity_card(self):
21   - "随机姓名"
22   - return self.fake.ssn(min_age=18, max_age=90)
23   -
24   - def plate(self):
25   - "随机车牌号"
26   - return self.fake.license_plate()
27   -
28   - def plate_cn(self,plate_len=6):
29   - char0='京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽赣粤青藏川宁琼'
30   - char1='ABCDEFGHJKLMNPQRSTUVWXYZ'#车牌号中没有I和O,可自行百度
31   - char2='1234567890'
32   - len0=len(char0)-1
33   - len1 = len(char1) - 1
34   - len2 = len(char2) - 1
35   - ########
36   - code = ''
37   - index0 = random.randint(0,len0 )
38   - index1 = random.randint(0,len1)
39   - code += char0[index0]
40   - code += char1[index1]
41   - for i in range(0, plate_len-1):
42   - index2 = random.randint(1, len2)
43   - code += char2[index2]
44   - return(code)
45   -
46   - def country(self):
47   - "随机国家代码"
48   - return self.fake.country()
49   -
50   - def province(self):
51   - "随机省份"
52   - return self.fake.province()
53   -
54   - def city(self):
55   - "随机城市"
56   - return self.fake.city_suffix()
57   -
58   - def district(self):
59   - "随机街道"
60   - return self.fake.district()
61   -
62   - def address(self):
63   - "随机地址全称"
64   - return self.fake.address()
65   -
66   - def phone_number(self):
67   - "随机手机号"
68   - return self.fake.phone_number()
69   -
70   - def email(self):
71   - "随机邮件"
72   - return self.fake.email()
73   -
74   - def longitude(self):
75   - "随机经度"
76   - return self.fake.longitude()
77   -
78   - def latitude (self):
79   - "随机维度"
80   - return self.fake.latitude ()
81   -
82   - def credit_card_number (self):
83   - "随机卡号"
84   - return self.fake.credit_card_number ()
85   -
86   -
87   -
88   -a=random_data()
89   -print(a.date())
90   -print(a.name())
91   -print(a.identity_card())
92   -print(a.plate())
93   -print(a.plate_cn(6))
94   -print(a.country())
95   -print(a.province())
96   -print(a.city())
97   -print(a.district())
98   -print(a.address())
99   -print(a.phone_number())
100   -print(a.email())
101   -print(a.longitude())
102   -print(a.latitude())
103   -print(a.credit_card_number())
104   -
  1 +#!/usr/bin/python
  2 +# -*- coding: UTF-8 -*-
  3 +import random
  4 +from faker import Factory
  5 +
  6 +class random_data():
  7 +
  8 + def __init__(self, type='zh_CN'):
  9 + self.type = type
  10 + self.fake = Factory().create(self.type)
  11 +
  12 + def date(self):
  13 + "随机时间"
  14 + return self.fake.date(pattern="%Y-%m-%d")
  15 +
  16 + def name(self):
  17 + "随机姓名"
  18 + return self.fake.name()
  19 +
  20 + def identity_card(self):
  21 + "随机证件"
  22 + return self.fake.ssn(min_age=18, max_age=90)
  23 +
  24 + def plate(self):
  25 + "随机车牌号"
  26 + return self.fake.license_plate()
  27 +
  28 + def plate_cn(self,plate_len=6):
  29 + "随机车牌号"
  30 + char0='京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽赣粤青藏川宁琼'
  31 + char1='ABCDEFGHJKLMNPQRSTUVWXYZ'#车牌号中没有I和O,可自行百度
  32 + char2='1234567890'
  33 + len0=len(char0)-1
  34 + len1 = len(char1) - 1
  35 + len2 = len(char2) - 1
  36 + ########
  37 + code = ''
  38 + index0 = random.randint(0,len0 )
  39 + index1 = random.randint(0,len1)
  40 + code += char0[index0]
  41 + code += char1[index1]
  42 + for i in range(0, plate_len-1):
  43 + index2 = random.randint(1, len2)
  44 + code += char2[index2]
  45 + return(code)
  46 +
  47 + def country(self):
  48 + "随机国家代码"
  49 + return self.fake.country()
  50 +
  51 + def province(self):
  52 + "随机省份"
  53 + return self.fake.province()
  54 +
  55 + def city(self):
  56 + "随机城市"
  57 + return self.fake.city_suffix()
  58 +
  59 + def district(self):
  60 + "随机街道"
  61 + return self.fake.district()
  62 +
  63 + def address(self):
  64 + "随机地址全称"
  65 + return self.fake.address()
  66 +
  67 + def phone_number(self):
  68 + "随机手机号"
  69 + return self.fake.phone_number()
  70 +
  71 + def email(self):
  72 + "随机邮件"
  73 + return self.fake.email()
  74 +
  75 + def longitude(self):
  76 + "随机经度"
  77 + return self.fake.longitude()
  78 +
  79 + def latitude (self):
  80 + "随机维度"
  81 + return self.fake.latitude ()
  82 +
  83 + def credit_card_number (self):
  84 + "随机卡号"
  85 + return self.fake.credit_card_number ()
  86 +
  87 +
  88 +
  89 +# a=random_data()
  90 +# print(a.date())
  91 +# print(a.name())
  92 +# print(a.identity_card())
  93 +# print(a.plate())
  94 +# print(a.plate_cn(6))
  95 +# print(a.country())
  96 +# print(a.province())
  97 +# print(a.city())
  98 +# print(a.district())
  99 +# print(a.address())
  100 +# print(a.phone_number())
  101 +# print(a.email())
  102 +# print(a.longitude())
  103 +# print(a.latitude())
  104 +# print(a.credit_card_number())
  105 +
... ...
commons/Logging.py
1 1 #!/usr/bin/python
2 2 # -*- coding: UTF-8 -*-
3 3 import logging,os
  4 +# from mylog import mylogger,logg
  5 +
4 6  
5 7 class Logger():
6 8  
7 9 def __init__(self, path=__name__,clevel = logging.ERROR,Flevel = logging.DEBUG,test = 'w'):
8 10 current_path=os.path.dirname(os.path.dirname(__file__))
9 11 path=current_path+"/report"+"/test.log"
  12 + # setattr(mylogger, "logpath", path)
  13 + # logg.setting()
10 14  
11 15 self.logger = logging.getLogger(path)
12 16  
... ... @@ -55,3 +59,6 @@ class Logger():
55 59 def critical(self,message):
56 60  
57 61 self.logger.critical(message)
  62 +
  63 +
  64 +log=Logger()
58 65 \ No newline at end of file
... ...
commons/MySession.py
... ... @@ -2,12 +2,12 @@
2 2 # -*- coding: UTF-8 -*-
3 3 import requests
4 4 from commons import common as com
5   -from commons.Logging import Logger
  5 +from commons.Logging import log
6 6 from commons.clientSession import cliSession
7 7 from commons.scripts.pwdCry import pwdCry
8   -log=Logger()
9 8  
10   -class mysession():
  9 +
  10 +class mysession(requests.Session):
11 11 "封装了requests的基类,以供后期统一使用"
12 12  
13 13 url = "http://test.uap.diligrp.com/login/login.action"
... ... @@ -38,24 +38,28 @@ class mysession():
38 38  
39 39 def __init__(self):
40 40 "如下代码,可以通过配置文件来控制测试环境和灰度环境,http和https"
  41 + super().__init__()
41 42 self.url = mysession.url.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
42 43 self.header = mysession.header
43 44 self.body = mysession.body
44 45 self.url_client = mysession.url_client.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
45 46 self.header_client = mysession.header_client
46 47 self.body_client = mysession.body_client
47   - self.timeout = (5, 5)
  48 + self.timeout = (6,6)
48 49 self.max_retries = 3
49 50 self.keep_alive = False
50 51 self.ssl_verify = False
51 52 self.proxies = None
52 53 # self.proxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'}
  54 + self.myproxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'}
53 55 self.allow_redirects = False
54 56 self.firmid={"group":"1","hd":"2","cd":"3","qqhe":"4","mdj":"5","gy":"6","cc":"7","sg":"8","sy":"9"}
  57 + self.market={"sy":"沈阳","heb":"哈尔滨","sg":"寿光","gy":"贵阳","cc":"长春","hs":"杭水","hg":"杭果"}
  58 + self.user={}
55 59  
56   -
57   - def cliLogin(self):
58   - self.webHeaders, self.clientHeaders, self.userInfo = cliSession().loginUser()
  60 + def cliLogin(self,user="sy_userName_01"):
  61 + self.webHeaders, self.clientHeaders, self.userInfo = cliSession().loginUser(user=user)
  62 + return self
59 63  
60 64 def get_session(self, account, **kwargs):
61 65 "如下代码,可以通过配置文件来控制登录的账户session"
... ... @@ -63,69 +67,53 @@ class mysession():
63 67 com.get_global_config("global_data", "account", account).split("&")[0])
64 68 self.body = self.body.replace("111111",
65 69 com.get_global_config("global_data", "account", account).split("&")[1])
66   - # requests.session()会话保持,比如使用session成功的登录了某个网站,
67   - # 则在再次使用该session对象求求该网站的其他网页都会默认使用该session之前使用的cookie等参数
68 70 self.se = requests.session()
69   - #更新cookie加入UAP_firmId
70 71 co = requests.cookies.RequestsCookieJar()
71   - #backup:通过提前配置的方法更新市场id
  72 + #加入UAP_firmId属性
72 73 firm=account.split("_")[0]
73 74 co.set("UAP_firmId", self.firmid[firm])
74   - #通过客户端登录的方法更新市场id
75   - # co.set("UAP_firmId", str(self.get_login_info(account).json()["data"]["user"]["firmId"]))
76 75 self.se.cookies.update(co)
77   - # 使用session对象的方法POST/GET等
  76 + # 进行登录请求
78 77 re = self.se.post(url=self.url, headers=self.header, data=self.body, proxies=self.proxies, **kwargs)
79   - #获取关键信息供其他接口header使用
80 78 self.UAP_accessToken=self.se.cookies["UAP_accessToken"]
81 79 self.UAP_refreshToken=self.se.cookies["UAP_refreshToken"]
82   - # 返回session对象,供其他接口使用
83 80 return self.se
84 81  
85 82 def get_login_info(self, account, **kwargs):
86 83 "用于获取用户信息"
87 84 self.body_client.update({"userName":com.get_global_config("global_data", "account", account).split("&")[0]})
88 85 self.body_client.update({"password":pwdCry(com.get_global_config("global_data", "account", account).split("&")[1])})
89   - # requests.session()会话保持,比如使用session成功的登录了某个网站,
90   - # 则在再次使用该session对象求求该网站的其他网页都会默认使用该session之前使用的cookie等参数
91 86 tmp = requests.post(url=self.url_client, headers=self.header_client, json=self.body_client, proxies=self.proxies, **kwargs)
92   - # 使用session对象的方法POST/GET等
93   - #获取关键信息供其他接口header使用
94   - # self.UAP_accessToken=tmp.json()["data"]["accessToken"]
95   - # self.UAP_refreshToken=tmp.json()["data"]["refreshToken"]
96   - # 返回session对象,供其他接口使用
97 87 return tmp
98 88  
99 89 def get_session_client(self, account, **kwargs):
100 90 "get_session和get_session_client的方法只能用一个"
101 91 self.body_client.update({"userName": com.get_global_config("global_data", "account", account).split("&")[0]})
102 92 self.body_client.update( {"password": pwdCry(com.get_global_config("global_data", "account", account).split("&")[1])})
103   - # requests.session()会话保持,比如使用session成功的登录了某个网站,
104   - # 则在再次使用该session对象求求该网站的其他网页都会默认使用该session之前使用的cookie等参数
105   - self.se = requests.session()
106   - # 使用session对象的方法POST/GET等
107   - self.re = self.se.post(url=self.url_client, headers=self.header_client, json=self.body_client, proxies=self.proxies, **kwargs)
108   - #组装请求的cookie
  93 + # 登录请求
  94 + self.re = super().post(url=self.url_client, headers=self.header_client, json=self.body_client, **kwargs)
  95 + #冗余登录账户信息
  96 + self.user[account]=self.re.json()["data"]["user"]
  97 + #配置cookie
109 98 co = requests.cookies.RequestsCookieJar()
110   - co.set("UAP_firmId", str(self.re.json()["data"]["user"]["firmId"]))
111   - co.set("UAP_accessToken", self.re.json()["data"]["accessToken"])
112   - co.set("UAP_refreshToken", self.re.json()["data"]["refreshToken"])
113   - self.se.cookies.update(co)
114   - # 返回session对象,供其他接口使用
115   - return self.se
116   -
  99 + co.set("UAP_firmId", str(self.re.json()["data"]["user"]["firmId"]),domain=".diligrp.com")
  100 + co.set("UAP_accessToken", self.re.json()["data"]["accessToken"],domain=".diligrp.com")
  101 + co.set("UAP_refreshToken", self.re.json()["data"]["refreshToken"],domain=".diligrp.com")
  102 + self.cookies.update(co)
  103 + return self
117 104  
118 105 def close_session(self):
119 106 "关闭session"
120   - self.se.close()
  107 + self.close()
121 108  
122 109 def check_login(self, account, **kwargs):
123 110 "验证登录接口"
124 111 self.body = self.body.replace("sg_wenze",
125 112 com.get_global_config("global_data", "account", account).split("&")[0])
126 113 self.body = self.body.replace("111111", com.get_global_config("global_data", "account", account).split("&")[1])
127   - # POST请求,
128   - re = self.se.post(url=self.url, headers=self.header, data=self.body, proxies=self.proxies,
  114 + # POST请求
  115 + print(self.body)
  116 + re = super().post(url=self.url, headers=self.header, data=self.body.encode('utf-8'),
129 117 allow_redirects=False, **kwargs)
130 118 # 判断请求
131 119 assert "UAP_accessToken" in re.headers["Set-Cookie"]
... ... @@ -165,7 +153,7 @@ class mysession():
165 153 log.info("{0:=^86}".format(''))
166 154 log.info("{}\n{}\n".format(url, kwargs))
167 155 # 进行请求
168   - re = self.se.request(method , url, **kwargs, proxies=self.proxies, timeout=self.timeout)
  156 + re = super().request(method , url, **kwargs,timeout=self.timeout)
169 157 return re
170 158  
171 159  
... ... @@ -176,11 +164,8 @@ class mysession():
176 164 :param \*\*kwargs: Optional arguments that ``request`` takes.
177 165 :rtype: requests.Response
178 166 """
179   - # 记录日志
180   - log.info("{0:=^86}".format(''))
181   - log.info("{}\n{}\n".format(url, kwargs))
182 167 # 进行请求
183   - re = self.se.get(url, **kwargs, proxies=self.proxies, timeout=self.timeout)
  168 + re = super().get(url, **kwargs)
184 169 return re
185 170  
186 171 def post(self, url, data=None, json=None, **kwargs):
... ... @@ -192,11 +177,8 @@ class mysession():
192 177 :param \*\*kwargs: Optional arguments that ``request`` takes.
193 178 :rtype: requests.Response
194 179 """
195   - # 记录日志
196   - log.info("{0:=^86}".format(''))
197   - log.info("{}\n{}\n{}\n{}".format(url, data, json, kwargs))
198 180 # 进行请求
199   - re = self.se.post(url, data=data, json=json, proxies=self.proxies, **kwargs, timeout=self.timeout)
  181 + re = super().post(url, data=data, json=json, **kwargs)
200 182 return re
201 183  
202 184 def options(self, url, **kwargs):
... ... @@ -280,12 +262,15 @@ class mysession():
280 262  
281 263 my = mysession()
282 264 my.set_mark()
283   -my.cliLogin()
284   -s1 = my.get_session_client("sg_user01")
285   -s2 = my.get_session_client("sg_user02")
286   -s3 = my.get_session_client("sg_user01")
287   -# s3= my.get_session_client("sg_user02")
288   -# sg01=my.get_session_client("sg_user01")
289   -# sg02=my.get_session_client("sg_user02")
290   -# sy=my.get_session_client("sy_user01")
  265 +
  266 +# 沈阳客户端session
  267 +sessionSy = mysession().cliLogin("sy_userName_01")
  268 +# 哈尔滨客户端session
  269 +sessionHeb = mysession().cliLogin("hd_userName_01")
  270 +# print(sessionSy.userInfo)
  271 +# print(sessionHeb.userInfo)
  272 +
  273 +sy1=mysession().get_session_client("sy_user01")
  274 +heb=mysession().get_session_client("heb_user01")
  275 +# sg=mysession().get_session_client("sg_user01")
291 276  
... ...
commons/SendEmail.py
... ... @@ -7,8 +7,7 @@ from email.header import Header
7 7 from email.mime.text import MIMEText
8 8 from email.mime.image import MIMEImage
9 9 from email.mime.application import MIMEApplication
10   -from commons.Logging import Logger
11   -log=Logger()
  10 +from commons.Logging import log
12 11  
13 12 def send_email_text():
14 13 # 1. 编写邮件内容(Email邮件需要专门的MIME格式)
... ... @@ -26,14 +25,16 @@ def send_email_text():
26 25 smtp.quit()
27 26  
28 27  
29   -def send_email(send_file,send_to=["lixi@diligrp.com"]):
  28 +def send_email(send_file,send_to=["lixi@diligrp.com"],cc_to=["lixi@diligrp.com"]):
30 29  
31 30 log_path=os.path.dirname(os.path.dirname(__file__))
32 31 log_path=log_path+"/report/test.log"
33 32 send_msg=(",".join(str(i) for i in send_to))
  33 + cc_msg = (",".join(str(j) for j in cc_to))
34 34 msg = MIMEMultipart() # 混合MIME格式
35 35 msg['From'] = 'autotest@diligrp.com' # 发件人
36 36 msg['To'] = send_msg # 收件人
  37 + msg['cc'] = cc_msg # 抄送人
37 38 msg['Subject'] = Header('接口测试报告', 'utf-8') # 中文邮件主题,指定utf-8编码
38 39  
39 40 text = MIMEText('this is a test email', 'plain', 'utf-8')
... ... @@ -54,7 +55,7 @@ def send_email(send_file,send_to=["lixi@diligrp.com"]):
54 55 try:
55 56 smtp = smtplib.SMTP_SSL('smtp.exmail.qq.com') # smtp服务器地址 使用SSL模式
56 57 re=smtp.login('autotest@diligrp.com', 'MvkuGGCfMtAdbJvE') # 用户名和密码
57   - smtp.sendmail("autotest@diligrp.com", send_to, msg.as_string())
  58 + smtp.sendmail("autotest@diligrp.com", send_to+cc_to, msg.as_string())
58 59 print(re)
59 60 except Exception as e:
60 61 log.error(str(e))
... ...
commons/clientSession.py
... ... @@ -16,29 +16,27 @@ from commons.scripts.pwdCry import pwdCry
16 16  
17 17 class cliSession(object):
18 18 def __init__(self):
19   - rConf = readConfig()
20   -
21   - def __init__(self):
22   - rC = readConfig()
23   - self.userName = rC.returnOptionsItems("loginInfo","userName")
24   - self.password = pwdCry(rC.returnOptionsItems("loginInfo","password"))
25   - self.loginUrl = rC.returnOptionsItems("host","uapHost")+"/api/authenticationApi/loginWeb"
26   - self.loginData = {"userName":self.userName,"password":self.password}
  19 + self.rC = readConfig()
27 20 self.webHeaders = {"X-Requested-With":"XMLHttpRequest",
28 21 "Content-Type":"application/x-www-form-urlencoded",
29 22 "Cookie":"UAP_accessToken=${UAP_accessToken}; UAP_refreshToken=${UAP_refreshToken};UAP_firmId=${UAP_firmId}"}
30   -
31 23 self.clientHeaders={"UAP_accessToken":"${UAP_accessToken}",
32 24 "UAP_refreshToken":"${UAP_refreshToken}",
33 25 "UAP_firmId":"${UAP_firmId}",
34 26 "Cookie":"UAP_accessToken=${UAP_accessToken}; UAP_refreshToken=${UAP_refreshToken}",
35 27 "Content-Type":"application/json"}
36 28  
37   - def loginUser(self):
38   - """
39 29  
  30 + def loginUser(self,user="sy_userName_01"):
  31 + """
40 32 :return:
41 33 """
  34 + # 登录信息准备
  35 + self.userName,self.password = self.rC.returnOptionsItems("loginInfo",user).split(",")
  36 + self.password = pwdCry(self.password)
  37 + self.loginUrl = self.rC.returnOptionsItems("host","uapHost")+"/api/authenticationApi/loginWeb"
  38 + self.loginData = {"userName":self.userName,"password":self.password}
  39 +
42 40 # 返回登录信息,以及可用headers,clientHeaders用户客户端操作header,webHeaders用于web页面使用headers
43 41 res = requests.post(url=self.loginUrl,data=json.dumps(self.loginData))
44 42 # print(res.json())
... ... @@ -51,3 +49,6 @@ class cliSession(object):
51 49 self.clientHeaders["UAP_firmId"] = str(UAP_firmId)
52 50 self.clientHeaders["Cookie"] = clientHeadersCookie
53 51 return self.webHeaders,self.clientHeaders,res.json()
  52 +
  53 +# a,b,c = cliSession().loginUser()
  54 +# print(c)
54 55 \ No newline at end of file
... ...
commons/common.py
... ... @@ -4,8 +4,7 @@ import os
4 4 import configparser
5 5 import unittest
6 6 from discover import DiscoveringTestLoader
7   -from commons.Logging import Logger
8   -log=Logger()
  7 +from commons.Logging import log
9 8  
10 9  
11 10 def get_global_config(file,section, key):
... ... @@ -83,11 +82,15 @@ def run_one(name):
83 82 runner = unittest.TextTestRunner()
84 83 runner.run(test_suite)
85 84  
  85 +
86 86 def run_list(name):
87 87 test_suite = unittest.TestSuite()
88 88 test_suite.addTests(name)
89 89 #显示运行用例
90 90 print("运行用例为{}".format(test_suite))
  91 + # with open(file="E:\\PycharmWorkspace\\jmsf-re-local\\report\\test.log", mode="a", encoding="utf-8") as file:
  92 + # runner = unittest.TextTestRunner(stream=file,verbosity=2)
  93 + # runner.run(test_suite)
91 94 runner = unittest.TextTestRunner()
92 95 runner.run(test_suite)
93 96  
... ... @@ -112,4 +115,8 @@ def run_Name(name):
112 115 runner = unittest.TextTestRunner()
113 116 runner.run(test_cases)
114 117  
115   -# print(get_market_config("test_config_hg2","loginInfo","userName"))
116 118 \ No newline at end of file
  119 +def mylog(func):
  120 + def RebackTest(self):
  121 + log.info("{}".format(func.__name__))
  122 + return func(self)
  123 + return RebackTest
117 124 \ No newline at end of file
... ...
commons/scripts/dealContentType.py
... ... @@ -9,10 +9,10 @@
9 9 用于hearders中Content-Type格式处理
10 10 """
11 11  
12   -def jsonCT(headers=None):
  12 +def jsonCode(headers={}):
13 13 headers["Content-Type"] = "application/json; charset=UTF-8"
14 14 return headers
15 15  
16   -def urlCode(headers=None):
  16 +def urlCode(headers={}):
17 17 headers["Content-Type"] = "application/x-www-form-urlencoded"
18 18 return headers
19 19 \ No newline at end of file
... ...
commons/scripts/readConf.py
... ... @@ -19,7 +19,7 @@ class readConfig(object):
19 19 # 按市场读取配置文件数据
20 20 self.conf = configparser.ConfigParser()
21 21 self.evn_name = os.name
22   - self.file_name = r'test_config_hg.conf'
  22 + self.file_name = r'conf_test.conf'
23 23 self.relative_path = r'/config/marketConfig/'
24 24 self.file_path = os.path.abspath(
25 25 os.path.join(os.path.dirname(__file__), "../../")) + self.relative_path + self.file_name
... ... @@ -53,7 +53,7 @@ class readConfig(object):
53 53 print(self.file_path)
54 54 return self.file_path
55 55  
56   -# rc = readConfig()
  56 +rC = readConfig()
57 57 # rc.returnSections()
58 58 # rc.returnOptions("loginInfo")
59 59 # rc.returnOptionsInfo("loginInfo")
... ...
config/global_data.conf
1 1 # -*- coding: UTF-8 -*-
2 2  
  3 +[market]
  4 +#该字段存放市场的缩略名称,运行指定市场的用例,目前为着冗余配置
  5 +#list为空时,默认运行所有市场用例,需要指定市场时,参考demo格式
  6 +list=[]
  7 +demo=["sy","heb"]
  8 +
3 9 [account]
4 10 #取值字段根据市场拼音首字母缩写组合而成,尾号数字按照01-99叠加
5 11 #账户和密码通过&符号隔开
  12 +sy_user01=sy_chen&123456
  13 +sy_user02=sygangda&111111
  14 +heb_user01=哈尔滨田太子&a123456
  15 +heb_user02=sy_wenze&111111
6 16 sg_user01=sg_wenze&111111
7   -sg_user02=sgwanggang&111111
8   -sg_user03=hz_wenze&111111
9   -sy_user01=sy_wenze&111111
10 17  
11 18 [userId]
12 19 #冗余配置字段,可不配置
... ... @@ -16,21 +23,15 @@ user03=256
16 23  
17 24 [email]
18 25 #为空时[]不发邮件,若要发邮件,参考demo
19   -list=["lixi@diligrp.com","175930106@qq.com"]
20   -demo=["tg@diligrp.com","175930106@qq.com"]
  26 +to_list=["tianlichang@diligrp.com","liaokaihua@diligrp.com"]
  27 +cc_list=["lixi@diligrp.com","liujiqiang@diligrp.com","wenleiming@diligrp.com"]
  28 +demo=["lixi@diligrp.com","liujiqiang@diligrp.com","wenleiming@diligrp.com","tg@diligrp.com"]
21 29  
22 30 [mark]
23 31 #为空时[]运行所有用例,若要运行指定用例,参考demo
24 32 list=[]
25   -demo=["p1","P2",1,"test"]
  33 +demo=["heb1","P3","v1.6","沈阳",None]
26 34  
27   -[Database]
28   -dbhost=10.35.100.34
29   -dbport=3306
30   -dbname=dili_trace
31   -dbuser=root
32   -dbpassword=123456
33   -dbcharset=utf8
34 35  
35 36 [environment]
36 37 #格式只能为一下几种
... ... @@ -41,6 +42,21 @@ dbcharset=utf8
41 42 en=http://test.
42 43  
43 44  
  45 +[Database]
  46 +dbhost=10.35.100.34
  47 +dbport=3306
  48 +dbname=dili_jmsf
  49 +dbuser=root
  50 +dbpassword=123456
  51 +dbcharset=utf8
  52 +
  53 +
  54 +[host]
  55 +gateway=test.gateway.diligrp.com:8285
  56 +
  57 +
  58 +
  59 +
44 60  
45 61  
46 62  
... ...