コード例 #1
0
 def testCSGetOverhalfYear(self):
     # 客服可取得半年內的資料
     sqlList = []
     apiName = '/api/v2/identity/instantMessage/history?dialogId={id}&item=10&page=1'
     UpdateDatetime = datetime.fromtimestamp(int(
         time.time())) - timedelta(days=183)
     sqlList.append("update instant_message set create_at = '" +
                    UpdateDatetime.strftime('%Y-%m-%d %H:%M:%S') +
                    "' where dialog_id = '" + self.dialogIdList[0] + "'")
     dbConnect.dbSetting(test_parameter['db'], sqlList)
     apiName = apiName.replace('{id}', self.dialogIdList[0])
     header['X-Auth-Token'] = test_parameter['liveController1_token']
     header['X-Auth-Nonce'] = test_parameter['liveController1_nonce']
     res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get',
                           None)
     restext = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restext['totalCount'] == 2
     sqlList.clear()
     UpdateDatetime = datetime.fromtimestamp(int(
         time.time())) - timedelta(days=184)
     sqlList.append("update instant_message set create_at = '" +
                    UpdateDatetime.strftime('%Y-%m-%d %H:%M:%S') +
                    "' where dialog_id = '" + self.dialogIdList[0] + "'")
     dbConnect.dbSetting(test_parameter['db'], sqlList)
     apiName = apiName.replace('{id}', self.dialogIdList[0])
     header['X-Auth-Token'] = test_parameter['liveController1_token']
     header['X-Auth-Nonce'] = test_parameter['liveController1_nonce']
     res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get',
                           None)
     restext = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restext['totalCount'] == 0
コード例 #2
0
 def testRegisterToActive(self, condition, expected):
     url = '/api/v2/identity/register/email/activate'
     tempToken, actCode = self.getActiveCode()
     body = {
         "tmpToken": tempToken,
         "activateCode": actCode,
         "pushToken": "emailRegrjhjayegrkldfkhgdkfasd"
     }
     if condition == 'tokenWrong':
         body["tmpToken"] = "wJalrXUtnFEMI..."
     elif condition == 'codeWrong':
         body["activateCode"] = "214520"
     elif condition == 'wihtoutPushToken':
         body["pushToken"] = ""
     elif condition == 'expired':
         sqlStr = "select max(id) from identity_email_register_history"
         result = dbConnect.dbQuery(test_parameter['db'], sqlStr)
         sqlList = [
             "update identity_email_register_history set expires_in = 1  where id = "
             + str(result[0][0])
         ]
         dbConnect.dbSetting(test_parameter['db'], sqlList)
         time.sleep(2)
     pprint(condition)
     res = api.apiFunction(test_parameter['prefix'], self.head, url, 'post',
                           body)
     assert res.status_code // 100 == expected
     if res.status_code // 100 == 2:
         restext = json.loads(res.text)
         sqlStr = "select nickname from identity where token = '" + restext[
             'data']['token'] + "' and  nonce = '" + restext['data'][
                 'nonce'] + "'"
         record = dbConnect.dbQuery(test_parameter['db'], sqlStr)
         #pprint(record)
         assert '初樂用戶 ' in record[0][0]
コード例 #3
0
 def setup_class(self):
     sqlList = []
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']                  
     self.idlist.append(api.search_user(test_parameter['prefix'], test_parameter['broadcaster_acc'], header))
     self.idlist.append(api.search_user(test_parameter['prefix'], test_parameter['broadcaster1_acc'], header))
     self.idlist.append(api.search_user(test_parameter['prefix'], test_parameter['user_acc'], header))        
     self.idlist.append(api.search_user(test_parameter['prefix'], test_parameter['user1_acc'], header))        
     getLinkAddr = '/api/v2/backend/announcement/list?item=1000&page=1'
     delLinkaddr = '/api/v2/backend/announcement/{announcementid}'   
     res = api.apiFunction(test_parameter['prefix'], header, getLinkAddr, 'get', '')
     restext = json.loads(res.text)
     for i in restext['data']:
         linkAddr = delLinkaddr.replace('{announcementid}', str(i['id']))
         res = api.apiFunction(test_parameter['prefix'], header, linkAddr, 'delete', '')
     #update token
     sqlstr = "update identity set push_token = '" +  "' where id in ('"
     for i in range(4):
         sqlstr += self.idlist[i] 
         if i < 3:
             sqlstr += "', '"  
         else:
             sqlstr += "')"
     sqlList.append(sqlstr)  
     dbConnect.dbSetting(test_parameter['db'], sqlList)     
