Пример #1
0
 def test_broadcast_sends_message_to_all_actors_of_given_class_name(self):
     ActorRegistry.broadcast({'command': 'foo'}, target_class='AnActor')
     for actor_ref in ActorRegistry.get_by_class(self.AnActor):
         received_messages = actor_ref.proxy().received_messages.get()
         self.assertTrue({'command': 'foo'} in received_messages)
     for actor_ref in ActorRegistry.get_by_class(self.BeeActor):
         received_messages = actor_ref.proxy().received_messages.get()
         self.assertTrue({'command': 'foo'} not in received_messages)
Пример #2
0
 def test_broadcast_sends_message_to_all_actors_of_given_class(self):
     ActorRegistry.broadcast({'command': 'foo'}, target_class=self.AnActor)
     for actor_ref in ActorRegistry.get_by_class(self.AnActor):
         received_messages = actor_ref.proxy().received_messages.get()
         self.assert_({'command': 'foo'} in received_messages)
     for actor_ref in ActorRegistry.get_by_class(self.BeeActor):
         received_messages = actor_ref.proxy().received_messages.get()
         self.assert_({'command': 'foo'} not in received_messages)
Пример #3
0
def test_broadcast_sends_message_to_all_actors_if_no_target(
        a_actor_refs, b_actor_refs):
    ActorRegistry.broadcast({'command': 'foo'})

    running_actors = ActorRegistry.get_all()
    assert running_actors

    for actor_ref in running_actors:
        received_messages = actor_ref.proxy().received_messages.get()
        assert {'command': 'foo'} in received_messages
Пример #4
0
def test_broadcast_sends_message_to_all_actors_if_no_target(
    a_actor_refs, b_actor_refs
):
    ActorRegistry.broadcast({'command': 'foo'})

    running_actors = ActorRegistry.get_all()
    assert running_actors

    for actor_ref in running_actors:
        received_messages = actor_ref.proxy().received_messages.get()
        assert {'command': 'foo'} in received_messages
Пример #5
0
def test_broadcast_sends_message_to_all_actors_of_given_class_name(
        actor_a_class, actor_b_class):
    ActorRegistry.broadcast({'command': 'foo'}, target_class='ActorA')

    for actor_ref in ActorRegistry.get_by_class(actor_a_class):
        received_messages = actor_ref.proxy().received_messages.get()
        assert {'command': 'foo'} in received_messages

    for actor_ref in ActorRegistry.get_by_class(actor_b_class):
        received_messages = actor_ref.proxy().received_messages.get()
        assert {'command': 'foo'} not in received_messages
Пример #6
0
def test_broadcast_sends_message_to_all_actors_of_given_class_name(
    actor_a_class, actor_b_class
):
    ActorRegistry.broadcast({'command': 'foo'}, target_class='ActorA')

    for actor_ref in ActorRegistry.get_by_class(actor_a_class):
        received_messages = actor_ref.proxy().received_messages.get()
        assert {'command': 'foo'} in received_messages

    for actor_ref in ActorRegistry.get_by_class(actor_b_class):
        received_messages = actor_ref.proxy().received_messages.get()
        assert {'command': 'foo'} not in received_messages
Пример #7
0
 def test_broadcast_sends_message_to_all_actors_if_no_target(self):
     ActorRegistry.broadcast({'command': 'foo'})
     for actor_ref in ActorRegistry.get_all():
         received_messages = actor_ref.proxy().received_messages.get()
         self.assert_({'command': 'foo'} in received_messages)
Пример #8
0
 def test_broadcast_sends_message_to_all_actors_if_no_target(self):
     ActorRegistry.broadcast({'command': 'foo'})
     for actor_ref in ActorRegistry.get_all():
         received_messages = actor_ref.proxy().received_messages.get()
         self.assertTrue({'command': 'foo'} in received_messages)
Пример #9
0
def tell_tick():
    ActorRegistry.broadcast({'msg': 'tick'})