示例#1
0
    def test_received_msg_is_delivered_to_messaging_queue(self):

        comm1 = InProcessCommunicationLayer()
        Messaging('a1', comm1)
        comm1.messaging.post_msg = MagicMock()

        comm1.receive_msg('a2', 'a1', ('c2', 'c1', 'msg', MSG_MGT))

        comm1.messaging.post_msg.assert_called_with('c2', 'c1', 'msg', 10)
示例#2
0
    def test_msg_to_another_agent(self):

        comm1 = InProcessCommunicationLayer()
        Messaging('a1', comm1)
        comm1.discovery = Discovery('a1', comm1)

        comm2 = InProcessCommunicationLayer()
        Messaging('a2', comm2)
        comm2.discovery = Discovery('a2', comm2)
        comm2.receive_msg = MagicMock()

        comm1.discovery.register_agent('a2', comm2)

        full_msg = ('c1', 'c2', 'msg')
        comm1.send_msg('a1', 'a2', full_msg)

        comm2.receive_msg.assert_called_with('a1', 'a2', full_msg)