Commit b1740de42b62c42fa4ac0fd42c00a8caaca21c38

Authored by wenleiming
2 parents b7f43970 bf44a126

Merge remote-tracking branch 'origin/master'

commons/ConfigDB.py
@@ -2,11 +2,9 @@ @@ -2,11 +2,9 @@
2 # -*- coding: UTF-8 -*- 2 # -*- coding: UTF-8 -*-
3 import pymysql 3 import pymysql
4 import time 4 import time
5 -import commons.common as ca  
6 import json 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 dbhost=ca.get_global_config('global_data','Database','dbhost') 10 dbhost=ca.get_global_config('global_data','Database','dbhost')
commons/Logging.py
@@ -55,3 +55,6 @@ class Logger(): @@ -55,3 +55,6 @@ class Logger():
55 def critical(self,message): 55 def critical(self,message):
56 56
57 self.logger.critical(message) 57 self.logger.critical(message)
  58 +
  59 +
  60 +log=Logger()
58 \ No newline at end of file 61 \ No newline at end of file
commons/MySession.py
@@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
2 # -*- coding: UTF-8 -*- 2 # -*- coding: UTF-8 -*-
3 import requests 3 import requests
4 from commons import common as com 4 from commons import common as com
5 -from commons.Logging import Logger 5 +from commons.Logging import log
6 from commons.clientSession import cliSession 6 from commons.clientSession import cliSession
7 from commons.scripts.pwdCry import pwdCry 7 from commons.scripts.pwdCry import pwdCry
8 -log=Logger() 8 +
9 9
10 class mysession(requests.Session): 10 class mysession(requests.Session):
11 "封装了requests的基类,以供后期统一使用" 11 "封装了requests的基类,以供后期统一使用"
@@ -49,8 +49,8 @@ class mysession(requests.Session): @@ -49,8 +49,8 @@ class mysession(requests.Session):
49 self.max_retries = 3 49 self.max_retries = 3
50 self.keep_alive = False 50 self.keep_alive = False
51 self.ssl_verify = False 51 self.ssl_verify = False
52 - # self.proxies = None  
53 - self.proxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'} 52 + self.proxies = None
  53 + # self.proxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'}
