test_doAddA.py 1.52 KB
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import unittest
import urllib3
from commons import common as com
from commons.MySession import my,s1,s2
from commons.api.fieldConfig import fieldConfig
from commons.api.doAdd import doAdd
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
do=doAdd()
field=fieldConfig()

import json


class test_doAdd(unittest.TestCase):
    "新增登记接口"
    
    @classmethod
    def setUpClass(cls):
        #通过字段配置接口提前配置新增页的字段配置
        my.post(url=field.url,headers=field.header,json=field.body)

    # @unittest.case_mark(my.mark("test"))
    def test_doAdd_01(self):
        "成功新增一个商品为大白菜的报备单,重量为111"
        #请求数据不需要修改,直接POST请求
        re = my.useHeadersRequests(method="POST",url=do.url,headers=do.header,data=json.dumps(do.body))
        print(re.json())
        #响应断言
        self.assertEqual(re.status_code, 200)
        self.assertTrue("'code':'200'" in str(re.json()).replace(" ",""))
        re = s1.post(url=do.url,headers=do.header,data=json.dumps(do.body))
        print(re.json())
        #响应断言
        self.assertEqual(re.status_code, 200)
        self.assertTrue("'code':'200'" in str(re.json()).replace(" ",""))
        re = s2.post(url=do.url,headers=do.header,data=json.dumps(do.body))
        print(re.json())
        #响应断言
        self.assertEqual(re.status_code, 200)
        self.assertTrue("'code':'200'" in str(re.json()).replace(" ",""))