コード例 #4
0
 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
コード例 #5
0
ファイル: test_getnewuserlist.py プロジェクト: tl-lisa/v2api
 def testUserLevelOver10(self):
     # 用戶等級大於青銅10
     sqlList = []
     sqlList.append(
         "update user_experience set experience = experience + 15000 where identity_id = '"
         + idList[3] + "'")
     dbConnect.dbSetting(test_parameter['db'], sqlList)
     if idList[3] in self.newlist:
         self.newlist.remove(idList[3])
     apiName = '/api/v2/liveMaster/newUsersToSendIM'
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
     res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get',
                           None)
     restext = json.loads(res.text)
     pprint(restext)
     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
     sqlList.clear()
     sqlList.append(
         "update user_experience set experience = experience - 15000 where identity_id = '"
         + idList[3] + "'")
     dbConnect.dbSetting(test_parameter['db'], sqlList)
     self.newlist.append(idList[3])
コード例 #6
0
ファイル: test_getnewuserlist.py プロジェクト: tl-lisa/v2api
 def setup_class(self):
     sqlList = []
     experience = 11662
     dtDay = (datetime.today() -
              timedelta(days=8 + datetime.today().weekday()) -
              timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S')
     sqlStr1 = "update identity set create_at = '" + dtDay + "' where id in ('"
     for i in range(len(idList)):
         sqlStr = "update user_experience set experience = " + str(
             experience +
             i * 4500) + " where identity_id = '" + idList[i] + "'"
         sqlList.append(sqlStr)
         if len(idList) - i == 1:
             sqlStr1 += idList[i] + "')"
         else:
             sqlStr1 += idList[i] + "', '"
         if i < 4:
             self.newlist.append(idList[i])
     sqlList.append(sqlStr1)
     sqlStr = "update user_experience set experience = 42000 where identity_id in ('"
     for i in range(len(liveList)):
         if len(liveList) - i == 1:
             sqlStr += liveList[i] + "')"
         else:
             sqlStr += liveList[i] + "', '"
     sqlList.append(sqlStr)
     dbConnect.dbSetting(test_parameter['db'], sqlList)
コード例 #7
0
ファイル: test_getGiftCategory.py プロジェクト: tl-lisa/v2api
    def setData(self, startTime, endTime, isDelete):
        sqlList = []
        startTimeStr = ''
        endTimeStr = ''

        if startTime == 'Null':
            startTimeStr = 'start_time = NULL'
        elif startTime == 'small':
            startTimeStr = "start_time = '" + (datetime.today() - timedelta(
                days=2)).strftime('%Y-%m-%d %H:%M:%S') + "'"
        elif startTime == 'bigger':
            startTimeStr = "start_time = '" + (datetime.today() + timedelta(
                days=2)).strftime('%Y-%m-%d %H:%M:%S') + "'"

        if endTime == 'Null':
            endTimeStr = 'end_time = NULL'
        elif endTime == 'small':
            endTimeStr = "end_time = '" + (datetime.today() - timedelta(
                days=2)).strftime('%Y-%m-%d %H:%M:%S') + "'"
        elif endTime == 'bigger':
            endTimeStr = "end_time = '" + (datetime.today() + timedelta(
                days=2)).strftime('%Y-%m-%d %H:%M:%S') + "'"

        sqlStr = "update gift_category_v2 set " + startTimeStr + ", " + endTimeStr
        if isDelete:
            sqlStr += ", delelet_at = '" + (datetime.today() - timedelta(
                days=3)).strftime('%Y-%m-%d %H:%M:%S') + "'"
        #print(sqlStr)
        sqlList.append(sqlStr)
        dbConnect.dbSetting(test_parameter['db'], sqlList)
コード例 #8
0
 def test_changeRole(self, token, nonce, idInfo, role, experience,
                     expected):
     ori_experience = 0
     if ori_experience != experience:
         sqlList = [
             "update user_experience set experience = " + str(experience) +
             " where identity_id = '" + idInfo[0] + "'"
         ]
         dbConnect.dbSetting(test_parameter['db'], sqlList)
         ori_experience = experience
     header['X-Auth-Token'] = test_parameter[token]
     header['X-Auth-Nonce'] = test_parameter[nonce]
     url = '/api/v2/backend/user/role'
     body = {'ids': idInfo, 'role': role}
     res = api.apiFunction(test_parameter['prefix'], header, url, 'patch',
                           body)
     if type(idInfo) == list:
         id = idInfo[0]
     else:
         id = idInfo
     sqlStr = "select count(*) from identity_tag_association where identity_id = '" + id + "' and tag_id = 6"
     result = dbConnect.dbQuery(test_parameter['db'], sqlStr)
     print('dbcount=%d' % result[0][0])
     assert res.status_code // 100 == expected
     if role == 4 and experience < 4577455:
         assert result[0][0] == 1
     else:
         assert result[0][0] == 0
コード例 #9
0
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
コード例 #10
0
ファイル: test_backendUserInfo.py プロジェクト: tl-lisa/v2api
def createAccountByEmail():
    sqlStr = "select id from identity where login_id = '*****@*****.**'" 
    result = dbConnect.dbQuery(test_parameter['db'], sqlStr)
    sqlStr = "update identity set login_id = '" + str(int(time.time())) + "' where id = '" + result[0] + "'"
    dbConnect.dbSetting(test_parameter['db'], [sqlStr])
    head = {'Content-Type': 'application/json'}
    url = '/api/v2/identity/register/email/send'
    body = {
                'email': '*****@*****.**',
                'password': '******',
                'pushToken': 'emailRegrjhjayegrkldfkhgdkfasd'
            }
    res = api.apiFunction(test_parameter['prefix'], head, url, 'post', body)  
    restext = json.loads(res.text)    
    tempToken = restext['data']['tmpToken']
    sqlStr = "select activate_code from identity_email_register_history where token = '" + tempToken + "'"
    result = dbConnect.dbQuery(test_parameter['db'], sqlStr)
    actCode = result[0][0]
    url = '/api/v2/identity/register/email/activate'
    body = {
            "tmpToken": tempToken,
            "activateCode": actCode,
            "pushToken": "emailRegrjhjayegrkldfkhgdkfasd"
        }
    api.apiFunction(test_parameter['prefix'], head, url, 'post', body)
    sqlStr = "select id from identity where login_id = '*****@*****.**'" 
    result = dbConnect.dbQuery(test_parameter['db'], sqlStr)
    print('email註冊的uid(%s)'%result[0][0])
    return result[0][0]
コード例 #11
0
ファイル: test_emailBind.py プロジェクト: tl-lisa/v2api
 def testMailCreateTime(self, regEmail, PWD, expected):
     url = '/api/v2/identity/binding/email/send'
     for i in range(len(regEmail)):
         sqlList = []
         createTime = ''
         body = {'email': regEmail[i]}
         res = api.apiFunction(test_parameter['prefix'], self.head, url,
                               'post', body)
         restext = json.loads(res.text)
         pprint(restext)
         assert res.status_code // 100 == expected[i]
         if i == 0:
             createTime = (datetime.today() -
                           timedelta(days=8 + datetime.today().weekday()) -
                           timedelta(hours=8)).strftime('%Y-%m-%d 16:00:00')
         elif i == 1:
             createTime = (datetime.today() -
                           timedelta(days=2 + datetime.today().weekday()) -
                           timedelta(hours=8)).strftime('%Y-%m-%d 15:59:59')
         elif i == 2:
             createTime = (datetime.today() -
                           timedelta(days=2 + datetime.today().weekday()) -
                           timedelta(hours=8)).strftime('%Y-%m-%d 16:00:00')
         if len(createTime) > 0:
             sqlStr = "select max(id) from identity_email_bind_history"
             result = dbConnect.dbQuery(test_parameter['db'], sqlStr)
             sqlList = [
                 "update identity_email_bind_history set created_at = '" +
                 createTime + "' where id = " + str(result[0][0])
             ]
             dbConnect.dbSetting(test_parameter['db'], sqlList)
コード例 #12
0
 def testHistoryTalkWithCS(self):
     # 與客服的訊息不限時間
     sqlList = []
     changelist = []
     apiName = '/api/v2/identity/instantMessage/history?dialogId={id}&item=10&page=1'
     UpdateDatetime = datetime.fromtimestamp(int(
         time.time())) - timedelta(days=366)
     sqlList.append("update instant_message set create_at = '" +
                    UpdateDatetime.strftime('%Y-%m-%d %H:%M:%S') +
                    "' where dialog_id = '" + self.dialogIdList[0] + "'")
     dbConnect.dbSetting(test_parameter['db'], sqlList)
     apiName = apiName.replace('{id}', self.dialogIdList[0])
     #print(apiName)
     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)
     restext = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restext['totalCount'] == 2
     changelist.append(idList[3])
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']
     api.change_roles(test_parameter['prefix'], header, changelist,
                      '4')  #轉成直播主
     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)
     restext = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restext['totalCount'] == 2
