Esempio n. 1
0
def test_user_all04():
    user1 = auth.register("*****@*****.**", "test", "John", "Smith")
    user2 = auth.register("*****@*****.**", "Example", "Jhn", "Smith")
    user3 = auth.register("*****@*****.**", "Example", "Jon", "Smith")
    user4 = auth.register("*****@*****.**", "Example", "Bon", "Smoth")
    
    pub_channel = channels.create(user1['token'], 'awesomechannel', True)
    priv_channel = channels.create(user2['token'], 'notcool', False)
    
    channel.joi(user3['token'],pub_channel['channel_id'])
    channel.joi(user2['token'],priv_channel['channel_id'])

    users_dictionary = {
        'users' : [
            profile(user1['token'],user1['u_id']),
            profile(user2['token'],user2['u_id']),
            profile(user3['token'],user3['u_id']),
            profile(user4['token'],user4['u_id'])
        ]
    }
    
    assert all_(user1['token']) == users_dictionary
    assert all_(user2['token']) == users_dictionary
    assert all_(user3['token']) == users_dictionary
    assert all_(user4['token']) == users_dictionary
Esempio n. 2
0
def test_user_all02():
    user1 = auth.register("*****@*****.**", "test", "John", "Smith")
    user2 = auth.register("*****@*****.**", "Example", "John", "Smith")
    user3 = auth.register("*****@*****.**", "Example", "John", "Smith")
    
    users_dictionary = {
        'users' : [
            profile(user1['token'],user1['u_id'])['user'],
            profile(user2['token'],user2['u_id'])['user'],
            profile(user3['token'],user3['u_id'])['user']
        ]
    }
    assert all_(user2['token']) == users_dictionary
Esempio n. 3
0
def test_user_all01():
    test_user = create_user()
    users_dictionary = {
        'users' : [
            profile(test_user['token'],['u_id'])['user']
        ]
    }
    assert all_(test_user['token']) == users_dictionary
Esempio n. 4
0
def test_setemail01():
    new_user = create_user()
    setemail(new_user['token'],"*****@*****.**")
    new_user_dictionary = {
        "u_id": new_user['u_id'],
        "email": '*****@*****.**',
        "name_first": "John",
        "name_last": "Smith",
        "handle_str": "JohnSmith"
    }
    assert profile(new_user['token'],['u_id']) == new_user_dictionary
Esempio n. 5
0
def test_sethandle05():
    new_user = create_user()
    sethandle(new_user['token'],"a" * 20)
    new_user_dictionary = {
        "user": {
            "u_id" : new_user["u_id"],
            "email" : "*****@*****.**",
            "name_first" : "John",
            "name_last" : "Smith",
            "handle_str": "a" * 20
        }
    }
    assert new_user_dictionary == profile(new_user['token'],new_user['u_id'])
Esempio n. 6
0
def test_user_profile01():
    new_user = create_user()
    user_dictionary = { 
        'user': {
            'u_id': new_user['u_id'],
            'email': '*****@*****.**',
            'name_first': 'John',
            'name_last': 'Smith', 'profile_img_url': 'http://127.0.0.1:8080/profileimages/default.jpg',
            'handle_str' : 'JohnSmith'
        }
    }
    #Makes sure the profile returns the user_dictionary.
    assert profile(new_user['token'],new_user['u_id']) == user_dictionary
Esempio n. 7
0
def test_setname11():
    new_user = create_user()
    setname(new_user['u_id'], 's', 'Smith')
    new_user_dictionary = { #Dictionary with new information
        "user": {
            "u_id": new_user['u_id'],
            "email": '*****@*****.**',
            "name_first": "s",
            "name_last": "Smith",
            "handle_str": "JohnSmith"
        }
    }
    assert profile(new_user['token'],new_user['u_id']) == new_user_dictionary
Esempio n. 8
0
def test_user_profile06():
    new_user = create_user()
    new_user2 = create_user2()
    user_dictionary = { 
        'user': {
            'u_id': new_user['u_id'],
            'email': '*****@*****.**',
            'name_first': 'John2',
            'name_last': 'Smith2',
            'handle_str' : 'JohnSmith'
        }
    }
    user_dictionary2 = { 
        'user': {
            'u_id': new_user2['u_id'],
            'email': '*****@*****.**',
            'name_first': 'Donaldo',
            'name_last': 'Trumpu',
            'handle_str' : 'donaldotrumpu'
        }
    }
    #Makes sure the profile returns the correct user_dictionary.
    assert profile(new_user2['token'],new_user['u_id']) == user_dictionary
    assert profile(new_user['token'],new_user2['u_id']) == user_dictionary2
Esempio n. 9
0
def test_setname03():
    new_user = create_user()
    #changes and last name to Slopsmcgee
    setname(new_user['u_id'],"John","Slopsmcgee")
   
    new_user_dictionary = { #Dictionary with new information
        "user": {
            "u_id": new_user['u_id'],
            "email": '*****@*****.**',
            "name_first": "John",
            "name_last": "Slopsmcgee",
            "handle_str": "JohnSmith"
        }
    }
    #assert they are the same
    assert profile(new_user['token'],new_user['u_id']) == new_user_dictionary
Esempio n. 10
0
def test_setname02():
    new_user = create_user()
    #changes first name to Citizen
    setname(new_user['u_id'],"Citizen","Smith")
   
    new_user_dictionary = { #Dictionary with updated first name
        "user": {
            "u_id": new_user['u_id'],
            "email": '*****@*****.**',
            "name_first": "Citizen",
            "name_last": "Smith",
            "handle_str": "JohnSmith"
        }
    }
    #assert they are the same
    assert profile(new_user['token'],new_user['u_id']) == new_user_dictionary
Esempio n. 11
0
def test_user_profile03():
    new_user = create_user()
    with pytest.raises(AccessError):
        profile('NOT_VALID_TOKEN', new_user['u_id'])
Esempio n. 12
0
def test_user_profile02(): 
    new_user = create_user()
    with pytest.raises(InputError):
        profile(new_user['u_id'], 000000000000)
Esempio n. 13
0
def user_profile():
    return dumps(
        user.profile(request.args.get("token"), int(request.args.get("u_id"))))