def test_mixed_success(create_input):
    current_time = int(time.time())
    message_senddm_v1(create_input[0][0]["token"], create_input[1][0]["dm_id"],
                      "This is the first normal message")
    assert len(
        dm_messages_v1(create_input[0][0]["token"],
                       create_input[1][0]["dm_id"], 0).json()["messages"]) == 1
    msg = message_sendlaterdm_v1(create_input[0][1]["token"],
                                 create_input[1][0]["dm_id"],
                                 "Hey there, I'm from the past!",
                                 current_time + 2).json()
    assert type(msg) == dict
    assert type(msg["message_id"]) == int
    message_senddm_v1(create_input[0][2]["token"], create_input[1][0]["dm_id"],
                      "This is the second normal message")

    # Make sure delayed message has not been sent yet
    msgs = dm_messages_v1(create_input[0][1]["token"],
                          create_input[1][0]["dm_id"], 0).json()["messages"]
    assert len(msgs) == 2

    # Wait 2.5 seconds and check again; delayed message should be there
    time.sleep(2.5)
    msgs = dm_messages_v1(create_input[0][1]["token"],
                          create_input[1][0]["dm_id"], 0).json()["messages"]
    assert len(msgs) == 3
    assert msgs[0]["message"] == "Hey there, I'm from the past!"
    assert msgs[0]["time_created"] == current_time + 2
    assert msgs[1]["message"] == "This is the second normal message"
    assert msgs[1]["time_created"] == current_time
    assert msgs[2]["message"] == "This is the first normal message"
    assert msgs[2]["time_created"] == current_time
コード例 #2
0
def test_multiple_dm_pin(create_input):
    message_pin_v1(create_input[0][0]['token'], create_input[4][0])
    message_pin_v1(create_input[0][0]['token'], create_input[4][2])
    message_pin_v1(create_input[0][0]['token'], create_input[4][4])
    assert dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                          0).json()['messages'][4]['is_pinned'] == True
    assert dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                          0).json()['messages'][3]['is_pinned'] == False
    assert dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                          0).json()['messages'][2]['is_pinned'] == True
    assert dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                          0).json()['messages'][1]['is_pinned'] == False
    assert dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                          0).json()['messages'][0]['is_pinned'] == True
コード例 #3
0
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']
コード例 #4
0
def test_removed_dms():
    """Tests that sent dm messages are now 'Removed user' after the user is
    removed
    """
    clear_v1()
    user_1 = auth_register_v2("*****@*****.**", "finalpassword", "Eric",
                              "Zheng").json()
    user_2 = auth_register_v2("*****@*****.**", "validpassword", "Josh",
                              "Hatton").json()

    dm_1 = dm_create_v1(user_1["token"], [user_2["auth_user_id"]]).json()

    message_senddm_v1(user_1["token"], dm_1["dm_id"], "Hello user 2!")
    message_2 = message_senddm_v1(user_2["token"], dm_1["dm_id"],
                                  "Nice to meet you user 1").json()
    message_senddm_v1(user_2["token"], dm_1["dm_id"], "you are a donkey :)")

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

    dm_1_messages = dm_messages_v1(user_1["token"], dm_1["dm_id"], 0).json()
    for dm in dm_1_messages["messages"]:
        if dm["message_id"] == message_2["message_id"]:
            assert dm["message"] == "Removed user"

    clear_v1()
def test_success_no_delay(create_input):
    assert dm_messages_v1(create_input[0][0]["token"],
                          create_input[1][0]["dm_id"],
                          0).json()["messages"] == []
    current_time = int(time.time())
    msg = message_sendlaterdm_v1(create_input[0][0]["token"],
                                 create_input[1][0]["dm_id"], "Hey there!",
                                 current_time).json()
    assert type(msg) == dict
    assert type(msg["message_id"]) == int

    # Message should have been sent already
    msgs = dm_messages_v1(create_input[0][0]["token"],
                          create_input[1][0]["dm_id"], 0).json()["messages"]
    assert len(msgs) == 1
    assert msgs[0]["message"] == "Hey there!"
    assert msgs[0]["time_created"] == current_time
コード例 #6
0
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_simple_success(create_input):
    assert dm_messages_v1(create_input[0][0]["token"],
                          create_input[1][0]["dm_id"],
                          0).json()["messages"] == []
    current_time = int(time.time())
    msg = message_sendlaterdm_v1(create_input[0][0]["token"],
                                 create_input[1][0]["dm_id"], "Hey there!",
                                 current_time + 2).json()
    assert type(msg) == dict
    assert type(msg["message_id"]) == int

    # Make sure message has not been sent yet
    assert dm_messages_v1(create_input[0][0]["token"],
                          create_input[1][0]["dm_id"],
                          0).json()["messages"] == []

    # Wait 2.5 seconds and check again; message should be there
    time.sleep(2.5)
    msgs = dm_messages_v1(create_input[0][0]["token"],
                          create_input[1][0]["dm_id"], 0).json()["messages"]
    assert len(msgs) == 1
    assert msgs[0]["message"] == "Hey there!"
    assert msgs[0]["time_created"] == current_time + 2
