当前位置:网站首页>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()
边栏推荐
- toRaw和markRaw
- Shell batch file name (excluding extension) lowercase to uppercase
- Dry goods | summarize the linkage use of those vulnerability tools
- 供应链供需预估-[时间序列]
- 带你掌握三层架构(建议收藏)
- 2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
- mysql导入文件出现Data truncated for column ‘xxx’ at row 1的原因
- Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
- [high frequency interview questions] difficulty 2.5/5, simple combination of DFS trie template level application questions
- 2022-7-7 Leetcode 844. Compare strings with backspace
猜你喜欢
随机推荐
搜索框效果的实现【每日一题】
Cinnamon taskbar speed
Evolution of customer service hotline of dewu
Help tenants
2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置
The difference between memory overflow and memory leak
PHP - laravel cache
[1] ROS2基础知识-操作命令总结版
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
Did login metamask
Lavarel之环境配置 .env
DID登陆-MetaMask
QQ medicine, Tencent ticket
作战图鉴:12大场景详述容器安全建设要求
2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
MySQL error 28 and solution
Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
2022-7-6 使用SIGURG来接受外带数据,不知道为什么打印不出来
Solve the cache breakdown problem