コード例 #13
0
ファイル: test_getnewuserlist.py プロジェクト: tl-lisa/v2api
 def testCreateAtbeforLastWeekend(self):
     # 用戶註冊時間為上上周六23:59:59
     sqlList = []
     dtDay = datetime.today() - timedelta(days=9 +
                                          datetime.today().weekday())
     dtDay = (dtDay.replace(hour=15, minute=59,
                            second=59)).strftime('%Y-%m-%d %H:%M:%S')
     sqlList.append("update identity set create_at = '" + dtDay +
                    "' where id = '" + idList[0] + "'")
     dbConnect.dbSetting(test_parameter['db'], sqlList)
     if idList[0] in self.newlist:
         self.newlist.remove(idList[0])
     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)
     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
     assert restext['data'][0]['userLevel']['levelNum'] >= restext['data'][
         1]['userLevel']['levelNum']
コード例 #14
0
ファイル: test_requestResetPwd.py プロジェクト: tl-lisa/v2api
 def setup_class(self):
     initdata.clearIdentityData(test_parameter['db'])
     emailReg('*****@*****.**', '123456')
     sqlList = [
         "update identity set phone_number = '0988114885', phone_country_code = '886' where login_id = 'track0050'"
     ]
     sqlList.append('truncate table identity_pwd_reset_history')
     dbConnect.dbSetting(test_parameter['db'], sqlList)
