def test_directory(): directory = Directory() mock_actor_1 = MockActor(1) mock_actor_2 = MockActor(2) directory.add_actor("mock-actor-1", mock_actor_1) directory.add_actor("mock-actor-2", mock_actor_2) assert(mock_actor_1 == directory.get_actor("mock-actor-1")) assert(mock_actor_2 == directory.get_actor("mock-actor-2"))
def test_worker_scheduler(): curr_supervisor = Supervisor('supervisor', [MockActor(1), MockActor(2)]) curr_directory = Directory() curr_directory.add_actor('supervisor', curr_supervisor) scheduler = MockScheduler("scheduler", curr_directory, curr_supervisor) # -- Test receive() -- # blocks until greenlet is complete # --> Done gevent.joinall([gevent.spawn(scheduler.receive, ActorMessages.Done)]) assert scheduler.did_ack # --> Start gevent.joinall([gevent.spawn(scheduler.receive, ActorMessages.Start)]) assert scheduler.state == ActorStates.Running assert scheduler.did_loop assert scheduler.supervisor == curr_supervisor # --> Stop gevent.joinall([gevent.spawn(scheduler.receive, ActorMessages.Stop)]) assert scheduler.state == ActorStates.Stopped