当前位置:网站首页>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()
边栏推荐
猜你喜欢

Ways to improve the performance of raspberry pie

Flink | multi stream conversion

AI人才培育新思路,这场直播有你关心的

【堡垒机】云堡垒机和普通堡垒机的区别是什么?

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

Redis 核心数据结构 & Redis 6 新特性详

2022-7-6 beginner redis (I) download, install and run redis under Linux

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

Navicat运行sql文件导入数据不全或导入失败

DID登陆-MetaMask
随机推荐
Talk about pseudo sharing
Data refresh of recyclerview
Indoor ROS robot navigation commissioning record (experience in selecting expansion radius)
requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement
566. Reshaping the matrix
Laravel5 call to undefined function openssl cipher iv length() 报错 PHP7开启OpenSSL扩展失败
现在网上开户安全么?那么网上开户选哪个证券公司?
toRaw和markRaw
室内ROS机器人导航调试记录(膨胀半径的选取经验)
带你掌握三层架构(建议收藏)
作战图鉴:12大场景详述容器安全建设要求
Show the mathematical formula in El table
"Song of ice and fire" in the eleventh issue of "open source Roundtable" -- how to balance the natural contradiction between open source and security?
SSRF漏洞file伪协议之[网鼎杯 2018]Fakebook1
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)
Thread pool reject policy best practices
JS function returns multiple values
Introduction to database system - Chapter 1 introduction [conceptual model, hierarchical model and three-level mode (external mode, mode, internal mode)]
flask session伪造之hctf admin
1. Deep copy 2. Call apply bind 3. For of in differences