test_weightBizBill_listPage.py
2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import unittest
import urllib3
import time
from commons import common as com
from commons.MySession import my,sy1
from commons.api.weightBizBill_listPage import weightBizBill_listPage
from commons.api.weighingServiceSave import weighingServiceSave
from commons.basic.listCarType import listCarType
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
bi=weightBizBill_listPage()
ad=weighingServiceSave(sy1)
ca=listCarType(sy1)
class test_weightBizBill_listPage(unittest.TestCase):
"称重服务单列表"
def setUp(self):
"数据准备:新增一条称重单"
#获取当前时间
self.time=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
#新增数据
body=ad.body.copy()
body["carTypeId"]=ca.car_list()["data"][0]["id"]
body["carTypeName"]=ca.car_list()["data"][0]["carTypeName"]
body["carTypeCode"]=ca.car_list()["data"][0]["code"]
self.re=sy1.post(url=ad.url,headers=ad.header,json=body)
#刷新防重码
ad.refresh_commit_token()
@unittest.case_mark(my.mark())
def test_weightBizBill_listPage_01(self):
"称重服务单列表-查询:查询条件为“单据编号”,其余查询条件输入合法值,查询一条指定数据"
body=bi.body.replace("202108030900001",self.re.json()["data"]["number"]).replace(
"carTypeId=53","carTypeId={}".format(ca.car_list()["data"][0]["id"])).replace(
"depId=139","depId={}".format(my.user["sy_user01"]["departmentId"]))
re=sy1.post(url=bi.url,headers=bi.header,data=body)
print(re.json())
self.assertEqual(re.status_code, 200)
self.assertTrue("'total':1" in str(re.json()).replace(" ",""))
self.assertTrue(self.re.json()["data"]["number"] in str(re.json()).replace(" ",""))
@unittest.case_mark(my.mark())
def test_weightBizBill_listPage_02(self):
"称重服务单列表-查询:查询条件为“车号”,其余查询条件输入合法值,查询一条指定数据"
body=bi.body.replace("attr=number","attr=plate").replace(
"202108030900001","{}".format(ad.body["plate"])).replace(
"2020-08-03 00:00:00","{}".format(self.time))
re=sy1.post(url=bi.url,headers=bi.header,data=body.encode('utf-8'))
print(re.json())
self.assertEqual(re.status_code, 200)
self.assertTrue("'total':1" in str(re.json()).replace(" ",""))
self.assertTrue(ad.body["plate"] in str(re.json()).replace(" ",""))
if __name__ == "__main__":
unittest.main(verbosity=2)
# com.run_one(test_weightBizBill_listPage("test_weightBizBill_listPage_01"))