示例#1
0
class DispatcherTest(unittest.TestCase):
    def setUp(self):
        self.am = AgentManager()
        self.dispatcher = Dispatcher()
        self.dispatcher.daemon = True
        self.dispatcher.start()

    def test_subscription(self):
        agent = MockAgent()
        self.am.add_agent(agent)
        self.dispatcher.bind(agent, "test")

        agent.create_event()
        agent.start()

        timed_out = not agent.event_received.wait(1)
        if timed_out:
            self.fail("Event not received")

    def tearDown(self):
        AgentManager.reset_singleton()
        Dispatcher.reset_singleton()
示例#2
0
 def tearDown(self):
     AgentManager.reset_singleton()
     Dispatcher.reset_singleton()
示例#3
0
 def setUp(self):
     self.am = AgentManager()
     self.dispatcher = Dispatcher()
     self.dispatcher.daemon = True
     self.dispatcher.start()