python接口自动化(二十四)--unittest断言——中(详解)
本站寻求有缘人接手,详细了解请联系站长QQ1493399855
简介
上一篇通过简单的案例给小伙伴们介绍了一下unittest断言,这篇我们将通过结合和围绕实际的工作来进行unittest的断言。这里以获取城市天气预报的接口为例,设计了 2 个用例,一个是查询北京的天气,一个是查询
南京为例,你也可以查询别的城市的天气预报。
接口文档
1、在实际工作中,开发人员都会给你接口文档方便QA测试,和其他系统的开发人员对接。接口文档如下:
天气预报
获取实时天气
请求方式:POST
请求地址:https://www.apiopen.top/weatherApi
Query参数名 | 类型 | 必需 | 描述 | 示例 e.g. |
---|---|---|---|---|
city | string | 是 | 城市名称 | 成都 |
返回示例:
{"code": 200,"msg": "成功!","data": {"yesterday": {"date": "14日星期五","high": "高温 7℃","fx": "无持续风向","low": "低温 4℃","fl": "","type": "阴"},"city": "成都","aqi": "89","forecast": [{"date": "15日星期六","high": "高温 10℃","fengli": "","low": "低温 2℃","fengxiang": "无持续风向","type": "多云"},{"date": "16日星期天","high": "高温 15℃","fengli": "","low": "低温 3℃","fengxiang": "无持续风向","type": "晴"},{"date": "17日星期一","high": "高温 14℃","fengli": "","low": "低温 5℃","fengxiang": "无持续风向","type": "晴"},{"date": "18日星期二","high": "高温 11℃","fengli": "","low": "低温 6℃","fengxiang": "无持续风向","type": "多云"},{"date": "19日星期三","high": "高温 12℃","fengli": "","low": "低温 6℃","fengxiang": "无持续风向","type": "多云"}],"ganmao": "昼夜温差较大,较易发生感冒,请适当增减衣服。体质较弱的朋友请注意防护。","wendu": "9"}
}