예제 #1
0
def test_assorted_notifications():
    clear_v1()
    user1 = auth_register_v2("*****@*****.**", "finalpassword", "Eric",
                             "Zheng").json()
    user2 = auth_register_v2("*****@*****.**", "validpassword", "Josh",
                             "Hatton").json()
    channel1 = channels_create_v2(user1['token'], 'Channel 1', True).json()
    channel_invite_v2(user1['token'], channel1['channel_id'],
                      user2['auth_user_id'])
    msg1str = "Welcome to the channel @joshhatton"
    msg1 = message_send_v2(user1['token'], channel1['channel_id'],
                           msg1str).json()
    message_react_v1(user2['token'], msg1['message_id'], 1)
    msg2str = "Thanks for having me @ericzheng"
    msg2 = message_send_v2(user2['token'], channel1['channel_id'],
                           msg2str).json()
    message_react_v1(user1['token'], msg2['message_id'], 1)

    assert notifications_get_v1(user1['token']).json() == {
        'notifications': [{
            'channel_id':
            channel1['channel_id'],
            'dm_id':
            -1,
            'notification_message':
            f"joshhatton tagged you in Channel 1: {msg2str[0:20]}"
        }, {
            'channel_id':
            channel1['channel_id'],
            'dm_id':
            -1,
            'notification_message':
            "joshhatton reacted to your message in Channel 1"
        }]
    }
    assert notifications_get_v1(user2['token']).json() == {
        'notifications': [
            {
                'channel_id':
                channel1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                "ericzheng reacted to your message in Channel 1"
            },
            {
                'channel_id':
                channel1['channel_id'],
                'dm_id':
                -1,
                'notification_message':
                f"ericzheng tagged you in Channel 1: {msg1str[0:20]}"
            },
            {
                'channel_id': channel1['channel_id'],
                'dm_id': -1,
                'notification_message': "ericzheng added you to Channel 1"
            },
        ]
    }
def test_react_invalid_message(create_input):
    message_remove_v1(create_input[0][0]['token'], create_input[3][0])
    message_remove_v1(create_input[0][0]['token'], create_input[4][0])
    assert message_react_v1(create_input[0][0]['token'], create_input[3][0],
                            1).status_code == INPUT_ERROR
    assert message_react_v1(create_input[0][0]['token'], create_input[4][0],
                            1).status_code == INPUT_ERROR
    assert message_unreact_v1(create_input[0][0]['token'], create_input[3][0],
                              1).status_code == INPUT_ERROR
    assert message_unreact_v1(create_input[0][0]['token'], create_input[4][0],
                              1).status_code == INPUT_ERROR
def test_simple_dm_react(create_input):
    message_react_v1(create_input[0][0]['token'], create_input[4][0], 1)
    assert len(
        dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                       0).json()['messages'][4]['reacts']) == 1
    assert dm_messages_v1(
        create_input[0][0]['token'], create_input[2][0],
        0).json()['messages'][4]['reacts'][0]['react_id'] == 1
    assert dm_messages_v1(
        create_input[0][0]['token'], create_input[2][0],
        0).json()['messages'][4]['reacts'][0]['is_this_user_reacted'] == True
    assert dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                          0).json()['messages'][4]['reacts'][0]['u_ids'][
                              0] == create_input[0][0]['auth_user_id']
def test_invalid_reactid(create_input):
    assert message_react_v1(create_input[0][0]['token'], create_input[3][0],
                            2).status_code == INPUT_ERROR
    assert message_react_v1(create_input[0][1]['token'], create_input[3][1],
                            3).status_code == INPUT_ERROR
    assert message_react_v1(create_input[0][1]['token'], create_input[3][4],
                            5).status_code == INPUT_ERROR
    assert message_react_v1(create_input[0][0]['token'], create_input[4][0],
                            2).status_code == INPUT_ERROR
    assert message_react_v1(create_input[0][2]['token'], create_input[4][1],
                            3).status_code == INPUT_ERROR
    assert message_react_v1(create_input[0][2]['token'], create_input[4][4],
                            5).status_code == INPUT_ERROR
    assert message_unreact_v1(create_input[0][0]['token'], create_input[3][0],
                              2).status_code == INPUT_ERROR
    assert message_unreact_v1(create_input[0][1]['token'], create_input[3][1],
                              3).status_code == INPUT_ERROR
    assert message_unreact_v1(create_input[0][1]['token'], create_input[3][4],
                              5).status_code == INPUT_ERROR
    assert message_unreact_v1(create_input[0][0]['token'], create_input[4][0],
                              2).status_code == INPUT_ERROR
    assert message_unreact_v1(create_input[0][2]['token'], create_input[4][1],
                              3).status_code == INPUT_ERROR
    assert message_unreact_v1(create_input[0][2]['token'], create_input[4][4],
                              5).status_code == INPUT_ERROR
