forked from Zie619/n8n-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_workflows.py
More file actions
106 lines (88 loc) · 3.75 KB
/
test_workflows.py
File metadata and controls
106 lines (88 loc) · 3.75 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
#!/usr/bin/env python3
"""
Test Sample Workflows
Validate that our upgraded workflows are working properly
"""
import json
from pathlib import Path
def test_sample_workflows():
"""Test sample workflows to ensure they're working"""
print("🔍 Testing sample workflows...")
samples = []
categories = ["Manual", "Webhook", "Schedule", "Http", "Code"]
for category in categories:
category_path = Path("workflows") / category
if category_path.exists():
workflow_files = list(category_path.glob("*.json"))[
:2
] # Test first 2 from each category
for workflow_file in workflow_files:
try:
with open(workflow_file, "r", encoding="utf-8") as f:
data = json.load(f)
# Validate basic structure
has_name = "name" in data and data["name"]
has_nodes = "nodes" in data and isinstance(data["nodes"], list)
has_connections = "connections" in data and isinstance(
data["connections"], dict
)
samples.append(
{
"file": str(workflow_file),
"name": data.get("name", "Unnamed"),
"nodes": len(data.get("nodes", [])),
"connections": len(data.get("connections", {})),
"has_name": has_name,
"has_nodes": has_nodes,
"has_connections": has_connections,
"valid": has_name and has_nodes and has_connections,
"category": category,
}
)
except Exception as e:
samples.append(
{
"file": str(workflow_file),
"error": str(e),
"valid": False,
"category": category,
}
)
print(f"\n📊 Tested {len(samples)} sample workflows:")
print("=" * 60)
valid_count = 0
for sample in samples:
if sample["valid"]:
print(
f"✅ {sample['name']} ({sample['category']}) - {sample['nodes']} nodes, {sample['connections']} connections"
)
valid_count += 1
else:
print(
f"❌ {sample['file']} - Error: {sample.get('error', 'Invalid structure')}"
)
print(f"\n🎯 Result: {valid_count}/{len(samples)} workflows are valid and ready!")
# Category breakdown
category_stats = {}
for sample in samples:
category = sample.get("category", "unknown")
if category not in category_stats:
category_stats[category] = {"valid": 0, "total": 0}
category_stats[category]["total"] += 1
if sample["valid"]:
category_stats[category]["valid"] += 1
print("\n📁 Category Breakdown:")
for category, stats in category_stats.items():
success_rate = (
(stats["valid"] / stats["total"]) * 100 if stats["total"] > 0 else 0
)
print(f" {category}: {stats['valid']}/{stats['total']} ({success_rate:.1f}%)")
return valid_count, len(samples)
if __name__ == "__main__":
valid_count, total_count = test_sample_workflows()
if valid_count == total_count:
print("\n🎉 ALL SAMPLE WORKFLOWS ARE VALID! 🎉")
elif valid_count > total_count * 0.8:
print(f"\n✅ Most workflows are valid ({valid_count}/{total_count})")
else:
print(f"\n⚠️ Some workflows need attention ({valid_count}/{total_count})")