Ejemplo n.º 1
0
def test_channel_messages_4():
    owner_token, owner_id, u_token, u_id, channel_id, channel_id2 = user_setup(
    )
    messagelist = message_setup()

    list1 = []
    start = 53
    with pytest.raises(ValueError):
        channel_messages(owner_token, channel_id, 53)
Ejemplo n.º 2
0
def test_channel_messages_6():
    owner_token, owner_id, u_token, u_id, channel_id, channel_id2 = user_setup(
    )
    messagelist = message_setup()

    list1 = []
    start = 0
    end = start + 50
    for i in range(start, end):
        list1.append(messagelist[i])
    with pytest.raises(AccessError):
        channel_messages(u_token, 2, 0)
Ejemplo n.º 3
0
def test_channel_messages_9():
    data = get_data()
    owner_token, owner_id, u_token, u_id, channel_id, channel_id2 = user_setup(
    )

    now = datetime.datetime.now()
    one_hour_later = (now + datetime.timedelta(hours=1)).timestamp()

    m_1 = message_send(owner_token, channel_id, "message1")
    m_2 = message_send(owner_token, channel_id, "message2")
    m_3 = message_send(owner_token, channel_id, "message3")
    m_4 = message_send(owner_token, channel_id, "message4")
    m_5 = message_sendlater(owner_token, channel_id, "message5 (future)",
                            one_hour_later)
    m_6 = message_send(owner_token, channel_id, "message6")

    messagelist = data['messages']
    messagelist.sort(key=lambda i: i['time_created'], reverse=True)
    ##########################    END SETUP   ########################

    list1 = []
    start = 0
    end = 6
    timestamp = datetime.datetime.now().timestamp()
    for i in range(start, end):
        if timestamp > messagelist[i]['time_created']:
            list1.append(messagelist[i])
    assert (channel_messages(owner_token, channel_id, 0) == {
        'messages': list1,
        'start': 0,
        'end': -1
    })
Ejemplo n.º 4
0
def test_channel_messages_2():
    owner_token, owner_id, u_token, u_id, channel_id, channel_id2 = user_setup(
    )
    messagelist = message_setup()

    list1 = []
    start = 2
    end = start + 50
    for i in range(start, end):
        list1.append(messagelist[i])
    assert (channel_messages(owner_token, channel_id, 2) == {
        'messages': list1,
        'start': 2,
        'end': 52,
    })
Ejemplo n.º 5
0
def test_channel_messages_3():
    owner_token, owner_id, u_token, u_id, channel_id, channel_id2 = user_setup(
    )
    messagelist = message_setup()

    list1 = []
    start = 25
    end = 52
    for i in range(start, end):
        list1.append(messagelist[i])
    assert (channel_messages(owner_token, channel_id, 25) == {
        'messages': list1,
        'start': 25,
        'end': -1
    })
Ejemplo n.º 6
0
def test_channel_messages_8():
    owner_token, owner_id, u_token, u_id, channel_id, channel_id2 = user_setup(
    )
    messagelist = message_setup()

    list1 = []
    start = 25
    end = 52
    message_react(u_token, 52, 1)
    for i in range(start, end):
        list1.append(messagelist[i])
    assert (channel_messages(owner_token, channel_id, 25) == {
        'messages': list1,
        'start': 25,
        'end': -1
    })
    assert not messagelist[0]['reacts'][0]['is_this_user_reacted']