-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fix.py
More file actions
111 lines (86 loc) · 3.29 KB
/
Copy pathtest_fix.py
File metadata and controls
111 lines (86 loc) · 3.29 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
#!/usr/bin/env python3
"""
Test script to verify the recycle bin scan fix
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def test_recycle_bin_scan():
"""Test the recycle bin scanning functionality"""
try:
from forensic_analysis_tool import FileRecoveryEngine
print("Testing FileRecoveryEngine...")
recovery = FileRecoveryEngine()
print("Scanning recycle bin...")
recycle_files = recovery.scan_recycle_bin()
print(f"✅ Successfully scanned recycle bin: {len(recycle_files)} files found")
# Test a few files
for i, file_info in enumerate(recycle_files[:3]):
print(f" File {i+1}: {file_info.get('name', 'N/A')} ({file_info.get('source', 'N/A')})")
return True
except Exception as e:
print(f"❌ Error in recycle bin scan: {e}")
import traceback
traceback.print_exc()
return False
def test_gui_components():
"""Test GUI components without showing the window"""
try:
from forensic_analysis_tool import PYQT_AVAILABLE
if not PYQT_AVAILABLE:
print("⚠️ PyQt5 not available, skipping GUI test")
return True
from PyQt5.QtWidgets import QApplication
from forensic_analysis_tool import ForensicAnalysisGUI
# Create application (required for PyQt)
app = QApplication.instance()
if app is None:
app = QApplication(sys.argv)
print("Testing GUI initialization...")
window = ForensicAnalysisGUI()
print("Testing recycle bin scan method...")
# Test the scan method directly
window.scan_recycle_bin()
print(f"✅ GUI scan method completed: {len(window.file_data)} files found")
return True
except Exception as e:
print(f"❌ Error in GUI test: {e}")
import traceback
traceback.print_exc()
return False
def main():
"""Run all tests"""
print("🧪 Testing Recycle Bin Scan Fix")
print("=" * 40)
tests = [
("File Recovery Engine", test_recycle_bin_scan),
("GUI Components", test_gui_components)
]
passed = 0
failed = 0
for test_name, test_func in tests:
print(f"\n🔍 {test_name}...")
try:
if test_func():
passed += 1
print(f"✅ {test_name}: PASSED")
else:
failed += 1
print(f"❌ {test_name}: FAILED")
except Exception as e:
failed += 1
print(f"❌ {test_name}: CRITICAL FAILURE - {e}")
print("\n" + "=" * 40)
print("🏁 Fix Test Summary")
print(f"✅ Passed: {passed}")
print(f"❌ Failed: {failed}")
if failed == 0:
print("🎉 All fixes working correctly! The recycle bin scan should no longer crash.")
else:
print("⚠️ Some issues remain. Please check the errors above.")
return failed
if __name__ == '__main__':
exit_code = main()
print(f"\nPress Enter to exit...")
input()
sys.exit(exit_code)