test_fc_view.py
1.53 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
import unittest
import urllib3
import commons.ConfigDB as db
from commons.MySession import my,sy1
from commons.api.fc_view import fc_view
from commons.api.fc_add import fc_add
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
ad = fc_add()
vi = fc_view()
class test_fc_view(unittest.TestCase):
"查看返还人"
@classmethod
def setUpClass(cls):
# # 通过字段配置接口提前配置新增页的字段配置
# my.post(url = ad.url, headers = ad.header, data = ad.body.encode('utf-8'))
pass
def setUp(self):
# 准备数据
my.post(url=ad.url, headers=ad.header, data=ad.body.encode('utf-8'))
# 获取数据:从MYSQL获取新增返还人的id号
self.code = db.mysql_selectOne("SELECT * FROM `dili_jmsf`.`feedback_customer` ORDER BY `id` DESC LIMIT 1")[0]
# print("查询出返还人id", self.code)
# @unittest.case_mark(my.mark())
def test_fc_view_01(self):
"查看返还人"
# 请求url中的需要替换为新增返还人的id
url = vi.url.replace("40", str(self.code))
print("数据处理后的url", url)
# 进行GET请求
re = sy1.get(url=url, headers=vi.header)
# 打印请求结果(可删除该代码,一般只在调试时使用)
# print(re.text)
# 断言响应数据中是否存在期望字符串
self.assertTrue('关联交费卡号' in str(re.text))
@classmethod
def tearDownClass(cls):
pass
if __name__ == '__main__':
unittest.main()