接口自动化get请求方式的处理

from conf.settings import HOST_INFO
import unittest
import requests


class AdmissionDetail(unittest.TestCase):
def setUp(self):
self.url = HOST_INFO + '/tAdmissionn/admissionDetail'
self.headers = {"content-type": "application/json"}

def test_060_admission_detail(self):
"""准入审核详情,id正确"""
query_string = {
"id": "B73F85B0EEC14E55805B4D5754430990"
}
data = ""
res = requests.request('get', self.url, params=query_string, data=data, headers=self.headers)
dic = res.json()
print(dic)
self.assertIsInstance(dic, dict)
self.assertEqual(None, dic.get('code'))
self.assertEqual('详情查询成功', dic.get('message'))
self.assertIn('id', str(dic))
self.assertIn('companyId', str(dic))
self.assertIn('companyName', str(dic))
self.assertIn('companyCompanyPhone', str(dic))
self.assertIn('checkState', str(dic))

def test_061_admission_detail(self):
"""准入审核详情,id不正确"""
query_string = {
"id": "B73F85B0EEC14E55805B4D57544"
}
data = ""
res = requests.request('get', self.url, params=query_string, data=data, headers=self.headers)
dic = res.json()
print(dic)
self.assertIsInstance(dic, dict)
self.assertEqual(None, dic.get('code'))
self.assertEqual(None, dic.get('message'))
self.assertEqual(None, dic.get('result'))


if __name__ == '__main__':
unittest.main()
posted @ 2019-07-26 18:16  laosun0204  阅读(294)  评论(0编辑  收藏  举报