Пример #1
0
def test_successful_remove(create_input):
    user_1, user_2, user_3, user_4, user_5 = create_input[0]

    assert admin_user_remove_v1(user_1["token"],
                                user_2["auth_user_id"]).status_code == SUCCESS
    assert admin_user_remove_v1(user_1["token"],
                                user_3["auth_user_id"]).status_code == SUCCESS
    assert admin_user_remove_v1(user_1["token"],
                                user_4["auth_user_id"]).status_code == SUCCESS
    assert admin_user_remove_v1(user_1["token"],
                                user_5["auth_user_id"]).status_code == SUCCESS

    # check to see that these users are indeed removed

    # only user_1 should be shown when calling users_all
    assert users_all_v1(user_1["token"]).json() == {
        "users": [
            user_profile_v2(user_1["token"],
                            user_1["auth_user_id"]).json()["user"]
        ]
    }

    # calling channels list should raise an input error as their u_id's are invalid
    assert channels_list_v2(user_2["token"]).status_code == ACCESS_ERROR
    assert channels_list_v2(user_3["token"]).status_code == ACCESS_ERROR
    assert channels_list_v2(user_4["token"]).status_code == ACCESS_ERROR
    assert channels_list_v2(user_5["token"]).status_code == ACCESS_ERROR

    # Check to see each removed user's profile is retrievable and their name is
    # now 'Removed user'
    for user in [user_2, user_3, user_4, user_5]:
        user_profile = user_profile_v2(user_1["token"],
                                       user["auth_user_id"]).json()
        assert type(user_profile) == dict
        assert (
            f"{user_profile['user']['name_first']}{user_profile['user']['name_last']}"
            == "Removed user" or
            f"{user_profile['user']['name_first']} {user_profile['user']['name_last']}"
            == "Removed user")

    # CHECK THAT MESSAGES SENT ARE 'REMOVED USER'
    # check channel messages for user 2
    channel_join_v2(user_1["token"], create_input[1][1]["channel_id"])
    channel_1_messages = channel_messages_v2(user_1["token"],
                                             create_input[1][1]["channel_id"],
                                             0).json()
    for message in channel_1_messages["messages"]:
        if message["message_id"] == create_input[2][1]:
            assert message["message"] == "Removed user"

    # check channel messages for user 3
    channel_join_v2(user_1["token"], create_input[1][0]["channel_id"])
    channel_2_messages = channel_messages_v2(user_1["token"],
                                             create_input[1][0]["channel_id"],
                                             0).json()
    for message in channel_2_messages["messages"]:
        if message["message_id"] == create_input[2][2]:
            assert message["message"] == "Removed user"

    clear_v1()
Пример #2
0
def test_invalid_token():
    """ Tests return of expected output when given a token that doesn't exist,
        or if the user is not in the channel/dm.
    """
    clear_v1()
    # Token doesnt exist
    user_1 = auth_register_v2('*****@*****.**', 'happydays1', 'Eric',
                              'Zheng').json()

    assert notifications_get_v1(user_1['token'] +
                                'bug').status_code == ACCESS_ERROR

    # User not in channel
    user_2 = auth_register_v2('*****@*****.**', 'happydays2', 'Josh',
                              'Hatton').json()
    channel_1 = channels_create_v2(user_1['token'], 'Channel 1', True).json()

    user_2_handle = user_profile_v2(user_1['token'],
                                    user_2['auth_user_id']).json()

    message_send_v2(user_1['token'], channel_1['channel_id'],
                    f"Hi @{user_2_handle['user']['handle_str']}")

    assert notifications_get_v1(user_2['token']).json() == {
        'notifications': []
    }

    # User not in dm
    dm_1 = dm_create_v1(user_1['token'], [user_2['auth_user_id']]).json()
    user_3 = auth_register_v2('*****@*****.**', 'hihihi!!!', 'Bunny',
                              'Dong').json()
    user_3_handle = user_profile_v2(user_1['token'],
                                    user_3['auth_user_id']).json()

    message_senddm_v1(user_1['token'], dm_1['dm_id'],
                      f"Hello @{user_3_handle['user']['handle_str']}")

    assert notifications_get_v1(user_3['token']).json() == {
        'notifications': []
    }
