def test_broadcast_message(self): destination_list = [2] node_with_power = Node(node_id="1", location=self.location_a, power=10) broadcast_message = BroadcastMessage(sender=node_with_power, emit_location=self.location_a, function_to_call=TestMessages.an_example_function, arguments={}) self.assertEqual(broadcast_message.power, 10)
def setUp(self): location_a = Location(5, 3) node_a = Node(node_id="1", location=location_a) arguments_a = {'arg_1': 1, 'arg_2': 2, 'arg_3': 3} self.asynchronous_event_1 = AsynchronousEvent( node_id=node_a.id, function_to_call=self.an_example_function, arguments=arguments_a) location_b = Location(1, 2) node_b = Node(node_id="1", location=location_b) arguments_b = {'arg_1': 5, 'arg_2': 4, 'arg_3': 3} self.asynchronous_event_2 = AsynchronousEvent( node_id=node_b.id, function_to_call=self.an_example_function, arguments=arguments_b) self.simulator_event_1 = SimulatorEvent(arguments=arguments_a) self.simulator_event_2 = SimulatorEvent(arguments=arguments_b) self.event_broker = EventBroker()
def setUp(self): self.location_a = Location(5, 3) self.node_a = Node(node_id="1", location=self.location_a) self.arguments_a = {'arg_1':1, 'arg_2':2, 'arg_3':3} self.message_a = Message(sender=self.node_a, emit_location=self.location_a, \ function_to_call=self.an_example_function, arguments=self.arguments_a) self.location_b = Location(1, 2) self.message_b = Message(sender=self.node_a, emit_location=self.location_b, \ function_to_call=self.an_example_function, arguments=self.arguments_a) self.message_broker = MessageBroker()
def test_direct_message(self): node_b = Node(node_id="2", location=self.location_b) destination_list = [node_b.id] direct_message = DirectMessage(sender=self.node_a, emit_location=self.location_a, function_to_call=self.an_example_function, arguments={}, destination_list=destination_list) self.assertEqual(direct_message.destination_list, destination_list) ret = direct_message.run(all_nodes={self.node_a.id:self.node_a, node_b.id:node_b}, plane=None) self.assertFalse(ret['messages']) self.assertFalse(ret['asynchronous']) self.assertFalse(ret['simulator'])