Commit 7d034dfe by 文鑫

Delete test_Source1.py

parent f65632bc
# _*_ coding:utf-8 _*_
_author_ = 'wenxin'
_date_ = '2020/6/11 11:03'
import requests
import allure
import pytest
import sys
sys.path.append('../')
from common import getSourceId
from common.getData import DoExcelByPandas
@allure.feature('数据源')
class TestSource():
parametrize = DoExcelByPandas().get_data_for_pytest('../data/DataA_Source.xlsx', 'Sheet1')
@allure.title('{story}')
@pytest.mark.parametrize('id,url,data,story,method,severity,condition,except_result',parametrize)
def test(self,id,url,data,story,method,severity,condition,except_result): # test开头的测试函数
url = url
#测试删除数据源接口
if story == '删除mysql数据源' or story == '删除oracle数据源':
id = getSourceId.get_SourceId(data)
#将数据源id拼接在url地址上
url = url + id
r = requests.post(url=url)
#测试需要传递dataSourceId的接口
elif 'dataSourceId' in story :
id = getSourceId.get_SourceId(data)
url = url + id
r = requests.get(url=url)
#测试post接口
elif method == 'post':
json = eval(data) #eval返回传入字符串的表达式的结果
r = requests.post(url = url,json = json)
#测试get接口
elif method == 'get':
r = requests.get(url=url)
response = r.json()
# print (type(response[condition]))
assert response[condition] == str(except_result)
if __name__ == '__main__':
pytest.main(['-s','test_Source.py']) #-s参数是为了显示用例的打印信息。 -q参数只显示结果,不显示过程
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment