コード例 #1
0
def test_admin_but_non_members():
    channel_id2 = channel_create(token2, "Example channel 2",
                                 True)["channel_id"]
    m_id = message_send(token2, channel_id2, "test_message")["message_id"]
    message_pin(token2, m_id)

    with pytest.raises(AccessError):
        message_unpin(token1, m_id)
コード例 #2
0
def test_message_pin():
    ## set up
    AuthRegDict = auth_register("*****@*****.**", "123456", "Hayden", "Smith")
    token = AuthRegDict['token']
    AuthRegDict2 = auth_register("*****@*****.**", "1123456", "Hayen", "Sith")
    token2 = AuthRegDict['token']
    publicChan = channels_create(token, "public", True)
    publicId = publicChan['channel_id']
    
    message_send(token, publicId, "message one")
    messageDic = channel_messages(token, publicChan, 0)
    ###messageDic{ message_id, u_id, message, time_created, is_unread }
    firstId = messageDic[message_id][0]
    firstMessage = messageDic[message][0]
    ## set up done

   
    message_pin(token, firstId)
    message_unpin(token,firstId)
コード例 #3
0
def test_message_unpinFAILinvalidMessage():
    ## set up
    AuthRegDict = auth_register("*****@*****.**", "123456", "Hayden", "Smith")
    token = AuthRegDict['token']
    AuthRegDict2 = auth_register("*****@*****.**", "1123456", "Hayen", "Sith")
    token2 = AuthRegDict['token']
    publicChan = channels_create(token, "public", True)
    publicId = publicChan['channel_id']
    
    message_send(token, publicId, "message one")
    messageDic = channel_messages(token, publicChan, 0)
    ###messageDic{ message_id, u_id, message, time_created, is_unread }
    firstId = messageDic[message_id][0]
    fakeId = "asdfg123#"
    firstMessage = messageDic[message][0]
    ## set up done

    with pytest.raises(AccessError, match=r"*"):
        message_unpin(token, fakeId)
コード例 #4
0
def test_message_unpin_non_admin():
    # test an invalid message Id case
    with pytest.raises(ValueError):
        message_unpin(token2, 1)
コード例 #5
0
def test_message_unpin_invalid_msg_id():
    with pytest.raises(ValueError):
        message_unpin(token1, -1)
コード例 #6
0
def test_message_already_unpinned():
    with pytest.raises(ValueError):
        message_unpin(token1, 0)
コード例 #7
0
def test_message_unpin():
    message_send(token1, 0, "test_message")
    message_send(token1, 0, "test_message2")  # assume message id 2
    message_send(token1, 0, "test_message3")  # assume message id 2
    message_pin(token1, 0)
    assert message_unpin(token1, 0) == {}