File size: 1,876 Bytes
e23e895
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
"""
Simple test for the Document Classification application
"""

import os
import sys

# Load .env file only in development (optional)
try:
    from dotenv import load_dotenv
    load_dotenv()
except ImportError:
    pass  # dotenv not available in production

def test_imports():
    """Test that all modules can be imported."""
    print("🧪 Testing Document Classification Structure")
    print("=" * 50)
    
    try:
        from pdf_qa.pdf_processor import PDFProcessor
        from pdf_qa.product_classifier import ProductClassifier
        print("✅ All modules imported successfully")
        
        # Test initialization
        pdf_processor = PDFProcessor()
        classifier = ProductClassifier()
        print("✅ Components initialized successfully")
        
        # Test classification methods
        test_products = {
            "test": {
                "name": "Test Product",
                "description": "A test product for classification",
                "keywords": ["test", "product"]
            }
        }
        
        # Test classifier initialization
        classifier = ProductClassifier(test_products)
        print("✅ Classification methods available")
        
        # Check API key
        if not os.getenv("OPENAI_API_KEY"):
            print("⚠️  OPENAI_API_KEY not set (expected for testing)")
        else:
            print("✅ OPENAI_API_KEY found")
        
        print("\n🎉 Document classification structure working correctly!")
        print("\nTo run the app:")
        print("1. Set OPENAI_API_KEY environment variable")
        print("2. Run: python app.py")
        
        return True
        
    except Exception as e:
        print(f"❌ Error: {str(e)}")
        return False

if __name__ == "__main__":
    success = test_imports()
    sys.exit(0 if success else 1)