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

Posted laosun0204

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了接口自动化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()

以上是关于接口自动化get请求方式的处理的主要内容,如果未能解决你的问题,请参考以下文章

python接口自动化--发送get请求接口(详解)

python接口自动化测试三:代码发送HTTP请求

接口自动化接口测试基础

Java接口自动化测试框架设计-4-POST请求方法封装过程和测试

python接口自动化测试-requests.get()

python接口自动化测试-requests.get()