当前位置:网站首页>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()
边栏推荐
- Getting started with MySQL
- DID登陆-MetaMask
- Esp32 series column
- 【堡垒机】云堡垒机和普通堡垒机的区别是什么?
- 参数关键字Final,Flags,Internal,映射关键字Internal
- The meaning of variables starting with underscores in PHP
- Is it safe to open an account online now? Which securities company should I choose to open an account online?
- 作战图鉴:12大场景详述容器安全建设要求
- AI人才培育新思路,这场直播有你关心的
- [1] ROS2基础知识-操作命令总结版
猜你喜欢
高等数学---第八章多元函数微分学1
2022-7-7 Leetcode 844. Compare strings with backspace
flask session伪造之hctf admin
Flink | multi stream conversion
The delivery efficiency is increased by 52 times, and the operation efficiency is increased by 10 times. See the compilation of practical cases of financial cloud native technology (with download)
Excerpt from "misogyny: female disgust in Japan"
566. 重塑矩阵
. Net core about redis pipeline and transactions
作战图鉴:12大场景详述容器安全建设要求
QQ medicine, Tencent ticket
随机推荐
带你掌握三层架构(建议收藏)
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
648. 单词替换 : 字典树的经典运用
【堡垒机】云堡垒机和普通堡垒机的区别是什么?
Mysql怎样控制replace替换的次数?
Environment configuration of lavarel env
xshell连接服务器把密钥登陆改为密码登陆
Talk about pseudo sharing
postgresql array类型,每一项拼接
室内ROS机器人导航调试记录(膨胀半径的选取经验)
FCOS3D label assignment
Getting started with cinnamon applet
2022-7-6 Leetcode 977. Square of ordered array
Thread pool reject policy best practices
flask session伪造之hctf admin
【面试高频题】难度 2.5/5,简单结合 DFS 的 Trie 模板级运用题
为租客提供帮助
Deep understanding of array related problems in C language
PHP - laravel cache
Error lnk2019: unresolved external symbol