def setup_class(self): initdata.clearPhoto(test_parameter['db']) dbConnect.dbSetting(test_parameter['db'], [ "update remain_points set remain_points = 15000 where identity_id in( '" + idlist[2] + "', '" + idlist[3] + "')", "update gift_v2 set is_active = 1, deleted_at is NULL" ]) photo.createPhoto(test_parameter['broadcaster_token'], test_parameter['broadcaster_nonce'], test_parameter['prefix'], photo.createBody(*self.createPhotoList)) for i in range(2): photo.sendPhotoGift(test_parameter['broadcaster_token'], test_parameter['broadcaster_nonce'], test_parameter['prefix'], 1, self.giftId) time.sleep(1)
def setup_class(self): initdata.clearPhoto(test_parameter['db']) for i in range(3): body = photo.createBody(self.createPhotoList[i][0], self.createPhotoList[i][1], self.createPhotoList[i][2], self.createPhotoList[i][3], self.createPhotoList[i][4], self.createPhotoList[i][5]) photo.createPhoto(test_parameter['broadcaster_token'], test_parameter['broadcaster_nonce'], test_parameter['prefix'], body) res = photo.getPhotoList(test_parameter['broadcaster_token'], test_parameter['broadcaster_nonce'], test_parameter['prefix'], idlist[0], 10, 1) restext = json.loads(res.text) for i in restext['data']: self.photoIdList.append(i['id'])
def testInit(): createPhotoList = [ [ 'photo', 'https://d3eq1e23ftm9f0.cloudfront.net/story/photo/6e7103c048cd11ea83b942010a8c0017.png', '動態照片上傳', '', '', '108' ], [ '', 'https://d3eq1e23ftm9f0.cloudfront.net/story/photo/6e7103c048cd11ea83b942010a8c0017.png', '動態照片上傳,未設type跟gift category', '', '', '' ], [ 'video', '', '動態影片上傳', 'https://d3eq1e23ftm9f0.cloudfront.net/story/photo/096ee460b45c11eab2d142010a8c0017.png', 'https://d3eq1e23ftm9f0.cloudfront.net/story/vedio/ef79cfbab45c11eab2d142010a8c0017.mp4', '108' ] ] initdata.clearFansInfo(test_parameter['db']) initdata.clearPhoto(test_parameter['db']) api.changeRole(test_parameter['prefix'], test_parameter['backend_token'], test_parameter['backend_nonce'], [idList[0], idList[1]], 4) header['X-Auth-Token'] = test_parameter['user_token'] header['X-Auth-Nonce'] = test_parameter['user_nonce'] urlName = '/api/v2/identity/track' for i in range(2): body = {"liveMasterId": idList[i]} api.apiFunction(test_parameter['prefix'], header, urlName, 'post', body) time.sleep(1.5) array1 = [ 'broadcaster_token', 'broadcaster_nonce', 'broadcaster1_token', 'broadcaster1_nonce' ] for i in range(2): for j in range(2): body = photo.createBody(*createPhotoList[j]) photo.createPhoto(test_parameter[array1[i * 2]], test_parameter[array1[i * 2 + 1]], test_parameter['prefix'], body) time.sleep(5)
def getTestData(testName): testData = [] if testName == 'addPhoto': #scenario, token, nonce, body, expected testData = [ ('直播主上傳動態_照片', 'broadcaster_token', 'broadcaster_nonce', photo.createBody('photo', urlList[0], '動態照片上傳', '', '', '108'), 200), ('直播主上傳動態未給type,應預設', 'broadcaster_token', 'broadcaster_nonce', photo.createBody('', urlList[0], '動態照片上傳', '', '', '108'), 200), ('直播主上傳動態_影音檔', 'broadcaster_token', 'broadcaster_nonce', photo.createBody('video', '', '動態影片上傳', urlList[1], urlList[2], '108'), 200), ('直播主上傳動態_影音檔但未設禮物類別', 'broadcaster_token', 'broadcaster_nonce', photo.createBody('video', '', '動態影片上傳', urlList[1], urlList[2], ''), 200), ('直播主上傳動態_照片,但url不存在', 'broadcaster_token', 'broadcaster_nonce', photo.createBody('photo', urlList[3], '動態照片上傳', '', '', '108'), 404), ('直播主上傳動態_影音檔,但url不存在', 'broadcaster_token', 'broadcaster_nonce', photo.createBody('video', '', '動態影片上傳', urlList[3], urlList[2], '108'), 404), ('直播主上傳動態_影音檔,但預覧url空值', 'broadcaster_token', 'broadcaster_nonce', photo.createBody('video', '', '動態影片上傳', urlList[1], '', '108'), 406), ('直播主上傳動態_照片,但禮物類別不存在', 'broadcaster_token', 'broadcaster_nonce', photo.createBody('photo', urlList[0], '動態照片上傳', '', '', '333'), 404), ('token_nonce不存在', 'err_token', 'err_nonce', photo.createBody('photo', urlList[0], '動態照片上傳', '', '', '108'), 401), ('使用者上傳照片', 'user_token', 'user_nonce', photo.createBody('photo', urlList[0], '動態照片上傳', '', '', '108'), 403) ] elif testName == 'photolist': #scenario, token, nonce, masterId, items, pages, totalCount, expected testData = [('取得該直播主動態列表_有資料', 'backend_token', 'backend_nonce', 0, 10, 1, 3, '', 200), ('取得該直播主動態列表_無資料', 'broadcaster_token', 'broadcaster_nonce', 1, 10, 1, 0, '', 200), ('取得該直播主動態列表_指定item=1;page=1', 'user_token', 'user_nonce', 0, 1, 1, 3, '', 200), ('取得該直播主動態列表_有資料', 'user_token', 'user_nonce', 0, 10, 1, 3, '', 200), ('原直播主轉成一般user,其動態無法再取得', 'user_token', 'user_nonce', 0, 10, 1, 3, 'changeRole', 400), ('user被列入黑名單,無法取得該直播主的動態', 'user_token', 'user_nonce', 0, 10, 1, 3, 'black', 400), ('auth 不存在', 'err_token', 'err_nonce', 0, 10, 1, 3, '', 401)] elif testName == 'singlePhoto': #scenario, token, nonce, postId, action, isLike, likeNum, totalLike, comment, totalComment, expected (photo like合併驗證) testData = [('指定動態id', 'backend_token', 'backend_nonce', 1, '', False, 0, 0, '', 0, 200), ('指定動態id不存在', 'backend_token', 'backend_nonce', 0, '', False, 0, 0, '', 0, 200), ('對指定的動態id按喜歡', 'user_token', 'user_nonce', 1, 'like', True, 10, 10, '', 0, 200), ('指定有被按喜歡動態id', 'user1_token', 'user1_nonce', 1, '', False, 0, 10, '', 0, 200), ('指定有被加過評論的動態id', 'user1_token', 'user1_nonce', 1, 'comment', False, 0, 10, 'like 直播主😎🥳㊙️^-^!① ', 1, 200), ('指定已被刪除的動態id', 'user1_token', 'user1_nonce', 2, 'delete', False, 0, 10, '', 0, 400), ('原直播主轉成一般user,其動態無法再取得', 'user_token', 'user_nonce', 1, 'changeRole', False, 0, 10, '', 0, 400), ('user被列入黑名單,無法取得該直播主的動態', 'user_token', 'user_nonce', 1, 'black', False, 0, 10, '', 0, 400), ('auth 不存在', 'err_token', 'err_nonce', 1, '', False, 0, 10, '', 0, 401)] elif testName == 'updatePhoto': #scenario, token, nonce, body, origenal, action, expected testData = [ ('直播主修改個人動態說明_動態說明含emoji', 'broadcaster_token', 'broadcaster_nonce', { 'content': 'wahaha 😎🥳㊙️^-^!① %。。。' }, '動態照片上傳', '', 200), ('直播主修改個人動態說明_動態說明為空字串', 'broadcaster_token', 'broadcaster_nonce', { 'content': '' }, 'wahaha 😎🥳㊙️^-^!① %。。。', '', 200), ('直播主修改個人動態說明_body不正確', 'broadcaster_token', 'broadcaster_nonce', {}, '', '', 400), ('直播主修改不屬於自己的動態說明', 'broadcaster1_token', 'broadcaster1_nonce', { 'content': 'wahaha 😎🥳㊙️^-^!① %。。。' }, '', '', 401), ('直播主轉為非直播主,修改自己的動態說明', 'broadcaster_token', 'broadcaster_nonce', { 'content': 'wahaha 😎🥳㊙️^-^!① %。。。' }, '', 'changeRole', 401) ] elif testName == 'deletePhoto': #scenario, token, nonce, postId, action, totalCount, expected testData = [('直播主不可刪除非自己的動態 ', 'broadcaster1_token', 'broadcaster1_nonce', 1, '', 3, 400), ('直播主可刪除有加評論的動態', 'broadcaster_token', 'broadcaster_nonce', 1, 'comment', 2, 200), ('直播主可刪除有被按喜歡的動態', 'broadcaster_token', 'broadcaster_nonce', 2, 'like', 1, 200), ('直播主可刪除有被送禮物的動態', 'broadcaster_token', 'broadcaster_nonce', 3, 'sendGift', 0, 200)] elif testName == 'photoGift': #scenario, token, nonce, action, totalCount, expected testData = [('直播主無法查到非自己動態送禮明細', 'broadcaster1_token', 'broadcaster1_nonce', '', '', 400), ('禮物下架仍可在送禮記錄裡查到', 'broadcaster_token', 'broadcaster_nonce', 1, 'inactive', 1, 200), ('禮物已被刪除仍可在送禮記錄裡查到', 'broadcaster_token', 'broadcaster_nonce', 2, 'deleted', 1, 200), ('送禮者雖被列入黑名單,仍可在送禮記錄裡查到', 'broadcaster_token', 'broadcaster_nonce', 3, 'black', 1, 200), ('直播主轉成一般使用者則無法查詢送禮記錄', 'broadcaster_token', 'broadcaster_nonce', 3, 'changeRole', 1, 400)] return testData