Ejemplo n.º 1
0
def test_standard_pin():
    global my_users
    setupDict = setup()
    message_id = message_send(setupDict['token'], setupDict['channel_id'],
                              "Hello")
    message_pin(setupDict['token'], message_id['message_id'])
    message = get_message_from_m_id(message_id['message_id'])

    assert message.is_pinned == True
Ejemplo n.º 2
0
def test_invalid_message_id_pin():
    global my_users
    setupDict = setup()
    message_id = message_send(setupDict['token'], setupDict['channel_id'],
                              "Hello")

    with pytest.raises(ValueError, match=r'Message no long exist') as excinfo:
        message_pin(setupDict['token'], "123")
    assert excinfo.type == ValueError

    message = get_message_from_m_id(message_id['message_id'])
    assert message.is_pinned == False
Ejemplo n.º 3
0
def test_already_unpinned():
    global my_users
    setupDict = setup()
    message_id = message_send(setupDict['token'], setupDict['channel_id'],
                              "Hello")
    message = get_message_from_m_id(message_id['message_id'])

    with pytest.raises(ValueError,
                       match=r'Message is already unpinned') as excinfo:
        message_unpin(setupDict['token'], message_id['message_id'])
    assert excinfo.type == ValueError

    assert message.is_pinned == False
Ejemplo n.º 4
0
def test_already_reacted():
    global my_users
    setupDict = setup()
    message_id = message_send(setupDict['token'], setupDict['channel_id'],
                              "Hello")
    react_id = 1
    message_react(setupDict['token'], message_id['message_id'], react_id)
    message = get_message_from_m_id(message_id['message_id'])
    reacts = message.get_reacts()
    assert setupDict['u_id'] in reacts[0].get_uids()

    with pytest.raises(ValueError,
                       match=r'Already contains an active react') as excinfo:
        message_react(setupDict['token'], message_id['message_id'], react_id)
    assert excinfo.type == ValueError
Ejemplo n.º 5
0
def test_invalid_token_unpin():
    global my_users
    setupDict = setup()
    message_id = message_send(setupDict['token'], setupDict['channel_id'],
                              "Hello")

    message_pin(setupDict['token'], message_id['message_id'])

    message = get_message_from_m_id(message_id['message_id'])
    auth_logout(setupDict['token'])
    with pytest.raises(AccessError,
                       match=r'User is not a valid user') as excinfo:
        message_unpin(setupDict['token'], message_id['message_id'])
    assert excinfo.type == AccessError

    assert message.is_pinned == True
Ejemplo n.º 6
0
def test_unauthorized():
    global my_users
    setupDict = setup()
    message_id = message_send(setupDict['token'], setupDict['channel_id'],
                              "Hello")

    auth_register("*****@*****.**", "password", "Student", "Citizen")
    userDict = auth_login("*****@*****.**", 'password')

    with pytest.raises(
            AccessError,
            match=r'User is not a member of the channel') as excinfo:
        message_pin(userDict['token'], message_id['message_id'])
    assert excinfo.type == AccessError

    message = get_message_from_m_id(message_id['message_id'])
    assert message.is_pinned == False
Ejemplo n.º 7
0
def test_not_admin_pin():
    global my_users
    setupDict = setup()
    message_id = message_send(setupDict['token'], setupDict['channel_id'],
                              "Hello")

    auth_register("*****@*****.**", "password", "Student", "Citizen")
    userDict = auth_login("*****@*****.**", 'password')
    channel_invite(setupDict['token'], setupDict['channel_id'],
                   userDict['u_id'])

    with pytest.raises(ValueError,
                       match=r'The user is not an admin') as excinfo:
        message_pin(userDict['token'], message_id['message_id'])
    assert excinfo.type == ValueError

    message = get_message_from_m_id(message_id['message_id'])
    assert message.is_pinned == False
Ejemplo n.º 8
0
def test_standard_unreact():
    global my_users
    setupDict = setup()
    message_id = message_send(setupDict['token'], setupDict['channel_id'],
                              "Hello")
    react_id = 1
    message_react(setupDict['token'], message_id['message_id'], react_id)
    message = get_message_from_m_id(message_id['message_id'])
    reacts = message.get_reacts()

    auth_register("*****@*****.**", "password", "Student", "Citizen")
    userDict = auth_login("*****@*****.**", 'password')
    channel_invite(setupDict['token'], setupDict['channel_id'],
                   userDict['u_id'])
    message_react(userDict['token'], message_id['message_id'], react_id)

    message_unreact(userDict['token'], message_id['message_id'], react_id)
    assert userDict['u_id'] not in reacts[0].get_uids()
Ejemplo n.º 9
0
def test_react_not_in_channel():
    global my_users
    setupDict = setup()
    userDict = auth_register("*****@*****.**", "password", "Student", "Citizen")
    message_id = message_send(setupDict['token'], setupDict['channel_id'],
                              "Hello")
    react_id = 1
    message_react(setupDict['token'], message_id['message_id'], react_id)
    message = get_message_from_m_id(message_id['message_id'])
    reacts = message.get_reacts()
    assert setupDict['u_id'] in reacts[0].get_uids()

    with pytest.raises(
            ValueError,
            match=r'Invalid message_id with in the user joined channel'
    ) as excinfo:
        message_react(userDict['token'], message_id['message_id'], react_id)
    assert excinfo.type == ValueError