forked from Ripplingsnake12/optiscaler-auto-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_dependencies.py
More file actions
121 lines (94 loc) · 3.46 KB
/
test_dependencies.py
File metadata and controls
121 lines (94 loc) · 3.46 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
#!/usr/bin/env python3
"""
Test script for dependency management functionality
"""
import sys
from optiscaler_manager import DependencyManager
def test_system_detection():
"""Test system detection capabilities."""
print("🔍 Testing system detection...")
dep_manager = DependencyManager()
# Test package manager detection
pm = dep_manager.detect_package_manager()
print(f"Package manager detected: {pm}")
# Test distro detection
distro = dep_manager.detect_distro()
print(f"Distribution detected: {distro}")
# Test display server detection
wayland = dep_manager.is_wayland()
print(f"Wayland display server: {wayland}")
return pm is not None
def test_clipboard_detection():
"""Test clipboard app detection."""
print("\n📋 Testing clipboard detection...")
dep_manager = DependencyManager()
installed_apps = []
for app_name in dep_manager.clipboard_apps.keys():
try:
import subprocess
result = subprocess.run(['which', app_name], capture_output=True, text=True)
if result.returncode == 0:
installed_apps.append(app_name)
print(f"✅ {app_name} found")
else:
print(f"❌ {app_name} not found")
except Exception:
print(f"❌ {app_name} not found")
return len(installed_apps) > 0
def test_tool_detection():
"""Test system tool detection."""
print("\n🔧 Testing system tool detection...")
dep_manager = DependencyManager()
tools = ['7z', 'git', 'wine', 'curl', 'wget']
found_tools = []
for tool in tools:
try:
import subprocess
result = subprocess.run(['which', tool], capture_output=True, text=True)
if result.returncode == 0:
found_tools.append(tool)
print(f"✅ {tool} found")
else:
print(f"❌ {tool} not found")
except Exception:
print(f"❌ {tool} not found")
return len(found_tools) > 0
def test_python_modules():
"""Test Python module detection."""
print("\n🐍 Testing Python module detection...")
dep_manager = DependencyManager()
# Test requests module
if dep_manager.check_python_module('requests'):
print("✅ requests module available")
return True
else:
print("❌ requests module not available")
return False
def main():
"""Run all tests."""
print("=" * 60)
print("🧪 Dependency Management Test Suite")
print("=" * 60)
test_results = []
# Run tests
test_results.append(("System Detection", test_system_detection()))
test_results.append(("Python Modules", test_python_modules()))
test_results.append(("System Tools", test_tool_detection()))
test_results.append(("Clipboard Apps", test_clipboard_detection()))
# Print results
print("\n" + "=" * 60)
print("📊 Test Results:")
print("=" * 60)
all_passed = True
for test_name, result in test_results:
status = "✅ PASS" if result else "❌ FAIL"
print(f"{test_name:.<40} {status}")
if not result:
all_passed = False
print("=" * 60)
overall_status = "✅ ALL TESTS PASSED" if all_passed else "⚠️ SOME TESTS FAILED"
print(f"Overall: {overall_status}")
print("=" * 60)
return 0 if all_passed else 1
if __name__ == "__main__":
sys.exit(main())