def test_msg_13(self): '''弹幕卡不足,余额足时,发言彩色弹幕''' user = user_ids[8] set_money(user, 1) exp = { 'code': 200, 'data': { 'chat_code': 100001, 'msg_type': 'msg', 'msg_content': { 'color': { 'color_mobile': True } } } } def ver(): return get_money(user) == 0 assert_res(sys._getframe(), 'msg', user, exp, ver=ver, color_barrage=1, cid=cid) del_dmk(user)
def test_admingag_01(self): '''非超管用户禁言超管''' assert_res(sys._getframe(), 'admingag', users[0], '', cid=cid, user_uid=superuid)
def test_setroomadmin_03(self): '''房主设置房主为房管''' user = fz exp = {'code': '4302', 'status': False, 'message': '无法对自己进行设置'} assert_res(sys._getframe(), 'setroomadmin', user, exp, username=room_data['fz_name'])
def test_setroomadmin_04(self): '''用户设置用户为房管''' user = yh[2] exp = {'code': '4302', 'status': False, 'message': '参数错误!'} assert_res(sys._getframe(), 'setroomadmin', user, exp, username=yh_name[3])
def test_delroomadmin_02(self): '''用户不是房管,取消用户房管''' user = fz exp = {'code': '4000', 'status': True, 'message': '处理成功!'} assert_res(sys._getframe(), 'delroomadmin', user, exp, username=yh_name[6], uid=yh[6])
def test_admingag_03(self): '''超管禁言房主''' uid = fz assert_res(sys._getframe(), 'admingag', superuid, exp_t, ver=ver(uid), cid=cid, user_uid=uid)
def test_setroomadmin_02(self): '''房主设置房管为房管''' user = room_data2['fz_id'] redis_inst.set('hm_channel_admin_{}'.format(room_data2['cid']), json.dumps({yh[1]: times})) exp = {'code': '266', 'status': False, 'message': '已经是房管'} assert_res(sys._getframe(), 'setroomadmin', user, exp, username=yh_name[1])
def test_admingag_04(self): '''房管已被普通禁言,超管再禁言''' uid = fg[0] assert_res(sys._getframe(), 'admingag', superuid, exp_t2, ver=ver(uid), cid=cid, user_uid=uid, gag_type=0)
def test_admingag_02(self): '''超管禁言普通用户''' uid = users[0] assert_res(sys._getframe(), 'admingag', superuid, exp_t2, ver=ver(uid), cid=cid, user_uid=uid, gag_type=0)
def test_setroomadmin_05(self): '''房管已达到上限''' user = room_data3['fz_id'] redis_inst.set('hm_channel_admin_{}'.format(room_data3['cid']), json.dumps({i: times for i in range(1, 11)})) exp = {'code': '4305', 'status': False, 'message': '房管最多10位'} assert_res(sys._getframe(), 'setroomadmin', user, exp, username=yh_name[4])
def test_msg_08(self): '''注册时间''' user = user_ids[5] # 设置用户注册时间 regtime = int(time.time()) user_info_key = 'hm_{}'.format(user) user_info = json.loads(redis_inst.get(user_info_key)) user_info['regtime'] = regtime redis_inst.set(user_info_key, json.dumps(user_info)) # 设置房间发言限制 redis_inst.hset('hm_chat_limit_admin_{}'.format(cid2), 'regTime', '120') exp = {'code': 2018, 'status': False, 'message': '您刚来,还得2分钟才能发言~'} assert_res(sys._getframe(), 'msg', user, exp, cid=cid2)
def test_msg_09(self): '''房主''' user = fz exp = { 'code': 200, 'data': { 'chat_code': 100001, 'msg_type': 'msg', 'msg_content': { 'is_zb': 1 } } } assert_res(sys._getframe(), 'msg', user, exp, cid=cid)
def test_msg_15(self): '''弹幕卡消耗顺序''' user = user_ids[10] dmk_time = int(time.time()) expire_time1 = dmk_time + 100 expire_time2 = dmk_time + 200 add_dmk(user, expire_time=expire_time1) add_dmk(user, expire_time=expire_time2) exp = { 'code': 200, 'data': { 'chat_code': 100001, 'msg_type': 'msg', 'msg_content': { 'color': { 'color_mobile': True } } } } def ver(): mysql_inst.select_db('hm_user_bag') cur = mysql_inst.cursor() sql = "SELECT num FROM user_bag_{} WHERE uid={} and expire_time ={}".format( hash_table(user), user, expire_time1) cur.execute(sql) mysql_inst.commit() data = cur.fetchone()[0] # cur.fetchall() cur.close() if data == 0: return True assert_res(sys._getframe(), 'msg', user, exp, ver=ver, color_barrage=1, cid=cid) del_dmk(user)
def test_setroomadmin_01(self): '''房主设置普通用户为房管''' user = fz redis_inst.delete('hm_channel_admin_{}'.format(cid)) exp = {'code': 200, 'status': True, 'message': '处理成功!'} exp_yz = { 'code': 200, 'data': { 'chat_code': 100001, 'msg_type': 'msg', 'msg_content': { 'is_fg': 1 } } } assert_res(sys._getframe(), 'setroomadmin', user, exp, ver=ver(yh[0], cid, exp_yz), username=yh_name[0])
def test_delroomadmin_01(self): '''用户是房管,取消用户房管''' user = room_data4['fz_id'] cid = room_data4['cid'] redis_inst.set('hm_channel_admin_{}'.format(cid), json.dumps({yh[5]: times})) exp = {'code': '4000', 'status': True, 'message': '处理成功!'} exp_yz = { 'code': 200, 'data': { 'chat_code': 100001, 'msg_type': 'msg', 'msg_content': { 'is_fg': 0 } } } assert_res(sys._getframe(), 'delroomadmin', user, exp, ver=ver(yh[5], cid, exp_yz), username=yh_name[5], uid=yh[5])
def test_gag_11(self): '''房主禁言房主''' user = fz assert_res(sys._getframe(), 'gag', user, exp_f2, cid=cid, uid=fz)
def test_gag_12(self): '''房主禁言超管''' user = fz assert_res(sys._getframe(), 'gag', user, exp_f5, cid=cid, uid=superuid)
def test_gag_13(self): '''用户已被房管1,24h禁言,再被房管1,永久禁言''' user = fg[0] assert_res(sys._getframe(), 'gag', user, exp_t, status=0, cid=cid, uid=users[3])
def test_gag_14(self): '''用户已被房管1,24h禁言,不能被房管2禁言操作''' user = fg[1] assert_res(sys._getframe(), 'gag', user, exp_f6, cid=cid, uid=users[4])
def test_gag_03(self): '''普通用户禁言房主''' user = users[0] assert_res(sys._getframe(), 'gag', user, exp_f1, cid=cid, uid=fz)
def test_gag_16(self): '''已被房管1禁言用户,被房主,24h禁言''' user = fz assert_res(sys._getframe(), 'gag', user, exp_t, cid=cid, uid=users[6])
def test_gag_17(self): '''已被房管1禁言用户,被房主永久禁言''' user = fz assert_res(sys._getframe(), 'gag', user, exp_t, status=0, cid=cid, uid=users[7])
def tearDown(self): # 比较结果 assert_res(self)
def test_gag_07(self): '''房管禁言房主''' user = fg[0] assert_res(sys._getframe(), 'gag', user, exp_f4, cid=cid, uid=fz)
def test_gag_06(self): '''房管禁言房管''' user = fg[0] assert_res(sys._getframe(), 'gag', user, exp_f3, cid=cid, uid=fg[1])
def test_gag_18(self): '''已被房主禁言用户,被房管1,24h禁言''' user = fg[0] assert_res(sys._getframe(), 'gag', user, exp_f6, cid=cid, uid=users[8])
def test_gag_04(self): '''普通用户禁言超管''' user = users[0] assert_res(sys._getframe(), 'gag', user, exp_f1, cid=cid, uid=superuid)
def test_gag_15(self): '''用户已被房管1,24h禁言,被房管2,永久禁言''' user = fg[1] assert_res(sys._getframe(), 'gag', user, exp_f6, status=0, cid=cid, uid=users[5])
def test_gag_05(self): '''房管禁言普通用户''' user = fg[0] assert_res(sys._getframe(), 'gag', user, exp_t, ver=ver(users[1]), cid=cid, uid=users[1])
def test_gag_19(self): '''已被房主禁言用户,被房管1,永久禁言''' user = fg[0] assert_res(sys._getframe(), 'gag', user, exp_f6, status=0, cid=cid, uid=users[9])