test_weightBizBill_listPage.py 2.75 KB
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import unittest
import urllib3
import time
from commons.MySession import my,heb
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(heb)
ca=listCarType(heb)


class test_weightBizBill_listPage(unittest.TestCase):
    "哈尔滨市场-称重服务-称重服务单列表"

    def setUp(self):
        "数据准备:新增一条称重单"
        #获取当前时间
        self.time=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        #刷新增防重码
        ad.refresh_commit_token()
        #新增数据
        body=ad.body.copy()
        car=ca.car_list()["data"]
        body["carTypeId"]=car[0]["id"]
        body["carTypeName"]=car[0]["carTypeName"]
        body["carTypeCode"]=car[0]["code"]
        self.re=heb.post(url=ad.url,headers=ad.header,json=body)


    @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(heb.user["heb_user01"]["departmentId"]))
        re=heb.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)).replace(
            "carTypeId=53", "carTypeId={}".format(ca.car_list()["data"][0]["id"])).replace(
            "depId=139", "depId={}".format(heb.user["heb_user01"]["departmentId"]))
        re=heb.post(url=bi.url,headers=bi.header,data=body.encode('utf-8'))
        print(re.json())
        self.assertEqual(re.status_code, 200)
        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"))