test_doUndo.py
1.56 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
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import unittest
import urllib3
import commons.ConfigDB as db
from commons import common as com
from commons.MySession import my
from commons.api.fieldConfig import fieldConfig
from commons.api.doAdd import doAdd
from commons.api.doUndo import doUndo
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
field=fieldConfig()
ad=doAdd()
un=doUndo()
class test_doUndo(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]
@unittest.case_mark(my.mark())
def test_doUndo_01(self):
"成功删除新增的一个报备单"
#请求数据不需要修改,直接POST请求
url=un.url.replace("6668",str(self.code))
re=my.get(url=url,headers=un.header)
print(re.json())
#响应断言
self.assertEqual(re.status_code, 200)
self.assertTrue("'code':'200'" in str(re.json()).replace(" ",""))
@classmethod
def tearDownClass(cls):
pass
if __name__ == "__main__":
# unittest.main(verbosity=2)
com.run_one(test_doUndo("test_doUndo_01"))