コード例 #1
0
    def testAssociatedAddressesDoNotMatchArbitraryStuff(self):
        myAddress = 'my addr'
        am = ActorAddressManager(None, myAddress)
        lclAddr1, mainAddr1 = self._makeLocalAndAssociated(myAddress, am)

        assert None != lclAddr1
        assert id(self) != lclAddr1
        assert 0 != lclAddr1
        assert "hi" != lclAddr1
        assert SomeRandomObject != lclAddr1

        assert None != mainAddr1
        assert id(self) != mainAddr1
        assert 0 != mainAddr1
        assert "hi" != mainAddr1
        assert SomeRandomObject != mainAddr1

        assert lclAddr1 != None
        assert lclAddr1 != id(self)
        assert lclAddr1 != 0
        assert lclAddr1 != "hi"
        assert lclAddr1 != SomeRandomObject

        assert mainAddr1 != None
        assert mainAddr1 != id(self)
        assert mainAddr1 != 0
        assert mainAddr1 != "hi"
        assert mainAddr1 != SomeRandomObject
コード例 #2
0
 def testMainAddressRevocation(self):
     myAddress = 'me'
     am = ActorAddressManager(None, myAddress)
     addr = ActorAddress(id(self))
     am.deadAddress(addr)
     assert addr == am.sendToAddress(addr)
     assert am.isDeadAddress(addr)
コード例 #3
0
    def testAssociationHashEqualityWithReconstitutedNonLocalAddress(self):
        myAddress = 'me'
        am = ActorAddressManager(None, myAddress)
        lclAddr = am.createLocalAddress()
        mainAddr1 = ActorAddress(None)
        mainAddr2 = ActorAddress(9)
        assert mainAddr1 != mainAddr2

        raises(TypeError, hash, lclAddr)
        raises(TypeError, hash, mainAddr1)
        raises(TypeError, hash, mainAddr2)

        am.associateUseableAddress(myAddress,
                                   lclAddr.addressDetails.addressInstanceNum,
                                   mainAddr1)

        raises(TypeError, hash, lclAddr)
        raises(TypeError, hash, mainAddr1)
        raises(TypeError, hash, mainAddr2)

        mainAddr1_dup = ActorAddress(None)
        assert mainAddr1 == mainAddr1_dup

        raises(TypeError, hash, lclAddr)
        raises(TypeError, hash, mainAddr1)
        raises(TypeError, hash, mainAddr1_dup)
        raises(TypeError, hash, mainAddr2)

        am.importAddr(mainAddr1_dup)

        raises(TypeError, hash, lclAddr)
        raises(TypeError, hash, mainAddr1)
        raises(TypeError, hash, mainAddr1_dup)
        raises(TypeError, hash, mainAddr2)
コード例 #4
0
    def testAssociationEqualityWithReconstitutedNonLocalAddress(self):
        myAddress = 'me'
        am = ActorAddressManager(None, myAddress)
        lclAddr = am.createLocalAddress()
        mainAddr1 = ActorAddress(None)
        mainAddr2 = ActorAddress(9)
        assert mainAddr1 != mainAddr2

        am.associateUseableAddress(myAddress,
                                   lclAddr.addressDetails.addressInstanceNum,
                                   mainAddr1)

        assert lclAddr == mainAddr1
        assert mainAddr1 == lclAddr

        assert lclAddr != mainAddr2
        assert mainAddr2 != lclAddr

        mainAddr1_dup = ActorAddress(None)
        assert mainAddr1 == mainAddr1_dup

        assert mainAddr1_dup == lclAddr
        assert lclAddr == mainAddr1_dup

        am.importAddr(mainAddr1_dup)

        assert mainAddr1_dup == lclAddr
        assert lclAddr == mainAddr1_dup
        assert mainAddr1_dup == mainAddr1
コード例 #5
0
 def testGetUniqueLocalAddresses(self):
     am = ActorAddressManager(None, "an address")
     addr1 = am.createLocalAddress()
     addr2 = am.createLocalAddress()
     assert addr1 != addr2
     assert addr2 != addr1
     assert addr1 == addr1
     assert addr2 == addr2
コード例 #6
0
 def testLocalAddressRevocation(self):
     myAddress = 'me'
     am = ActorAddressManager(None, myAddress)
     lcladdr = am.createLocalAddress()
     am.deadAddress(lcladdr)
     assert am.sendToAddress(lcladdr) is None
     assert am.isDeadAddress(lcladdr)
     assert lcladdr == am.getLocalAddress(
         lcladdr.addressDetails.addressInstanceNum)
コード例 #7
0
 def testMakeAssociation(self):
     myAddress = 'me'
     am = ActorAddressManager(None, myAddress)
     lclAddr = am.createLocalAddress()
     mainAddr = ActorAddress(id(self))
     am.associateUseableAddress(myAddress,
                                lclAddr.addressDetails.addressInstanceNum,
                                mainAddr)
     # No exception thrown
     assert True
