当前位置:网站首页>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
- Data refresh of recyclerview
- FCOS3D label assignment
- 干货|总结那些漏洞工具的联动使用
- Indoor ROS robot navigation commissioning record (experience in selecting expansion radius)
- AI人才培育新思路,这场直播有你关心的
- 【堡垒机】云堡垒机和普通堡垒机的区别是什么?
- 请问指南针股票软件可靠吗?交易股票安全吗?
- Environment configuration of lavarel env
猜你喜欢
Leetcode simple question sharing (20)
2022-7-6 Leetcode27. Remove the element - I haven't done the problem for a long time. It's such an embarrassing day for double pointers
Show the mathematical formula in El table
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)
Navicat运行sql文件导入数据不全或导入失败
【堡垒机】云堡垒机和普通堡垒机的区别是什么?
最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
Milkdown control icon
Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
"Song of ice and fire" in the eleventh issue of "open source Roundtable" -- how to balance the natural contradiction between open source and security?
随机推荐
Leetcode simple question sharing (20)
高等數學---第八章多元函數微分學1
Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
[1] Basic knowledge of ros2 - summary version of operation commands
室內ROS機器人導航調試記錄(膨脹半徑的選取經驗)
LeetCode_ Binary search_ Medium_ 153. Find the minimum value in the rotation sort array
Redis can only cache? Too out!
566. Reshaping the matrix
Flink | 多流转换
Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
PHP - laravel cache
PostgreSQL array type, each splice
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
toRaw和markRaw
2022-7-6 sigurg is used to receive external data. I don't know why it can't be printed out
Custom thread pool rejection policy
【日常训练--腾讯精选50】231. 2 的幂
Supply chain supply and demand estimation - [time series]
Realize the IP address home display function and number home query