Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
AutoApiTest
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
business
AutoApiTest
Commits
9f8cd1d0
Commit
9f8cd1d0
authored
Jan 08, 2021
by
liangfenglong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初始框架上传
parent
6724f8aa
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
173 additions
and
0 deletions
+173
-0
settings.py
conf/settings.py
+12
-0
requirement.txt
requirement.txt
+2
-0
livecase.py
testCase/live/livecase.py
+17
-0
test_live_add_service.py
testCase/live/test_live_add_service.py
+47
-0
test_live_delete_service.py
testCase/live/test_live_delete_service.py
+31
-0
test_live_search_service.py
testCase/live/test_live_search_service.py
+46
-0
test_live_services.py
testCase/live/test_live_services.py
+18
-0
No files found.
conf/settings.py
View file @
9f8cd1d0
...
@@ -35,3 +35,14 @@ BACKEND_ADMIN = 'http://backend.paas-develop.env'
...
@@ -35,3 +35,14 @@ BACKEND_ADMIN = 'http://backend.paas-develop.env'
SEND_MSG_TIME
=
6
SEND_MSG_TIME
=
6
# 搜索关键字
EMPUTY
=
''
PROJECT_NAME
=
'双眼皮'
HOSPITAL_NAME
=
'凯瑞婷'
# 执行顺序,空出来 一些数字
SEARCH_ORER
=
100
ADD_SERVICE_ONE_ORER
=
201
ADD_SERVICE_MANY_ORER
=
202
DELETE_SERVICE_ORER
=
301
\ No newline at end of file
requirement.txt
View file @
9f8cd1d0
requests
requests
pytest
pytest
pytest-ordering
\ No newline at end of file
testCase/live/livecase.py
View file @
9f8cd1d0
...
@@ -11,6 +11,7 @@ class LiveCase(unittest.TestCase):
...
@@ -11,6 +11,7 @@ class LiveCase(unittest.TestCase):
'''
'''
channel_id
=
None
channel_id
=
None
stream_id
=
None
stream_id
=
None
service_ids
=
None
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
...
@@ -89,3 +90,19 @@ class LiveCase(unittest.TestCase):
...
@@ -89,3 +90,19 @@ class LiveCase(unittest.TestCase):
params
=
dict
(
settings
.
GENGMEI_PARAMS
,
stream_id
=
cls
.
stream_id
)
params
=
dict
(
settings
.
GENGMEI_PARAMS
,
stream_id
=
cls
.
stream_id
)
r
=
requests
.
get
(
url
,
params
=
params
)
.
json
()
r
=
requests
.
get
(
url
,
params
=
params
)
.
json
()
return
not
r
[
'data'
][
'stream_status'
][
'is_finish'
]
return
not
r
[
'data'
][
'stream_status'
][
'is_finish'
]
@classmethod
def
live_services
(
cls
):
uri
=
'/api/janus/live/live_services'
url
=
settings
.
BACKEND_ADMIN
+
uri
params
=
dict
(
settings
.
GENGMEI_PARAMS
,
channel_id
=
cls
.
channel_id
,
stream_id
=
cls
.
stream_id
,
offset
=
0
,
size
=
20
)
r
=
requests
.
get
(
url
,
params
=
params
)
.
json
()
return
r
# @classmethod
# def live_add_service(cls):
# uri = '/api/janus/live/add_live_service'
# url = settings.BACKEND_ADMIN + uri
# params = dict(settings.GENGMEI_PARAMS, channel_id=cls.channel_id, stream_id=cls.stream_id, offset=0, size=20)
# r = requests.get(url, params=params).json()
# return r
testCase/live/test_live_add_service.py
0 → 100644
View file @
9f8cd1d0
import
requests
import
pytest
from
utils.gmhttp
import
require_login
from
.livecase
import
LiveCase
from
conf
import
settings
class
LiveAddService
(
LiveCase
):
'''直播添加美购'''
def
setUp
(
self
):
uri
=
'/api/janus/live/add_live_service'
self
.
url
=
self
.
host
+
uri
self
.
data
=
{
'channel_id'
:
self
.
channel_id
}
@pytest.mark.post
@pytest.mark.run
(
order
=
settings
.
ADD_SERVICE_ONE_ORER
)
@require_login
(
settings
.
LIVE_USER
)
def
test_live_add_service_one
(
self
):
'''
主播添加单个美购
'''
self
.
data
.
update
(
service_item_ids
=
f
'{LiveCase.service_ids[0]}'
)
rep
=
requests
.
post
(
self
.
url
,
data
=
self
.
data
)
.
json
()
self
.
assertEqual
(
rep
[
'error'
],
0
,
rep
)
self
.
assertEqual
(
rep
[
'data'
][
'toast'
],
'成功添加1件商品'
,
rep
)
print
(
'主播添加单个美购成功!'
)
@pytest.mark.post
@pytest.mark.run
(
order
=
settings
.
ADD_SERVICE_MANY_ORER
)
@require_login
(
settings
.
LIVE_USER
)
def
test_live_add_service_many
(
self
):
'''
主播添加多个美购
'''
import
random
num
=
random
.
choice
(
range
(
2
,
10
))
# 2-9个先写死
self
.
data
.
update
(
service_item_ids
=
','
.
join
(
LiveCase
.
service_ids
[
-
num
:]))
rep
=
requests
.
post
(
self
.
url
,
data
=
self
.
data
)
.
json
()
self
.
assertEqual
(
rep
[
'error'
],
0
,
rep
)
self
.
assertEqual
(
rep
[
'data'
][
'toast'
],
f
'成功添加{num}件商品'
,
rep
)
print
(
f
'主播添加{num}个美购成功!'
)
testCase/live/test_live_delete_service.py
0 → 100644
View file @
9f8cd1d0
import
requests
import
pytest
from
utils.gmhttp
import
require_login
from
.livecase
import
LiveCase
from
conf
import
settings
class
LiveDeleteService
(
LiveCase
):
'''直播间删除美购'''
def
setUp
(
self
):
uri
=
'/api/janus/live/delete_live_service'
self
.
url
=
self
.
host
+
uri
self
.
data
=
{
'channel_id'
:
self
.
channel_id
}
@pytest.mark.post
@pytest.mark.run
(
order
=
settings
.
DELETE_SERVICE_ORER
)
@require_login
(
settings
.
LIVE_USER
)
def
test_live_delete_service
(
self
):
'''
直播间删除美购
'''
self
.
data
.
update
(
live_service_id
=
LiveCase
.
service_ids
[
0
])
rep
=
requests
.
post
(
self
.
url
,
data
=
self
.
data
)
.
json
()
self
.
assertEqual
(
rep
[
'error'
],
0
,
rep
)
self
.
assertEqual
(
rep
[
'data'
][
'toast'
],
'商品已删除'
,
rep
)
# 不做具体内容判断,在添加的用例里会有相关部分判断
print
(
'直播间删除美购成功!'
)
testCase/live/test_live_search_service.py
0 → 100644
View file @
9f8cd1d0
import
requests
import
pytest
from
utils.gmhttp
import
require_login
from
.livecase
import
LiveCase
from
conf
import
settings
from
ddt
import
ddt
,
data
@ddt
class
LiveSearchService
(
LiveCase
):
'''直播间搜索美购'''
def
setUp
(
self
):
uri
=
'/api/janus/live/search_service'
self
.
url
=
self
.
host
+
uri
self
.
params
=
dict
(
settings
.
GENGMEI_PARAMS
,
**
{
'channel_id'
:
self
.
channel_id
,
'offset'
:
0
,
'size'
:
20
})
@pytest.mark.get
@pytest.mark.run
(
order
=
settings
.
SEARCH_ORER
)
@data
(
*
[
settings
.
EMPUTY
,
settings
.
PROJECT_NAME
,
settings
.
HOSPITAL_NAME
])
def
test_live_search_service
(
self
,
value
):
'''
直播间搜索美购
'''
q
=
value
self
.
params
.
update
(
query
=
q
)
rep
=
requests
.
get
(
self
.
url
,
params
=
self
.
params
)
.
json
()
self
.
assertEqual
(
rep
[
'error'
],
0
,
rep
)
# 理论上说每次搜索都有结果的
services
=
rep
[
'data'
][
'services'
]
self
.
assertIsInstance
(
services
,
list
,
rep
)
if
q
!=
settings
.
EMPUTY
:
# 防止数据较少情况,仅对前两条进行判断
[
self
.
assertIn
(
q
,
item
[
'service_name'
]
+
item
[
'hospital_name'
])
for
item
in
services
[:
2
]]
# 对 外显的价格 销量和距离进行关键字断言
[
self
.
assertNotEqual
(
item
[
'display_price'
],
''
)
for
item
in
services
]
[
self
.
assertNotEqual
(
item
[
'distance'
],
''
)
for
item
in
services
]
[
self
.
assertNotEqual
(
item
[
'sell_num_desc'
],
''
)
for
item
in
services
]
if
q
==
settings
.
EMPUTY
:
LiveCase
.
service_ids
=
[
item
[
'service_id'
]
for
item
in
services
]
print
(
'直播间搜索美购成功!'
)
testCase/live/test_live_services.py
0 → 100644
View file @
9f8cd1d0
import
pytest
from
.livecase
import
LiveCase
class
LiveServices
(
LiveCase
):
'''获取直播间美购列表'''
@pytest.mark.get
def
test_live_services
(
self
):
'''
获取直播间美购列表
'''
rep
=
self
.
live_services
()
self
.
assertEqual
(
rep
[
'error'
],
0
,
rep
)
self
.
assertIsInstance
(
rep
[
'data'
][
'services'
],
list
,
rep
)
# 不做具体内容判断,在添加的用例里会有相关部分判断
print
(
'获取直播间美购列表成功!'
)
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