Commit b1740de42b62c42fa4ac0fd42c00a8caaca21c38

Authored by wenleiming
2 parents b7f43970 bf44a126

Merge remote-tracking branch 'origin/master'

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