Commit 1df65361f91f87d94ba93100c2bd1d0c826052c2

Authored by liujiqiang
1 parent f9878f3e

备注添加

commons/MySession.py
... ... @@ -210,6 +210,6 @@ class mysession():
210 210  
211 211 my = mysession()
212 212 my.set_mark()
213   -s1 = my.get_session("user01")
214   -# s2=my.get_session("user02")
215 213 my.cliLogin()
  214 +s1 = my.get_session("user01")
  215 +s2 = my.get_session("user02")
216 216 \ No newline at end of file
... ...
commons/scripts/readConf.py
... ... @@ -8,7 +8,6 @@
8 8 """
9 9 配置文件读取
10 10 """
11   -
12 11 import configparser
13 12 import os
14 13  
... ... @@ -17,9 +16,10 @@ class readConfig(object):
17 16 ROBOT_LIBRARY_VERSION = '0.1'
18 17  
19 18 def __init__(self):
  19 + # 按市场读取配置文件数据
20 20 self.conf = configparser.ConfigParser()
21 21 self.evn_name = os.name
22   - self.file_name = r'test_config_hg'
  22 + self.file_name = r'test_config_hg.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
... ... @@ -27,20 +27,24 @@ class readConfig(object):
27 27 self.conf.read(self.file_path,encoding="utf-8")
28 28  
29 29 def returnSections(self):
  30 + # 读取所有的options选项
30 31 sections = self.conf.sections()
31 32 print(sections)
32 33 return sections
33 34  
34 35 def returnOptions(self,options):
  36 + # 通过options读取所有items
35 37 options = self.conf.options(options)
36 38 print(options)
37 39 return options
38 40  
39   - def returnOptionsInfo(self,items):
40   - items = self.conf.items(items)
  41 + def returnOptionsInfo(self,options):
  42 + # 通过options读取相关的items和value
  43 + items = self.conf.items(options)
41 44 print(items)
42 45  
43 46 def returnOptionsItems(self,options,items):
  47 + # 通过options和items的组合关系读取对应的value
44 48 value = self.conf.get(options,items)
45 49 print(value)
46 50 return value
... ... @@ -49,4 +53,9 @@ class readConfig(object):
49 53 print(self.file_path)
50 54 return self.file_path
51 55  
52   -# readConfig().returnOptionsItems("loginInfo","userName")
53 56 \ No newline at end of file
  57 +# rc = readConfig()
  58 +# rc.returnSections()
  59 +# rc.returnOptions("loginInfo")
  60 +# rc.returnOptionsInfo("loginInfo")
  61 +# rc.returnOptionsItems("loginInfo","username")
  62 +# rc.ReturnFilePath()
54 63 \ No newline at end of file
... ...
report/test.log
1   -[2021-07-20 14:27:04] [INFO] : ======================================================================================
2   -[2021-07-20 14:27:04] [INFO] : http://test.trace.diligrp.com:8393/fieldConfig/doUpdate.action
  1 +[2021-07-20 14:36:11] [INFO] : ======================================================================================
  2 +[2021-07-20 14:36:11] [INFO] : http://test.trace.diligrp.com:8393/fieldConfig/doUpdate.action