コード例 #8
0
ファイル: systemCommon.py プロジェクト: perlchild/Thespian
 def __init__(self, adminAddr, transport):
     self._adminAddr   = adminAddr
     self.transport    = transport
     self._addrManager = ActorAddressManager(adminAddr, self.transport.myAddress)
     self.transport.setAddressManager(self._addrManager)
     self._pendingTransmits = PendingTransmits(self._addrManager)
     self._awaitingAddressUpdate = AddressWaitTransmits()
     self._receiveQueue = []  # array of ReceiveMessage to be processed
     self._children = []  # array of Addresses of children of this Actor/Admin
     self._governer = RateThrottle(RATE_THROTTLE)
     self._sCBStats = StatsManager()
コード例 #9
0
 def testNonLocalAddressRevocationAssociation(self):
     myAddress = 'me'
     am = ActorAddressManager(None, myAddress)
     lclAddr, mainAddr = self._makeLocalAndAssociated(myAddress, am)
     am.deadAddress(mainAddr)
     assert mainAddr == am.sendToAddress(lclAddr)
     assert mainAddr == am.sendToAddress(mainAddr)
     assert am.isDeadAddress(lclAddr)
     assert am.isDeadAddress(mainAddr)
     assert am.isDeadAddress(am.sendToAddress(mainAddr))
     assert am.isDeadAddress(am.sendToAddress(lclAddr))
コード例 #10
0
    def testAssociatedAddressEqualityIsUnique(self):
        myAddress = 'thisaddr'
        am = ActorAddressManager(None, myAddress)
        lclAddr1, mainAddr1 = self._makeLocalAndAssociated(myAddress, am)
        print('Set 1: %s --> %s' % (str(lclAddr1), str(mainAddr1)))
        lclAddr2, mainAddr2 = self._makeLocalAndAssociated(myAddress, am)
        print('Set 2: %s --> %s' % (str(lclAddr2), str(mainAddr2)))
        lclAddr3, mainAddr3 = self._makeLocalAndAssociated(myAddress, am)
        print('Set 3: %s --> %s' % (str(lclAddr3), str(mainAddr3)))

        assert lclAddr1 == lclAddr1
        assert lclAddr2 == lclAddr2
        assert lclAddr3 == lclAddr3

        assert mainAddr1 == mainAddr1
        assert mainAddr2 == mainAddr2
        assert mainAddr3 == mainAddr3

        assert lclAddr1 == mainAddr1
        assert lclAddr2 == mainAddr2
        assert lclAddr3 == mainAddr3

        assert mainAddr1 == lclAddr1
        assert mainAddr2 == lclAddr2
        assert mainAddr3 == lclAddr3

        assert lclAddr1 != lclAddr2
        assert lclAddr2 != lclAddr1
        assert lclAddr3 != lclAddr2
        assert lclAddr2 != lclAddr3
        assert lclAddr3 != lclAddr1
        assert lclAddr1 != lclAddr3

        assert mainAddr1 != mainAddr2
        assert mainAddr2 != mainAddr1
        assert mainAddr3 != mainAddr2
        assert mainAddr2 != mainAddr3
        assert mainAddr3 != mainAddr1
        assert mainAddr1 != mainAddr3

        assert mainAddr1 != lclAddr2
        assert mainAddr2 != lclAddr1
        assert mainAddr3 != lclAddr2
        assert mainAddr2 != lclAddr3
        assert mainAddr3 != lclAddr1
        assert mainAddr1 != lclAddr3

        assert lclAddr1 != mainAddr2
        assert lclAddr2 != mainAddr1
        assert lclAddr3 != mainAddr2
        assert lclAddr2 != mainAddr3
        assert lclAddr3 != mainAddr1
        assert lclAddr1 != mainAddr3
コード例 #11
0
 def __init__(self, adminAddr, transport):
     self._adminAddr = adminAddr
     self.transport = transport
     self._addrManager = ActorAddressManager(adminAddr,
                                             self.transport.myAddress)
     self.transport.setAddressManager(self._addrManager)
     self._finalTransmitPending = {
     }  # key = target ActorAddress, value=None or the last pending Intent
     self._awaitingAddressUpdate = {
     }  # key = actorAddress waited on (usually local), value=array of transmit Intents
     self._receiveQueue = []  # array of ReceiveMessage to be processed
     self._children = [
     ]  # array of Addresses of children of this Actor/Admin
     self._governer = RateThrottle(RATE_THROTTLE)
     self._sCBStats = StatsManager()
コード例 #12
0
    def testAssociationStillNotHashable(self):
        myAddress = 'me'
        am = ActorAddressManager(None, myAddress)
        lclAddr = am.createLocalAddress()
        mainAddr = ActorAddress(id(self))

        raises(TypeError, hash, lclAddr)
        raises(TypeError, hash, mainAddr)

        am.associateUseableAddress(myAddress,
                                   lclAddr.addressDetails.addressInstanceNum,
                                   mainAddr)

        raises(TypeError, hash, lclAddr)
        raises(TypeError, hash, mainAddr)
