Exemplo n.º 1
0
def f():
    giftId = 887  #'234df236-8826-4938-8340-32f39df43ed1'; category=108(post_gift)
    giftId1 = 736  #'e5741caa-2924-4e22-a955-02a4f50f382d'; category=65(非post_gift)
    testData = []
    photoId = photo.getPhotoList(test_parameter['broadcaster_token'],
                                 test_parameter['broadcaster_nonce'],
                                 test_parameter['prefix'], idlist[0])
    testData = [([
        test_parameter['user_token'], test_parameter['user_nonce'], 10000,
        giftId, photoId[0]
    ], 2),
                ([
                    test_parameter['user_token'], test_parameter['user_nonce'],
                    10000, giftId1, photoId[0]
                ], 4),
                ([
                    test_parameter['user_token'], test_parameter['user_nonce'],
                    0, giftId, photoId[0]
                ], 4),
                ([
                    test_parameter['user_token'], test_parameter['user_nonce'],
                    10000, '1234454', photoId[0]
                ], 4),
                ([
                    test_parameter['user_token'], test_parameter['user_nonce'],
                    10000, giftId, 0
                ], 4),
                ([
                    test_parameter['err_token'], test_parameter['err_nonce'],
                    10000, giftId, photoId[0]
                ], 4)]
    return testData
Exemplo n.º 2
0
def sendPostGift(timeList, today, yesterday, thisWeek, thisMonth, lastMonth):
    sqlStr = "select id, point from gift where category_id = 108 and status = 1"
    result = dbConnect.dbQuery(test_parameter['db'], sqlStr)
    giftId = result[0][0]
    point = result[0][1]
    photo.createPhoto(test_parameter['broadcaster_token'],
                      test_parameter['broadcaster_nonce'],
                      test_parameter['prefix'], test_parameter['photo_url'], 3)
    photoId = photo.getPhotoList(test_parameter['broadcaster_token'],
                                 test_parameter['broadcaster_nonce'],
                                 test_parameter['prefix'], idList[2])
    photo.sendPhotoGift(test_parameter['user1_token'],
                        test_parameter['user1_nonce'],
                        test_parameter['prefix'], photoId[0], giftId)
    if idList[1] in today:
        today[idList[1]] += point
    else:
        today[idList[1]] = point
    if idList[1] in thisMonth:
        thisMonth[idList[1]] += point
    else:
        thisMonth[idList[1]] = point
    if idList[1] in thisWeek:
        thisWeek[idList[1]] += point
    else:
        thisWeek[idList[1]] = point
Exemplo n.º 3
0
 def testGetPhotolist(self, scenario, token, nonce, masterId, items, pages,
                      totalCount, action, expected):
     actionDic = {
         'block': {
             'funName':
             api.blockUser,
             'parameter': [
                 test_parameter['prefix'],
                 test_parameter['broadcaster_token'],
                 test_parameter['broadcaster_nonce'], idlist[2]
             ]
         },
         'changeRole': {
             'funName':
             api.changeRole,
             'parameter': [
                 test_parameter['prefix'], test_parameter['backend_token'],
                 test_parameter['backend_nonce'], [idlist[0]], 5
             ]
         }
     }
     if action != '':
         actionDic[action]['funName'](*actionDic[action]['parameter'])
     time.sleep(30)
     res = photo.getPhotoList(test_parameter[token], test_parameter[nonce],
                              test_parameter['prefix'], idlist[0], items,
                              pages)
     restext = json.loads(res.text)
     assert res.status_code == expected
     assert restext['Status'] == Msg[expected]['Status']
     assert restext['Message'] in Msg[expected]['Message']
     if expected == 200:
         assert restext['totalCount'] == totalCount
         assert restext['data'][0]['id'] > restext['data'][1]['id']
         if totalCount == 0:
             assert len(restext['data']) == 0
         else:
             assert len(restext['data']) <= items
             for i in len(restext):
                 assert restext['data'][i][
                     'content'] == self.createPhotoList[abs(i - 2)][2]
                 assert restext['data'][i]['owner']['id'] == idlist[0]
                 assert len(
                     restext['data'][i]['owner']['profilePicture']) > 0
                 if restext['data'][i]['type'] == 'photo':
                     assert restext['data'][i][
                         'photoPath'] == self.createPhotoList[abs(i - 2)][1]
                     assert restext['data'][i]['giftCategoryId'] == int(
                         self.createPhotoList[abs(i - 2)][5])
                 else:
                     assert restext['data'][i][
                         'videoPath'] == self.createPhotoList[abs(i - 2)][3]
                     assert restext['data'][i][
                         'previewPath'] == self.createPhotoList[abs(i -
                                                                    2)][4]
                     assert restext['data'][i]['giftCategoryId'] == int(
                         self.createPhotoList[abs(i - 2)][5])
