Ejemplo n.º 1
0
def test_errors_in_pre_start_are_reported(defer):
    class MyActor(Actor):
        def pre_start(self):
            raise MockException()
    node = DummyNode()
    defer(node.stop)
    with expect_failure(MockException):
        node.spawn(MyActor)
Ejemplo n.º 2
0
def test_errors_in_pre_start_are_reported(defer):
    class MyActor(Actor):
        def pre_start(self):
            raise MockException()

    node = DummyNode()
    defer(node.stop)
    with expect_failure(MockException):
        node.spawn(MyActor)
Ejemplo n.º 3
0
def test_errors_in_process_while_processing_a_message_are_reported(defer):
    class MyProc(Actor):
        def run(self):
            self.get()
            raise MockException
    node = DummyNode()
    defer(node.stop)
    p = node.spawn(MyProc)
    with expect_failure(MockException):
        p << 'dummy'
Ejemplo n.º 4
0
def test_errors_in_process_while_processing_a_message_are_reported(defer):
    class MyProc(Actor):
        def run(self):
            self.get()
            raise MockException

    node = DummyNode()
    defer(node.stop)
    p = node.spawn(MyProc)
    with expect_failure(MockException):
        p << 'dummy'
Ejemplo n.º 5
0
def test_errors_while_stopping_are_reported(defer):
    class MyProc(Actor):
        def run(self):
            try:
                self.get()
            finally:
                raise MockException
    node = DummyNode()
    defer(node.stop)
    a = node.spawn(MyProc)
    sleep(.001)
    with expect_failure(MockException):
        a.stop()
Ejemplo n.º 6
0
def test_errors_while_stopping_are_reported(defer):
    class MyProc(Actor):
        def run(self):
            try:
                self.get()
            finally:
                raise MockException

    node = DummyNode()
    defer(node.stop)
    a = node.spawn(MyProc)
    sleep(.001)
    with expect_failure(MockException):
        a.stop()
Ejemplo n.º 7
0
def test_unhandled_termination_message_causes_receiver_to_raise_unhandledtermination(defer):
    class Watcher(Actor):
        def pre_start(self):
            self.watch(watchee)

        def receive(self, message):
            raise Unhandled

    node = DummyNode()
    defer(node.stop)
    watchee = node.spawn(Actor)
    watchee.stop()
    with expect_failure(UnhandledTermination):
        node.spawn(Watcher)
Ejemplo n.º 8
0
def test_unhandled_termination_message_causes_receiver_to_raise_unhandledtermination(
        defer):
    class Watcher(Actor):
        def pre_start(self):
            self.watch(watchee)

        def receive(self, message):
            raise Unhandled

    node = DummyNode()
    defer(node.stop)
    watchee = node.spawn(Actor)
    watchee.stop()
    with expect_failure(UnhandledTermination):
        node.spawn(Watcher)
Ejemplo n.º 9
0
def test_error_in_stopping_proc_is_reported_nevertheless(defer):
    class MyProc(Actor):
        def run(self):
            self.get()
            released.wait()
            raise MockException
    released = Event()
    node = node = DummyNode()
    defer(node.stop)
    a = node.spawn(MyProc)
    a << 'dummy'
    sleep(.001)
    a.stop()
    with expect_failure(MockException):
        released.set()
Ejemplo n.º 10
0
def test_error_in_stopping_proc_is_reported_nevertheless(defer):
    class MyProc(Actor):
        def run(self):
            self.get()
            released.wait()
            raise MockException

    released = Event()
    node = node = DummyNode()
    defer(node.stop)
    a = node.spawn(MyProc)
    a << 'dummy'
    sleep(.001)
    a.stop()
    with expect_failure(MockException):
        released.set()
Ejemplo n.º 11
0
def test_error_in_post_stop_reports_error_and_termination_messages_are_sent_as_normal(defer):
    class Child(Actor):
        def post_stop(self):
            raise MockException

    class Parent(Actor):
        def pre_start(self):
            self.child = self.spawn(Child)
            self.watch(self.child)
            self.child.stop()

        def receive(self, message):
            eq_(message, ('terminated', self.child))
            termination_message_received.set()

    node = DummyNode()
    defer(node.stop)
    termination_message_received = Event()
    with expect_failure(MockException):
        node.spawn(Parent)
    termination_message_received.wait()
Ejemplo n.º 12
0
def test_error_in_post_stop_reports_error_and_termination_messages_are_sent_as_normal(
        defer):
    class Child(Actor):
        def post_stop(self):
            raise MockException

    class Parent(Actor):
        def pre_start(self):
            self.child = self.spawn(Child)
            self.watch(self.child)
            self.child.stop()

        def receive(self, message):
            eq_(message, ('terminated', self.child))
            termination_message_received.set()

    node = DummyNode()
    defer(node.stop)
    termination_message_received = Event()
    with expect_failure(MockException):
        node.spawn(Parent)
    termination_message_received.wait()