def test_chat_list(flask_client, db_setting): # 일반 채팅 테스트 resp = flask_client.get("/chat/list", headers=jwt_token(2)) assert resp.status_code == 200 data = resp.data.decode('utf8').replace("'", '"') data = json.loads(data) assert data[0].get('roomid') == 1 assert data[0].get('clubid') == 1 assert data[0].get('clubname') == '세미콜론' assert data[0].get('clubimage') == 'profile_image' assert data[0].get('userid') == 2 assert data[0].get('username') == '조호원' assert data[0].get('userimage') == 'profile2' assert data[0].get('lastdate') != None assert data[0].get('lastmessage') == '두번째 채팅' # 동아리장 채팅 테스트 resp = flask_client.get("/chat/list?club_id=1", headers=jwt_token(1)) assert resp.status_code == 200 data = resp.data.decode('utf8').replace("'", '"') data = json.loads(data) assert data[0].get('roomid') == 1 assert data[0].get('clubid') == 1 assert data[0].get('clubname') == '세미콜론' assert data[0].get('clubimage') == 'profile_image' assert data[0].get('userid') == 2 assert data[0].get('username') == '조호원' assert data[0].get('userimage') == 'profile2' assert data[0].get('lastdate') != None assert data[0].get('lastmessage') == '두번째 채팅'
def test_chat_section(flask_client, db_setting): resp = flask_client.get('/chat/section', headers=jwt_token(1)) assert resp.status_code == 200 data = resp.data.decode('utf8').replace("'", '"') data = json.loads(data) assert data[0].get('club_name') == '세미콜론' assert data[0].get('club_id') == 1 assert data[0].get('club_profile') == 'profile_image'
def test_make_room(flask_client, db_setting): resp = flask_client.post('/club/1/room', headers=jwt_token(2)) assert resp.status_code == 200 data = resp.json assert data.get('room_id') == 1 resp = flask_client.post('/club/1/room', headers=jwt_token(2)) assert resp.status_code == 200 data = resp.json assert data.get('room_id') == 1 resp = flask_client.post('/club/1/room', headers=jwt_token(1)) assert resp.status_code == 200 data = resp.json assert data.get('room_id') == 2
def test_room_token(flask_client, db_setting): # 동아리장 토큰 resp = flask_client.post('/room/1/token', headers=jwt_token(1)) assert resp.status_code == 200 token = resp.json['room_token'] json = jwt.decode(token, Config.ROOM_SECRET_KEY, algorithms='HS256') assert json.get('room_id') == 1 assert json.get('user_id') == 1 assert json.get('user_type') == 'C' # 일반 유저 토큰 resp = flask_client.post('/room/1/token', headers=jwt_token(2)) assert resp.status_code == 200 token = resp.json['room_token'] json = jwt.decode(token, Config.ROOM_SECRET_KEY, algorithms='HS256') assert json.get('room_id') == 1 assert json.get('user_id') == 2 assert json.get('user_type') == 'U'
def test_breakdown(flask_client, db_setting): resp = flask_client.get('/chat/1/breakdown', headers=jwt_token(1)) assert resp.status_code == 200 data = resp.data.decode('utf8').replace("'", '"') data = json.loads(data) assert data[0].get('msg') == '두번째 채팅' assert data[0].get('user_type') == 'C' assert data[0].get('created_at') != None assert data[1].get('msg') == '첫번째 채팅' assert data[1].get('user_type') == 'U' assert data[1].get('created_at') != None