def sendGiftToPost(masterid, userid): sql = "select g.id, g.point from gift g join gift_category gc on category_id = gc.id where gc.type = 'post_gif'" dbResult = dbConnect.dbQuery(test_parameter, sql) giftId = dbResult[0][0] giftPoint = dbResult[0][1] result = api.user_login(test_parameter['prefix'], 'broadcaster100', test_parameter['user_pass']) header['X-Auth-Token'] = result['token'] header['X-Auth-Nonce'] = result['nonce'] apiName = '/api/v2/liveMaster/photoPost' body = {"photoPath": test_parameter['photo_url'], "content": "動態送禮。。測試中"} api.apiFunction(test_parameter['prefix'], header, apiName, 'post', body) apiName = '/api/v2/liveMaster/' + masterid + '/photoPost?item=5&page=1' res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get', None) restext = json.loads(res.text) postId = restext['data'][0]['id'] result = api.user_login(test_parameter['prefix'], 'track0077', test_parameter['user_pass']) header['X-Auth-Token'] = result['token'] header['X-Auth-Nonce'] = result['nonce'] apiName = '/api/v2/identity/sendGift' body = {'giftId': giftId, 'postId': postId} api.apiFunction(test_parameter['prefix'], header, apiName, 'post', body) totalPoint[userid] += giftPoint totalMaster[masterid] += giftPoint newMaster[masterid] += giftPoint
def OneToOneMessage(): result = api.user_login(test_parameter['prefix'], 'broadcaster100', test_parameter['user_pass']) header['X-Auth-Token'] = result['token'] header['X-Auth-Nonce'] = result['nonce'] apiName = '/api/v2/liveMaster/instantMessage' content = '哈囉,你好。歡迎來到Truelove😄😄😄 ' body = { "receiver": URlist[2], "msgType": "text", "textContent": content, "imageUrl": "", "previewUrl": "", "videoUrl": "", "origin": "giftGiversToSendIM" } api.apiFunction(test_parameter['prefix'], header, apiName, 'post', body) apiName = '/api/v2/identity/instantMessage' header['X-Auth-Token'] = test_parameter['user_token'] header['X-Auth-Nonce'] = test_parameter['user_nonce'] content = '哈囉,你好。我是你的小粉絲😄😄😄 ' body = { "receiver": BClist[15], "msgType": "text", "textContent": content, "imageUrl": "", "previewUrl": "", "videoUrl": "", "origin": "giftGiversToSendIM" } api.apiFunction(test_parameter['prefix'], header, apiName, 'post', body) totalPoint[URlist[2]] += 20 totalMaster[BClist[15]] += 20 newMaster[BClist[15]] += 20
def OneToOneMessage(): sqlList = [] sqlList.append("update remain_points set remain_points = 50 where identity_id = '" + URlist[2] + "'") dbConnect.dbSetting(test_parameter['db'], sqlList) result = api.user_login(test_parameter['prefix'], 'broadcaster100', test_parameter['user_pass']) header['X-Auth-Token'] = result['token'] header['X-Auth-Nonce'] = result['nonce'] apiName = '/api/v2/liveMaster/instantMessage' content = '哈囉,你好。歡迎來到Truelove😄😄😄 ' body = { "receiver": URlist[2], "msgType": "text", "textContent": content, "imageUrl": "", "previewUrl": "", "videoUrl": "", "origin": "giftGiversToSendIM" } api.apiFunction(test_parameter['prefix'], header, apiName, 'post', body) apiName = '/api/v2/identity/instantMessage' header['X-Auth-Token'] = test_parameter['user_token'] header['X-Auth-Nonce'] = test_parameter['user_nonce'] content = '哈囉,你好。我是你的小粉絲😄😄😄 ' body = { "receiver": BClist[15], "msgType": "text", "textContent": content, "imageUrl": "", "previewUrl": "", "videoUrl": "", "origin": "giftGiversToSendIM" } api.apiFunction(test_parameter['prefix'], header, apiName, 'post', body) totalPoint[URlist[2]] += 20
def testReceive10Message(self): # 用戶已收到10個訊息即不會再被挑選出 for i in range(12): liveAccount = 'broadcaster0' + str(30 + i) result = api.user_login(test_parameter['prefix'], liveAccount, test_parameter['user_pass']) header['X-Auth-Token'] = result['token'] header['X-Auth-Nonce'] = result['nonce'] self.sendMessage(idList[2], 'newUsersToSendIM') if idList[2] in self.newlist: self.newlist.remove(idList[2]) header['X-Auth-Token'] = test_parameter['broadcaster_token'] header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce'] apiName = '/api/v2/liveMaster/newUsersToSendIM' res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get', None) restext = json.loads(res.text) pprint(restext) assert res.status_code // 100 == 2 for i in restext['data']: assert i['id'] in self.newlist assert restext['totalCount'] == len(self.newlist) assert restext['sentCount'] == 1
def setup_class(self): result = api.user_login(test_parameter['prefix'], 'broadcaster010', '123456') self.broadcaster['X-Auth-Token'] = result['token'] self.broadcaster['X-Auth-Nonce'] = result['nonce']