1 Star 0 Fork 0

羁旅 / wangdazhu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
接口自动化实战 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
羁旅 提交于 2023-06-02 04:45 . add 接口自动化实战.
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
1
https://gitee.com/fhhfjksajfh/wangdazhu.git
git@gitee.com:fhhfjksajfh/wangdazhu.git
fhhfjksajfh
wangdazhu
wangdazhu
master

搜索帮助