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
68ede6ea
Commit
68ede6ea
authored
Jan 05, 2021
by
liangfenglong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新上传第一个demo:test_enter_live进入直播间
parent
e982382b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
33 deletions
+96
-33
settings.py
conf/settings.py
+10
-3
livecase.py
testCase/live/livecase.py
+43
-14
test_case.py
testCase/live/test_case.py
+0
-14
test_enter_live.py
testCase/live/test_enter_live.py
+42
-0
gmhttp.py
utils/gmhttp.py
+1
-2
No files found.
conf/settings.py
View file @
68ede6ea
# something here
LIVE_USER
=
{
'phone'
:
'18633668899'
,
'password'
:
'123456'
'phone'
:
'12345678912'
,
'password'
:
'a123456'
}
LIVE_WATCHER
=
{
'phone'
:
'13608913121'
,
'password'
:
'a123456'
}
HERA_SESSION
=
'tm115sjlt2nzimgxfa34c91xghvor1ue'
# 公共参数
GENGMEI_PARAMS
=
{
'app_name'
:
'com.wanmeizhensuo.zhensuo'
,
...
...
@@ -23,4 +29,5 @@ GENGMEI_PARAMS = {
'uuid'
:
'19a56bb4-4ff7-46d4-b156-904297b91385'
# 不影响逻辑
}
BACKEND_ADMIN
=
'https://backend.igengmei.com'
# BACKEND_ADMIN = 'https://backend.igengmei.com'
BACKEND_ADMIN
=
'http://backend.paas-develop.env'
testCase/live/livecase.py
View file @
68ede6ea
...
...
@@ -6,7 +6,11 @@ from utils.gmhttp import require_login
class
LiveCase
(
unittest
.
TestCase
):
live_id
=
None
'''
'''
channel_id
=
None
stream_id
=
None
@classmethod
def
setUpClass
(
cls
):
...
...
@@ -16,7 +20,9 @@ class LiveCase(unittest.TestCase):
2. hera上为直播做配置
:return:
'''
cls
.
host
=
settings
.
BACKEND_ADMIN
cls
.
create_live
()
cls
.
stream_info
()
@classmethod
def
tearDownClass
(
cls
):
...
...
@@ -29,20 +35,22 @@ class LiveCase(unittest.TestCase):
创建直播间
:return:
'''
if
cls
.
live_status
():
return
uri
=
'/api/live/push_live_info'
url
=
settings
.
BACKEND_ADMIN
+
uri
params
=
settings
.
GENGMEI_PARAMS
.
update
(
{
'notice'
:
'测试'
,
'tag_id'
:
3161
,
'title'
:
'测试'
,
'cover_url'
:
'2021/01/04/1506/ba72d863e638'
,
'device_type'
:
1
}
)
params
=
dict
(
settings
.
GENGMEI_PARAMS
,
**
{
'notice'
:
'测试'
,
'tag_id'
:
3161
,
'title'
:
'测试'
,
'cover_url'
:
'2021/01/04/1506/ba72d863e638'
,
'device_type'
:
1
}
)
r
=
requests
.
get
(
url
,
params
=
params
)
.
json
()
cls
.
live_id
=
r
[
'data'
][
'channel'
]
cls
.
channel_id
=
r
[
'data'
][
'channel'
]
print
(
'创建直播间成功!'
)
@classmethod
@require_login
...
...
@@ -51,12 +59,33 @@ class LiveCase(unittest.TestCase):
关闭直播间
:return:
'''
if
cls
.
live
_id
==
None
:
if
cls
.
stream
_id
==
None
:
print
(
'没有成功创建直播间!'
)
return
uri
=
'/api/live/finish'
url
=
settings
.
BACKEND_ADMIN
+
uri
data
=
{
'channel_id'
:
cls
.
live
_id
}
data
=
{
'channel_id'
:
cls
.
channel
_id
}
r
=
requests
.
post
(
url
,
data
=
data
)
.
json
()
if
r
[
'error'
]
==
0
:
print
(
'关闭直播间成功!'
)
@classmethod
@require_login
def
stream_info
(
cls
):
if
cls
.
stream_id
:
return
uri
=
'/api/live/get_live_info/anchor'
url
=
settings
.
BACKEND_ADMIN
+
uri
params
=
dict
(
settings
.
GENGMEI_PARAMS
,
channel_id
=
cls
.
channel_id
)
r
=
requests
.
get
(
url
,
params
=
params
)
.
json
()
cls
.
stream_id
=
r
[
'data'
][
'id'
]
@classmethod
def
live_status
(
cls
):
if
not
cls
.
stream_id
:
return
False
uri
=
'/api/janus/live/polling'
url
=
settings
.
BACKEND_ADMIN
+
uri
params
=
dict
(
settings
.
GENGMEI_PARAMS
,
stream_id
=
cls
.
stream_id
)
r
=
requests
.
get
(
url
,
params
=
params
)
.
json
()
return
not
r
[
'data'
][
'stream_status'
][
'is_finish'
]
testCase/live/test_case.py
deleted
100644 → 0
View file @
e982382b
import
requests
from
utils.gmhttp
import
require_login
from
.livecase
import
LiveCase
class
LiveXXX
(
LiveCase
):
@require_login
def
test_xxx
(
self
):
'''
to be continued
:return:
'''
# 直播id self.live_id
testCase/live/test_enter_live.py
0 → 100644
View file @
68ede6ea
import
requests
from
utils.gmhttp
import
require_login
from
.livecase
import
LiveCase
from
conf
import
settings
class
LiveEnter
(
LiveCase
):
'''进入直播间'''
def
setUp
(
self
):
uri
=
'/api/live/enter'
self
.
url
=
self
.
host
+
uri
self
.
params
=
dict
(
settings
.
GENGMEI_PARAMS
,
**
{
'channel_id'
:
self
.
channel_id
})
def
test_live_enter_visitor
(
self
):
'''
游客进入直播间
'''
rep
=
requests
.
get
(
self
.
url
,
params
=
self
.
params
)
.
json
()
assert
rep
[
'error'
]
==
0
,
rep
print
(
'游客进入直播间成功!'
)
@require_login
(
settings
.
LIVE_WATCHER
)
def
test_live_enter_user
(
self
):
'''
app用户进入直播间
'''
rep
=
requests
.
get
(
self
.
url
,
params
=
self
.
params
)
.
json
()
assert
rep
[
'error'
]
==
0
,
rep
print
(
'app用户进入直播间成功!'
)
@require_login
(
settings
.
LIVE_USER
)
def
test_live_enter_author
(
self
):
'''
主播进入直播间
'''
rep
=
requests
.
get
(
self
.
url
,
params
=
self
.
params
)
.
json
()
assert
rep
[
'error'
]
==
0
,
rep
print
(
'主播进入直播间成功!'
)
utils/gmhttp.py
View file @
68ede6ea
...
...
@@ -19,7 +19,6 @@ class LoginFailedException(Exception):
# 支持更换用户
def
require_login
(
arg
=
None
,
**
user_dict
):
'''
依然使用requests,只不过在使用过程中被替换成了gmhttp
...
...
@@ -84,7 +83,7 @@ class _Gmhttp(requests.Session):
self
.
params
=
deepcopy
(
self
.
_params
)
@classmethod
def
instance
(
cls
,
userinfo
):
def
instance
(
cls
,
**
userinfo
):
# 登录,如果phone和password有任意None 则使用默认账户
phone
=
userinfo
.
get
(
'phone'
,
_Gmhttp
.
_userinfo
[
'phone'
])
password
=
userinfo
.
get
(
'password'
,
_Gmhttp
.
_userinfo
[
'password'
])
...
...
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