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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
"""
|
| 3 |
+
Resume Verification System - Installation Test
|
| 4 |
+
Tests basic functionality of all modules
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import sys
|
| 8 |
+
import json
|
| 9 |
+
from datetime import datetime
|
| 10 |
+
|
| 11 |
+
def test_imports():
|
| 12 |
+
"""Test that all modules can be imported"""
|
| 13 |
+
print("Testing module imports...")
|
| 14 |
+
|
| 15 |
+
try:
|
| 16 |
+
from modules.cv_parser import CVParser
|
| 17 |
+
print(" β CV Parser module")
|
| 18 |
+
except ImportError as e:
|
| 19 |
+
print(f" β CV Parser module: {e}")
|
| 20 |
+
return False
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
from modules.claim_extractor import ClaimExtractor
|
| 24 |
+
print(" β Claim Extractor module")
|
| 25 |
+
except ImportError as e:
|
| 26 |
+
print(f" β Claim Extractor module: {e}")
|
| 27 |
+
return False
|
| 28 |
+
|
| 29 |
+
try:
|
| 30 |
+
from modules.evidence_validator import EvidenceValidator
|
| 31 |
+
print(" β Evidence Validator module")
|
| 32 |
+
except ImportError as e:
|
| 33 |
+
print(f" β Evidence Validator module: {e}")
|
| 34 |
+
return False
|
| 35 |
+
|
| 36 |
+
try:
|
| 37 |
+
from modules.red_flag_detector import RedFlagDetector
|
| 38 |
+
print(" β Red Flag Detector module")
|
| 39 |
+
except ImportError as e:
|
| 40 |
+
print(f" β Red Flag Detector module: {e}")
|
| 41 |
+
return False
|
| 42 |
+
|
| 43 |
+
try:
|
| 44 |
+
from modules.sota_checker import SOTAChecker
|
| 45 |
+
print(" β SOTA Checker module")
|
| 46 |
+
except ImportError as e:
|
| 47 |
+
print(f" β SOTA Checker module: {e}")
|
| 48 |
+
return False
|
| 49 |
+
|
| 50 |
+
try:
|
| 51 |
+
from utils.gemini_client import GeminiClient, MockGeminiClient
|
| 52 |
+
print(" β Gemini Client utilities")
|
| 53 |
+
except ImportError as e:
|
| 54 |
+
print(f" β Gemini Client utilities: {e}")
|
| 55 |
+
return False
|
| 56 |
+
|
| 57 |
+
try:
|
| 58 |
+
from visualization.evidence_heatmap import EvidenceHeatmap
|
| 59 |
+
print(" β Visualization modules")
|
| 60 |
+
except ImportError as e:
|
| 61 |
+
print(f" β Visualization modules: {e}")
|
| 62 |
+
return False
|
| 63 |
+
|
| 64 |
+
try:
|
| 65 |
+
from visualization.report_generator import ReportGenerator
|
| 66 |
+
print(" β Report Generator module")
|
| 67 |
+
except ImportError as e:
|
| 68 |
+
print(f" β Report Generator module: {e}")
|
| 69 |
+
return False
|
| 70 |
+
|
| 71 |
+
return True
|
| 72 |
+
|
| 73 |
+
def test_mock_client():
|
| 74 |
+
"""Test mock client functionality"""
|
| 75 |
+
print("\nTesting mock client...")
|
| 76 |
+
|
| 77 |
+
try:
|
| 78 |
+
from utils.gemini_client import MockGeminiClient
|
| 79 |
+
|
| 80 |
+
client = MockGeminiClient()
|
| 81 |
+
response = client.generate_content("extract claims from resume")
|
| 82 |
+
parsed = client.validate_json_response(response)
|
| 83 |
+
|
| 84 |
+
if parsed and 'claims' in parsed:
|
| 85 |
+
print(" β Mock client working")
|
| 86 |
+
return True
|
| 87 |
+
else:
|
| 88 |
+
print(" β Mock client not returning expected format")
|
| 89 |
+
return False
|
| 90 |
+
|
| 91 |
+
except Exception as e:
|
| 92 |
+
print(f" β Mock client error: {e}")
|
| 93 |
+
return False
|
| 94 |
+
|
| 95 |
+
def test_sample_parsing():
|
| 96 |
+
"""Test parsing a sample text"""
|
| 97 |
+
print("\nTesting CV parser with sample text...")
|
| 98 |
+
|
| 99 |
+
try:
|
| 100 |
+
from modules.cv_parser import CVParser
|
| 101 |
+
import tempfile
|
| 102 |
+
|
| 103 |
+
# Create sample CV text
|
| 104 |
+
sample_cv = """
|
| 105 |
+
John Doe
|
| 106 |
+
Senior Software Engineer
|
| 107 |
+
|
| 108 |
+
WORK EXPERIENCE
|
| 109 |
+
Software Engineer at TechCorp (2020-2023)
|
| 110 |
+
- Developed microservices architecture
|
| 111 |
+
- Improved system performance by 40%
|
| 112 |
+
|
| 113 |
+
SKILLS
|
| 114 |
+
Python, JavaScript, Docker, Kubernetes
|
| 115 |
+
|
| 116 |
+
PROJECTS
|
| 117 |
+
Built e-commerce platform serving 10,000 users
|
| 118 |
+
"""
|
| 119 |
+
|
| 120 |
+
# Save to temp file
|
| 121 |
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.txt', delete=False) as f:
|
| 122 |
+
f.write(sample_cv)
|
| 123 |
+
temp_path = f.name
|
| 124 |
+
|
| 125 |
+
# Parse
|
| 126 |
+
parser = CVParser()
|
| 127 |
+
result = parser.parse(temp_path)
|
| 128 |
+
|
| 129 |
+
if result and 'sections' in result:
|
| 130 |
+
print(" β Parser successfully processed sample CV")
|
| 131 |
+
print(f" Found {len(result['sections'])} sections")
|
| 132 |
+
return True
|
| 133 |
+
else:
|
| 134 |
+
print(" β Parser failed to process sample CV")
|
| 135 |
+
return False
|
| 136 |
+
|
| 137 |
+
except Exception as e:
|
| 138 |
+
print(f" β Parser error: {e}")
|
| 139 |
+
return False
|
| 140 |
+
|
| 141 |
+
def test_gradio_import():
|
| 142 |
+
"""Test Gradio import"""
|
| 143 |
+
print("\nTesting Gradio import...")
|
| 144 |
+
|
| 145 |
+
try:
|
| 146 |
+
import gradio as gr
|
| 147 |
+
print(f" β Gradio version {gr.__version__} imported successfully")
|
| 148 |
+
return True
|
| 149 |
+
except ImportError:
|
| 150 |
+
print(" β Gradio not installed. Run: pip install gradio")
|
| 151 |
+
return False
|
| 152 |
+
|
| 153 |
+
def main():
|
| 154 |
+
"""Run all tests"""
|
| 155 |
+
print("=" * 50)
|
| 156 |
+
print("Resume Verification System - Installation Test")
|
| 157 |
+
print("=" * 50)
|
| 158 |
+
print()
|
| 159 |
+
|
| 160 |
+
all_passed = True
|
| 161 |
+
|
| 162 |
+
# Run tests
|
| 163 |
+
if not test_imports():
|
| 164 |
+
all_passed = False
|
| 165 |
+
|
| 166 |
+
if not test_mock_client():
|
| 167 |
+
all_passed = False
|
| 168 |
+
|
| 169 |
+
if not test_sample_parsing():
|
| 170 |
+
all_passed = False
|
| 171 |
+
|
| 172 |
+
if not test_gradio_import():
|
| 173 |
+
all_passed = False
|
| 174 |
+
|
| 175 |
+
# Summary
|
| 176 |
+
print("\n" + "=" * 50)
|
| 177 |
+
if all_passed:
|
| 178 |
+
print("β
All tests passed! Installation is working correctly.")
|
| 179 |
+
print("\nYou can now run the application with:")
|
| 180 |
+
print(" python app.py")
|
| 181 |
+
else:
|
| 182 |
+
print("β Some tests failed. Please check the errors above.")
|
| 183 |
+
print("\nTry running:")
|
| 184 |
+
print(" pip install -r requirements.txt")
|
| 185 |
+
|
| 186 |
+
print("=" * 50)
|
| 187 |
+
|
| 188 |
+
return 0 if all_passed else 1
|
| 189 |
+
|
| 190 |
+
if __name__ == "__main__":
|
| 191 |
+
sys.exit(main())
|