Commit e6a4f9dd by taoke

4.企业云login不使用通用请求

parent f8e5fa1f
......@@ -32,7 +32,7 @@ def request_main(url, headers, method, data):
# if headers == None or headers == {} or headers == "":
# 如果传的headers为空,使用各自产品的通用headers
headers = build_headers(headers)
print(headers)
# print("打印headers",headers)
try:
res = request_by_method(method, headers)
except requests.exceptions.ConnectionError as e:
......
......@@ -34,7 +34,7 @@ def get_excelData(workBook,sheetName,caseName):
try:
dict0['headers'] = json.loads(dict0['headers'])
except:
print('header无')
# print('header无')
dict0['headers']=None
lis.append(dict0)
idx += 1
......
......@@ -5,7 +5,7 @@ class BaseConfig():
"""基础配置类"""
# 请求头
headers = {'Content-Type': 'application/json'}
# 当前运行的产品名
# 当前运行的产品名 #auto
current_name = "auto"
test_case_dir = "test_case/"
......@@ -66,8 +66,7 @@ class BmyConfig(BaseConfig):
test_name_password = {"username": "15151500000", "password": "bmy123456"}
# 企业云接口的Authorization
bmy_token = ''
headers = {'Authorization':bmy_token,"Content-Type":"application/json"}
header = {"Content-Type":"application/json"}
headers = {"Content-Type":"application/json"}
class SSOConfig(BaseConfig):
......
......@@ -116,4 +116,5 @@ if __name__ == '__main__':
# indata= {"username":"15150000000","password":"A123456"}
# token= BMY().bmy_login(indata,getToken=False)
# print(token)
pass
LIST1=BMY().get_imageCode( '15150000000', '8e4b595babec901009ff84f269ee5147')
print(LIST1)
......@@ -11,3 +11,7 @@ def bmy_login():
"""BMY登录获取token"""
res = BMY().bmy_login(BmyConfig.test_name_password)
setattr(BmyConfig,'bmy_token',res)
# res= BMY().get_authorization()
# setattr(BmyConfig, 'bmy_token', res)
......@@ -37,19 +37,19 @@ class TestLogin():
req_data['imageId'] = imageinfo[0]
req_data['imageCode'] = imageinfo[1]
"""请求"""
res = request_main(url, headers, method, req_data)
print(res)
# """请求"""
# res = request_main(url, headers, method, req_data)
# # print(res)
# """断言"""
# assert res['code'] == expectData['code']
"""断言"""
assert res['code'] == expectData['code']
""" 请求和断言若不使用通用方法
# res = requests.post(f"http://testyun.banmago.com/api{url}", data=req_data, headers=headers)
# print(res.json())
# assert res.json()['code'] == expectData['code']
"""
""" 请求和断言若不使用通用方法"""
res = requests.post(f"http://testyun.banmago.com/api{url}", data=req_data, headers=headers)
print("我是headers",headers)
print("我是data",req_data)
print(res.json())
assert res.json()['code'] == expectData['code']
def teardown_class(self):
"""清除"""
......@@ -61,3 +61,4 @@ if __name__ == '__main__':
pytest.main(['test_login.py', '-s', '--alluredir', '../../report/tmp'])
# # 启动默认浏览器打开报告
os.system('allure serve ../../report/tmp')
# requests.post("http://testyun.banmago.com/api/auth/login",data=)
\ No newline at end of file
......@@ -27,13 +27,8 @@ class TestLogin():
expectData = inData['expectData']
headers = inData['headers']
# """处理"""
# headers['Authorization'] = BmyConfig.bmy_token
"""请求"""
res = request_main(url, headers, method, req_data)
print("我打印一下headers",headers)
"""断言"""
assert res['code'] == expectData['code']
......
#作者: taoke
#时间: 2021/5/8 10:39
#编码: -- coding: utf-8 --
#版本: !python3.7
import pytest,allure,xlrd,requests,os
from common.utils.getExcelData import get_excelData
from service.login import BMY
from common.tools import request_main
from config import BmyConfig
from service.login import BMY
@allure.epic("营运车企业端")
@allure.feature("风控台")
class TestLogin():
workBook = xlrd.open_workbook(f'{BmyConfig.root_path}/test_case_data/bmy/bmy_case.xlsx')
@allure.story("风险监控列表接口")
@allure.title("风险监控列表用例")
@allure.testcase("http://yapi.hikcreate.com/")
@allure.description("url:/auth/login 。。。。")
@pytest.mark.parametrize("inData", get_excelData(workBook,'风控台', 'riskMonitorList'))
def test_login(self,inData):
url = f"{BmyConfig().test_host}{inData['url']}"
method = inData['method']
req_data = inData['reqData']
expectData = inData['expectData']
headers = inData['headers']
"""处理"""
headers['Authorization'] = BmyConfig.bmy_token
"""请求"""
res = request_main(url, headers, method, req_data)
"""断言"""
assert res['code'] == expectData['code']
def teardown_class(self):
"""清除"""
if __name__ == '__main__':
for one in os.listdir('../../report/tmp'): # 列出对应文件夹的数据
if 'json' in one:
os.remove(f'../../report/tmp/{one}')
pytest.main(['test_riskMonitar.py', '-s', '--alluredir', '../../report/tmp'])
# # 启动默认浏览器打开报告
os.system('allure serve ../../report/tmp')
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