"""
Test script to verify NLM OAuth helper is working.
"""
import sys
sys.path.insert(0, '/home/ashraffarid2010/jadwaai.com')

from app import create_app

app = create_app()

with app.app_context():
    print("Checking NLM OAuth helper...\n")

    # Check if the module exists
    try:
        from app.ai.nlm_oauth_helper import get_nlm_cookies_with_oauth, refresh_nlm_session_with_refresh_token
        print("✓ nlm_oauth_helper module found")
        print("  - get_nlm_cookies_with_oauth function exists")
        print("  - refresh_nlm_session_with_refresh_token function exists")
    except ImportError as e:
        print(f"✗ Import error: {e}")

    # Check if the route exists
    from flask import url_for
    try:
        url = url_for('study.api_notebook_connect_with_oauth')
        print(f"✓ Route registered: {url}")
    except Exception as e:
        print(f"✗ Route error: {e}")

    # Check if disconnect route exists
    try:
        url = url_for('study.api_notebook_disconnect')
        print(f"✓ Disconnect route registered: {url}")
    except Exception as e:
        print(f"✗ Disconnect route error: {e}")

    print("\nAll checks completed!")
