Exemplo n.º 1
0
 def teardown_class(self):
     changelist = []
     changelist.append(idList[0])
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']
     api.change_roles(test_parameter['prefix'], header, changelist,
                      '4')  #轉回直播主
Exemplo n.º 2
0
 def testHistoryTalkWithCS(self):
     # 與客服的訊息不限時間
     sqlList = []
     changelist = []
     apiName = '/api/v2/identity/instantMessage/history?dialogId={id}&item=10&page=1'
     UpdateDatetime = datetime.fromtimestamp(int(
         time.time())) - timedelta(days=366)
     sqlList.append("update instant_message set create_at = '" +
                    UpdateDatetime.strftime('%Y-%m-%d %H:%M:%S') +
                    "' where dialog_id = '" + self.dialogIdList[0] + "'")
     dbConnect.dbSetting(test_parameter['db'], sqlList)
     apiName = apiName.replace('{id}', self.dialogIdList[0])
     #print(apiName)
     header['X-Auth-Token'] = test_parameter['user_token']
     header['X-Auth-Nonce'] = test_parameter['user_nonce']
     res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get',
                           None)
     restext = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restext['totalCount'] == 2
     changelist.append(idList[3])
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']
     api.change_roles(test_parameter['prefix'], header, changelist,
                      '4')  #轉成直播主
     header['X-Auth-Token'] = test_parameter['user_token']
     header['X-Auth-Nonce'] = test_parameter['user_nonce']
     res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get',
                           None)
     restext = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restext['totalCount'] == 2
Exemplo n.º 3
0
 def testLiveController(self):        
     midlist = []
     apilink = '/api/v2/identity/{{uid}}/role/liveController?item=20&page=1'
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']         
     #非任何人的場控   
     uid = api.search_user(test_parameter['prefix'], test_parameter['user_acc'], header)
     mid = api.search_user(test_parameter['prefix'], test_parameter['broadcaster_acc'], header)
     linkadd = apilink.replace('{{uid}}', uid)
     res = api.apiFunction(test_parameter['prefix'], header, linkadd, 'get', '')
     restext = json.loads(res.text)
     assert int(res.status_code / 100) == 4
     assert restext['Message'] == "User's live controller is not existed."
     #設為場控
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']         
     addController = '/api/v2/liveMaster/liveController'
     body = {"userId": uid}
     res = api.apiFunction(test_parameter['prefix'], header, addController, 'post', body)
     assert int(res.status_code / 100) == 2
     res = api.apiFunction(test_parameter['prefix'], header, linkadd, 'get', '')
     restext = json.loads(res.text)
     assert int(res.status_code / 100) == 2
     assert restext['data'][0]['userId'] == mid
     assert restext['totalCount'] == 1
     #直播主變成一般用戶 
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']    
     midlist.append(mid)     
     api.change_roles(test_parameter['prefix'], header, midlist, 5)         
     res = api.apiFunction(test_parameter['prefix'], header, linkadd, 'get', '')
     restext = json.loads(res.text)
     assert int(res.status_code / 100) == 4
     assert restext['Message'] == "User's live controller is not existed."
Exemplo n.º 4
0
def testGetOpenType(test_input, expected, isChangeRole):
    if isChangeRole:
        changelist = [idlist[0]]
        header['X-Auth-Token'] = test_parameter['backend_token']
        header['X-Auth-Nonce'] = test_parameter['backend_nonce']
        api.change_roles(test_parameter['prefix'], header, changelist,
                         '5')  #轉成一般用戶
    header['X-Auth-Token'] = test_input[0]
    header['X-Auth-Nonce'] = test_input[1]
    apiName = '/api/v2/liveMaster/zego/liveRoom'
    res = api.apiFunction(test_parameter['prefix'], header, apiName, 'post',
                          {})
    restext = json.loads(res.text)
    pprint(restext)
    assert res.status_code // 100 == expected[0]
    if expected[0] == 2:
        rid = sundry.Openroom(test_parameter['prefix'], header, 5, True,
                              restext['data']['roomId'], 'Zegp開播', 5)
        assert restext['data']['roomId'] == rid
        assert restext['data']['streamId'] > 0
    if isChangeRole:
        changelist = [idlist[0]]
        header['X-Auth-Token'] = test_parameter['backend_token']
        header['X-Auth-Nonce'] = test_parameter['backend_nonce']
        api.change_roles(test_parameter['prefix'], header, changelist,
                         '4')  #轉回直播主
Exemplo n.º 5
0
 def setup_class(self):
     sqlList = ['truncate table user_notification_settings']
     dbConnect.dbSetting(test_parameter['db'], sqlList)
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']   
     self.mid = api.search_user(test_parameter['prefix'], test_parameter['broadcaster_acc'], header)   
     changelist = [self.mid]  
     api.change_roles(test_parameter['prefix'], header, changelist, 4) #一般用戶:5;直播主:4
