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
e6a4f9dd
Commit
e6a4f9dd
authored
May 11, 2021
by
taoke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4.企业云login不使用通用请求
parent
f8e5fa1f
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
70 deletions
+23
-70
common/tools.py
+1
-1
common/utils/getExcelData.py
+1
-1
config.py
+2
-3
service/login.py
+2
-1
test_case/bmy/conftest.py
+4
-0
test_case/bmy/test_login.py
+13
-11
test_case/bmy/test_riskMonitar.py
+0
-5
test_case/bmy/test_riskMonitor2.py
+0
-48
test_case_data/bmy/bmy_case.xlsx
+0
-0
No files found.
common/tools.py
View file @
e6a4f9dd
...
...
@@ -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
:
...
...
common/utils/getExcelData.py
View file @
e6a4f9dd
...
...
@@ -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
...
...
config.py
View file @
e6a4f9dd
...
...
@@ -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
):
...
...
service/login.py
View file @
e6a4f9dd
...
...
@@ -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
)
test_case/bmy/conftest.py
View file @
e6a4f9dd
...
...
@@ -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)
test_case/bmy/test_login.py
View file @
e6a4f9dd
...
...
@@ -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
test_case/bmy/test_riskMonitar.py
View file @
e6a4f9dd
...
...
@@ -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'
]
...
...
test_case/bmy/test_riskMonitor2.py
deleted
100644 → 0
View file @
f8e5fa1f
#作者: 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'
)
test_case_data/bmy/bmy_case.xlsx
View file @
e6a4f9dd
No preview for this file type
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