test_weightBizBill_doRefund.py 1.74 KB
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import unittest
import urllib3
from commons import common as com
from commons import ConfigDB as db
from commons.MySession import my,sy1
from commons.api.weightBizBill_doRefund import weightBizBill_doRefund
from commons.api.weighingServiceSave import weighingServiceSave
from commons.basic.listCarType import listCarType
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
do=weightBizBill_doRefund()
ad=weighingServiceSave(sy1)
ca=listCarType(sy1)


class test_weightBizBill_doRefund(unittest.TestCase):
    "称重服务单列表"


    def setUp(self):
        "数据准备:新增一条称重单"
        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=sy1.post(url=ad.url,headers=ad.header,json=body)

    @unittest.case_mark(my.mark())  
    def test_weightBizBill_doRefund_01(self):
        "称重服务单列表-退款:成功退款一个现金交费的称重单"
        body=do.body.replace("206",str(self.re.json()["data"]["id"]))
        re=sy1.post(url=do.url,headers=do.header,data=body.encode('utf-8'))
        print(re.json())
        #获取退款后称重单的状态,3为已退款
        bill_status=db.mysql_selectOne(
            "SELECT status FROM `weight_biz_bill` WHERE id={};".format(self.re.json()["data"]["id"]))[0]
        self.assertEqual(re.status_code, 200)
        self.assertTrue("'result':'操作成功!'" in str(re.json()).replace(" ",""))
        self.assertEqual(bill_status ,3)

if __name__ == "__main__":

    unittest.main(verbosity=2)

    # com.run_one(test_weightBizBill_listPage("test_weightBizBill_listPage_01"))