def test_dm_invite(create_dms):
    users = create_dms['users']
    dm_1 = create_dms['dms'][0]
    dm_2 = create_dms['dms'][1]
    #dm_3 = create_dms['dms'][2]

    profile_0 = user_profile_v2(users[0]['token'], users[0]['auth_user_id']).json()['user']
    profile_1 = user_profile_v2(users[0]['token'], users[1]['auth_user_id']).json()['user']
    profile_2 = user_profile_v2(users[0]['token'], users[2]['auth_user_id']).json()['user']
    profile_3 = user_profile_v2(users[0]['token'], users[3]['auth_user_id']).json()['user']

    dm_invite_v1(users[0]['token'], dm_1['dm_id'], users[3]['auth_user_id'])

    rt_val_1 = dm_details_v1(users[0]['token'], dm_1['dm_id'])
    rt_val_1 = rt_val_1.json()

    assert rt_val_1['name'] == "ab, cd, ef"
    assert sorted(rt_val_1['members'], key=lambda x:x['u_id']) == sorted([
                                {  'u_id': users[1]['auth_user_id'],
                                    'name_first': 'c',
                                    'name_last': 'd',
                                    'email': '*****@*****.**',
                                    'handle_str': 'cd',
                                    'profile_img_url' : profile_1['profile_img_url'],

                                },
                                {  'u_id': users[2]['auth_user_id'],
                                    'name_first': 'e',
                                    'name_last': 'f',
                                    'email': '*****@*****.**',
                                    'handle_str': 'ef',
                                    'profile_img_url' : profile_2['profile_img_url'],

                                },
                                {  'u_id': users[0]['auth_user_id'],
                                    'name_first': 'a',
                                    'name_last': 'b',
                                    'email': '*****@*****.**',
                                    'handle_str': 'ab',
                                    'profile_img_url' : profile_0['profile_img_url'],

                                },
                                {  'u_id': users[3]['auth_user_id'],
                                    'name_first': 'g',
                                    'name_last': 'h',
                                    'email': '*****@*****.**',
                                    'handle_str': 'gh',
                                    'profile_img_url' : profile_3['profile_img_url'],

                                },
                                ], key=lambda x:x['u_id'])

    dm_invite_v1(users[1]['token'], dm_2['dm_id'], users[2]['auth_user_id'])
    dm_invite_v1(users[1]['token'], dm_2['dm_id'], users[3]['auth_user_id'])

    rt_val_2 = dm_details_v1(users[1]['token'], dm_2['dm_id'])
    rt_val_2 = rt_val_2.json()
    assert rt_val_2['name'] == "ab, cd"
    assert sorted(rt_val_2['members'], key=lambda x:x['u_id']) == sorted([
                                {  'u_id': users[0]['auth_user_id'],
                                    'name_first': 'a',
                                    'name_last': 'b',
                                    'email': '*****@*****.**',
                                    'handle_str': 'ab',
                                    'profile_img_url' : profile_0['profile_img_url'],

                                },
                                {  'u_id': users[1]['auth_user_id'],
                                    'name_first': 'c',
                                    'name_last': 'd',
                                    'email': '*****@*****.**',
                                    'handle_str': 'cd',
                                    'profile_img_url' : profile_1['profile_img_url'],

                                },
                                {  'u_id': users[2]['auth_user_id'],
                                    'name_first': 'e',
                                    'name_last': 'f',
                                    'email': '*****@*****.**',
                                    'handle_str': 'ef',
                                    'profile_img_url' : profile_2['profile_img_url'],

                               },
                                {  'u_id': users[3]['auth_user_id'],
                                    'name_first': 'g',
                                    'name_last': 'h',
                                    'email': '*****@*****.**',
                                    'handle_str': 'gh',
                                    'profile_img_url' : profile_3['profile_img_url'],

                                },
                                ], key=lambda x:x['u_id'])
    

    clear_v1()
