evgeniy778 commited on
Commit
0e10e87
·
verified ·
1 Parent(s): eb700c2

Add Module Registry Test Version 1.0

Browse files
Files changed (1) hide show
  1. test_module_registry.py +195 -0
test_module_registry.py ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # =====================================================
2
+ # Apckeyl Framework
3
+ # Version 1.0
4
+ # test_module_registry.py
5
+ # =====================================================
6
+
7
+ """
8
+ Tests for Apckeyl Module Registry.
9
+
10
+ Version 1.0
11
+ """
12
+
13
+ from module_registry import registry
14
+
15
+
16
+ # =====================================================
17
+ # Test 1 — Registry Exists
18
+ # =====================================================
19
+
20
+ def test_registry_exists():
21
+
22
+ assert registry is not None
23
+
24
+
25
+ # =====================================================
26
+ # Test 2 — RealESRGAN Exists
27
+ # =====================================================
28
+
29
+ def test_realesrgan_exists():
30
+
31
+ assert registry.exists(
32
+ "realesrgan"
33
+ )
34
+
35
+
36
+ # =====================================================
37
+ # Test 3 — Module Information
38
+ # =====================================================
39
+
40
+ def test_realesrgan_information():
41
+
42
+ module = registry.get(
43
+ "realesrgan"
44
+ )
45
+
46
+ assert module is not None
47
+
48
+ assert module["module_id"] == "realesrgan"
49
+
50
+ assert module["module_name"] == "Apckeyl_RealESRGAN"
51
+
52
+ assert module["module_type"] == "image_upscaler"
53
+
54
+
55
+ # =====================================================
56
+ # Test 4 — Capability
57
+ # =====================================================
58
+
59
+ def test_realesrgan_capability():
60
+
61
+ module = registry.get(
62
+ "realesrgan"
63
+ )
64
+
65
+ assert "image_upscale" in module[
66
+ "capabilities"
67
+ ]
68
+
69
+
70
+ # =====================================================
71
+ # Test 5 — Status
72
+ # =====================================================
73
+
74
+ def test_realesrgan_status():
75
+
76
+ module = registry.get(
77
+ "realesrgan"
78
+ )
79
+
80
+ assert module["status"] == "available"
81
+
82
+
83
+ # =====================================================
84
+ # Test 6 — Find By Type
85
+ # =====================================================
86
+
87
+ def test_find_by_type():
88
+
89
+ modules = registry.find_by_type(
90
+ "image_upscaler"
91
+ )
92
+
93
+ assert len(modules) >= 1
94
+
95
+ assert any(
96
+ module["module_id"] == "realesrgan"
97
+ for module in modules
98
+ )
99
+
100
+
101
+ # =====================================================
102
+ # Test Runner
103
+ # =====================================================
104
+
105
+ def main():
106
+
107
+ tests = [
108
+
109
+ test_registry_exists,
110
+
111
+ test_realesrgan_exists,
112
+
113
+ test_realesrgan_information,
114
+
115
+ test_realesrgan_capability,
116
+
117
+ test_realesrgan_status,
118
+
119
+ test_find_by_type,
120
+ ]
121
+
122
+ passed = 0
123
+
124
+ failed = 0
125
+
126
+ print(
127
+ "===================================="
128
+ )
129
+
130
+ print(
131
+ "Apckeyl Module Registry Test"
132
+ )
133
+
134
+ print(
135
+ "Version 1.0"
136
+ )
137
+
138
+ print(
139
+ "===================================="
140
+ )
141
+
142
+ for test in tests:
143
+
144
+ try:
145
+
146
+ test()
147
+
148
+ print(
149
+ f"PASS: {test.__name__}"
150
+ )
151
+
152
+ passed += 1
153
+
154
+ except Exception as error:
155
+
156
+ print(
157
+ f"FAIL: {test.__name__}"
158
+ )
159
+
160
+ print(
161
+ f"ERROR: {error}"
162
+ )
163
+
164
+ failed += 1
165
+
166
+ print(
167
+ "===================================="
168
+ )
169
+
170
+ print(
171
+ f"PASSED: {passed}"
172
+ )
173
+
174
+ print(
175
+ f"FAILED: {failed}"
176
+ )
177
+
178
+ print(
179
+ "===================================="
180
+ )
181
+
182
+ if failed > 0:
183
+
184
+ raise RuntimeError(
185
+ "Module Registry Test FAILED"
186
+ )
187
+
188
+ print(
189
+ "MODULE REGISTRY TEST: PASSED"
190
+ )
191
+
192
+
193
+ if __name__ == "__main__":
194
+
195
+ main()