diff --git a/daemon/core/api/grpc/wrappers.py b/daemon/core/api/grpc/wrappers.py index 0ab9cdd5..a49b9932 100644 --- a/daemon/core/api/grpc/wrappers.py +++ b/daemon/core/api/grpc/wrappers.py @@ -1195,13 +1195,13 @@ class EmanePathlossesRequest: ) -@dataclass +@dataclass(frozen=True) class MoveNodesRequest: session_id: int node_id: int - source: str = None - position: Position = None - geo: Geo = None + source: str = field(compare=False, default=None) + position: Position = field(compare=False, default=None) + geo: Geo = field(compare=False, default=None) def to_proto(self) -> core_pb2.MoveNodesRequest: position = self.position.to_proto() if self.position else None @@ -1213,15 +1213,3 @@ class MoveNodesRequest: position=position, geo=geo, ) - - def __members(self) -> Tuple[int, int]: - return self.session_id, self.node_id - - def __eq__(self, other: "MoveNodesRequest") -> bool: - if type(other) is type(self): - return self.__members() == other.__members() - else: - return False - - def __hash__(self): - return hash(self.__members()) diff --git a/daemon/tests/test_grpc.py b/daemon/tests/test_grpc.py index 27ebcfc5..49dcb381 100644 --- a/daemon/tests/test_grpc.py +++ b/daemon/tests/test_grpc.py @@ -8,7 +8,7 @@ import grpc import pytest from mock import patch -from core.api.grpc import core_pb2, wrappers +from core.api.grpc import wrappers from core.api.grpc.client import CoreGrpcClient, InterfaceHelper, MoveNodesStreamer from core.api.grpc.server import CoreGrpcServer from core.api.grpc.wrappers import ( @@ -22,6 +22,7 @@ from core.api.grpc.wrappers import ( Link, LinkOptions, MobilityAction, + MoveNodesRequest, Node, NodeServiceData, NodeType, @@ -918,7 +919,7 @@ class TestGrpc: client = CoreGrpcClient() session = grpc_server.coreemu.create_session() streamer = MoveNodesStreamer(session.id) - request = core_pb2.MoveNodesRequest() + request = MoveNodesRequest(session.id + 1, 1) streamer.send(request) streamer.stop()