当前位置:网站首页>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()
边栏推荐
- 3D Detection: 3D Box和点云 快速可视化
- Environment configuration of lavarel env
- Solve the cache breakdown problem
- PC端页面如何调用QQ进行在线聊天?
- 566. 重塑矩阵
- 118. Yanghui triangle
- requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement
- 2022-7-6 Leetcode 977.有序数组的平方
- Xshell connection server changes key login to password login
- Flink | 多流转换
猜你喜欢

Navicat run SQL file import data incomplete or import failed

Use of polarscatter function in MATLAB

Battle Atlas: 12 scenarios detailing the requirements for container safety construction

社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生

《厌女:日本的女性嫌恶》摘录

2022-7-7 Leetcode 844.比较含退格的字符串

118. 杨辉三角

作战图鉴:12大场景详述容器安全建设要求

Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)

Deep understanding of array related problems in C language
随机推荐
Redis只能做缓存?太out了!
属性关键字Aliases,Calculated,Cardinality,ClientName
PHP中用下划线开头的变量含义
提升树莓派性能的方法
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
如何让join跑得更快?
最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
Flink | 多流转换
Redis 核心数据结构 & Redis 6 新特性详
Dry goods | summarize the linkage use of those vulnerability tools
【日常训练】648. 单词替换
带你掌握三层架构(建议收藏)
[high frequency interview questions] difficulty 2.5/5, simple combination of DFS trie template level application questions
THINKPHP框架的优秀开源系统推荐
mysql 局域网内访问不到的问题
requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement
作战图鉴:12大场景详述容器安全建设要求
Laravel form builder uses
Environment configuration of lavarel env
【日常训练--腾讯精选50】231. 2 的幂