From 4ab415e37d9adac06e57d7a3b534dc5b17b6d469 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Thu, 28 May 2020 16:12:11 -0700 Subject: [PATCH] grpc: updated node events to contain geo data when present --- daemon/core/api/grpc/events.py | 2 ++ daemon/tests/test_grpc.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/daemon/core/api/grpc/events.py b/daemon/core/api/grpc/events.py index a53ad971..837860e3 100644 --- a/daemon/core/api/grpc/events.py +++ b/daemon/core/api/grpc/events.py @@ -23,11 +23,13 @@ def handle_node_event(event: NodeData) -> core_pb2.NodeEvent: :return: node event that contains node id, name, model, position, and services """ position = core_pb2.Position(x=event.x_position, y=event.y_position) + geo = core_pb2.Geo(lat=event.latitude, lon=event.longitude, alt=event.altitude) node_proto = core_pb2.Node( id=event.id, name=event.name, model=event.model, position=position, + geo=geo, services=event.services, ) return core_pb2.NodeEvent(node=node_proto, source=event.source) diff --git a/daemon/tests/test_grpc.py b/daemon/tests/test_grpc.py index 5e55f346..47cfe744 100644 --- a/daemon/tests/test_grpc.py +++ b/daemon/tests/test_grpc.py @@ -1002,11 +1002,18 @@ class TestGrpc: client = CoreGrpcClient() session = grpc_server.coreemu.create_session() node = session.add_node(CoreNode) + node.position.lat = 10.0 + node.position.lon = 20.0 + node.position.alt = 5.0 queue = Queue() def handle_event(event_data): assert event_data.session_id == session.id assert event_data.HasField("node_event") + event_node = event_data.node_event.node + assert event_node.geo.lat == node.position.lat + assert event_node.geo.lon == node.position.lon + assert event_node.geo.alt == node.position.alt queue.put(event_data) # then