Exemplo n.º 4
0
def sendGift():
    #print('sendGift')
    sqlList = [
        "update remain_points set remain_points = 2000 where identity_id = '" +
        idList[1] + "'"
    ]
    dbConnect.dbSetting(test_parameter['db'], sqlList)
    photoId = photo.getPhotoList(test_parameter['user_token'],
                                 test_parameter['user_nonce'],
                                 test_parameter['prefix'], idList[0])
    photo.sendPhotoGift(test_parameter['user_token'],
                        test_parameter['user_nonce'], test_parameter['prefix'],
                        photoId[0], 888)
    return
Exemplo n.º 5
0
 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'])
Exemplo n.º 6
0
 def testDeletePhoto(self, scenario, token, nonce, postId, action,
                     totalCount, expected):
     actionDic = {
         'like': {
             'funName':
             photo.likePhoto,
             'parameter': [
                 test_parameter[token], test_parameter[nonce],
                 test_parameter['prefix'], postId, 10
             ]
         },
         'sendGift': {
             'funName':
             photo.sendPhotoGift,
             'parameter': [
                 test_parameter['broadcaster_token'],
                 test_parameter['broadcaster_nonce'],
                 test_parameter['prefix'], postId,
                 '234df236-8826-4938-8340-32f39df43ed1'
             ]
         },
         'comment': {
             'funName':
             photo.addComment,
             'parameter': [
                 test_parameter[token], test_parameter[nonce],
                 test_parameter['prefix'], postId, '測試有註解也可正常刪除'
             ]
         }
     }
     if action != '':
         actionDic[action]['funName'](*actionDic[action]['parameter'])
     time.sleep(30)
     res = photo.delPhoto(test_parameter[token], test_parameter[nonce],
                          test_parameter['prefix'], postId)
     restext = json.loads(res.text)
     assert res.status_code == expected
     assert restext['Status'] == Msg[expected]['Status']
     assert restext['Message'] in Msg[expected]['Message']
     res = photo.getPhotoList(test_parameter[token], test_parameter[nonce],
                              test_parameter['prefix'], idlist[0], '10',
                              '1')
     restext = json.loads(res.text)
     restext['totalCount'] == totalCount
Exemplo n.º 7
0
class TestSendGiftToPhoto():
    giftUUID = '234df236-8826-4938-8340-32f39df43ed1'
    postGetTotalPoint = 0
    photo.createPhoto(test_parameter['broadcaster_token'],
                      test_parameter['broadcaster_nonce'],
                      test_parameter['prefix'], test_parameter['photo_url'], 3)
    photoId = photo.getPhotoList(test_parameter['broadcaster_token'],
                                 test_parameter['broadcaster_nonce'],
                                 test_parameter['prefix'], idlist[0])

    @pytest.mark.parametrize("test_input, expected", f())
    def testSendGift(self, test_input, expected):
        sqlList = []
        sqlList.append("update remain_points set remain_points = " +
                       str(test_input[2]) + " where identity_id = '" +
                       idlist[2] + "'")
        dbConnect.dbSetting(test_parameter['db'], sqlList)
        if expected == 2:
            sqlStr = "select experience, identity_id from user_experience where identity_id in ('" + idlist[
                0] + "', '" + idlist[2] + "') order by identity_id"
            bfExperience = dbConnect.dbQuery(test_parameter['db'], sqlStr)
        header['X-Auth-Token'] = test_input[0]
        header['X-Auth-Nonce'] = test_input[1]
        apiName = '/api/v2/identity/sendGift'
        body = {'giftId': test_input[3], 'postId': test_input[4]}
        res = api.apiFunction(test_parameter['prefix'], header, apiName,
                              'post', body)
        #pprint(json.loads(res.text))
        assert res.status_code // 100 == expected
        if expected == 2:
            restext = json.loads(res.text)
            self.postGetTotalPoint += 1000
            assert restext['data']['pointLeft'] == 9000
            assert restext['data']['postPoint'] == self.postGetTotalPoint
            sqlStr = "select experience, identity_id from user_experience where identity_id in ('" + idlist[
                0] + "', '" + idlist[2] + "') order by identity_id"
            afExperience = dbConnect.dbQuery(test_parameter['db'], sqlStr)
            for i in range(2):
                if bfExperience[i][1] == idlist[0]:
                    assert afExperience[i][0] - bfExperience[i][0] == 1000
                else:
                    assert afExperience[i][0] - bfExperience[i][0] == 3000