コード例 #15
0
ファイル: test_notifySetting.py プロジェクト: tl-lisa/v2api
 def setup_class(self):
     sqlList = ['truncate table user_notification_settings']
     dbConnect.dbSetting(test_parameter['db'], sqlList)
     header['X-Auth-Token'] = test_parameter['backend_token']
     header['X-Auth-Nonce'] = test_parameter['backend_nonce']   
     self.mid = api.search_user(test_parameter['prefix'], test_parameter['broadcaster_acc'], header)   
     changelist = [self.mid]  
     api.change_roles(test_parameter['prefix'], header, changelist, 4) #一般用戶:5;直播主:4
コード例 #16
0
def addAgencyName():
    sqlStr = "delete from agency_master_contract"
    midDate1 = (datetime.today() - timedelta(hours=9)).strftime('%Y-%m-%d %H:%M:%S')
    midDate = (datetime.today() - timedelta(hours=10)).strftime('%Y-%m-%d %H:%M:%S')
    cDate = (datetime.today() - timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S')
    sqlStr1  = "insert into agency_master_contract(create_at, contract_end_date, contract_start_date, master_charge_rate, agency_id, identity_id, version) values "
    sqlStr1 += "('" + cDate + "', '" + midDate + "', '2017-10-01 00:00:00', 0.3, 1, 'd82a7ba2-5c11-4615-aba7-2a768d927165', 1), "
    sqlStr1 += "('" + cDate + "',  '2028-10-01 00:00:00', '" + midDate1 + "', 0.3, 2, 'd82a7ba2-5c11-4615-aba7-2a768d927165', 2)"
    dbConnect.dbSetting(test_parameter['db'], [sqlStr, sqlStr1])
コード例 #17
0
ファイル: test_IMforLivemaster.py プロジェクト: tl-lisa/v2api
 def setup_class(self):
     sqlList = []
     sqlList.append(
         "update user_experience set experience = 25088 where identity_id = '"
         + idList[0] + "'")
     sqlList.append(
         "update user_experience set experience = 0 where identity_id = '" +
         idList[1] + "'")
     dbConnect.dbSetting(test_parameter['db'], sqlList)
コード例 #18
0
ファイル: test_requestResetPwd.py プロジェクト: tl-lisa/v2api
    def testVerifyActive(self, scenario, expected):
        urlName = '/api/v2/identity/password/verify'
        body = {}
        if len(self.info) < 2:
            self.getActiveCode()
        if scenario == 'tokenWrong':
            body = {
                "tmpToken": "wJalrXUtnFEMI...",
                "activateCode": self.info[0]['activateCode']
            }
        elif scenario == 'codeWrong':
            body = {
                "tmpToken": self.info[0]['tmpToken'],
                "activateCode": '214324'
            }
        elif scenario == 'notMatch':
            body = {
                "tmpToken": self.info[0]['tmpToken'],
                "activateCode": self.info[1]['activateCode']
            }
        elif scenario == 'expired':
            sqlList = [
                "update identity_pwd_reset_history set expires_in = 1 where token = '"
                + self.info[0]['tmpToken'] + "'"
            ]
            dbConnect.dbSetting(test_parameter['db'], sqlList)
            body = {
                "tmpToken": self.info[0]['tmpToken'],
                "activateCode": self.info[0]['activateCode']
            }
            time.sleep(2)
        elif scenario == 'success':
            body = {
                "tmpToken": self.info[1]['tmpToken'],
                "activateCode": self.info[1]['activateCode']
            }

        res = api.apiFunction(test_parameter['prefix'],
                              {'Content-Type': 'application/json'}, urlName,
                              'post', body)
        assert res.status_code // 100 == expected
        if res.status_code // 100 == 2:
            head = {
                'Content-Type': 'application/json',
                'Connection': 'Keep-alive'
            }
            restext = json.loads(res.text)
            urlName = '/api/v2/identity/myInfo'
            head['X-Auth-Token'] = restext['data']['token']
            head['X-Auth-Nonce'] = restext['data']['nonce']
            res = api.apiFunction(test_parameter['prefix'], head, urlName,
                                  'get', None)
            restext = json.loads(res.text)
            assert restext['data']['verifiedEmail'] == '*****@*****.**'
コード例 #19
0
ファイル: test_getOpentype.py プロジェクト: tl-lisa/v2api
def init():
    initdata.set_test_data(env, test_parameter)    
    header['X-Auth-Token'] = test_parameter['backend_token']
    header['X-Auth-Nonce'] = test_parameter['backend_nonce'] 
    idlist.append(api.search_user(test_parameter['prefix'], test_parameter['broadcaster_acc'], header))
    idlist.append(api.search_user(test_parameter['prefix'], test_parameter['broadcaster1_acc'], header))
    idlist.append(api.search_user(test_parameter['prefix'], test_parameter['user_acc'], header))
    idlist.append(api.search_user(test_parameter['prefix'], test_parameter['user1_acc'], header))
    initdata.resetData(test_parameter['db'], idlist[0])
    sqlList = ["insert into zego_master values('" + idlist[0] + "')"]
    dbConnect.dbSetting(test_parameter['db'], sqlList)
コード例 #20
0
 def insertData(self, table, index):
     sqlList = []
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     for i in table:
         sqlStr = "insert into " + i + " set "
         if i == 'sticker_group':
             sqlStr += self.sticker_group[index]
         else:
             sqlStr += self.sticker[index]
         sqlStr += ", created_at='" + now + "', updated_at=' " + now + "', create_user_id='lisa', update_user_id='lisa'"
         sqlList.append(sqlStr)
     dbConnect.dbSetting(test_parameter['db'], sqlList)
コード例 #21
0
ファイル: test_masterInfo.py プロジェクト: tl-lisa/v2api
def setup_module():
    initdata.set_test_data(env, test_parameter)
    initdata.initIdList(
        test_parameter['prefix'], test_parameter['backend_token'],
        test_parameter['backend_nonce'], [
            test_parameter['broadcaster_acc'],
            test_parameter['broadcaster1_acc'], test_parameter['backend_acc'],
            test_parameter['user_acc'], test_parameter['user1_acc']
        ], idList)
    initdata.clearFansInfo(test_parameter['db'])
    sqlList = ["insert into zego_master values ('" + idList[0] + "')"]
    dbConnect.dbSetting(test_parameter['db'], sqlList)
コード例 #22
0
 def testgetgiftlist(self, scenario, token, nonce, action, totalCount,
                     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
             ]
         },
         'inactive':
         "update gift_v2 set is_active = 0 where uuid = '" + self.giftId +
         "'",
         'deleted':
         "update gift_v2 set deleted_at = '" +
         (datetime.today() -
          timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S') +
         "' where uuid = '" + self.giftId + "'"
     }
     if action in ('block', 'changeRole'):
         actionDic[action]['funName'](*actionDic[action]['parameter'])
     elif action in ['inactive', 'deleted']:
         dbConnect.dbSetting(test_parameter['db'], [actionDic[action]])
     time.sleep(30)
     apiName = '/api/v2/liveMaster/photoPost/1/giftList?item=20&page=1'
     header['X-Auth-Token'] = test_parameter[token]
     header['X-Auth-Nonce'] = test_parameter[nonce]
     res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get',
                           None)
     restext = json.loads(res.text)
     pprint(restext)
     assert res.status_code == expected
     if expected == 200:
         assert restext['totalCount'] == totalCount
         assert restext['totalPoints'] == self.giftPoint * totalCount
         if restext['totalCount'] > 0:
             assert restext['data'][0]['sender'] == idlist[2]
             assert restext['data'][0]['point'] == self.giftPoint
             assert restext['data'][0]['giftName'] == self.giftName
             assert restext['data'][0]['datetime'] >= restext['data'][1][
                 'datetime']
             assert restext['data'][0]['id'] >= restext['data'][1]['id']
