-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cache_detection.py
More file actions
126 lines (106 loc) · 4.36 KB
/
test_cache_detection.py
File metadata and controls
126 lines (106 loc) · 4.36 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
#!/usr/bin/env python3
"""
Test script to verify cache detection improvements.
Tests WindowsPlatform cache detection with comprehensive coverage.
"""
import sys
from pathlib import Path
# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent))
from diskcleaner.platforms.windows import WindowsPlatform
def test_cache_detection():
"""Test comprehensive cache detection."""
print("=" * 60)
print("Testing Windows Cache Detection")
print("=" * 60)
# Test cache locations
print("\n[1] Testing Cache Locations:")
print("-" * 60)
cache_locations = WindowsPlatform.get_cache_locations()
if not cache_locations:
print(" No cache locations found!")
else:
print(f" Found {len(cache_locations)} cache locations:")
for i, loc in enumerate(cache_locations, 1):
# Encode to ASCII-safe representation
try:
ascii_path = loc.encode('ascii', errors='replace').decode('ascii')
except:
ascii_path = "<path encoding error>"
print(f" {i}. {ascii_path}")
# Test temp locations
print("\n[2] Testing Temp Locations:")
print("-" * 60)
temp_locations = WindowsPlatform.get_temp_locations()
if not temp_locations:
print(" No temp locations found!")
else:
print(f" Found {len(temp_locations)} temp locations:")
for i, loc in enumerate(temp_locations, 1):
try:
ascii_path = loc.encode('ascii', errors='replace').decode('ascii')
except:
ascii_path = "<path encoding error>"
print(f" {i}. {ascii_path}")
# Test log locations
print("\n[3] Testing Log Locations:")
print("-" * 60)
log_locations = WindowsPlatform.get_log_locations()
if not log_locations:
print(" No log locations found!")
else:
print(f" Found {len(log_locations)} log locations:")
for i, loc in enumerate(log_locations, 1):
try:
ascii_path = loc.encode('ascii', errors='replace').decode('ascii')
except:
ascii_path = "<path encoding error>"
print(f" {i}. {ascii_path}")
# Test Docker locations
print("\n[4] Testing Docker Locations:")
print("-" * 60)
docker_locations = WindowsPlatform.get_docker_locations()
if not docker_locations:
print(" No Docker locations found!")
else:
print(f" Found {len(docker_locations)} Docker locations:")
for i, loc in enumerate(docker_locations, 1):
try:
ascii_path = loc.encode('ascii', errors='replace').decode('ascii')
except:
ascii_path = "<path encoding error>"
print(f" {i}. {ascii_path}")
# Summary
print("\n" + "=" * 60)
print("Summary:")
print("-" * 60)
print(f" Cache locations: {len(cache_locations)}")
print(f" Temp locations: {len(temp_locations)}")
print(f" Log locations: {len(log_locations)}")
print(f" Docker locations: {len(docker_locations)}")
print(f" Total: {len(cache_locations) + len(temp_locations) + len(log_locations) + len(docker_locations)}")
print("=" * 60)
# Check for expected cache types
print("\n[5] Checking for Expected Cache Types:")
print("-" * 60)
cache_types = {
"Chrome": any("Chrome" in loc for loc in cache_locations),
"Edge": any("Edge" in loc for loc in cache_locations),
"Firefox": any("Firefox" in loc for loc in cache_locations),
"JetBrains": any("JetBrains" in loc for loc in cache_locations),
"npm": any("npm" in loc.lower() for loc in cache_locations),
"yarn": any("yarn" in loc.lower() for loc in cache_locations),
"pnpm": any("pnpm" in loc.lower() for loc in cache_locations),
"pip": any("pip" in loc.lower() for loc in cache_locations),
"poetry": any("poetry" in loc.lower() for loc in cache_locations),
"gradle": any("gradle" in loc.lower() for loc in cache_locations),
"maven": any("maven" in loc.lower() for loc in cache_locations),
}
for cache_type, found in cache_types.items():
status = "FOUND" if found else "NOT FOUND"
print(f" {cache_type:15} {status}")
print("\n" + "=" * 60)
print("Test completed successfully!")
print("=" * 60)
if __name__ == "__main__":
test_cache_detection()