Esempio n. 1
0
 def testUserInBlack(self):
     # 用戶在A直播主黑名單內;但不在B直播主名單內
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
     apiName = '/api/v2/liveMaster/newUsersToSendIM'
     body = {'userId': idList[0]}
     api.add_block_user(test_parameter['prefix'], header, body)
     res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get',
                           None)
     restext = json.loads(res.text)
     if idList[0] in self.newlist:
         self.newlist.remove(idList[0])
     for i in restext['data']:
         assert i['id'] in self.newlist
     assert res.status_code // 100 == 2
     assert restext['totalCount'] == len(self.newlist)
     assert restext['sentCount'] == 0
     api.delete_block_user(test_parameter['prefix'], header, idList[0])
     self.newlist.append(idList[0])
     header['X-Auth-Token'] = test_parameter['broadcaster1_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster1_nonce']
     apiName = '/api/v2/liveMaster/newUsersToSendIM'
     res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get',
                           None)
     restext = json.loads(res.text)
     for i in restext['data']:
         assert i['id'] in self.newlist
     assert res.status_code // 100 == 2
     assert restext['totalCount'] == len(self.newlist)
     assert restext['sentCount'] == 0
Esempio n. 2
0
 def test_get_comment(self, scenario, token, nonce, blackId, suspendedId,
                      item, page, expected, totalCount):
     if blackId >= 0:
         header['X-Auth-Token'] = test_parameter['broadcaster_token']
         header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
         api.add_block_user(test_parameter['prefix'], header,
                            {'userId': idList[blackId]})
     if suspendedId >= 0:
         header['X-Auth-Token'] = test_parameter['backend_token']
         header['X-Auth-Nonce'] = test_parameter['backend_nonce']
         api.change_user_mode(test_parameter['prefix'], idList[suspendedId],
                              -2, header)
     time.sleep(5)
     header['X-Auth-Token'] = test_parameter[token]
     header['X-Auth-Nonce'] = test_parameter[nonce]
     res = api.get_comment_list(test_parameter['prefix'], header, self.pid,
                                item, page)
     assert res.status_code // 100 == expected
     if expected == 2:
         restext = json.loads(res.text)
         assert len(restext['data']) <= item
         assert restext['totalCount'] == totalCount
         if page == 1:
             assert restext['data'][0]['createAt'] >= restext['data'][1][
                 'createAt']
     if blackId >= 0:
         assert str(restext['data']).find(idList[blackId]) < 0
     if suspendedId >= 0:
         assert str(restext['data']).find(idList[suspendedId]) < 0
Esempio n. 3
0
 def testLiveMasterBlackUser(self):
     # 直播主封鎖該名user,該user仍可傳訊息
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
     body = {'userId': idList[3]}
     api.add_block_user(test_parameter['prefix'], header, body)
     valuesList = []
     sqlStr = "select experience, identity_id from user_experience where identity_id in ('" + idList[
         0] + "', '" + idList[3] + "') order by identity_id"
     bfExperience = self.getDBData(sqlStr)
     self.updatePoint(20, idList[3])
     #直播主封鎖該名user;直播主聊天室無該名user,但該user卻可看到聊天室
     apiName = '/api/v2/identity/instantMessage/roomList?item=20&page=1'
     res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get',
                           None)
     assert res.status_code // 100 == 2
     restext = json.loads(res.text)
     assert idList[3] not in restext['data']
     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)
     assert res.status_code // 100 == 2
     restext = json.loads(res.text)
     assert restext['data']['userId'] == idList[0]
     dialogId = restext['data']['dialogId']
     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)
     restest = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restest['data']['pointLeft'] == 0
     afExperience = self.getDBData(sqlStr)
     for i in range(2):
         if bfExperience[i][1] == idList[0]:
             assert afExperience[i][0] - bfExperience[i][0] == 20
         else:
             assert afExperience[i][0] - bfExperience[i][0] == 60
     #直播主無法取得黑名單聊天室的內容;但被黑的user卻仍可以看到
     apiName = '/api/v2/identity/instantMessage/history?dialogId=' + dialogId
     res = api.apiFunction(test_parameter['prefix'], header, apiName,
                           'post', body)
     restest = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restest['data']['receiver'] == idList[0]
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
     res = api.apiFunction(test_parameter['prefix'], header, apiName,
                           'post', body)
     restest = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restest['data'] == []
Esempio n. 4
0
 def testUserInBlack(self):
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
     body = {'userId': userList[0]}
     api.add_block_user(test_parameter['prefix'], header, body)
     stime = (datetime.today()).replace(hour=0, minute=0, second=0)
     apiName = '/api/v2/liveMaster/giftGiversToSendIM?startTime={sTime}&endTime={eTime}&item=10&page=1'
     apiName = apiName.replace('{sTime}',
                               str(int(datetime.timestamp(stime))))
     apiName = apiName.replace('{eTime}', str(int(time.time())))
     res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get',
                           None)
     restext = json.loads(res.text)
     assert userList[0] not in restext['data']
Esempio n. 5
0
 def test_case7(self):
     #8.重複加入黑名單會回報錯誤
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
     body = {'userId': idlist[2]}
     res = api.add_block_user(test_parameter['prefix'], header, body)
     assert res.status_code // 100 == 4
Esempio n. 6
0
 def test_case6(self):
     #7.json空值
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
     body = {}
     res = api.add_block_user(test_parameter['prefix'], header, body)
     assert res.status_code // 100 == 4
Esempio n. 7
0
 def test_case5(self):
     #6.token/nonce不存在
     header['X-Auth-Token'] = test_parameter['err_token']
     header['X-Auth-Nonce'] = test_parameter['err_nonce']
     body = {'userId': idlist[1]}
     res = api.add_block_user(test_parameter['prefix'], header, body)
     assert res.status_code // 100 == 4
Esempio n. 8
0
 def test_case2(self):
     #2.輸入不正確的uuid
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
     body = {'userId': '123459BB'}
     res = api.add_block_user(test_parameter['prefix'], header, body)
     assert res.status_code // 100 == 4
Esempio n. 9
0
 def test_case1(self):
     #輸入正確的uuid
     #被黑該帳號無法搜尋到該直播主
     #被黑追蹤清單看不到該直播主
     #被黑粉絲清單不受影響
     #被黑直播主開播不會收到開播通知
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
     body = {'userId': idlist[2]}
     res = api.add_block_user(test_parameter['prefix'], header, body)
     assert res.status_code // 100 == 2
     res = api.get_block_user(test_parameter['prefix'], header, '10', '1')
     restext = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restext['data'][0]['userId'] == idlist[2]
     header['X-Auth-Token'] = test_parameter['user_token']
     header['X-Auth-Nonce'] = test_parameter['user_nonce']
     body = {'liveMasterLoginId': 'api'}
     res = api.search_master(test_parameter['prefix'], header, body, '10',
                             '0')
     restext = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert len(restext['liveMasters']) == 0