forked from sdgilley/content-maintenance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_exclude.py
More file actions
43 lines (35 loc) · 1.62 KB
/
test_exclude.py
File metadata and controls
43 lines (35 loc) · 1.62 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
#!/usr/bin/env python3
"""Test the exclude directory logic"""
def test_exclude_logic():
"""Test the new exclude directory logic"""
# Simulate the logic from helpers.py
def should_exclude_path(content_path, content_name, exclude_dirs):
for exclude_pattern in exclude_dirs:
exclude_pattern = exclude_pattern.lower().strip('/')
content_path_lower = content_path.lower()
content_name_lower = content_name.lower()
if (exclude_pattern == content_name_lower or
exclude_pattern in content_path_lower or
content_path_lower.endswith(exclude_pattern)):
return True
return False
# Test cases
exclude_dirs = ["media", "ai-foundry/openai"]
test_cases = [
# (path, name, should_be_excluded)
("articles/ai-foundry/openai", "openai", True),
("articles/ai-foundry/openai/subfolder", "subfolder", True),
("articles/ai-foundry/tutorials", "tutorials", False),
("articles/machine-learning/media", "media", True),
("articles/ai-foundry/includes", "includes", False),
("articles/ai-foundry", "ai-foundry", False),
]
print("Testing exclude directory logic:")
print(f"Exclude patterns: {exclude_dirs}")
print()
for path, name, expected in test_cases:
result = should_exclude_path(path, name, exclude_dirs)
status = "✅ PASS" if result == expected else "❌ FAIL"
print(f"{status} Path: {path}, Name: {name} -> Excluded: {result} (Expected: {expected})")
if __name__ == "__main__":
test_exclude_logic()