Exemplo n.º 1
0
def test_user_model_validates(user):
    """Tests user validator returns user after correct validation"""
    User.drop_collection()

    validated_user = _service.validate_user_model(user)

    assert isinstance(validated_user, User)
def test_can_authenticate_password():
    """Tests whether a users hashed password can be authenticated"""
    User.drop_collection()
    User(id=str(uuid4()),
         email="*****@*****.**",
         password=_service.hash_password("S0meFunkyP455")).save()
    result = User.objects(email="*****@*****.**").first()

    assert _service.check_password("S0meFunkyP455", result.password)
Exemplo n.º 3
0
def test_user_is_created():
    """Tests whether a user can be added to the database"""
    User.drop_collection()

    user = generate_user()
    user.save()

    result = User.objects(email=user.email).first()

    assert result.email == user.email
Exemplo n.º 4
0
def drop_all_collections():
    User.drop_collection()
    Role.drop_collection()
    Permission.drop_collection()
Exemplo n.º 5
0
def register_test_db():
    connect(alias='default', host="mongodb://localhost/maintesoft_test")
    User.drop_collection()
    Role.drop_collection()
    Permission.drop_collection()
Exemplo n.º 6
0
def seed_all(all_permissions: dict) -> None:
    User.drop_collection()
    Role.drop_collection()
    Permission.drop_collection()
    seed_roles_and_permissions(all_permissions)
    seed_some_users()