from app import create_app, db
from app.models import User
from flask_login import login_user

app = create_app()
with app.app_context():
    with app.test_request_context('/'):
        try:
            # Get a user from the database
            user = User.query.filter_by(username='admin').first()
            print(f"Found user: {user}")
            print(f"User ID: {user.id}")
            print(f"User full_name: {user.full_name}")
            
            # Test login_user
            login_user(user, remember=False)
            print("login_user successful")
            
        except Exception as e:
            print(f"Error during login_user test: {e}")
            import traceback
            traceback.print_exc()