#!/usr/bin/env python3 """ Simple test script to verify import issues are fixed. This script tests that all the required services can be imported and initialized without import errors. Usage: python test_imports.py """ import sys import os from pathlib import Path # Add the backend directory to the Python path backend_dir = Path(__file__).parent sys.path.insert(0, str(backend_dir)) def test_imports(): """Test that all required modules can be imported.""" print("๐Ÿงช Testing Imports...") try: print("๐Ÿ“ฆ Testing LinkedIn Models...") from models.linkedin_models import ( LinkedInPostRequest, LinkedInPostResponse, PostContent, ResearchSource, LinkedInArticleRequest, LinkedInArticleResponse, ArticleContent, LinkedInCarouselRequest, LinkedInCarouselResponse, CarouselContent, CarouselSlide, LinkedInVideoScriptRequest, LinkedInVideoScriptResponse, VideoScript, LinkedInCommentResponseRequest, LinkedInCommentResponseResult, HashtagSuggestion, ImageSuggestion, Citation, ContentQualityMetrics, GroundingLevel ) print("โœ… LinkedIn Models imported successfully") except Exception as e: print(f"โŒ LinkedIn Models import failed: {e}") return False try: print("๐Ÿ“ฆ Testing Research Service...") from services.research import GoogleSearchService print("โœ… Research Service imported successfully") except Exception as e: print(f"โŒ Research Service import failed: {e}") return False try: print("๐Ÿ“ฆ Testing Citation Service...") from services.citation import CitationManager print("โœ… Citation Service imported successfully") except Exception as e: print(f"โŒ Citation Service import failed: {e}") return False try: print("๐Ÿ“ฆ Testing Quality Service...") from services.quality import ContentQualityAnalyzer print("โœ… Quality Service imported successfully") except Exception as e: print(f"โŒ Quality Service import failed: {e}") return False try: print("๐Ÿ“ฆ Testing LLM Providers...") from services.llm_providers.gemini_provider import gemini_structured_json_response, gemini_text_response print("โœ… LLM Providers imported successfully") except Exception as e: print(f"โŒ LLM Providers import failed: {e}") return False try: print("๐Ÿ“ฆ Testing Gemini Grounded Provider...") from services.llm_providers.gemini_grounded_provider import GeminiGroundedProvider print("โœ… Gemini Grounded Provider imported successfully") except Exception as e: print(f"โŒ Gemini Grounded Provider import failed: {e}") return False try: print("๐Ÿ“ฆ Testing LinkedIn Service...") from services.linkedin_service import LinkedInService print("โœ… LinkedIn Service imported successfully") except Exception as e: print(f"โŒ LinkedIn Service import failed: {e}") return False print("\n๐ŸŽ‰ All imports successful!") return True def test_service_initialization(): """Test that services can be initialized without errors.""" print("\n๐Ÿ”ง Testing Service Initialization...") try: print("๐Ÿ“ฆ Initializing LinkedIn Service...") from services.linkedin_service import LinkedInService service = LinkedInService() print("โœ… LinkedIn Service initialized successfully") # Check which services are available print(f" - Google Search: {'โœ…' if service.google_search else 'โŒ'}") print(f" - Gemini Grounded: {'โœ…' if service.gemini_grounded else 'โŒ'}") print(f" - Citation Manager: {'โœ…' if service.citation_manager else 'โŒ'}") print(f" - Quality Analyzer: {'โœ…' if service.quality_analyzer else 'โŒ'}") print(f" - Fallback Provider: {'โœ…' if service.fallback_provider else 'โŒ'}") return True except Exception as e: print(f"โŒ LinkedIn Service initialization failed: {e}") return False def main(): """Main test function.""" print("๐Ÿš€ Starting Import Tests") print("=" * 50) # Test imports import_success = test_imports() if import_success: # Test service initialization init_success = test_service_initialization() if init_success: print("\n๐ŸŽ‰ SUCCESS: All tests passed!") print("โœ… Import issues have been resolved") print("โœ… Services can be initialized") print("โœ… Ready for testing native grounding") else: print("\nโš ๏ธ PARTIAL SUCCESS: Imports work but initialization failed") print("๐Ÿ’ก This may be due to missing dependencies or configuration") else: print("\nโŒ FAILURE: Import tests failed") print("๐Ÿ’ก There are still import issues to resolve") sys.exit(1) if __name__ == "__main__": main()