当前位置:网站首页>Interface automation test - solution of data dependency between interfaces
Interface automation test - solution of data dependency between interfaces
2022-07-07 13:56:00 【though the night】
Ideas : Create a class , Define a class property , Defined as empty , Extract the return value of the interface , adopt setattar() Methods are stored in class properties , When the next interface is called , adopt getattar() Method to get the value of the class property
The code is as follows :
# -*- coding: utf-8 -*-
# @Time : 2022/7/6
# @Author : dyf
# @FileName: test_api01.py
import unittest
import requests
class RelyData:
project_id = None
class TestApi(unittest.TestCase):
def setUp(self):
pass
def test_api01(self):
'''
Add project interface
:return:
'''
url = "http://hy.gcjs.zdvictory.com/unionpro/unionpro/v-api/findByCode"
headers = {'Content-Type': 'application/json'}
datas = {"code": "2020-441621-05-01-010932"}
response = requests.post(url, params=datas, headers=headers)
print("response: ", response.json())
result = response.json()
# to RelyData Inside project_id=None Set a new property for the class property of
setattr(RelyData, "project_id", result['data']['code'])
print(result['data']['code'])
print("-"*50)
print(RelyData.project_id)
def test_api02(self):
""" Add environment interface , You need to rely on the... Returned by adding the project interface project_id Field data """
url = "http://hy.gcjs.zdvictory.com/unionpro/unionpro/v-api/findByProjectCode"
headers = {'Content-Type': 'application/json'}
print(getattr(RelyData, "project_id"))
datas = {
# getattr(RelyData,'project_id'), Take out the attribute value inside
"projectCode": getattr(RelyData, "project_id"),
"isFilterDefaultProject": 0
}
response = requests.get(url, params=datas, headers=headers)
print("response: ", response.json())
if __name__ == '__main__':
unittest.main()
边栏推荐
- High end for 8 years, how is Yadi now?
- move base参数解析及经验总结
- 566. 重塑矩阵
- Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
- QQ medicine, Tencent ticket
- Build a secure and trusted computing platform based on Kunpeng's native security
- requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement
- requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement
- Laravel Form-builder使用
- Server to server (S2S) event (adjust)
猜你喜欢

xshell连接服务器把密钥登陆改为密码登陆

Centso7 OpenSSL error Verify return code: 20 (unable to get local issuer certificate)

2022-7-7 Leetcode 844. Compare strings with backspace

Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou

MySQL error 28 and solution

Battle Atlas: 12 scenarios detailing the requirements for container safety construction

室內ROS機器人導航調試記錄(膨脹半徑的選取經驗)

Flask session forged hctf admin

Help tenants
![SSRF漏洞file伪协议之[网鼎杯 2018]Fakebook1](/img/10/6de1ee8467b18ae03894a8d5ba95ff.png)
SSRF漏洞file伪协议之[网鼎杯 2018]Fakebook1
随机推荐
作战图鉴:12大场景详述容器安全建设要求
2022-7-6 Leetcode 977.有序数组的平方
xshell连接服务器把密钥登陆改为密码登陆
【面试高频题】难度 2.5/5,简单结合 DFS 的 Trie 模板级运用题
Detr introduction
Xshell connection server changes key login to password login
QQ medicine, Tencent ticket
Supply chain supply and demand estimation - [time series]
[daily training -- Tencent select 50] 231 Power of 2
Error lnk2019: unresolved external symbol
Excellent open source system recommendation of ThinkPHP framework
Ways to improve the performance of raspberry pie
Navicat运行sql文件导入数据不全或导入失败
Getting started with MySQL
[1] ROS2基础知识-操作命令总结版
C语言数组相关问题深度理解
2022-7-7 Leetcode 844.比较含退格的字符串
LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
.net core 关于redis的pipeline以及事务
交付效率提升52倍,运营效率提升10倍,看《金融云原生技术实践案例汇编》(附下载)