61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
#!/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", "<xml/>", 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", "<xml/>", Version.V2024_10)
|
|
print(f"🔴 NewUnimplementedAction result: {result.xml_content}")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main()) |