Ejemplo n.º 1
0
def test_get_all_normal(db, user_foo):
    assert User.get_all_normal() == [user_foo]

    user_bar = User.create_application('base.bar')
    user_baz = User.create_normal('baz', '-', '*****@*****.**', is_active=True)
    user_too = User.create_normal('too', '-', '*****@*****.**', is_active=False)

    assert User.get_all_normal() == [user_foo, user_baz]
    assert user_bar not in User.get_all_normal()
    assert user_too not in User.get_all_normal()
Ejemplo n.º 2
0
def test_create_application(db):
    user = User.create_application('base.foo')
    assert user.username == 'base.foo'
    assert user.email is None
    assert user.is_active
    assert not user.huskar_admin
    assert user.is_admin is False
    assert user.is_application is True

    with db.close_on_exit(False):
        user.email = '*****@*****.**'
        user.is_active = False
    User.flush([user.id])

    old_attributes = dict(vars(user))

    user_shadow = User.create_application('base.foo')
    assert user_shadow is user
    assert user_shadow.id == old_attributes['id']
    assert user_shadow.email is None
    assert user_shadow.is_active
    assert not user_shadow.huskar_admin
    assert user_shadow.email != old_attributes['email']
    assert user_shadow.username == old_attributes['username']
    assert user_shadow.password == old_attributes['password']
    assert user_shadow.created_at == old_attributes['created_at']

    with db.close_on_exit(False):
        user.huskar_admin = True
    User.flush([user.id])

    user_shadow_foo = User.create_application('base.foo')
    assert user_shadow_foo is user
    assert user_shadow_foo.id == old_attributes['id']
    assert user_shadow_foo.email is None
    assert user_shadow_foo.is_active
    assert user_shadow_foo.huskar_admin
    assert user_shadow_foo.username == old_attributes['username']
    assert user_shadow_foo.password == old_attributes['password']
    assert user_shadow_foo.created_at == old_attributes['created_at']