コード例 #13
0
    def testAssociationEquality(self):
        myAddress = 'me'
        am = ActorAddressManager(None, myAddress)
        lclAddr = am.createLocalAddress()
        mainAddr = ActorAddress(id(self))

        assert lclAddr != mainAddr
        assert mainAddr != lclAddr

        am.associateUseableAddress(myAddress,
                                   lclAddr.addressDetails.addressInstanceNum,
                                   mainAddr)

        assert lclAddr == mainAddr
        assert mainAddr == lclAddr
コード例 #14
0
    def testAssociatedAddressRevocationIsUnique(self):
        myAddress = 'me'
        am = ActorAddressManager(None, myAddress)
        lclAddr1, mainAddr1 = self._makeLocalAndAssociated(myAddress, am)
        print('1', str(lclAddr1), str(mainAddr1))
        lclAddr2, mainAddr2 = self._makeLocalAndAssociated(myAddress, am)
        print('2', str(lclAddr2), str(mainAddr2))
        lclAddr3, mainAddr3 = self._makeLocalAndAssociated(myAddress, am)
        print('3', str(lclAddr3), str(mainAddr3))

        assert not am.isDeadAddress(lclAddr1)
        assert not am.isDeadAddress(mainAddr1)
        print('1sm', str(am.sendToAddress(mainAddr1)))
        assert not am.isDeadAddress(am.sendToAddress(mainAddr1))
        print('1sl', str(am.sendToAddress(lclAddr1)))
        assert not am.isDeadAddress(am.sendToAddress(lclAddr1))

        assert not am.isDeadAddress(lclAddr2)
        assert not am.isDeadAddress(mainAddr2)
        assert not am.isDeadAddress(am.sendToAddress(mainAddr2))
        assert not am.isDeadAddress(am.sendToAddress(lclAddr2))

        assert not am.isDeadAddress(lclAddr3)
        assert not am.isDeadAddress(mainAddr3)
        assert not am.isDeadAddress(am.sendToAddress(mainAddr3))
        assert not am.isDeadAddress(am.sendToAddress(lclAddr3))

        am.deadAddress(lclAddr1)
        am.deadAddress(mainAddr2)

        assert am.isDeadAddress(lclAddr1)
        assert am.isDeadAddress(mainAddr1)
        assert am.isDeadAddress(am.sendToAddress(mainAddr1))
        assert am.isDeadAddress(am.sendToAddress(lclAddr1))

        assert am.isDeadAddress(lclAddr2)
        assert am.isDeadAddress(mainAddr2)
        assert am.isDeadAddress(am.sendToAddress(mainAddr2))
        assert am.isDeadAddress(am.sendToAddress(lclAddr2))

        assert not am.isDeadAddress(lclAddr3)
        assert not am.isDeadAddress(mainAddr3)
        assert not am.isDeadAddress(am.sendToAddress(mainAddr3))
        assert not am.isDeadAddress(am.sendToAddress(lclAddr3))
コード例 #15
0
 def testLocalAddressCannotBePickled(self):
     am = ActorAddressManager(None, 'me')
     addr = am.createLocalAddress()
     raises(CannotPickleAddress, pickle.dumps, addr)
コード例 #16
0
 def testGetValidLocalAddress(self):
     am = ActorAddressManager(None, "I am me")
     addr = ActorAddress(ActorLocalAddress('I am me', 12, am))
     assert isinstance(addr.addressDetails, ActorLocalAddress)
コード例 #17
0
 def testCreate(self):
     am = ActorAddressManager(None, 'me')
     # no exception thrown
     assert True
コード例 #18
0
 def testGetValidLocalAddress(self):
     am = ActorAddressManager(None, "self.myAddress")
     addr = am.createLocalAddress()
     assert isinstance(addr.addressDetails, ActorLocalAddress)
コード例 #19
0
 def testLocalAddressCanBeReconstituted(self):
     am = ActorAddressManager(None, "my own: address")
     addr = am.createLocalAddress()
     addr2 = am.getLocalAddress(addr.addressDetails.addressInstanceNum)
     assert addr == addr2
コード例 #20
0
 def testLocalAddressCannotBeUsedForSending(self):
     am = ActorAddressManager(None, "here")
     addr = am.createLocalAddress()
     assert am.sendToAddress(addr) is None
コード例 #21
0
 def testAssociationRemembered(self):
     myAddress = 'me'
     am = ActorAddressManager(None, myAddress)
     lclAddr, mainAddr = self._makeLocalAndAssociated(myAddress, am)
     assert mainAddr == am.sendToAddress(lclAddr)
     assert mainAddr == am.sendToAddress(mainAddr)
コード例 #22
0
 def setUp(self):
     self.myAddress = 'me'
     self.am = ActorAddressManager(None, self.myAddress)
コード例 #23
0
 def testAssociationNotRequiredForUseableNonLocal(self):
     myAddress = 'me'
     am = ActorAddressManager(None, myAddress)
     addr = ActorAddress(id(self))
     assert addr == am.sendToAddress(addr)
コード例 #24
0
 def testAssociationUnique(self):
     myAddress = 'me'
     am = ActorAddressManager(None, myAddress)
     self.testAssociationRemembered()
     lclAddr2 = am.createLocalAddress()
     assert am.sendToAddress(lclAddr2) is None