コード例 #23
0
def setup_module():
    initdata.set_test_data(env, test_parameter)
    initdata.clearFansInfo(test_parameter['db'])
    initdata.initIdList(
        test_parameter['prefix'], test_parameter['backend_token'],
        test_parameter['backend_nonce'], [
            test_parameter['broadcaster_acc'],
            test_parameter['broadcaster1_acc'], test_parameter['user_acc'],
            test_parameter['user1_acc']
        ], idlist)
    sqlList = [
        "update gift_v2 set deleted_at = NULL, is_active = 1 where uuid = '234df236-8826-4938-8340-32f39df43ed1'"
    ]
    dbConnect.dbSetting(test_parameter['db'], sqlList)
コード例 #24
0
ファイル: test_backendUserInfo.py プロジェクト: tl-lisa/v2api
def liveAcc0004Login():
    body = {
            "account":"liveAcc0004",
            "password":"******",
            "pushToken":"tllisa123jhjayegrkldfkhgdkfasd"
        }
    res = api.apiFunction(test_parameter['prefix'], {'Content-Type': 'application/json', 'Connection': 'Keep-alive'}, 
        '/api/v2/identity/auth/login', 'post', body)
    sqlList = ["delete from identity_profile where identity_id = '0610edb2-2c38-4089-b664-c54d8e3ec0b4'"]
    sqlStr  = "insert into identity_profile set identity_id = '0610edb2-2c38-4089-b664-c54d8e3ec0b4', "
    sqlStr += "email = '*****@*****.**', created_at = '2020-08-12 08:54:27', updated_at = '2020-08-12 08:54:27'"
    sqlList.append(sqlStr)
    dbConnect.dbSetting(test_parameter['db'], sqlList)
    return res
