Spaces:
Running on Zero
Running on Zero
| # ===================================================== | |
| # Apckeyl Framework | |
| # Version 1.0 | |
| # test_control_plane.py | |
| # ===================================================== | |
| """ | |
| Tests for Apckeyl Control Plane. | |
| Version 1.0 | |
| """ | |
| from control_plane import control_plane | |
| # ===================================================== | |
| # Test 1 — Control Plane Exists | |
| # ===================================================== | |
| def test_control_plane_exists(): | |
| assert control_plane is not None | |
| # ===================================================== | |
| # Test 2 — Resolve Image Upscale | |
| # ===================================================== | |
| def test_resolve_image_upscale(): | |
| module = control_plane.resolve_task( | |
| "image_upscale" | |
| ) | |
| assert module is not None | |
| assert module["module_id"] == "realesrgan" | |
| # ===================================================== | |
| # Test 3 — Module Type | |
| # ===================================================== | |
| def test_resolved_module_type(): | |
| module = control_plane.resolve_task( | |
| "image_upscale" | |
| ) | |
| assert module["module_type"] == "image_upscaler" | |
| # ===================================================== | |
| # Test 4 — Module Name | |
| # ===================================================== | |
| def test_resolved_module_name(): | |
| module = control_plane.resolve_task( | |
| "image_upscale" | |
| ) | |
| assert ( | |
| module["module_name"] | |
| == "Apckeyl_RealESRGAN" | |
| ) | |
| # ===================================================== | |
| # Test 5 — Module Status | |
| # ===================================================== | |
| def test_resolved_module_status(): | |
| module = control_plane.resolve_task( | |
| "image_upscale" | |
| ) | |
| assert module["status"] == "available" | |
| # ===================================================== | |
| # Test 6 — Unknown Task | |
| # ===================================================== | |
| def test_unknown_task(): | |
| try: | |
| control_plane.resolve_task( | |
| "unknown_task" | |
| ) | |
| except LookupError: | |
| return | |
| raise AssertionError( | |
| "Unknown task was not rejected" | |
| ) | |
| # ===================================================== | |
| # Test 7 — Get Module | |
| # ===================================================== | |
| def test_get_module(): | |
| module = control_plane.get_module( | |
| "realesrgan" | |
| ) | |
| assert module is not None | |
| assert ( | |
| module["module_name"] | |
| == "Apckeyl_RealESRGAN" | |
| ) | |
| # ===================================================== | |
| # Test 8 — List Modules | |
| # ===================================================== | |
| def test_list_modules(): | |
| modules = control_plane.list_modules() | |
| assert isinstance( | |
| modules, | |
| dict | |
| ) | |
| assert "realesrgan" in modules | |
| # ===================================================== | |
| # Test Runner | |
| # ===================================================== | |
| def main(): | |
| tests = [ | |
| test_control_plane_exists, | |
| test_resolve_image_upscale, | |
| test_resolved_module_type, | |
| test_resolved_module_name, | |
| test_resolved_module_status, | |
| test_unknown_task, | |
| test_get_module, | |
| test_list_modules, | |
| ] | |
| passed = 0 | |
| failed = 0 | |
| print( | |
| "====================================" | |
| ) | |
| print( | |
| "Apckeyl Control Plane Test" | |
| ) | |
| print( | |
| "Version 1.0" | |
| ) | |
| print( | |
| "====================================" | |
| ) | |
| for test in tests: | |
| try: | |
| test() | |
| print( | |
| f"PASS: {test.__name__}" | |
| ) | |
| passed += 1 | |
| except Exception as error: | |
| print( | |
| f"FAIL: {test.__name__}" | |
| ) | |
| print( | |
| f"ERROR: {error}" | |
| ) | |
| failed += 1 | |
| print( | |
| "====================================" | |
| ) | |
| print( | |
| f"PASSED: {passed}" | |
| ) | |
| print( | |
| f"FAILED: {failed}" | |
| ) | |
| print( | |
| "====================================" | |
| ) | |
| if failed > 0: | |
| raise RuntimeError( | |
| "Control Plane Test FAILED" | |
| ) | |
| print( | |
| "CONTROL PLANE TEST: PASSED" | |
| ) | |
| if __name__ == "__main__": | |
| main() |