Commit 0d943153 by taoke

header获取获取空,或不是非 json字符串,存为None

parent 51b0a598
...@@ -32,6 +32,7 @@ def request_main(url, headers, method, data): ...@@ -32,6 +32,7 @@ def request_main(url, headers, method, data):
if headers == None or headers == {} or headers == "": if headers == None or headers == {} or headers == "":
# 如果传的headers为空,使用各自产品的通用headers # 如果传的headers为空,使用各自产品的通用headers
headers = get_headers() headers = get_headers()
print("内部我打印一下headers", headers)
try: try:
res = request_by_method(method, headers) res = request_by_method(method, headers)
except requests.exceptions.ConnectionError as e: except requests.exceptions.ConnectionError as e:
...@@ -50,6 +51,7 @@ def get_headers(): ...@@ -50,6 +51,7 @@ def get_headers():
headers = BMCConfig.headers headers = BMCConfig.headers
elif name == BmyConfig.name: elif name == BmyConfig.name:
headers = BmyConfig.headers headers = BmyConfig.headers
return headers
elif name == SSOConfig.name: elif name == SSOConfig.name:
headers = SSOConfig.headers headers = SSOConfig.headers
return headers return headers
......
...@@ -35,6 +35,7 @@ def get_excelData(workBook,sheetName,caseName): ...@@ -35,6 +35,7 @@ def get_excelData(workBook,sheetName,caseName):
dict0['headers'] = json.loads(dict0['headers']) dict0['headers'] = json.loads(dict0['headers'])
except: except:
print('header无') print('header无')
dict0['headers']=None
lis.append(dict0) lis.append(dict0)
idx += 1 idx += 1
return lis return lis
......
...@@ -9,7 +9,7 @@ class BaseConfig(): ...@@ -9,7 +9,7 @@ class BaseConfig():
current_name = "auto" current_name = "auto"
test_case_dir = "test_case/" test_case_dir = "test_case/"
secs=0.1 # 测试用例间隔运行时间 secs = 0.1 # 测试用例间隔运行时间
test_redis = {"host": "10.197.236.197", "port": 6379, "password": "123456"} test_redis = {"host": "10.197.236.197", "port": 6379, "password": "123456"}
root_path = os.path.abspath(os.path.dirname(__file__)) # 项目根目录 root_path = os.path.abspath(os.path.dirname(__file__)) # 项目根目录
...@@ -66,7 +66,8 @@ class BmyConfig(BaseConfig): ...@@ -66,7 +66,8 @@ class BmyConfig(BaseConfig):
test_name_password = {"username": "15151500000", "password": "bmy123456"} test_name_password = {"username": "15151500000", "password": "bmy123456"}
# 企业云接口的Authorization # 企业云接口的Authorization
bmy_token = '' bmy_token = ''
header = {"Content-Type":"application/json"} # header = {"Authorization":bmy_token,"Content-Type":"application/json"}
header = ''
class SSOConfig(BaseConfig): class SSOConfig(BaseConfig):
......
...@@ -10,4 +10,5 @@ import pytest ...@@ -10,4 +10,5 @@ import pytest
def bmy_login(): def bmy_login():
"""BMY登录获取token""" """BMY登录获取token"""
res = BMY().bmy_login(BmyConfig.test_name_password) res = BMY().bmy_login(BmyConfig.test_name_password)
setattr(BmyConfig,'bmy_token',res) header = {"Authorization": res,"Content-Type":"application/json"}
setattr(BmyConfig,'header', header)
...@@ -27,11 +27,13 @@ class TestLogin(): ...@@ -27,11 +27,13 @@ class TestLogin():
expectData = inData['expectData'] expectData = inData['expectData']
headers = inData['headers'] headers = inData['headers']
"""处理""" # """处理"""
headers['Authorization'] = BmyConfig.bmy_token # headers['Authorization'] = BmyConfig.bmy_token
"""请求""" """请求"""
res = request_main(url, headers, method, req_data) res = request_main(url, headers, method, req_data)
print("我打印一下headers",headers)
"""断言""" """断言"""
assert res['code'] == expectData['code'] assert res['code'] == expectData['code']
......
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