Пример #4
0
def test_dm_create(register_users):
    users = register_users
    user_list = []
    user_list.append(users[1]['auth_user_id'])
    user_list.append(users[2]['auth_user_id'])
    user_1 = users[0]

    profile_0 = user_profile_v2(users[0]['token'],
                                users[0]['auth_user_id']).json()['user']
    profile_1 = user_profile_v2(users[0]['token'],
                                users[1]['auth_user_id']).json()['user']
    profile_2 = user_profile_v2(users[0]['token'],
                                users[2]['auth_user_id']).json()['user']
    profile_3 = user_profile_v2(users[0]['token'],
                                users[3]['auth_user_id']).json()['user']

    dm_1 = dm_create_v1(user_1['token'], user_list)  #create dm 1
    dm_1 = dm_1.json()

    rt_val = dm_details_v1(user_1['token'], dm_1['dm_id'])
    rt_val = rt_val.json()

    assert rt_val['name'] == "ab, cd, ef"
    assert sorted(rt_val['members'],
                  key=lambda x: x['u_id']) == sorted([
                      {
                          'u_id': users[1]['auth_user_id'],
                          'name_first': 'c',
                          'name_last': 'd',
                          'email': '*****@*****.**',
                          'handle_str': 'cd',
                          'profile_img_url': profile_1['profile_img_url'],
                      },
                      {
                          'u_id': users[2]['auth_user_id'],
                          'name_first': 'e',
                          'name_last': 'f',
                          'email': '*****@*****.**',
                          'handle_str': 'ef',
                          'profile_img_url': profile_2['profile_img_url'],
                      },
                      {
                          'u_id': users[0]['auth_user_id'],
                          'name_first': 'a',
                          'name_last': 'b',
                          'email': '*****@*****.**',
                          'handle_str': 'ab',
                          'profile_img_url': profile_0['profile_img_url'],
                      },
                  ],
                                                     key=lambda x: x['u_id'])

    user_2 = users[1]
    user_list = []
    user_list.append(users[0]['auth_user_id'])
    dm_2 = dm_create_v1(user_2['token'], user_list)  #create dm 2
    dm_2 = dm_2.json()

    rt_val = dm_details_v1(user_2['token'], dm_2['dm_id'])
    rt_val = rt_val.json()

    assert rt_val['name'] == "ab, cd"
    assert sorted(rt_val['members'],
                  key=lambda x: x['u_id']) == sorted([
                      {
                          'u_id': users[1]['auth_user_id'],
                          'name_first': 'c',
                          'name_last': 'd',
                          'email': '*****@*****.**',
                          'handle_str': 'cd',
                          'profile_img_url': profile_1['profile_img_url'],
                      },
                      {
                          'u_id': users[0]['auth_user_id'],
                          'name_first': 'a',
                          'name_last': 'b',
                          'email': '*****@*****.**',
                          'handle_str': 'ab',
                          'profile_img_url': profile_0['profile_img_url'],
                      },
                  ],
                                                     key=lambda x: x['u_id'])

    user_4 = users[3]
    user_list = []
    user_list.append(users[0]['auth_user_id'])
    user_list.append(users[1]['auth_user_id'])
    user_list.append(users[2]['auth_user_id'])

    dm_3 = dm_create_v1(user_4['token'], user_list)  #create dm 3
    dm_3 = dm_3.json()

    rt_val = dm_details_v1(user_4['token'], dm_3['dm_id'])
    rt_val = rt_val.json()

    assert rt_val['name'] == "ab, cd, ef, gh"
    assert sorted(rt_val['members'],
                  key=lambda x: x['u_id']) == sorted([
                      {
                          'u_id': users[0]['auth_user_id'],
                          'name_first': 'a',
                          'name_last': 'b',
                          'email': '*****@*****.**',
                          'handle_str': 'ab',
                          'profile_img_url': profile_0['profile_img_url'],
                      },
                      {
                          'u_id': users[1]['auth_user_id'],
                          'name_first': 'c',
                          'name_last': 'd',
                          'email': '*****@*****.**',
                          'handle_str': 'cd',
                          'profile_img_url': profile_1['profile_img_url'],
                      },
                      {
                          'u_id': users[2]['auth_user_id'],
                          'name_first': 'e',
                          'name_last': 'f',
                          'email': '*****@*****.**',
                          'handle_str': 'ef',
                          'profile_img_url': profile_2['profile_img_url'],
                      },
                      {
                          'u_id': users[3]['auth_user_id'],
                          'name_first': 'g',
                          'name_last': 'h',
                          'email': '*****@*****.**',
                          'handle_str': 'gh',
                          'profile_img_url': profile_3['profile_img_url'],
                      },
                  ],
                                                     key=lambda x: x['u_id'])

    clear_v1()