def test_multiple_dm_react(create_input):
    dm_invite_v1(create_input[0][0]['token'], create_input[2][0],
                 create_input[0][1]['auth_user_id'])
    dm_invite_v1(create_input[0][0]['token'], create_input[2][0],
                 create_input[0][3]['auth_user_id'])
    dm_invite_v1(create_input[0][0]['token'], create_input[2][0],
                 create_input[0][4]['auth_user_id'])
    message_react_v1(create_input[0][0]['token'], create_input[4][0], 1)
    message_react_v1(create_input[0][1]['token'], create_input[4][0], 1)
    message_react_v1(create_input[0][2]['token'], create_input[4][0], 1)
    assert len(
        dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                       0).json()['messages'][4]['reacts']) == 1
    assert dm_messages_v1(
        create_input[0][0]['token'], create_input[2][0],
        0).json()['messages'][4]['reacts'][0]['react_id'] == 1
    assert dm_messages_v1(
        create_input[0][0]['token'], create_input[2][0],
        0).json()['messages'][4]['reacts'][0]['is_this_user_reacted'] == True
    assert len(
        dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                       0).json()['messages'][4]['reacts'][0]['u_ids']) == 3
    assert create_input[0][0]['auth_user_id'] in dm_messages_v1(
        create_input[0][0]['token'], create_input[2][0],
        0).json()['messages'][4]['reacts'][0]['u_ids']
    assert create_input[0][1]['auth_user_id'] in dm_messages_v1(
        create_input[0][0]['token'], create_input[2][0],
        0).json()['messages'][4]['reacts'][0]['u_ids']
    assert create_input[0][2]['auth_user_id'] in dm_messages_v1(
        create_input[0][0]['token'], create_input[2][0],
        0).json()['messages'][4]['reacts'][0]['u_ids']
def test_duplicate_react(create_input):
    message_react_v1(create_input[0][0]['token'], create_input[3][0], 1)
    message_react_v1(create_input[0][0]['token'], create_input[4][0], 1)
    assert message_react_v1(create_input[0][0]['token'], create_input[3][0],
                            1).status_code == INPUT_ERROR
    assert message_react_v1(create_input[0][0]['token'], create_input[4][0],
                            1).status_code == INPUT_ERROR
예제 #7
0
def test_single_react_notification():
    clear_v1()
    user1 = auth_register_v2("*****@*****.**", "finalpassword", "Eric",
                             "Zheng").json()
    user2 = auth_register_v2("*****@*****.**", "validpassword", "Josh",
                             "Hatton").json()
    channel1 = channels_create_v2(user1['token'], 'Channel 1', True).json()
    channel_join_v2(user2['token'], channel1['channel_id'])
    msg1 = message_send_v2(user1['token'], channel1['channel_id'],
                           "1 like = 1 prayer").json()
    message_react_v1(user2['token'], msg1['message_id'], 1)

    assert notifications_get_v1(user1['token']).json() == {
        'notifications': [{
            'channel_id':
            channel1['channel_id'],
            'dm_id':
            -1,
            'notification_message':
            "joshhatton reacted to your message in Channel 1"
        }]
    }
