Example #1
0
def profile():
    token = request.args.get('token')
    u_id = request.args.get('u_id')
    #data = data if data is not None else False

    user_profile = user_profile_v1(token, u_id)
    return dumps(user_profile)
Example #2
0
def test_invalid_token(register_users):
    with pytest.raises(AccessError):
        assert user_profile_v1(make_token(5), 0)
        assert user_profile_setname_v1(make_token(5), 'Eyal', 'Dorfan')
        assert user_profile_setemail_v1(make_token(5), '*****@*****.**')
        assert user_profile_sethandle_v1(make_token(5), 'eyaldorfan')
        assert users_all_v1(make_token(5))
        assert user_stats_v1(make_token(5))
        assert users_stats_v1(make_token(5))
Example #3
0
def test_user_profile(register_users):
    assert user_profile_v1(make_token(0), 0) == {
        'user': {
            'u_id': 0,
            'email': '*****@*****.**',
            'name_first': 'Gungeet',
            'name_last': 'Singh',
            'handle_str': 'gungeetsingh',
        }
    }
Example #4
0
def test_proper_setname():
    assert user_profile_setname_v1(make_token(0), 'Eyal', 'Dorfan') == {}
    assert user_profile_v1(make_token(0), 0) == {
        'user': {
            'u_id': 0,
            'email': '*****@*****.**',
            'name_first': 'Eyal',
            'name_last': 'Dorfan',
            'handle_str': 'gungeetsingh',
        }
    }
Example #5
0
def test_valid_email_reset(register_users):
    result = user_profile_setemail_v1(make_token(0), '*****@*****.**')
    assert result == {}
    assert user_profile_v1(make_token(0), 0) == {
        'user': {
            'u_id': 0,
            'email': '*****@*****.**',
            'name_first': 'Gungeet',
            'name_last': 'Singh',
            'handle_str': 'gungeetsingh',
        }
    }
Example #6
0
def test_handle_whitespace():  
    clear_v1()
    auth_register_v2('*****@*****.**', '123456', 'T ad hg', 'Av rah\nami   ')
    assert user_profile_v1(make_token(0), 0) == {
        'user': {
            'u_id': 0,
            'email': '*****@*****.**',
            'name_first': 'T ad hg',
            'name_last': 'Av rah\nami   ',
            'handle_str': 'tadhgavrahami',
        }
    }
Example #7
0
def test_handle_at_sign():
    clear_v1()
    auth_register_v2('*****@*****.**', '123456', 'Tom', '@vrah@mi   ')
    assert user_profile_v1(make_token(0), 0) == {
        'user': {
            'u_id': 0,
            'email': '*****@*****.**',
            'name_first': 'Tom',
            'name_last': '@vrah@mi   ',
            'handle_str': 'tomvrahmi',
        }
    }
Example #8
0
def test_handle_iteration():
    clear_v1()
    auth_register_v2('*****@*****.**', '123abc!@#', 'Tal', 'Avrahami')
    result = auth_register_v2('*****@*****.**', '123456', 'Tal', 'Avrahami')
    assert result == {'token': make_token(1), 'auth_user_id': 1}
    assert user_profile_v1(make_token(1), 1) == {
        'user': {
            'u_id': 1,
            'email': '*****@*****.**',
            'name_first': 'Tal',
            'name_last': 'Avrahami',
            'handle_str': 'talavrahami0',
        }
    }
Example #9
0
def test_invalid_handle(register_users):
    assert user_profile_sethandle_v1(make_token(0), 'EEEEyaldorfan@  ') == {}
    assert user_profile_v1(make_token(0), 0) == {
        'user': {
            'u_id': 0,
            'email': '*****@*****.**',
            'name_first': 'Gungeet',
            'name_last': 'Singh',
            'handle_str': 'eeeeyaldorfan',
        }
    }

    with pytest.raises(InputError):
        user_profile_sethandle_v1(make_token(0), 'A')
        user_profile_sethandle_v1(make_token(0), 'A' * 21)
        user_profile_sethandle_v1(make_token(0), 'eeeeyaldorfan')
Example #10
0
def test_remove_admin():
    channels_create_v2(make_token(1), "PublicChannel1", True)
    channel_invite_v2(make_token(1), 0, 0)
    message_send_v2(make_token(1), 0, "Hello")
    assert admin_user_remove_v1(make_token(0), 1) == {}
    assert user_profile_v1(make_token(0), 1) == {
        'user': {
            'u_id': 1,
            'email': '*****@*****.**',
            'name_first': 'Removed user',
            'name_last': 'Removed user',
            'handle_str': 'petertran',
        }
    }
    assert channel_messages_v2(make_token(0), 0, 0) == {
        'messages': [{
            "message_id":
            0,
            "u_id":
            1,
            "message":
            "Removed user",
            "time_created":
            str(create_timestamp()),
            "channel_id":
            0,
            "dm_id":
            -1,
            "reacts": [{
                "react_id": 1,
                "u_ids": [],
                "is_this_user_reacted": False
            }],
            "is_pinned":
            False
        }],
        'start':
        0,
        'end':
        -1,
    }
Example #11
0
def test_invalid_user(register_users):
    with pytest.raises(InputError):
        assert user_profile_v1(make_token(2), 4)