def testAddCategory(self, scenario, token, nonce, body, expected): apiName = '/api/v2/backend/giftCategory' header['X-Auth-Token'] = test_parameter[token] header['X-Auth-Nonce'] = test_parameter[nonce] body['startTime'] = int(time.time()) - 2 body['endTime'] = int(time.time()) + 3 res = api.apiFunction(test_parameter['prefix'], header, apiName, 'post', body) assert res.status_code // 100 == expected if expected == 2: sundry.clearCache(test_parameter['db']) res = api.apiFunction( test_parameter['prefix'], header, '/api/v2/backend/giftCategory/list?statusFilter=all&item=2&page=1&typeFilter=' + str(body['type']), 'get', None) restext = json.loads(res.text) self.verifyAddResult(restext, body)
def editInit(): initdata.clearVoice(test_parameter['db']) sundry.clearCache(test_parameter['db']) for i in range(2): account = 'broadcaster01' + str(i) createVoiceRoom(account) header['X-Auth-Token'] = test_parameter['broadcaster011']['token'] header['X-Auth-Nonce'] = test_parameter['broadcaster011']['nonce'] for i in range(12, 15): admin = 'broadcaster0' + str(i) apiName = '/api/v2/liveMaster/voiceChat/admin' body = {'roomId': 2, 'userId': test_parameter[admin]['id']} api.apiFunction(test_parameter['prefix'], header, apiName, 'post', body) apiName = '/api/v2/liveMaster/voiceChat/admin/2/' + test_parameter[ 'broadcaster013']['id'] api.apiFunction(test_parameter['prefix'], header, apiName, 'delete', None) header['X-Auth-Token'] = test_parameter['tl-lisa']['token'] header['X-Auth-Nonce'] = test_parameter['tl-lisa']['nonce'] api.change_roles(test_parameter['prefix'], header, [test_parameter['broadcaster014']['id']], 5)
def testGetCategory(self, scenario, token, nonce, action, condition, idList, expected): if self.categoryList == []: id = '0' else: id = str(self.categoryList[0]) actionDic = { 'createData': { 'funName': self.addData }, 'delCategory': { 'funName': api.apiFunction, 'parameter': [ test_parameter['prefix'], header, '/api/v2/backend/giftCategory/' + id, 'delete', None ] } } if action != '': if actionDic.get(action).get('parameter'): actionDic.get(action).get('funName')( *actionDic.get(action).get('parameter')) else: actionDic.get(action).get('funName')() sundry.clearCache(test_parameter['db']) expectList = [self.categoryList[i] for i in idList] header['X-Auth-Token'] = test_parameter[token] header['X-Auth-Nonce'] = test_parameter[nonce] apiName = '/api/v2/backend/giftCategory/list' + condition res = api.apiFunction(test_parameter['prefix'], header, apiName, 'get', None) assert res.status_code // 100 == expected if expected == 2: restext = json.loads(res.text) for i in restext['data']: assert i['id'] in expectList
def createInit(): initdata.clearVoice(test_parameter['db']) sundry.clearCache(test_parameter['db']) for i in range(2): account = 'broadcaster01' + str(i) createVoiceRoom(account)
def setup_method(self): sundry.clearCache(test_parameter['db'])