Esempio n. 1
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
Esempio n. 2
0
 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)
Esempio n. 3
0
 def testAdd(self, scenario, token, nonce, body, expected):
     res = photo.createPhoto(test_parameter[token], test_parameter[nonce],
                             test_parameter['prefix'], body)
     restext = json.loads(res.text)
     assert res.status_code == expected
     assert restext['Status'] == Msg[expected]['Status']
     assert restext['Message'] in Msg[expected]['Message']
Esempio n. 4
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'])
Esempio n. 5
0
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)
Esempio n. 6
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