コード例 #25
0
ファイル: test_getGiftList.py プロジェクト: tl-lisa/v2api
 def setCondition(self, categoryId, isActive, isDelete, isDuriation, isExpired):
     sqlList = []
     result = dbConnect.dbQuery(test_parameter['db'], "select min(id) from gift_v2 where category_id = " + str(categoryId))
     if not isActive:          
         sqlStr = "update gift_v2 set is_active = 0 where id = "  + str(result[0][0])
     elif isDelete:
         sqlStr = "update gift_v2 set deleted_at = '" + (datetime.today() - timedelta(hours=7)).strftime('%Y-%m-%d %H:%M:%S') + "' where id = " + str(result[0][0])
     elif isDuriation:
         sqlStr  = "update gift_category_v2 set end_time = '" + (datetime.today() - timedelta(hours=6)).strftime('%Y-%m-%d %H:%M:%S') 
         sqlStr += "', start_time = '" + (datetime.today() - timedelta(hours=7)).strftime('%Y-%m-%d %H:%M:%S') + "' where id = " + str(categoryId)
     elif isExpired:
         sqlStr = "update gift_category_v2 set end_time = '" + (datetime.today() - timedelta(hours=9)).strftime('%Y-%m-%d %H:%M:%S') + "' where id = " + str(categoryId)
     sqlList.append(sqlStr)
     dbConnect.dbSetting(test_parameter['db'], sqlList) if sqlList else None
