Example #1
0
def create_user(last_name='should-be-last-name-1',
                first_name='test_create_user-1',
                email='should-be-email',
                username='******'):

    user = User()
    user.last_name = last_name
    user.first_name = first_name
    user.username = username
    user.gender = User._MALE
    user.created = datetime.now()
    user.last_login = datetime.now()
    user.email = email
    user.is_staff = False
    user.is_superuser = False
    user.is_active = True

    password = '******'

    m = hashlib.sha1()
    m.update(password)

    user.password = '******' + m.hexdigest()
    user.save()

    return user
def create_logged_user(last_name='should-be-last-name-1', first_name='test_create_user', email='should-be-email', username='******'):

    user = User()
    user.last_name = last_name
    user.first_name = first_name
    user.username = username
    user.gender = User._MALE
    user.created = datetime.now()
    user.last_login = datetime.now()
    user.email = email
    user.is_staff = False
    user.is_superuser = False
    user.is_active = True

    password = '******'

    m = hashlib.sha1()
    m.update(password)

    user.password = '******' + m.hexdigest()
    user.save()

    cache = get_cache()
    cache.set('should-be-user-auth', username)

    return user
Example #3
0
def test_user_can_be_saved():

    session = get_session()

    user = User()

    user.last_name = 'should-be-last-name'
    user.first_name = 'should-be-first-name'
    user.username = '******'
    user.created = datetime.now()
    user.last_login = datetime.now()
    user.password = '******'
    user.gender = 'M'
    user.email = 'should-be-email'
    user.is_staff = False
    user.is_superuser = False
    user.is_active = True
    user.save()

    user_db = session.query(User).filter(
        User.username == 'should-be-username').first()

    assert user_db.username == user.username

    user_db.delete()