Commit 7f0f13f2 authored by 杨彦's avatar 杨彦

add follow

parent bbd09a28
...@@ -5,4 +5,11 @@ ...@@ -5,4 +5,11 @@
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="pytest" />
</component>
</module> </module>
\ No newline at end of file
This diff is collapsed.
...@@ -48,3 +48,6 @@ ADD_SERVICE_MANY_ORER = 202 ...@@ -48,3 +48,6 @@ ADD_SERVICE_MANY_ORER = 202
MARK_SERVICE = 301 MARK_SERVICE = 301
UNDO_MARK_SERVICE = 302 UNDO_MARK_SERVICE = 302
DELETE_SERVICE_ORER = 401 DELETE_SERVICE_ORER = 401
USER_FOLLOW_ADD=500
USER_FOLLOW_DEL=501
\ No newline at end of file
...@@ -12,6 +12,9 @@ class LiveCase(unittest.TestCase): ...@@ -12,6 +12,9 @@ class LiveCase(unittest.TestCase):
channel_id = None channel_id = None
stream_id = None stream_id = None
service_ids = [5818403,588996,618573,510192] #单独的先写死 service_ids = [5818403,588996,618573,510192] #单独的先写死
user_id=None
is_following=None
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
...@@ -24,10 +27,13 @@ class LiveCase(unittest.TestCase): ...@@ -24,10 +27,13 @@ class LiveCase(unittest.TestCase):
cls.host = settings.BACKEND_ADMIN cls.host = settings.BACKEND_ADMIN
cls.create_live() cls.create_live()
cls.stream_info() cls.stream_info()
cls.follow_status()
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
cls.close_live() cls.close_live()
# cls.user_follow_del()
@classmethod @classmethod
@require_login @require_login
...@@ -81,6 +87,8 @@ class LiveCase(unittest.TestCase): ...@@ -81,6 +87,8 @@ class LiveCase(unittest.TestCase):
r = requests.get(url, params=params).json() r = requests.get(url, params=params).json()
cls.stream_id = r['data']['id'] cls.stream_id = r['data']['id']
@classmethod @classmethod
def live_status(cls): def live_status(cls):
if not cls.stream_id: if not cls.stream_id:
...@@ -91,6 +99,42 @@ class LiveCase(unittest.TestCase): ...@@ -91,6 +99,42 @@ class LiveCase(unittest.TestCase):
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
#@require_login(settings.LIVE_WATCHER)
def follow_status(cls):
if not cls.channel_id:
return
uri = '/api/live/get_live_info/audience'
url = settings.BACKEND_ADMIN + uri
params = dict(settings.GENGMEI_PARAMS, channel_id=cls.channel_id)
r = requests.get(url, params=params).json()
cls.is_following = r['data']['is_following']
cls.user_id = r['data']['user_id']
@classmethod
#@require_login(settings.LIVE_WATCHER)
def user_follow_add(cls):
uri='/api/user/follow/add'
url=settings.BACKEND_ADMIN+uri
data = {
"from_live":cls.stream_id,
"uid":cls.user_id
}
r=requests.post(url,data=data).json()
return r
@classmethod
#@require_login(settings.LIVE_WATCHER)
def user_follow_del(cls):
uri='/api/user/follow/del'
url=settings.BACKEND_ADMIN+uri
data = {
"uid":cls.user_id
}
r=requests.post(url,data=data).json()
return r
@classmethod @classmethod
@require_login(settings.LIVE_USER) @require_login(settings.LIVE_USER)
def live_services(cls): def live_services(cls):
...@@ -100,6 +144,8 @@ class LiveCase(unittest.TestCase): ...@@ -100,6 +144,8 @@ class LiveCase(unittest.TestCase):
r = requests.get(url, params=params).json() r = requests.get(url, params=params).json()
return r return r
# @classmethod # @classmethod
# def live_add_service(cls): # def live_add_service(cls):
# uri = '/api/janus/live/add_live_service' # uri = '/api/janus/live/add_live_service'
......
import requests
from utils.gmhttp import require_login
from .livecase import LiveCase
from conf import settings
import pytest
class LiveUserFollow(LiveCase):
# @pytest.mark.run(order=settings.USER_FOLLOW_ADD)
@require_login(settings.LIVE_WATCHER)
def test_live_follow_user(self):
'''
用户关注主播
'''
if self.is_following==False:
r = self.user_follow_add()
self.assertEqual(r['error'], 0, r)
print("用户关注主播成功")
else:
print("用户当前已经是关注状态")
import requests
from utils.gmhttp import require_login
from .livecase import LiveCase
from conf import settings
import pytest
class LiveUserUnFollow(LiveCase):
# @pytest.mark.run(order=settings.USER_FOLLOW_DEL)
@require_login(settings.LIVE_WATCHER)
def test_live_unfollow_user(self):
'''
用户关注主播
'''
if self.is_following==True:
r = self.user_follow_del()
self.assertEqual(r['error'], 0, r)
print("用户取消关注成功")
else:
print("用户当前非关注状态")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment