Exemplo n.º 1
0
 def testTwoAgentsTalking(self):
     receiver = self.agent
     desc = yield self.doc_factory(descriptor.Descriptor)
     sender = yield self.agency.start_agent(desc)
     receiver.register_interest(DummyReplier)
     requester = sender.initiate_protocol(DummyRequester, receiver, 1)
     r = yield requester.notify_finish()
     self.assertEqual(1, r)
     self.assertTrue(requester.got_response)
     self.assertEqual(1, receiver.agent.got_payload)
    def testLateRequester(self):

        medium = self.get_local('medium')
        agent = self.get_local('agent')
        recip = IRecipient(agent)

        requester = agent.initiate_protocol(LateRequester, recip)

        d = requester.notify_finish()
        self.assertFailure(d, protocols.ProtocolExpired)
        yield d

        yield agent.callback_event("late event", None)

        self.assertCalled(agent, 'called', times=0)