当前位置:网站首页>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()
边栏推荐
- JS slow motion animation principle teaching (super detail)
- Toraw and markraw
- Ikvm of toolbox Net project new progress
- Flink | multi stream conversion
- Distributed transaction solution
- Cinnamon taskbar speed
- 室內ROS機器人導航調試記錄(膨脹半徑的選取經驗)
- SSRF vulnerability file pseudo protocol [netding Cup 2018] fakebook1
- postgresql array类型,每一项拼接
- Thread pool reject policy best practices
猜你喜欢
Esp32 ① compilation environment
Flink | 多流转换
LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
2022-7-6 Leetcode 977. Square of ordered array
DID登陆-MetaMask
Navicat run SQL file import data incomplete or import failed
Did login metamask
实现IP地址归属地显示功能、号码归属地查询
Leetcode simple question sharing (20)
随机推荐
Error lnk2019: unresolved external symbol
Vmware共享主机的有线网络IP地址
2022-7-7 Leetcode 844.比较含退格的字符串
Mysql怎样控制replace替换的次数?
《厌女:日本的女性嫌恶》摘录
[high frequency interview questions] difficulty 2.5/5, simple combination of DFS trie template level application questions
实现IP地址归属地显示功能、号码归属地查询
搜索框效果的实现【每日一题】
PHP - laravel cache
Help tenants
566. 重塑矩阵
提升树莓派性能的方法
云计算安全扩展要求关注的安全目标和实现方式区分原则有哪些?
THINKPHP框架的优秀开源系统推荐
MySQL "invalid use of null value" solution
Attribute keywords aliases, calculated, cardinality, ClientName
Xshell connection server changes key login to password login
requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement
Realize the IP address home display function and number home query
Esp32 series column