#!/usr/bin/env python3 """ Quick test to demonstrate how the ServerCapabilities automatically discovers implemented vs unimplemented actions. """ from alpine_bits_python.alpinebits_server import ( ServerCapabilities, AlpineBitsAction, AlpineBitsActionName, Version, AlpineBitsResponse, HttpStatusCode ) import asyncio class NewImplementedAction(AlpineBitsAction): """A new action that IS implemented.""" def __init__(self): self.name = AlpineBitsActionName.OTA_HOTEL_DESCRIPTIVE_INFO_INFO self.version = Version.V2024_10 async def handle(self, action: str, request_xml: str, version: Version) -> AlpineBitsResponse: """This action is implemented.""" return AlpineBitsResponse("Implemented!", HttpStatusCode.OK) class NewUnimplementedAction(AlpineBitsAction): """A new action that is NOT implemented (no handle override).""" def __init__(self): self.name = AlpineBitsActionName.OTA_HOTEL_DESCRIPTIVE_CONTENT_NOTIF_INFO self.version = Version.V2024_10 # Notice: No handle method override - will use default "not implemented" async def main(): print("šŸ” Testing Action Discovery Logic") print("=" * 50) # Create capabilities and see what gets discovered capabilities = ServerCapabilities() print("šŸ“‹ Actions found by discovery:") for action_name in capabilities.get_supported_actions(): print(f" āœ… {action_name}") print(f"\nšŸ“Š Total discovered: {len(capabilities.get_supported_actions())}") # Test the new implemented action implemented_action = NewImplementedAction() result = await implemented_action.handle("test", "", Version.V2024_10) print(f"\n🟢 NewImplementedAction result: {result.xml_content}") # Test the unimplemented action (should use default behavior) unimplemented_action = NewUnimplementedAction() result = await unimplemented_action.handle("test", "", Version.V2024_10) print(f"šŸ”“ NewUnimplementedAction result: {result.xml_content}") if __name__ == "__main__": asyncio.run(main())