当前位置:网站首页>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()
边栏推荐
- Leetcode simple question sharing (20)
- MySQL error 28 and solution
- flask session伪造之hctf admin
- Server to server (S2S) event (adjust)
- 内存溢出和内存泄漏的区别
- 现在网上开户安全么?那么网上开户选哪个证券公司?
- Redis只能做缓存?太out了!
- [daily training] 648 Word replacement
- . Net core about redis pipeline and transactions
- The reason why data truncated for column 'xxx' at row 1 appears in the MySQL import file
猜你喜欢
随机推荐
Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1
move base参数解析及经验总结
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
Excellent open source system recommendation of ThinkPHP framework
Is it safe to open an account online now? Which securities company should I choose to open an account online?
What parameters need to be reconfigured to replace the new radar of ROS robot
PHP中用下划线开头的变量含义
Problems that cannot be accessed in MySQL LAN
566. 重塑矩阵
Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
JS slow motion animation principle teaching (super detail)
手里的闲钱是炒股票还是买理财产品好?
Did login metamask
LeetCode简单题分享(20)
云计算安全扩展要求关注的安全目标和实现方式区分原则有哪些?
参数关键字Final,Flags,Internal,映射关键字Internal
MySQL "invalid use of null value" solution
Getting started with cinnamon applet
室内ROS机器人导航调试记录(膨胀半径的选取经验)
LeetCode_ Binary search_ Medium_ 153. Find the minimum value in the rotation sort array