3 3 None
4 4 {'moduleType': '1', 'marketId': '8', 'fieldConfigDetailList': [{'fieldName': 'unitPrice', 'jsonPath': '$.unitPrice', 'defaultId': '3', 'displayed': '1', 'required': '0'}, {'fieldName': 'arrivalTallynos', 'jsonPath': '$.arrivalTallynos', 'defaultId': '10', 'displayed': '1', 'required': '0'}, {'fieldName': 'brandName', 'jsonPath': '$.brandName', 'defaultId': '5', 'displayed': '1', 'required': '0'}, {'fieldName': 'truckTareWeight', 'jsonPath': '$.truckTareWeight', 'defaultId': '1', 'displayed': '1', 'required': '0'}, {'fieldName': 'originId', 'jsonPath': '$.originId', 'defaultId': '7', 'displayed': '1', 'required': '0'}, {'fieldName': 'specName', 'jsonPath': '$.specName', 'defaultId': '4', 'displayed': '1', 'required': '0'}, {'fieldName': 'truckType', 'jsonPath': '$.truckType', 'defaultId': '2', 'displayed': '1', 'required': '1', 'availableValueList': ['10', '20']}, {'fieldName': 'imageCertList', 'jsonPath': '$.imageCertList[*]certType', 'defaultId': '11', 'displayed': '1', 'required': '0', 'availableValueList': ['2', '3']}, {'fieldName': 'arrivalDatetime', 'jsonPath': '$.arrivalDatetime', 'defaultId': '9', 'displayed': '1', 'required': '0'}, {'fieldName': 'remark', 'jsonPath': '$.remark', 'defaultId': '8', 'displayed': '1', 'required': '0'}, {'fieldName': 'remark', 'jsonPath': '$.remark', 'defaultId': '6', 'displayed': '1', 'required': '0'}, {'fieldName': 'measureType', 'jsonPath': '$.measureType', 'defaultId': '12', 'displayed': '1', 'required': '1', 'availableValueList': ['10', '20']}]}
5 5 {'headers': {'Host': 'test.trace.diligrp.com:8393', 'Connection': 'keep-alive', 'Content-Length': '1378', 'Accept': 'application/json,text/javascript,*/*;q=0.01', 'X-Requested-With': 'XMLHttpRequest', 'User-Agent': 'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/91.0.4472.77Safari/537.36', 'Content-Type': 'application/json', 'Origin': 'http://test.trace.diligrp.com:8393', 'Referer': 'http://test.trace.diligrp.com:8393/fieldConfig/bill.html', 'Accept-Encoding': 'gzip,deflate', 'Accept-Language': 'zh-CN,zh-TW;q=0.9,zh;q=0.8,en;q=0.7'}}
6   -[2021-07-20 14:27:04] [INFO] : ======================================================================================
7   -[2021-07-20 14:27:04] [INFO] : http://test.trace.diligrp.com:8393/newRegisterBill/doAdd.action
  6 +[2021-07-20 14:36:12] [INFO] : ======================================================================================
  7 +[2021-07-20 14:36:12] [INFO] : http://test.trace.diligrp.com:8393/newRegisterBill/doAdd.action
8 8 {"registerHeadWeight": "0", "registerHeadRemainWeight": "0", "imageCertList": [], "measureType": 20, "registType": 10, "userId": 516, "arrivalTallynos": [], "arrivalDatetime": "", "truckType": 10, "weight": "111", "weightUnit": 1, "productName": "\u5927\u767d\u83dc", "productId": 2190, "originName": "", "originId": "", "unitPrice": "", "truckTareWeight": "", "remark": "", "specName": "", "brandName": "", "plate": "\u5dddA123456"}
9 9 {}
10 10  
... ...
testcase/doAdd/test_doAddA.py
... ... @@ -3,7 +3,7 @@
3 3 import unittest
4 4 import urllib3
5 5 from commons import common as com
6   -from commons.MySession import my
  6 +from commons.MySession import my,s1,s2
7 7 from commons.api.fieldConfig import fieldConfig
8 8 from commons.api.doAdd import doAdd
9 9 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
... ... @@ -29,4 +29,15 @@ class test_doAdd(unittest.TestCase):
29 29 print(re.json())
30 30 #响应断言
31 31 self.assertEqual(re.status_code, 200)
32   - self.assertTrue("'code':'200'" in str(re.json()).replace(" ",""))
33 32 \ No newline at end of file
  33 + self.assertTrue("'code':'200'" in str(re.json()).replace(" ",""))
  34 + re = s1.post(url=do.url,headers=do.header,data=json.dumps(do.body))
  35 + print(re.json())
  36 + #响应断言
  37 + self.assertEqual(re.status_code, 200)
  38 + self.assertTrue("'code':'200'" in str(re.json()).replace(" ",""))
  39 + re = s2.post(url=do.url,headers=do.header,data=json.dumps(do.body))
  40 + print(re.json())
  41 + #响应断言
  42 + self.assertEqual(re.status_code, 200)
  43 + self.assertTrue("'code':'200'" in str(re.json()).replace(" ",""))
  44 +
... ...