54 self.myproxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'} 54 self.myproxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'}
55 self.allow_redirects = False 55 self.allow_redirects = False
56 self.firmid={"group":"1","hd":"2","cd":"3","qqhe":"4","mdj":"5","gy":"6","cc":"7","sg":"8","sy":"9"} 56 self.firmid={"group":"1","hd":"2","cd":"3","qqhe":"4","mdj":"5","gy":"6","cc":"7","sg":"8","sy":"9"}
@@ -127,7 +127,7 @@ class mysession(requests.Session): @@ -127,7 +127,7 @@ class mysession(requests.Session):
127 com.get_global_config("global_data", "account", account).split("&")[0]) 127 com.get_global_config("global_data", "account", account).split("&")[0])
128 self.body = self.body.replace("111111", com.get_global_config("global_data", "account", account).split("&")[1]) 128 self.body = self.body.replace("111111", com.get_global_config("global_data", "account", account).split("&")[1])
129 # POST请求, 129 # POST请求,
130 - re = self.se.post(url=self.url, headers=self.header, data=self.body, proxies=self.proxies, 130 + re = super().post(url=self.url, headers=self.header, data=self.body,
131 allow_redirects=False, **kwargs) 131 allow_redirects=False, **kwargs)
132 # 判断请求 132 # 判断请求
133 assert "UAP_accessToken" in re.headers["Set-Cookie"] 133 assert "UAP_accessToken" in re.headers["Set-Cookie"]
@@ -178,9 +178,6 @@ class mysession(requests.Session): @@ -178,9 +178,6 @@ class mysession(requests.Session):
178 :param \*\*kwargs: Optional arguments that ``request`` takes. 178 :param \*\*kwargs: Optional arguments that ``request`` takes.
179 :rtype: requests.Response 179 :rtype: requests.Response
180 """ 180 """
181 - # 记录日志  
182 - log.info("{0:=^86}".format(''))  
183 - log.info("{}\n{}\n".format(url, kwargs))  
184 # 进行请求 181 # 进行请求
185 re = super().get(url, **kwargs) 182 re = super().get(url, **kwargs)
186 return re 183 return re
@@ -194,9 +191,6 @@ class mysession(requests.Session): @@ -194,9 +191,6 @@ class mysession(requests.Session):
194 :param \*\*kwargs: Optional arguments that ``request`` takes. 191 :param \*\*kwargs: Optional arguments that ``request`` takes.
195 :rtype: requests.Response 192 :rtype: requests.Response
196 """ 193 """
197 - # 记录日志  
198 - log.info("{0:=^86}".format(''))  
199 - log.info("{}\n{}\n{}\n{}".format(url, data, json, kwargs))  
200 # 进行请求 194 # 进行请求
201 re = super().post(url, data=data, json=json, **kwargs) 195 re = super().post(url, data=data, json=json, **kwargs)
202 return re 196 return re
commons/SendEmail.py
@@ -7,8 +7,7 @@ from email.header import Header @@ -7,8 +7,7 @@ from email.header import Header
7 from email.mime.text import MIMEText 7 from email.mime.text import MIMEText
8 from email.mime.image import MIMEImage 8 from email.mime.image import MIMEImage
9 from email.mime.application import MIMEApplication 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 def send_email_text(): 12 def send_email_text():
14 # 1. 编写邮件内容(Email邮件需要专门的MIME格式) 13 # 1. 编写邮件内容(Email邮件需要专门的MIME格式)
commons/common.py
@@ -4,8 +4,7 @@ import os @@ -4,8 +4,7 @@ import os
4 import configparser 4 import configparser
5 import unittest 5 import unittest
6 from discover import DiscoveringTestLoader 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 def get_global_config(file,section, key): 10 def get_global_config(file,section, key):
@@ -118,8 +117,6 @@ def run_Name(name): @@ -118,8 +117,6 @@ def run_Name(name):
118 117
119 def mylog(func): 118 def mylog(func):
120 def RebackTest(self): 119 def RebackTest(self):
121 - print(func.__name__)  
122 - print(dir(func))  
123 - # print(self) 120 + log.info("{}".format(func.__name__))
124 return func(self) 121 return func(self)
125 return RebackTest 122 return RebackTest
126 \ No newline at end of file 123 \ No newline at end of file
config/api/sy/userApi.py
@@ -30,7 +30,7 @@ data={ @@ -30,7 +30,7 @@ data={
30 "email": "shenyangtangchuan@diligrp.com", 30 "email": "shenyangtangchuan@diligrp.com",
31 "firmCode": "sy", 31 "firmCode": "sy",
32 "id": 228, 32 "id": 228,
33 - "lastLoginTime": "2021-08-04 15:50:24", 33 + "lastLoginTime": "2021-08-05 16:23:14",
34 "metadata": {}, 34 "metadata": {},
35 "modified": "2021-07-13 15:56:44", 35 "modified": "2021-07-13 15:56:44",
36 "password": "DABF2BB8F4A3D0AAE5", 36 "password": "DABF2BB8F4A3D0AAE5",
@@ -67,7 +67,7 @@ data={ @@ -67,7 +67,7 @@ data={
67 "email": "shenyangdagang@diligrp.com", 67 "email": "shenyangdagang@diligrp.com",
68 "firmCode": "sy", 68 "firmCode": "sy",
69 "id": 320, 69 "id": 320,
70 - "lastLoginTime": "2021-08-04 15:23:56", 70 + "lastLoginTime": "2021-08-06 10:05:46",
71 "metadata": {}, 71 "metadata": {},
72 "modified": "2021-07-13 15:56:44", 72 "modified": "2021-07-13 15:56:44",
73 "password": "18965EB72C92A549DD", 73 "password": "18965EB72C92A549DD",
@@ -34,7 +34,7 @@ def Run_Testcase(testsuit): @@ -34,7 +34,7 @@ def Run_Testcase(testsuit):
34 34
35 runner=HTMLTestRunner_cn.HTMLTestRunner( 35 runner=HTMLTestRunner_cn.HTMLTestRunner(
36 stream=fp, 36 stream=fp,
37 - title=u'重构项目接口测试报告', 37 + title=u'进门收费系统--接口测试报告',
38 description=u'用例简要执行情况如下:(注:报告详细信息需要下载report.html并用浏览器打开)', 38 description=u'用例简要执行情况如下:(注:报告详细信息需要下载report.html并用浏览器打开)',
39 verbosity = 2) 39 verbosity = 2)
40 #执行用例 40 #执行用例
testcase/weightBizBill/test_weighingServiceSave.py
@@ -11,25 +11,27 @@ we=weighingServiceSave(sy1) @@ -11,25 +11,27 @@ we=weighingServiceSave(sy1)
11 li=listCarType(sy1) 11 li=listCarType(sy1)
12 12
13 13
14 -@com.mylog 14 +
15 class test_weighingServiceSave(unittest.TestCase): 15 class test_weighingServiceSave(unittest.TestCase):
16 "称重服务" 16 "称重服务"
17 17
  18 +
18 @classmethod 19 @classmethod
19 def setUpClass(cls): 20 def setUpClass(cls):
20 pass 21 pass
21 22
22 -  
23 def setUp(self) : 23 def setUp(self) :
24 pass 24 pass
25 25
  26 + # @com.mylog
26 @unittest.case_mark(my.mark()) 27 @unittest.case_mark(my.mark())
27 def test_weighingServiceSave_01(self): 28 def test_weighingServiceSave_01(self):
28 "称重服务:成功新增一条称重服务单" 29 "称重服务:成功新增一条称重服务单"
29 body=we.body.copy() 30 body=we.body.copy()
30 - body["carTypeId"]=li.car_list()["data"][0]["id"]  
31 - body["carTypeName"]=li.car_list()["data"][0]["carTypeName"]  
32 - body["carTypeCode"]=li.car_list()["data"][0]["code"] 31 + car=li.car_list()["data"]
  32 + body["carTypeId"]=car[0]["id"]
  33 + body["carTypeName"]=car[0]["carTypeName"]
  34 + body["carTypeCode"]=car[0]["code"]
33 re=sy1.post(url=we.url,headers=we.header,json=body) 35 re=sy1.post(url=we.url,headers=we.header,json=body)
34 print(re.json()) 36 print(re.json())
35 self.assertEqual(re.status_code, 200) 37 self.assertEqual(re.status_code, 200)