Exemplo n.º 6
0
 def teardown_class(self):
     #移除場控身份
     #回復直播主身份
     midlist = []
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']         
     mid = api.search_user(test_parameter['prefix'], test_parameter['broadcaster_acc'], header)  
     midlist.append(mid)    
     api.change_roles(test_parameter['prefix'], header, midlist, 4)         
     uid = api.search_user(test_parameter['prefix'], test_parameter['user_acc'], header)    
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']         
     delController = '/api/v2/liveMaster/liveController/' + uid
     api.apiFunction(test_parameter['prefix'], header, delController, 'delete', '')        
Exemplo n.º 7
0
def createAccount(account):
    header = {
        'Connection': 'Keep-alive',
        'X-Auth-Token': '',
        'X-Auth-Nonce': ''
    }
    header['X-Auth-Token'] = test_parameter['backend_token']
    header['X-Auth-Nonce'] = test_parameter['backend_nonce']
    idlist = []
    api.register(test_parameter['prefix'], account, header)
    uid = api.search_user(test_parameter['prefix'], account, header)
    print('uid=%s' % uid)
    api.change_user_mode(test_parameter['prefix'], uid, -2, header)
    api.change_user_mode(test_parameter['prefix'], uid, 1, header)
    idlist.append(uid)
    api.change_roles(test_parameter['prefix'], header, idlist, 5)
    return
Exemplo n.º 8
0
def editInit():
    initdata.clearVoice(test_parameter['db'])
    sundry.clearCache(test_parameter['db'])
    for i in range(2):
        account = 'broadcaster01' + str(i)
        createVoiceRoom(account)
    header['X-Auth-Token'] = test_parameter['broadcaster011']['token']
    header['X-Auth-Nonce'] = test_parameter['broadcaster011']['nonce']
    for i in range(12, 15):
        admin = 'broadcaster0' + str(i)
        apiName = '/api/v2/liveMaster/voiceChat/admin'
        body = {'roomId': 2, 'userId': test_parameter[admin]['id']}
        api.apiFunction(test_parameter['prefix'], header, apiName, 'post',
                        body)
    apiName = '/api/v2/liveMaster/voiceChat/admin/2/' + test_parameter[
        'broadcaster013']['id']
    api.apiFunction(test_parameter['prefix'], header, apiName, 'delete', None)
    header['X-Auth-Token'] = test_parameter['tl-lisa']['token']
    header['X-Auth-Nonce'] = test_parameter['tl-lisa']['nonce']
    api.change_roles(test_parameter['prefix'], header,
                     [test_parameter['broadcaster014']['id']], 5)
Exemplo n.º 9
0
 def testLivemasterChangeToUser(self):
     # 直播主轉成一般user;列表會顯示,但無法互傳訊息
     changelist = []
     valuesList = []
     changelist.append(idList[0])
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']
     api.change_roles(test_parameter['prefix'], header, changelist,
                      '5')  #轉成一般用戶
     self.updatePoint(20, idList[3])
     apiName = '/api/v2/identity/instantMessage'
     header['X-Auth-Token'] = test_parameter['user_token']
     header['X-Auth-Nonce'] = test_parameter['user_nonce']
     content = '哈囉大主播,我是你的小粉1號'
     valuesList.extend([idList[0], '', 'text', content, '', '', ''])
     body = createBody(valuesList)
     res = api.apiFunction(test_parameter['prefix'], header, apiName,
                           'post', body)
     assert res.status_code // 100 == 4
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']
     api.change_roles(test_parameter['prefix'], header, changelist,
                      '4')  #轉回直播主
Exemplo n.º 10
0
def setup_module():
    initdata.get_test_data(env, test_parameter)
    header['X-Auth-Token'] = test_parameter['tl-lisa']['token']
    header['X-Auth-Nonce'] = test_parameter['tl-lisa']['nonce']
    api.change_roles(test_parameter['prefix'], header,
                     [test_parameter['broadcaster014']['id']], 4)
Exemplo n.º 11
0
def teardown_module():
    print('i am teardown')
    header['X-Auth-Token'] = test_parameter['backend_token']
    header['X-Auth-Nonce'] = test_parameter['backend_nonce']   
    api.change_roles(test_parameter['prefix'], header, [idList[0]], '4') #轉回直播主
Exemplo n.º 12
0
 def changeRole(self, roleType):
     header['Content-Type'] = 'application/json'
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce'] 
     changelist = [self.mid]  
     api.change_roles(test_parameter['prefix'], header, changelist, roleType) #一般用戶:5;直播主:4