def test_channel_invite_valid_inputs(user_dav, user_jas, channel_dav): ''' user_dav invites user_jas to channel_dav ''' channel_invite(user_dav['token'], channel_dav['channel_id'], user_jas['u_id']) member_jas = {} member_jas['u_id'] = user_jas['u_id'] member_jas['name_first'] = "jas" member_jas['name_last'] = "zhu" member_jas['profile_img_url'] = "http://localhost:8080/imgurl/default.png" channel_dav_detail = channel_details(user_dav['token'], channel_dav['channel_id']) assert member_jas in channel_dav_detail['all_members']
def test_channel_invite_self_invite(user_dav, channel_dav, user_jas): # invite jas to the channel channel_invite(user_dav['token'], channel_dav['channel_id'], user_jas['u_id']) # jas invite himself again channel_invite(user_jas['token'], channel_dav['channel_id'], user_jas['u_id']) # create member jas member_jas = {} member_jas['u_id'] = user_jas['u_id'] member_jas['name_first'] = "jas" member_jas['name_last'] = "zhu" member_jas['profile_img_url'] = "http://localhost:8080/imgurl/default.png" # set up channel details channel_dav_detail = channel_details(user_dav['token'], channel_dav['channel_id']) assert member_jas in channel_dav_detail['all_members']
def test_channel_invite_already_member(user_dav, user_jas, channel_dav): # First invitation channel_invite(user_dav['token'], channel_dav['channel_id'], user_jas['u_id']) # Second invitation channel_invite(user_dav['token'], channel_dav['channel_id'], user_jas['u_id']) # create member jas member_jas = {} member_jas['u_id'] = user_jas['u_id'] member_jas['name_first'] = "jas" member_jas['name_last'] = "zhu" member_jas['profile_img_url'] = "http://localhost:8080/imgurl/default.png" # set up channel details channel_dav_detail = channel_details(user_dav['token'], channel_dav['channel_id']) assert member_jas in channel_dav_detail['all_members']
def test_channel_details(user_chas, user_dav, user_jas, channel_dav): # Invite jas and chas to the channel channel_invite(user_dav['token'], channel_dav['channel_id'], user_jas['u_id']) channel_invite(user_dav['token'], channel_dav['channel_id'], user_chas['u_id']) # Achieve the detail of the channel by dev channel_dav_detail = channel_details(user_dav['token'], channel_dav['channel_id']) # Set up the member card for every member member_dav = {} member_dav['u_id'] = user_dav['u_id'] member_dav['name_first'] = "dav" member_dav['name_last'] = "zhu" member_dav['profile_img_url'] = "http://localhost:8080/imgurl/default.png" member_jas = {} member_jas['u_id'] = user_jas['u_id'] member_jas['name_first'] = "jas" member_jas['name_last'] = "zhu" member_jas['profile_img_url'] = "http://localhost:8080/imgurl/default.png" member_chas = {} member_chas['u_id'] = user_chas['u_id'] member_chas['name_first'] = "chas" member_chas['name_last'] = "zhu" member_chas['profile_img_url'] = "http://localhost:8080/imgurl/default.png" assert channel_dav_detail['name'] == "channel_dav" assert channel_dav_detail['owner_members'][0] == member_dav assert member_chas in channel_dav_detail['all_members'] assert member_dav in channel_dav_detail['all_members'] assert member_jas in channel_dav_detail['all_members']
def channel_details_wsgi(): json = request.args return jsonify(channel_details(json['token'], int(json['channel_id'])))
def test_invalid_member(user_chas, channel_dav): with pytest.raises(AccessError): assert channel_details(user_chas['token'], channel_dav['channel_id'])
def test_invalid_channel(user_dav): with pytest.raises(InputError): assert channel_details(user_dav['token'], 000000)