#!/usr/bin/env python3 """Test cleaned action output from gRPC""" import sys import json sys.path.insert(0, r'C:\DEV\COPILOT\geutebruck-api\src\api') import grpc from protos import configuration_pb2 from protos import configuration_pb2_grpc def test_cleaned_actions(): """Test the cleaned action output""" print("Connecting to SDK Bridge at localhost:50051...") with grpc.insecure_channel('localhost:50051') as channel: stub = configuration_pb2_grpc.ConfigurationServiceStub(channel) request = configuration_pb2.ReadActionMappingsRequest() try: response = stub.ReadActionMappings(request) # Simulate what the REST API does clean_mappings = [] for idx, mapping in enumerate(response.mappings, 1): clean_mappings.append({ "id": idx, "actions": list(mapping.actions) }) clean_result = { "action_mappings": clean_mappings, "total_count": len(clean_mappings), "total_actions": sum(len(m["actions"]) for m in clean_mappings) } # Print first 10 mappings print("\n" + "=" * 60) print("CLEANED ACTION MAPPINGS OUTPUT") print("=" * 60) print(json.dumps({ "total_count": clean_result["total_count"], "total_actions": clean_result["total_actions"], "first_10_mappings": clean_result["action_mappings"][:10] }, indent=2)) return True except grpc.RpcError as e: print(f"\nError: {e.code()}") print(f"Details: {e.details()}") return False if __name__ == '__main__': test_cleaned_actions()