コード例 #26
0
ファイル: test_notifycation.py プロジェクト: tl-lisa/v2api
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
コード例 #27
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)
コード例 #28
0
 def setup_class(self):
     experience = [0, 1537090.91, 4623272.73, 34603636.36, 93818181.82]
     header['X-Auth-Token'] = test_parameter['broadcaster_token']
     header['X-Auth-Nonce'] = test_parameter['broadcaster_nonce']
     self.userList.append(
         api.search_user(test_parameter['prefix'], 'broadcaster100',
                         header))
     self.userList.append(
         api.search_user(test_parameter['prefix'], 'broadcaster099',
                         header))
     self.userList.append(
         api.search_user(test_parameter['prefix'], 'broadcaster098',
                         header))
     self.userList.append(
         api.search_user(test_parameter['prefix'], 'broadcaster097',
                         header))
     self.userList.append(
         api.search_user(test_parameter['prefix'], 'broadcaster096',
                         header))
     self.userList.append(
         api.search_user(test_parameter['prefix'], 'track0100', header))
     self.userList.append(
         api.search_user(test_parameter['prefix'], 'track0099', header))
     self.userList.append(
         api.search_user(test_parameter['prefix'], 'track0098', header))
     self.userList.append(
         api.search_user(test_parameter['prefix'], 'track0097', header))
     self.userList.append(
         api.search_user(test_parameter['prefix'], 'track0096', header))
     sqlList = []
     p_token = 'eUOePK4v6Xg:APA91bHqcnv2C7MSD9GMMTG2rs34cy4sVabpnNJ-hKqzjBzUHtWKHa84SRpZTQWDL7vX4b2tppZvFT25eXJerOVpBy_3xFWagcc6Z307JbJq'
     for i in range(len(self.userList)):
         j = i % 5
         sqlstr = "update user_experience set experience = " + str(
             experience[j]
         ) + " where identity_id = '" + self.userList[i] + "'"
         sqlList.append(sqlstr)
         sqlstr = "update identity set create_at = FROM_UNIXTIME(" + str(
             self.startTime + j * 20) + "), push_token = '" + p_token
         sqlstr += "', update_at = FROM_UNIXTIME(" + str(
             self.startTime +
             j * 25) + ") where id = '" + self.userList[i] + "'"
         print(sqlstr)
         sqlList.append(sqlstr)
     dbConnect.dbSetting(test_parameter['db'], sqlList)
