代码拉取完成,页面将自动刷新
import pytest
import requests
import allure
@allure.feature('宠物商店接口测试')
class TestPetStoreAPI:
@allure.title('新增宠物接口测试')
def test_add_pet(self):
with allure.step('准备新增宠物请求数据'):
headers = {'Content-Type': 'application/json'}
data = {
"id": 1,
"name": "panda",
"status": "available"
}
with allure.step('发送新增宠物请求'):
response = requests.post('https://petstore.swagger.io/v2/pet', headers=headers, json=data)
with allure.step('检查新增宠物请求响应状态码'):
assert response.status_code == 200
@allure.title('查询宠物接口测试')
def test_find_pet_by_status(self):
with allure.step('准备查询宠物请求数据'):
params = {'status': 'available'}
with allure.step('发送查询宠物请求'):
response = requests.get('https://petstore.swagger.io/v2/pet/findByStatus', params=params)
with allure.step('检查查询宠物请求响应状态码'):
assert response.status_code == 200
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。