Exemplo n.º 1
0
    def test_send_msg_between_threaded_actors(self):
        ''' test_threaded_actors.test_send_msg_between_threaded_actors
        '''        
        test_name = 'test_threaded_actors.test_send_msg_between_threaded_actors'
        logger = file_logger(test_name, filename='logs/%s.log' % test_name) 

        parent = TestActor()      
        parent.add_child(ThreadedSenderActor(name='Sender'))      
        parent.add_child(ThreadedReceiverActor(name='Receiver'))      
        parent.start()
        parent.run()
        parent.stop()       
        self.assertEqual(
                [actor.message for actor in parent.find(actor_name='Receiver')],
                ['message from sender']
        ) 
Exemplo n.º 2
0
    def test_generator_and_greenlet(self):
        ''' test_actors_zoo.test_generator_and_greenlet
        '''
        test_name = 'test_actors_zoo.test_generator_and_greenlet'
        logger = file_logger(test_name, filename='logs/%s.log' % test_name) 

        parent = ActorGe(name='parent')
        parent.add_child(ActorGe(name='child-actor-ge-1'))
        parent.add_child(ActorGr(name='child-actor-gr-2'))
        parent.add_child(ActorGe(name='child-actor-ge-3'))
        parent.add_child(ActorGe(name='child-actor-ge-4'))
        parent.add_child(ActorGr(name='child-actor-gr-5'))
        parent.start()
        parent.run()
        parent.stop()
        result = []
        while True:
            try:
                result.append(parent.inbox.get())
            except EmptyInboxException:
                break
        self.assertEqual(len(result), 50)
Exemplo n.º 3
0
    def test_run(self):
        ''' test_generator_actors.test_run
        '''
        test_name = 'test_generator_actors.test_run'
        logger = file_logger(test_name, filename='logs/%s.log' % test_name) 

        actor = TestActor()
        actor.start()
        self.assertEqual(actor.processing, True)
        actor.run()

        result = []
        while True:
            try:
                result.append(actor.inbox.get())
            except EmptyInboxException:
                break
        self.assertEqual(len(result), 10)

        self.assertEqual(actor.run_once(), False)
        self.assertEqual(actor.processing, False)
        self.assertEqual(actor.waiting, False)