コード例 #29
0
 def testMasterWithUserOnly7day(self):
     #超過7天的訊息即不會撈出
     sqlList = []
     self.getHistoy()
     apiName = '/api/v2/identity/instantMessage/history?dialogId={id}&item=10&page=1'
     UpdateDatetime = datetime.fromtimestamp(int(
         time.time())) - timedelta(days=8)
     sqlList.append("update instant_message set create_at = '" +
                    UpdateDatetime.strftime('%Y-%m-%d %H:%M:%S') +
                    "' where dialog_id = '" + self.dialogIdList[0] + "'")
     dbConnect.dbSetting(test_parameter['db'], sqlList)
     apiName = apiName.replace('{id}', self.dialogIdList[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, 'get',
                           None)
     restext = json.loads(res.text)
     assert res.status_code // 100 == 2
     assert restext['totalCount'] == 0
コード例 #30
0
def sendBarrage(timeList, today, yesterday, thisWeek, thisMonth, lastMonth):
    sqlList = []
    Barrage = [35, 350]
    for i in range(8, 10):
        ##print(timeList[i%8])
        sqlStr = "insert into live_room_gift(consumption_point, create_at, create_user_id, room_id, status, barrage_id, target_user_id) values (" + str(
            Barrage[i % 8])
        sqlStr += ", '" + timeList[i % 8] + "', '" + userList[
            i] + "', 5487, 0, '" + str(i % 8 + 1) + "', '" + idList[2] + "')"
        sqlList.append(sqlStr)
        print("i=%d, uid=%s, date=%s, point=%d" %
              (i, userList[i], timeList[i % 8], Barrage[i % 8]))
        if (i % 8) == 0:
            if userList[i] in today:
                today[userList[i]] += Barrage[i % 8]
            else:
                today[userList[i]] = Barrage[i % 8]
            if userList[i] in thisWeek:
                thisWeek[userList[i]] += Barrage[i % 8]
            else:
                thisWeek[userList[i]] = Barrage[i % 8]
        if (i % 8) == 1:
            if userList[i] in yesterday:
                yesterday[userList[i]] += Barrage[i % 8]
            else:
                yesterday[userList[i]] = Barrage[i % 8]
            if datetime.today().weekday() < 6:
                if userList[i] in thisWeek:
                    thisWeek[userList[i]] += Barrage[i % 8]
                else:
                    thisWeek[userList[i]] = Barrage[i % 8]
        if (i % 8) < 3:
            if userList[i] in thisMonth:
                thisMonth[userList[i]] += Barrage[i % 8]
            else:
                thisMonth[userList[i]] = Barrage[i % 8]
        else:
            if userList[i] in lastMonth:
                lastMonth[userList[i]] += Barrage[i % 8]
            else:
                lastMonth[userList[i]] = Barrage[i % 8]
    dbConnect.dbSetting(test_parameter['db'], sqlList)