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
ee17de83
Commit
ee17de83
authored
May 06, 2021
by
taoke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修改读取xecle的方法
2.完成企业云登录接口的测试用例
parent
07f344f5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
3 deletions
+64
-3
common/utils/getExcelData.py
+3
-3
service/login.py
+1
-0
test_case/bmy/__init__.py
+5
-0
test_case/bmy/test_login.py
+55
-0
test_case_data/bmy/bmy_case.xlsx
+0
-0
No files found.
common/utils/getExcelData.py
View file @
ee17de83
...
@@ -15,12 +15,13 @@ def get_excelData(workBook,sheetName,caseName):
...
@@ -15,12 +15,13 @@ def get_excelData(workBook,sheetName,caseName):
num_reqData
=
list_title
.
index
(
'reqData'
)
num_reqData
=
list_title
.
index
(
'reqData'
)
num_expectData
=
list_title
.
index
(
'expectData'
)
num_expectData
=
list_title
.
index
(
'expectData'
)
lis
=
[]
lis
=
[]
dict0
=
{
"url"
:
""
,
"headers"
:
""
,
"method"
:
""
,
"reqData"
:
""
,
"expectData"
:
""
}
idx
=
0
idx
=
0
try
:
try
:
for
one
in
workSheet
.
col_values
(
0
):
for
one
in
workSheet
.
col_values
(
0
):
result
=
''
.
join
(
re
.
findall
(
r'[A-Za-z]'
,
one
))
# 抽取字母字符串
result
=
''
.
join
(
re
.
findall
(
r'[A-Za-z]'
,
one
))
# 抽取字母字符串
if
caseName
==
result
:
if
caseName
==
result
:
dict0
=
{
"url"
:
""
,
"headers"
:
""
,
"method"
:
""
,
"reqData"
:
""
,
"expectData"
:
""
}
dict0
[
'url'
]
=
workSheet
.
cell_value
(
idx
,
num_url
)
dict0
[
'url'
]
=
workSheet
.
cell_value
(
idx
,
num_url
)
dict0
[
'headers'
]
=
workSheet
.
cell_value
(
idx
,
num_headers
)
dict0
[
'headers'
]
=
workSheet
.
cell_value
(
idx
,
num_headers
)
dict0
[
'method'
]
=
workSheet
.
cell_value
(
idx
,
num_method
)
dict0
[
'method'
]
=
workSheet
.
cell_value
(
idx
,
num_method
)
...
@@ -34,7 +35,6 @@ def get_excelData(workBook,sheetName,caseName):
...
@@ -34,7 +35,6 @@ def get_excelData(workBook,sheetName,caseName):
dict0
[
'headers'
]
=
json
.
loads
(
dict0
[
'headers'
])
dict0
[
'headers'
]
=
json
.
loads
(
dict0
[
'headers'
])
except
:
except
:
print
(
'header无'
)
print
(
'header无'
)
lis
.
append
(
dict0
)
lis
.
append
(
dict0
)
idx
+=
1
idx
+=
1
return
lis
return
lis
...
@@ -44,7 +44,7 @@ def get_excelData(workBook,sheetName,caseName):
...
@@ -44,7 +44,7 @@ def get_excelData(workBook,sheetName,caseName):
print
(
"检查excle中标题是否正确"
)
print
(
"检查excle中标题是否正确"
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
workBook
=
xlrd
.
open_workbook
(
'../../test_case_data/bmy_case.xlsx'
)
workBook
=
xlrd
.
open_workbook
(
'../../test_case_data/bmy
/bmy
_case.xlsx'
)
li
=
get_excelData
(
workBook
,
"登录模块"
,
"Login"
)
li
=
get_excelData
(
workBook
,
"登录模块"
,
"Login"
)
print
(
li
)
print
(
li
)
...
...
service/login.py
View file @
ee17de83
...
@@ -7,6 +7,7 @@ from common.utils.encryption import Encryption
...
@@ -7,6 +7,7 @@ from common.utils.encryption import Encryption
from
common.tools
import
request_main
from
common.tools
import
request_main
from
common.db
import
RedisString
from
common.db
import
RedisString
@pytest.fixture
(
scope
=
'session'
)
@pytest.fixture
(
scope
=
'session'
)
def
sso_login
(
url
,
headers
,
method
,
data
):
def
sso_login
(
url
,
headers
,
method
,
data
):
"""SSO登录"""
"""SSO登录"""
...
...
test_case/bmy/__init__.py
0 → 100644
View file @
ee17de83
# 作者: taoke
# 时间: 2021/5/6 21:10
# 编码: #coding:utf-8
# 版本: python3.7
\ No newline at end of file
test_case/bmy/test_login.py
0 → 100644
View file @
ee17de83
# 作者: taoke
# 时间: 2021/5/6 21:10
# 编码: #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
@allure.epic
(
"营运车企业端"
)
@allure.feature
(
"登录模块"
)
class
TestLogin
():
workBook
=
xlrd
.
open_workbook
(
'../../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
,
'登录模块'
,
'Login'
))
def
test_login
(
self
,
inData
):
url
=
inData
[
'url'
]
method
=
inData
[
'method'
]
req_data
=
inData
[
'reqData'
]
expectData
=
inData
[
'expectData'
]
headers
=
inData
[
'headers'
]
"""处理"""
authorization
=
BMY
()
.
get_authorization
()
#
headers
[
"Authorization"
]
=
authorization
# 密码加密
password_Encrypted
=
BMY
()
.
pwd_encrypted
(
req_data
[
'password'
])
req_data
[
'password'
]
=
password_Encrypted
# 获取图片信息
imageinfo
=
BMY
()
.
get_imageCode
(
req_data
[
'username'
],
req_data
[
'password'
])
req_data
[
'imageId'
]
=
imageinfo
[
0
]
req_data
[
'imageCode'
]
=
imageinfo
[
1
]
req_data
[
'grant_type'
]
=
"passwordImageCode"
"""请求"""
# res = request_main(f"http://testyun.banmago.com/api{url}", headers, method, req_data)
res
=
requests
.
post
(
f
"http://testyun.banmago.com/api{url}"
,
data
=
req_data
,
headers
=
headers
)
# print(res.json())
"""断言"""
assert
res
.
json
()[
'code'
]
==
expectData
[
'code'
]
if
__name__
==
'__main__'
:
for
one
in
os
.
listdir
(
'../../report/tmp'
):
# 列出对应文件夹的数据
if
'json'
in
one
:
os
.
remove
(
f
'../../report/tmp/{one}'
)
pytest
.
main
([
'test_login.py'
,
'-s'
,
'--alluredir'
,
'../../report/tmp'
])
# # 启动默认浏览器打开报告
os
.
system
(
'allure serve ../../report/tmp'
)
test_case_data/bmy/bmy_case.xlsx
View file @
ee17de83
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