Spaces:
Running on Zero
Running on Zero
| # ===================================================== | |
| # Apckeyl Framework | |
| # Version 1.0 | |
| # test_module_registry.py | |
| # ===================================================== | |
| """ | |
| Tests for Apckeyl Module Registry. | |
| Version 1.0 | |
| """ | |
| from module_registry import registry | |
| # ===================================================== | |
| # Test 1 — Registry Exists | |
| # ===================================================== | |
| def test_registry_exists(): | |
| assert registry is not None | |
| # ===================================================== | |
| # Test 2 — RealESRGAN Exists | |
| # ===================================================== | |
| def test_realesrgan_exists(): | |
| assert registry.exists( | |
| "realesrgan" | |
| ) | |
| # ===================================================== | |
| # Test 3 — Module Information | |
| # ===================================================== | |
| def test_realesrgan_information(): | |
| module = registry.get( | |
| "realesrgan" | |
| ) | |
| assert module is not None | |
| assert module["module_id"] == "realesrgan" | |
| assert module["module_name"] == "Apckeyl_RealESRGAN" | |
| assert module["module_type"] == "image_upscaler" | |
| # ===================================================== | |
| # Test 4 — Capability | |
| # ===================================================== | |
| def test_realesrgan_capability(): | |
| module = registry.get( | |
| "realesrgan" | |
| ) | |
| assert "image_upscale" in module[ | |
| "capabilities" | |
| ] | |
| # ===================================================== | |
| # Test 5 — Status | |
| # ===================================================== | |
| def test_realesrgan_status(): | |
| module = registry.get( | |
| "realesrgan" | |
| ) | |
| assert module["status"] == "available" | |
| # ===================================================== | |
| # Test 6 — Find By Type | |
| # ===================================================== | |
| def test_find_by_type(): | |
| modules = registry.find_by_type( | |
| "image_upscaler" | |
| ) | |
| assert len(modules) >= 1 | |
| assert any( | |
| module["module_id"] == "realesrgan" | |
| for module in modules | |
| ) | |
| # ===================================================== | |
| # Test Runner | |
| # ===================================================== | |
| def main(): | |
| tests = [ | |
| test_registry_exists, | |
| test_realesrgan_exists, | |
| test_realesrgan_information, | |
| test_realesrgan_capability, | |
| test_realesrgan_status, | |
| test_find_by_type, | |
| ] | |
| passed = 0 | |
| failed = 0 | |
| print( | |
| "====================================" | |
| ) | |
| print( | |
| "Apckeyl Module Registry 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( | |
| "Module Registry Test FAILED" | |
| ) | |
| print( | |
| "MODULE REGISTRY TEST: PASSED" | |
| ) | |
| if __name__ == "__main__": | |
| main() |