Exemple #1
0
 def test_inequality(self):
     m1 = DeadEnvelope(1, 2)
     assert m1 != 1
     assert m1 != DeadEnvelope('hi', True)
     assert m1 != DeadEnvelope(0, 2)
     assert m1 != DeadEnvelope(1, 3)
     assert m1 != DeadEnvelope(None, None)
 def test_inequality(self):
     m1 = DeadEnvelope(1, 2)
     self.assertNotEqual(m1, 1)
     self.assertNotEqual(m1, DeadEnvelope('hi', True))
     self.assertNotEqual(m1, DeadEnvelope(0, 2))
     self.assertNotEqual(m1, DeadEnvelope(1, 3))
     self.assertNotEqual(m1, DeadEnvelope(None, None))
Exemple #3
0
    def prepMessageSend(self, anAddress, msg):
        """Prepares to send the specified message to the specified address,
           returning a tuple of the send-to-address and the (possibly
           updated) message to send.

           The address may be converted from an internal to an
           exportable address.

           If the target address is known as a dead letter box, the
           Admin address is returned instead and the message is
           wrapped in a DeadEnvelope wrapper.

           If the target address is not ready for use, the
           send-to-address portion of the tuple will return a value of
           None.

           If the message should no longer be sent, the message
           portion of the tuple will be returned as
           SendStatus.DeadTarget (because this is *never* a valid
           message to actually send).

        """
        tgtaddr = self.exportAddr(anAddress)
        if tgtaddr is None:
            return None, msg
        if tgtaddr in self._deadAddrs:
            if isinstance(msg, (DeadEnvelope, ChildActorExited)):
                thesplog('Discarding %s to %s because the latter is dead.',
                         str(msg), str(tgtaddr))
                return None, SendStatus.DeadTarget
            return self._adminAddr, DeadEnvelope(anAddress, msg)
        return tgtaddr, msg
Exemple #4
0
    def test_properties(self):
        assert 1 == DeadEnvelope(1, 2).deadAddress
        assert 2 == DeadEnvelope(1, 2).deadMessage

        assert DeadEnvelope(None, '').deadAddress is None
        assert '' == DeadEnvelope(None, '').deadMessage

        assert 'foo' == DeadEnvelope('foo', 3.3).deadAddress
        assert 3.3 == DeadEnvelope('foo', 3.3).deadMessage
    def test_properties(self):
        self.assertEqual(1, DeadEnvelope(1, 2).deadAddress)
        self.assertEqual(2, DeadEnvelope(1, 2).deadMessage)

        self.assertEqual(None, DeadEnvelope(None, '').deadAddress)
        self.assertEqual('', DeadEnvelope(None, '').deadMessage)

        self.assertEqual('foo', DeadEnvelope('foo', 3.3).deadAddress)
        self.assertEqual(3.3, DeadEnvelope('foo', 3.3).deadMessage)
Exemple #6
0
    def prepMessageSend(self, anAddress, msg):
        """Prepares to send the specified message to the specified address,
           returning a tuple of the send-to-address and the (possibly
           updated) message to send.

           The address may be converted from an internal to an
           exportable address.

           If the target address is known as a dead letter box, the
           Admin address is returned instead and the message is
           wrapped in a DeadEnvelope wrapper.

           If the target address is not ready for use, the
           send-to-address portion of the tuple will return a value of
           None.
        """
        tgtaddr = self.exportAddr(anAddress)
        if tgtaddr is None:
            return None, msg
        if tgtaddr in self._deadAddrs:
            return self._adminAddr, DeadEnvelope(anAddress, msg)
        return tgtaddr, msg
Exemple #7
0
 def test_equality(self):
     m1 = DeadEnvelope(1, 2)
     assert m1 == DeadEnvelope(1, 2)
     m2 = DeadEnvelope('hi', False)
     assert m2 == DeadEnvelope('hi', False)
Exemple #8
0
 def test_inheritance(self):
     assert isinstance(DeadEnvelope(1, 2), DeadEnvelope)
     assert isinstance(DeadEnvelope('one', None), DeadEnvelope)
     assert isinstance(DeadEnvelope(1, 2), ActorSystemMessage)
     assert isinstance(DeadEnvelope('one', None), ActorSystemMessage)
 def test_equality(self):
     m1 = DeadEnvelope(1, 2)
     self.assertEqual(m1, DeadEnvelope(1, 2))
     m2 = DeadEnvelope('hi', False)
     self.assertEqual(m2, DeadEnvelope('hi', False))