Пример #5
0
def test_greater_than_20_notifications():
    """ Tests for correctly displayed most recent 20 notifications
    """
    clear_v1()
    user_1 = auth_register_v2('*****@*****.**', 'kjhfbshjbdf', 'Eric',
                              'Zheng').json()
    user_1_handle = user_profile_v2(user_1['token'],
                                    user_1['auth_user_id']).json()
    channel_1 = channels_create_v2(user_1['token'], 'Test', True).json()

    # Send 25 message notifications
    sent_messages = []
    for i in range(25):
        message_send_v2(
            user_1['token'], channel_1['channel_id'],
            f"@{user_1_handle['user']['handle_str']} - this is notification {i}"
        )
        sent_messages.append(
            f"@{user_1_handle['user']['handle_str']} - this is notification {i}"
        )

    assert notifications_get_v1(user_1['token']).json() == {
        'notifications': [
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[24][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[23][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[22][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[21][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[20][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[19][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[18][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[17][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[16][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[15][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[14][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[13][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[12][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[11][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[10][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[9][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[8][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[7][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[6][0:20]}"
            },
            {
                'channel_id':
                channel_1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"{user_1_handle['user']['handle_str']} tagged you in Test: {sent_messages[5][0:20]}"
            },
        ]
    }
Пример #6
0
def create_input():
    clear_v1()

    data_test_users = [
        auth_register_v2("*****@*****.**", "finalpassword", "Eric",
                         "Zheng").json(),
        auth_register_v2("*****@*****.**", "validpassword", "Josh",
                         "Hatton").json(),
        auth_register_v2("*****@*****.**", "anotherpassword", "Bunny",
                         "Dong").json(),
        auth_register_v2("*****@*****.**", "password3", "Jordan",
                         "Milch").json(),
        auth_register_v2("*****@*****.**", "4thpassword", "Dean",
                         "Zworestine").json(),
    ]

    data_test_users_handles = [
        user_profile_v2(data_test_users[0]['token'],
                        data_test_users[0]['auth_user_id']).json(),
        user_profile_v2(data_test_users[0]['token'],
                        data_test_users[1]['auth_user_id']).json(),
        user_profile_v2(data_test_users[0]['token'],
                        data_test_users[2]['auth_user_id']).json(),
        user_profile_v2(data_test_users[0]['token'],
                        data_test_users[3]['auth_user_id']).json(),
        user_profile_v2(data_test_users[0]['token'],
                        data_test_users[4]['auth_user_id']).json(),
    ]

    # user 1 is owner of channel 1
    # user 2 is owner of channel 2
    # user 3 is owner of channel 3 (private channel)
    data_test_channels = [
        channels_create_v2(data_test_users[0]['token'], 'Channel 1',
                           True).json(),
        channels_create_v2(data_test_users[1]['token'], 'Channel 2',
                           True).json(),
        channels_create_v2(data_test_users[2]['token'], 'Private',
                           False).json()
    ]

    # user 1 has dm with user 2 in dm 1
    # user 3 has dm with user 4 in dm2
    # user 5 has dm with user 2 in dm3
    data_test_dms = [
        dm_create_v1(data_test_users[0]['token'],
                     [data_test_users[1]['auth_user_id']]).json(),
        dm_create_v1(data_test_users[2]['token'],
                     [data_test_users[3]['auth_user_id']]).json(),
        dm_create_v1(data_test_users[4]['token'],
                     [data_test_users[1]['auth_user_id']]).json()
    ]

    data_test_messages = [
        f"Hello @{data_test_users_handles[0]}, how are you on such a fine lovely day? I hope you are well!",
        f"Hello @{data_test_users_handles[1]}, can you send me homework answers from yesterday please? Thanks!",
        f"Hello @{data_test_users_handles[2]}, I heard that your knees are the finest knees in all of Australia, is this true?",
        f"@{data_test_users_handles[3]} is cool.",
        f"@{data_test_users_handles[4]} is a donkey.",
        f"@{data_test_users_handles[2]} is an even bigger donkey than @{data_test_users_handles[4]}"
    ]

    return [
        data_test_users, data_test_users_handles, data_test_channels,
        data_test_dms, data_test_messages
    ]
Пример #7
0
def test_private_channel_details(set_up_server):
    """ Assume channel_details is able to reveal details of private channels 
        as well 
    """
    url = set_up_server
    user_1, user_2, user_3, user_4, user_5 = create_valid_user_data(url)
    
    channel_1 = requests.post(f"{url}channels/create/v2", json={'token': user_1['token'],
                                                                'name': 'NSFW',
                                                                'is_public': False}).json()
    requests.post(f"{url}channel/invite/v2", json={'token': user_1['token'],
                                                     'channel_id': channel_1['channel_id'],
                                                     'u_id': user_2['auth_user_id']})
    requests.post(f"{url}channel/invite/v2", json={'token': user_1['token'],
                                                     'channel_id': channel_1['channel_id'],
                                                     'u_id': user_3['auth_user_id']})
    requests.post(f"{url}channel/invite/v2", json={'token': user_1['token'],
                                                     'channel_id': channel_1['channel_id'], 
                                                     'u_id': user_4['auth_user_id']})
    requests.post(f"{url}channel/invite/v2", json={'token': user_1['token'],
                                                     'channel_id': channel_1['channel_id'],
                                                     'u_id': user_5['auth_user_id']})
    
    profile_1 = user_profile_v2(user_1['token'], user_1['auth_user_id']).json()['user']
    profile_2 = user_profile_v2(user_1['token'], user_2['auth_user_id']).json()['user']
    profile_3 = user_profile_v2(user_1['token'], user_3['auth_user_id']).json()['user']
    profile_4 = user_profile_v2(user_1['token'], user_4['auth_user_id']).json()['user']
    profile_5 = user_profile_v2(user_1['token'], user_5['auth_user_id']).json()['user']    
    
    assert requests.get(f"{url}channel/details/v2", params={'token': user_1['token'],
                                                            'channel_id': channel_1['channel_id']}).json() == {
        'name': 'NSFW',
        'owner_members': [
            {
                'u_id': user_1['auth_user_id'],
                'name_first': 'Eric',
                'name_last': 'Zheng',
                'email': '*****@*****.**',
                'handle_str': 'ericzheng',
                'profile_img_url' : profile_1['profile_img_url'],

            }
        ],
        'all_members': [
            {
                'u_id': user_1['auth_user_id'],
                'name_first': 'Eric',
                'name_last': 'Zheng',
                'email': '*****@*****.**',
                'handle_str': 'ericzheng',
                'profile_img_url' : profile_1['profile_img_url'],

            },
            {
                'u_id': user_2['auth_user_id'],
                'name_first': 'Josh',
                'name_last': 'Hatton',
                'email': '*****@*****.**',
                'handle_str': 'joshhatton',
                'profile_img_url' : profile_2['profile_img_url'],

            },
            {
                'u_id': user_3['auth_user_id'],
                'name_first': 'Bunny',
                'name_last': 'Dong',
                'email': '*****@*****.**',
                'handle_str': 'bunnydong',
                'profile_img_url' : profile_3['profile_img_url'],

            },
            {
                'u_id': user_4['auth_user_id'],
                'name_first': 'Dean',
                'name_last': 'Zworestine',
                'email': '*****@*****.**',
                'handle_str': 'deanzworestine',
                'profile_img_url' : profile_4['profile_img_url'],

            },
            {
                'u_id': user_5['auth_user_id'],
                'name_first': 'Jordan',
                'name_last': 'Milch',
                'email': '*****@*****.**',
                'handle_str': 'jordanmilch',
                'profile_img_url' : profile_5['profile_img_url'],

            }
        ],
    }
    
    requests.delete(f"{url}clear/v1")
Пример #8
0
def test_correct_details(set_up_server):
    """ Tests for successful list of channel details.
    """
    url = set_up_server
    user_1, user_2, user_3, user_4, user_5 = create_valid_user_data(url)
    # Create 3 channels with owners user1, user2 & user3 respectively
    channel_1 = requests.post(f"{url}channels/create/v2", json={'token': user_1['token'],
                                                                 'name': 'General',
                                                                 'is_public': True}).json()
    channel_2 = requests.post(f"{url}channels/create/v2", json={'token': user_2['token'],
                                                                 'name': 'Music',
                                                                 'is_public': True}).json()
    channel_3 = requests.post(f"{url}channels/create/v2", json={'token': user_3['token'],
                                                                 'name': 'Study',
                                                                 'is_public': True}).json()
    
    # User2, user3, user4 & user5 all join channel1
    requests.post(f"{url}channel/join/v2", json={'token': user_2['token'],
     'channel_id': channel_1['channel_id']})
    requests.post(f"{url}channel/join/v2", json={'token': user_3['token'],
     'channel_id': channel_1['channel_id']})
    requests.post(f"{url}channel/join/v2", json={'token': user_4['token'],
     'channel_id': channel_1['channel_id']})
    requests.post(f"{url}channel/join/v2", json={'token': user_5['token'],
     'channel_id': channel_1['channel_id']})
    # User4 & user5 join channel2
    requests.post(f"{url}channel/join/v2", json={'token': user_4['token'],
                                                 'channel_id': channel_2['channel_id']})
    requests.post(f"{url}channel/join/v2", json={'token': user_5['token'],
                                                 'channel_id': channel_2['channel_id']})
    # User1 & User5 join channel3
    requests.post(f"{url}channel/join/v2", json={'token': user_1['token'],
                                                 'channel_id': channel_3['channel_id']})
    requests.post(f"{url}channel/join/v2", json={'token': user_5['token'],
                                                 'channel_id': channel_3['channel_id']})
    
    profile_1 = user_profile_v2(user_1['token'], user_1['auth_user_id']).json()['user']
    profile_2 = user_profile_v2(user_1['token'], user_2['auth_user_id']).json()['user']
    profile_3 = user_profile_v2(user_1['token'], user_3['auth_user_id']).json()['user']
    profile_4 = user_profile_v2(user_1['token'], user_4['auth_user_id']).json()['user']
    profile_5 = user_profile_v2(user_1['token'], user_5['auth_user_id']).json()['user']
    
    
    assert requests.get(f"{url}channel/details/v2",
                        params={'token': user_1['token'], 'channel_id': channel_1['channel_id']}).json() == {
        'name': 'General',
        'owner_members': [
            {
                'u_id': user_1['auth_user_id'],     
                'name_first': 'Eric',
                'name_last': 'Zheng',
                'email': '*****@*****.**',
                'handle_str': 'ericzheng',
                'profile_img_url' : profile_1['profile_img_url'],
            }
        ],
        'all_members': [
            {
                'u_id': user_1['auth_user_id'],
                'name_first': 'Eric',
                'name_last': 'Zheng',
                'email': '*****@*****.**',
                'handle_str': 'ericzheng',
                'profile_img_url' : profile_1['profile_img_url'],

            },
            {
                'u_id': user_2['auth_user_id'],
                'name_first': 'Josh',
                'name_last': 'Hatton',
                'email': '*****@*****.**',
                'handle_str': 'joshhatton',
                'profile_img_url' : profile_2['profile_img_url'],

            },
            {
                'u_id': user_3['auth_user_id'],
                'name_first': 'Bunny',
                'name_last': 'Dong',
                'email': '*****@*****.**',
                'handle_str': 'bunnydong',
                'profile_img_url' : profile_3['profile_img_url'],

            },
            {
                'u_id': user_4['auth_user_id'],
                'name_first': 'Dean',
                'name_last': 'Zworestine',
                'email': '*****@*****.**',
                'handle_str': 'deanzworestine',
                'profile_img_url' : profile_4['profile_img_url'],

            },
            {
                'u_id': user_5['auth_user_id'],
                'name_first': 'Jordan',
                'name_last': 'Milch',
                'email': '*****@*****.**',
                'handle_str': 'jordanmilch',
                'profile_img_url' : profile_5['profile_img_url'],

            }
        ],
    }

    assert requests.get(f"{url}channel/details/v2",
                        params={'token': user_2['token'], 'channel_id': channel_2['channel_id']}).json() == {
        'name': 'Music',
        'owner_members': [
            {
                'u_id': user_2['auth_user_id'],
                'name_first': 'Josh',
                'name_last': 'Hatton',
                'email': '*****@*****.**',
                'handle_str': 'joshhatton',
                'profile_img_url' : profile_2['profile_img_url'],

            }
        ],
        'all_members': [
            {
                'u_id': user_2['auth_user_id'],
                'name_first': 'Josh',
                'name_last': 'Hatton',
                'email': '*****@*****.**',
                'handle_str': 'joshhatton',
                'profile_img_url' : profile_2['profile_img_url'],
            },
            {
                'u_id': user_4['auth_user_id'],
                'name_first': 'Dean',
                'name_last': 'Zworestine',
                'email': '*****@*****.**',
                'handle_str': 'deanzworestine',
                'profile_img_url' : profile_4['profile_img_url'],

            },
            {
                'u_id': user_5['auth_user_id'],
                'name_first': 'Jordan',
                'name_last': 'Milch',
                'email': '*****@*****.**',
                'handle_str': 'jordanmilch',
                'profile_img_url' : profile_5['profile_img_url'],

            },
        ],
    }
    
    assert requests.get(f"{url}channel/details/v2",
                        params={'token': user_3['token'], 'channel_id': channel_3['channel_id']}).json() == {
        'name': 'Study',
        'owner_members': [
            {
                'u_id': user_3['auth_user_id'],
                'name_first': 'Bunny',
                'name_last': 'Dong',
                'email': '*****@*****.**',
                'handle_str': 'bunnydong',
                'profile_img_url' : profile_3['profile_img_url'],
            }
        ],
        'all_members': [
            {
                'u_id': user_3['auth_user_id'],
                'name_first': 'Bunny',
                'name_last': 'Dong',
                'email': '*****@*****.**',
                'handle_str': 'bunnydong',
                'profile_img_url' : profile_3['profile_img_url'],
            },
            {
                'u_id': user_1['auth_user_id'],
                'name_first': 'Eric',
                'name_last': 'Zheng',
                'email': '*****@*****.**',
                'handle_str': 'ericzheng',
                'profile_img_url' : profile_1['profile_img_url'],
            },
            {
                'u_id': user_5['auth_user_id'],
                'name_first': 'Jordan',
                'name_last': 'Milch',
                'email': '*****@*****.**',
                'handle_str': 'jordanmilch',
                'profile_img_url' : profile_5['profile_img_url'],

           },
        ],
     }
    
    # Test that channel_details returns the same details for different users in 
    # the same channel.
    resp_1 = requests.get(f"{url}channel/details/v2",
     params={'token': user_1['token'], 'channel_id': channel_1['channel_id']}).json()
    resp_2 = requests.get(f"{url}channel/details/v2",
     params={'token': user_2['token'], 'channel_id': channel_1['channel_id']}).json()
    assert resp_1 == resp_2
    
    # Test that channel_details returns different details for users from 
    # different channels
    resp_1 = requests.get(f"{url}channel/details/v2",
     params={'token': user_1['token'], 'channel_id': channel_1['channel_id']}).json()
    resp_2 = requests.get(f"{url}channel/details/v2",
     params={'token': user_5['token'], 'channel_id': channel_2['channel_id']}).json()
    assert resp_1 != resp_2
    
    requests.delete(f"{url}clear/v1")