def test_not_channel_member_react(create_input):
    assert message_react_v1(create_input[0][2]['token'], create_input[3][0],
                            1).status_code == ACCESS_ERROR
    assert message_react_v1(create_input[0][3]['token'], create_input[3][1],
                            1).status_code == ACCESS_ERROR
    assert message_react_v1(create_input[0][3]['token'], create_input[3][4],
                            1).status_code == ACCESS_ERROR
    assert message_react_v1(create_input[0][4]['token'], create_input[4][3],
                            1).status_code == ACCESS_ERROR
    assert message_react_v1(create_input[0][3]['token'], create_input[4][1],
                            1).status_code == ACCESS_ERROR
    assert message_react_v1(create_input[0][3]['token'], create_input[4][4],
                            1).status_code == ACCESS_ERROR
    # Cannot occur (if the are not a member they can't have reacted - unless removed from channel)
    channel_join_v2(create_input[0][2]['token'], create_input[1][0])
    message_react_v1(create_input[0][2]['token'], create_input[3][0], 1)
    channel_leave_v1(create_input[0][2]['token'], create_input[1][0])
    assert message_unreact_v1(create_input[0][2]['token'], create_input[3][0],
                              1).status_code == ACCESS_ERROR
    message_react_v1(create_input[0][2]['token'], create_input[4][0], 1)
    dm_leave_v1(create_input[0][2]['token'], create_input[3][0])
    assert message_unreact_v1(create_input[0][2]['token'], create_input[4][0],
                              1).status_code == ACCESS_ERROR
def test_simple_dm_unreact(create_input):
    message_react_v1(create_input[0][0]['token'], create_input[4][0], 1)
    message_unreact_v1(create_input[0][0]['token'], create_input[4][0], 1)
    assert len(
        dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                       0).json()['messages'][4]['reacts']) == 0
def test_simple_channel_unreact(create_input):
    message_react_v1(create_input[0][0]['token'], create_input[3][0], 1)
    message_unreact_v1(create_input[0][0]['token'], create_input[3][0], 1)
    assert len(
        channel_messages_v2(create_input[0][0]['token'], create_input[1][0],
                            0).json()['messages'][4]['reacts']) == 0
예제 #11
0
def test_multiple_react_notification():
    clear_v1()
    user1 = auth_register_v2("*****@*****.**", "finalpassword", "Eric",
                             "Zheng").json()
    user2 = auth_register_v2("*****@*****.**", "validpassword", "Josh",
                             "Hatton").json()
    user3 = auth_register_v2("*****@*****.**", "anotherpassword", "Bunny",
                             "Dong").json()
    user4 = auth_register_v2("*****@*****.**", "password3", "Jordan",
                             "Milch").json()
    user5 = auth_register_v2("*****@*****.**", "4thpassword", "Dean",
                             "Zworestine").json()
    channel1 = channels_create_v2(user1['token'], 'Channel 1', True).json()
    channel_join_v2(user2['token'], channel1['channel_id'])
    channel_join_v2(user3['token'], channel1['channel_id'])
    channel_join_v2(user4['token'], channel1['channel_id'])
    channel_join_v2(user5['token'], channel1['channel_id'])
    msg1 = message_send_v2(user1['token'], channel1['channel_id'],
                           "1 like = 1 prayer").json()
    message_react_v1(user1['token'], msg1['message_id'], 1)
    message_react_v1(user2['token'], msg1['message_id'], 1)
    message_react_v1(user3['token'], msg1['message_id'], 1)
    message_react_v1(user4['token'], msg1['message_id'], 1)
    message_react_v1(user5['token'], msg1['message_id'], 1)

    assert notifications_get_v1(user1['token']).json() == {
        'notifications': [{
            'channel_id':
            channel1['channel_id'],
            'dm_id':
            -1,
            'notification_message':
            "deanzworestine reacted to your message in Channel 1"
        }, {
            'channel_id':
            channel1['channel_id'],
            'dm_id':
            -1,
            'notification_message':
            "jordanmilch reacted to your message in Channel 1"
        }, {
            'channel_id':
            channel1['channel_id'],
            'dm_id':
            -1,
            'notification_message':
            "bunnydong reacted to your message in Channel 1"
        }, {
            'channel_id':
            channel1['channel_id'],
            'dm_id':
            -1,
            'notification_message':
            "joshhatton reacted to your message in Channel 1"
        }, {
            'channel_id':
            channel1['channel_id'],
            'dm_id':
            -1,
            'notification_message':
            "ericzheng reacted to your message in Channel 1"
        }]
    }