コード例 #8
0
def test_simple_dm_unpin(create_input):
    message_pin_v1(create_input[0][0]['token'], create_input[4][0])
    message_unpin_v1(create_input[0][0]['token'], create_input[4][0])
    assert dm_messages_v1(create_input[0][0]['token'], create_input[2][0],
                          0).json()['messages'][4]['is_pinned'] == False
コード例 #9
0
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
コード例 #10
0
def test_multiple_success(create_input):
    message_senddm_v1(create_input[0][0]["token"], create_input[1][0]["dm_id"],
                      "This is the first normal message")
    assert len(
        dm_messages_v1(create_input[0][0]["token"],
                       create_input[1][0]["dm_id"], 0).json()["messages"]) == 1
    current_time = int(time.time())
    msg = message_sendlaterdm_v1(create_input[0][1]["token"],
                                 create_input[1][0]["dm_id"],
                                 "Hey there, I'm from the past!",
                                 current_time + 2).json()
    assert type(msg) == dict
    assert type(msg["message_id"]) == int
    msg = message_sendlaterdm_v1(create_input[0][2]["token"],
                                 create_input[1][0]["dm_id"],
                                 "Hey, I'm from the distant past!",
                                 current_time + 4).json()
    assert type(msg) == dict
    assert type(msg["message_id"]) == int
    msg = message_sendlaterdm_v1(create_input[0][0]["token"],
                                 create_input[1][0]["dm_id"],
                                 "Hey there, I'm from the past past!!",
                                 current_time + 3).json()
    assert type(msg) == dict
    assert type(msg["message_id"]) == int
    message_senddm_v1(create_input[0][2]["token"], create_input[1][0]["dm_id"],
                      "This is the second normal message")

    # Make sure delayed message has not been sent yet
    assert len(
        dm_messages_v1(create_input[0][0]["token"],
                       create_input[1][0]["dm_id"], 0).json()["messages"]) == 2

    # Wait 2.5 seconds and check again; first delayed message should be there
    time.sleep(2.5)
    msgs = dm_messages_v1(create_input[0][1]["token"],
                          create_input[1][0]["dm_id"], 0).json()["messages"]
    assert len(msgs) == 3
    assert msgs[0]["message"] == "Hey there, I'm from the past!"
    assert msgs[0]["time_created"] == current_time + 2
    assert msgs[1]["message"] == "This is the second normal message"
    assert msgs[1]["time_created"] == current_time
    assert msgs[2]["message"] == "This is the first normal message"
    assert msgs[2]["time_created"] == current_time

    # Wait 1 second; second delayed message should be there
    time.sleep(1)
    msgs = dm_messages_v1(create_input[0][1]["token"],
                          create_input[1][0]["dm_id"], 0).json()["messages"]
    assert len(msgs) == 4
    assert msgs[0]["message"] == "Hey there, I'm from the past past!!"
    assert msgs[0]["time_created"] == current_time + 3
    assert msgs[1]["message"] == "Hey there, I'm from the past!"
    assert msgs[1]["time_created"] == current_time + 2
    assert msgs[2]["message"] == "This is the second normal message"
    assert msgs[2]["time_created"] == current_time
    assert msgs[3]["message"] == "This is the first normal message"
    assert msgs[3]["time_created"] == current_time

    # Wait 1 more second; final delayed message should be there
    time.sleep(1)
    msgs = dm_messages_v1(create_input[0][1]["token"],
                          create_input[1][0]["dm_id"], 0).json()["messages"]
    assert len(msgs) == 5
    assert msgs[0]["message"] == "Hey, I'm from the distant past!"
    assert msgs[0]["time_created"] == current_time + 4
    assert msgs[1]["message"] == "Hey there, I'm from the past past!!"
    assert msgs[1]["time_created"] == current_time + 3
    assert msgs[2]["message"] == "Hey there, I'm from the past!"
    assert msgs[2]["time_created"] == current_time + 2
    assert msgs[3]["message"] == "This is the second normal message"
    assert msgs[3]["time_created"] == current_time
    assert msgs[4]["message"] == "This is the first normal message"
    assert msgs[4]["time_created"] == current_time