Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InterfaceAutoTest
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TestAuto
InterfaceAutoTest
Commits
6cae57f4
Commit
6cae57f4
authored
May 12, 2021
by
jiaqiying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify request_main
parent
8c90161b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
common/tools.py
+5
-4
No files found.
common/tools.py
View file @
6cae57f4
...
@@ -6,7 +6,7 @@ import requests
...
@@ -6,7 +6,7 @@ import requests
from
config
import
*
from
config
import
*
def
request_main
(
url
,
headers
,
method
,
data
):
def
request_main
(
url
,
headers
,
method
,
data
,
has_token
=
False
):
"""封装requests的通用请求方法"""
"""封装requests的通用请求方法"""
res
=
None
res
=
None
def
request_by_method
(
method
,
headers
):
def
request_by_method
(
method
,
headers
):
...
@@ -31,7 +31,7 @@ def request_main(url, headers, method, data):
...
@@ -31,7 +31,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
=
build_headers
(
headers
)
headers
=
build_headers
(
headers
,
has_token
)
# print("打印headers",headers)
# print("打印headers",headers)
try
:
try
:
res
=
request_by_method
(
method
,
headers
)
res
=
request_by_method
(
method
,
headers
)
...
@@ -44,9 +44,10 @@ def request_main(url, headers, method, data):
...
@@ -44,9 +44,10 @@ def request_main(url, headers, method, data):
return
res
return
res
def
build_headers
(
headers
):
def
build_headers
(
headers
,
has_token
):
name
=
BaseConfig
.
current_name
name
=
BaseConfig
.
current_name
# if headers == None or headers == {} or headers == "":
if
has_token
:
return
headers
if
name
==
BMCConfig
.
name
:
if
name
==
BMCConfig
.
name
:
if
headers
==
None
or
headers
==
""
:
if
headers
==
None
or
headers
==
""
:
headers
=
BMCConfig
.
headers
headers
=
BMCConfig
.
headers
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment