Check if required environment variables and dependencies are available.
()
| 82 | return True |
| 83 | |
| 84 | def check_environment(): |
| 85 | """Check if required environment variables and dependencies are available.""" |
| 86 | print("🔧 Checking test environment...") |
| 87 | |
| 88 | # Check for .env file |
| 89 | env_file = project_root / ".env" |
| 90 | if env_file.exists(): |
| 91 | print("✅ .env file found") |
| 92 | from dotenv import load_dotenv |
| 93 | load_dotenv(env_file) |
| 94 | else: |
| 95 | print("⚠️ No .env file found - some tests may fail without API keys") |
| 96 | |
| 97 | # Check for API keys |
| 98 | api_keys = { |
| 99 | "GOOGLE_API_KEY": "Google AI embedder tests", |
| 100 | "OPENAI_API_KEY": "OpenAI integration tests" |
| 101 | } |
| 102 | |
| 103 | for key, purpose in api_keys.items(): |
| 104 | if os.getenv(key): |
| 105 | print(f"✅ {key} is set ({purpose})") |
| 106 | else: |
| 107 | print(f"⚠️ {key} not set - {purpose} may fail") |
| 108 | |
| 109 | # Check Python dependencies |
| 110 | try: |
| 111 | import adalflow |
| 112 | print("✅ adalflow available") |
| 113 | except ImportError: |
| 114 | print("❌ adalflow not available - install with: pip install adalflow") |
| 115 | |
| 116 | try: |
| 117 | import google.generativeai |
| 118 | print("✅ google-generativeai available") |
| 119 | except ImportError: |
| 120 | print("❌ google-generativeai not available - install with: pip install google-generativeai") |
| 121 | |
| 122 | try: |
| 123 | import requests |
| 124 | print("✅ requests available") |
| 125 | except ImportError: |
| 126 | print("❌ requests not available - install with: pip install requests") |
| 127 | |
| 128 | def main(): |
| 129 | parser = argparse.ArgumentParser(description="Run DeepWiki tests") |