test_weighingServiceSave.py 1.93 KB
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import unittest
import urllib3
from commons import common as com
from commons.MySession import my,sy1
from commons.api.weighingServiceSave import weighingServiceSave
from commons.basic.listCarType import listCarType
#作用为禁用请求安全提示,平时默认加上上面的urllib3语句就行
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
we=weighingServiceSave()
li=listCarType()



class test_weighingServiceSave(unittest.TestCase):
    
    "登记单审核接口"
    # @classmethod
    # def setUpClass(cls):
    #     #通过字段配置接口提前配置新增页的字段配置
    #     my.post(url=field.url,headers=field.header,json=field.body)
    #
    # def setUp(self):
    #     #准备数据:新增一条登记单
    #     my.post(url=ad.url,headers=ad.header,json=ad.body)
    #     #获取数据:从MYSQL获取新增登记单的id号--因为响应没有id,需要数据库查询
    #     self.code=db.mysql_selectOne("SELECT id FROM `dili_trace`.register_bill ORDER BY id DESC LIMIT 1")[0]
    #     print("db id",self.code)

    @unittest.case_mark(my.mark())
    def test_weighingServiceSave_01(self):
        "成功新增一条称重单"
        body=we.body.copy()
        body["carTypeId"]=li.car_list()["data"][0]["id"]
        body["carTypeName"]=li.car_list()["data"][0]["carTypeName"]
        body["carTypeCode"]=li.car_list()["data"][0]["code"]
        re=sy1.post(url=we.url,headers=we.header,json=body)
        print(re.json())
        # #断言请求过程是否成功
        # self.assertEqual(re.status_code, 200)
        # #断言响应数据中是否存在期望字符串
        # self.assertTrue("'result':'操作成功'" in str(re.json()).replace(" ",""))

           
    @classmethod
    def tearDownClass(cls):
        pass


if __name__ == "__main__":

    # unittest.main(verbosity=2)

    com.run_one(test_weighingServiceSave("test_weighingServiceSave_01"))