-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_implementation.py
More file actions
129 lines (110 loc) · 4.11 KB
/
test_implementation.py
File metadata and controls
129 lines (110 loc) · 4.11 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env python3
"""
Test script to verify the smart report generation functionality
"""
import sys
import os
# Add backend directory to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'backend'))
def test_imports():
"""Test that all modules can be imported successfully"""
try:
from document_analyzer import DocumentAnalyzer
print("✓ DocumentAnalyzer imported successfully")
except Exception as e:
print(f"✗ DocumentAnalyzer import failed: {e}")
return False
try:
from content_generator import ContentGenerator
print("✓ ContentGenerator imported successfully")
except Exception as e:
print(f"✗ ContentGenerator import failed: {e}")
return False
try:
from image_processor import ImageProcessor
print("✓ ImageProcessor imported successfully")
except Exception as e:
print(f"✗ ImageProcessor import failed: {e}")
return False
try:
from smart_report_generator import SmartReportGenerator
print("✓ SmartReportGenerator imported successfully")
except Exception as e:
print(f"✗ SmartReportGenerator import failed: {e}")
return False
try:
from models.analysis import SampleDocumentAnalysis, ContentGenerationRequest
print("✓ Models imported successfully")
except Exception as e:
print(f"✗ Models import failed: {e}")
return False
return True
def test_document_analyzer():
"""Test basic document analyzer functionality"""
try:
from document_analyzer import DocumentAnalyzer
analyzer = DocumentAnalyzer()
print("✓ DocumentAnalyzer instantiated successfully")
return True
except Exception as e:
print(f"✗ DocumentAnalyzer instantiation failed: {e}")
return False
def test_content_generator():
"""Test basic content generator functionality"""
try:
from content_generator import ContentGenerator
generator = ContentGenerator()
print("✓ ContentGenerator instantiated successfully")
# Test basic content generation
content = generator.generate_content(
"Machine Learning Applications",
["Introduction", "Methodology", "Results", "Conclusion"]
)
print(f"✓ Content generated successfully ({content.overall_word_count} words)")
return True
except Exception as e:
print(f"✗ ContentGenerator test failed: {e}")
return False
def test_smart_report_generator():
"""Test basic smart report generator functionality"""
try:
from smart_report_generator import SmartReportGenerator
generator = SmartReportGenerator(".")
print("✓ SmartReportGenerator instantiated successfully")
return True
except Exception as e:
print(f"✗ SmartReportGenerator instantiation failed: {e}")
return False
def main():
print("Running Smart Report AI Implementation Tests")
print("=" * 50)
# Test imports
print("\n1. Testing module imports:")
if not test_imports():
print("Import tests failed!")
return False
# Test individual components
print("\n2. Testing individual components:")
tests = [
test_document_analyzer,
test_content_generator,
test_smart_report_generator
]
passed = 0
for test in tests:
if test():
passed += 1
print(f"\nResults: {passed}/{len(tests)} component tests passed")
if passed == len(tests):
print("\n🎉 All tests passed! The smart report generation system is ready.")
print("\nTo start the server:")
print("cd backend && uvicorn main:app --reload --host 0.0.0.0 --port 8000")
print("\nTo access the smart report interface:")
print("Open frontend/smart-report.html in your browser")
return True
else:
print(f"\n⚠️ {len(tests) - passed} tests failed. Please check the implementation.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)