当前位置:网站首页>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()
边栏推荐
- Esp32 series column
- 【日常训练--腾讯精选50】231. 2 的幂
- QQ medicine, Tencent ticket
- Talk about pseudo sharing
- [high frequency interview questions] difficulty 2.5/5, simple combination of DFS trie template level application questions
- 118. 杨辉三角
- 1. Deep copy 2. Call apply bind 3. For of in differences
- 2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置
- 华为镜像地址
- Ikvm of toolbox Net project new progress
猜你喜欢
Redis 核心数据结构 & Redis 6 新特性详
实现IP地址归属地显示功能、号码归属地查询
Realize the IP address home display function and number home query
C语言数组相关问题深度理解
SSRF vulnerability file pseudo protocol [netding Cup 2018] fakebook1
Thread pool reject policy best practices
Flink | 多流转换
Build a secure and trusted computing platform based on Kunpeng's native security
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
Xshell connection server changes key login to password login
随机推荐
Vmware 与主机之间传输文件
手里的闲钱是炒股票还是买理财产品好?
3D Detection: 3D Box和点云 快速可视化
Environment configuration of lavarel env
提升树莓派性能的方法
566. Reshaping the matrix
接口自动化测试-接口间数据依赖问题解决
高等數學---第八章多元函數微分學1
What are the principles for distinguishing the security objectives and implementation methods that cloud computing security expansion requires to focus on?
Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
Redis只能做缓存?太out了!
Ikvm of toolbox Net project new progress
Esp32 series column
社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生
内存溢出和内存泄漏的区别
118. 杨辉三角
Redis 核心数据结构 & Redis 6 新特性详
Dry goods | summarize the linkage use of those vulnerability tools
call undefined function openssl_cipher_iv_length
带你掌握三层架构(建议收藏)