예제 #1
0
def test1():
    restart()
    authRegisterDict1 = auth_register("*****@*****.**", "123456",
                                      "Tim", "Hu")
    token1 = authRegisterDict1["token"]
    UID1 = authRegisterDict1['u_id']
    authRegisterDict2 = auth_register("*****@*****.**", "1we33456",
                                      "Hayden", "Smith")
    token2 = authRegisterDict2["token"]
    UID2 = authRegisterDict2['u_id']
    authRegisterDict3 = auth_register("*****@*****.**", "1we33ee456",
                                      "Jeff", "Lu")
    token3 = authRegisterDict3["token"]

    UID3 = authRegisterDict3['u_id']

    authRegisterDict4 = auth_register("*****@*****.**", "jijijij37236",
                                      'daniel', 'quin')
    token4 = authRegisterDict4["token"]

    UID4 = authRegisterDict4['u_id']
    channel_id = channels_create(token1, 'test1', True)
    channel_invite(token1, channel_id, UID2)
    channel_invite(token1, channel_id, UID3)
    message_send(token1, channel_id, 'hello')
    message_send(token2, channel_id, 'hi')
    message_send(token3, channel_id, 'numb')
    result = search(token1, 'hello')
    assert result['messages'][0]['message'] == 'hello'
    assert result['messages'][0]['message_id'] == 1
예제 #2
0
def test_standup_all():
    restart()
    authRegisterDict1 = auth_register("*****@*****.**","123456","Tim","Hu")
    token1 = authRegisterDict1["token"]
    authRegisterDict2 = auth_register("*****@*****.**","1we33456","Hayden","Smith")
    token2 = authRegisterDict2["token"]
    UID2 = authRegisterDict2['u_id']
    authRegisterDict3 = auth_register(
        "*****@*****.**", "1we33ee456", "Jeff", "Lu")
    token3 = authRegisterDict3["token"]
    
    UID3 = authRegisterDict3['u_id']

    authRegisterDict4 = auth_register(
        "*****@*****.**", "jijijij37236", 'daniel', 'quin')
    token4 = authRegisterDict4["token"]
    
    channel_id = channels_create(token1,'test1',True)
    channel_invite(token1,channel_id,UID2)
    channel_invite(token1,channel_id,UID3)

    showtime(20)

    with pytest.raises(ValueError, match=r".*"):
        standup_send(token2, channel_id, 'hello')

    standup_start(token1,channel_id, 20)
    
    with pytest.raises(ValueError, match = r".*"):
        standup_start(token2, channel_id, 20)

    with pytest.raises(AccessError, match=r".*"):
        standup_start(token4,channel_id, 20)
        
    with pytest.raises(ValueError,match = r".*"):
        standup_start(token1,-1, 20)

    with pytest.raises(AccessError, match=r".*"):
        standup_send(token4, channel_id , 'hello')

    with pytest.raises(ValueError, match=r".*"):
        standup_send(token1, -1 , 'hello')

    with pytest.raises(ValueError, match=r".*"):
        standup_send(token3, channel_id, "dhbfuyawgefdahdhbfuyawgefdahsgfhiashfuihasfnrweiauehcyaacweynugirnnnnnnnnnnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnfnnnnnnnnnnnnnnnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfaecntyvufyyyyyyyyyyyyyyyfyfyfygyyywyyyyyyyyyyyyyyywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywydhbfuyawgefdahsgfhiashfuihasfnrweiauehcyaacweynugirnnnnnnnnnnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnfnnnnnnnnnnnnnnnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfaecntyvufyyyyyyyyyyyyyyyfyfyfygyyywyyyyyyyyyyyyyyywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywydhbfuyawgefdahsgfhiashfuihasfnrweiauehcyaacweynugirnnnnnnnnnnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnfnnnnnnnnnnnnnnnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfaecntyvufyyyyyyyyyyyyyyyfyfyfygyyywyyyyyyyyyyyyyyywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywyywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywyywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywyysgfhiashfuihasfnrweiauehcyaacweynugirnnnnnnnnnnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnfnnnnnnnnnnnnnnnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfaecntyvufyyyyyyyyyyyyyyyfyfyfygyyywyyyyyyyyyyyyyyywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywywyy")

    standup_send(token2,channel_id, 'hello')
    standup_send(token3,channel_id,'daniel')
    standup_send(token2,channel_id, 'quin' )
    channelDict = load()['channelDict']
    for ch in channelDict:
        if int(channel_id) == ch['channel_id']:
            assert 'hayden: hello' + '\r\n' + 'jeff: daniel' + '\r\n' + 'hayden: quin' == ch['standlist']
    pass
예제 #3
0
def test_channel_invite():
    reset_data()
    # SETUP BEGIN
    auth_dic1 = auth_register("*****@*****.**", "123456", "firstone",
                              "lastone")
    auth_dic1 = auth_login("*****@*****.**", "123456")
    token1 = auth_dic1['token']
    uid1 = auth_dic1['u_id']

    auth_dic2 = auth_register("*****@*****.**", "123456", "firstone",
                              "lastone")
    auth_dic2 = auth_login("*****@*****.**", "123456")
    token2 = auth_dic2['token']
    uid2 = auth_dic2['u_id']

    auth_dic3 = auth_register("*****@*****.**", "123456", "firstone",
                              "lastone")
    auth_dic3 = auth_login("*****@*****.**", "123456")
    token3 = auth_dic3['token']

    channelid_dic1 = channels_create(token1, "channel 1", True)
    channel_id1 = channelid_dic1['channel_id']

    channelid_dic2 = channels_create(token1, "channel 2", True)
    channel_id2 = channelid_dic2['channel_id']
    # SETUP END

    # successful test
    assert channel_invite(token1, channel_id1, uid2) == {}

    # error test
    with pytest.raises(ValueError):
        # the channel if does not exist
        channel_invite(token1, 10, uid2)

    with pytest.raises(AccessError):
        # channel_id does not refer to a valid channel that the authorised user is part of.
        channel_invite(token3, channel_id2, uid2)

    with pytest.raises(ValueError):
        # u_id does not refer to a valid user
        # assume u_id 5 does not refer to a valid user
        channel_invite(token1, channel_id1, 10)

    with pytest.raises(ValueError):
        # u_id does not refer to a valid user
        # invite the user that is in channel (by calling function above, uid2 is in channel)
        channel_invite(token2, channel_id1, uid1)

    # logout
    auth_logout(token1)
    auth_logout(token2)
    auth_logout(token3)

    reset_data()
예제 #4
0
def channels_invite():
    token = request.form.get('token')
    channel_id = request.form.get('channel_id')
    u_id = request.form.get('u_id')
    return dumps(channel_invite(token, channel_id, u_id))
예제 #5
0
def channel_invite_e():
    token = request.form.get('token')
    channel_id = int(request.form.get('channel_id'))
    u_id = int(request.form.get('u_id'))
    dumpstring = channel.channel_invite(token, channel_id, u_id)
    return dumps(dumpstring)
예제 #6
0
def app_channel_invite():
    channel_id = int(get_args('channel_id'))
    token = get_args('token')
    u_id = int(get_args('u_id'))
    return dumps(channel_invite(token, channel_id, u_id))