Esempio n. 1
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)
Esempio n. 2
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
Esempio n. 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)
Esempio n. 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
Esempio n. 5
0
class TestAddressManagerLocalAddressAssociations(unittest.TestCase):
    scope = 'unit'

    def setUp(self):
        self.myAddress = 'me'
        self.am = ActorAddressManager(None, self.myAddress)

    def testMakeAssociation(self):
        lclAddr = self.am.createLocalAddress()
        mainAddr = ActorAddress(id(self))
        self.am.associateUseableAddress(
            self.myAddress, lclAddr.addressDetails.addressInstanceNum,
            mainAddr)
        # No exception thrown
        self.assertTrue(True)

    def _makeLocalAndAssociated(self):
        lclAddr = self.am.createLocalAddress()
        mainAddr = ActorAddress(id(lclAddr))
        self.am.associateUseableAddress(
            self.myAddress, lclAddr.addressDetails.addressInstanceNum,
            mainAddr)
        return lclAddr, mainAddr

    def testAssociationRemembered(self):
        lclAddr, mainAddr = self._makeLocalAndAssociated()
        self.assertEqual(mainAddr, self.am.sendToAddress(lclAddr))
        self.assertEqual(mainAddr, self.am.sendToAddress(mainAddr))

    def testAssociationUnique(self):
        self.testAssociationRemembered()
        lclAddr2 = self.am.createLocalAddress()
        self.assertIsNone(self.am.sendToAddress(lclAddr2))

    def testAssociationNotRequiredForUseableNonLocal(self):
        addr = ActorAddress(id(self))
        self.assertEqual(addr, self.am.sendToAddress(addr))

    def testAssociationEquality(self):
        lclAddr = self.am.createLocalAddress()
        mainAddr = ActorAddress(id(self))

        self.assertNotEqual(lclAddr, mainAddr)
        self.assertNotEqual(mainAddr, lclAddr)

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

        self.assertEqual(lclAddr, mainAddr)
        self.assertEqual(mainAddr, lclAddr)

    def testAssociationEqualityWithReconstitutedNonLocalAddress(self):
        lclAddr = self.am.createLocalAddress()
        mainAddr1 = ActorAddress(None)
        mainAddr2 = ActorAddress(9)
        self.assertNotEqual(mainAddr1, mainAddr2)

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

        self.assertEqual(lclAddr, mainAddr1)
        self.assertEqual(mainAddr1, lclAddr)

        self.assertNotEqual(lclAddr, mainAddr2)
        self.assertNotEqual(mainAddr2, lclAddr)

        mainAddr1_dup = ActorAddress(None)
        self.assertEqual(mainAddr1, mainAddr1_dup)

        self.assertNotEqual(mainAddr1_dup, lclAddr)
        self.assertEqual(lclAddr, mainAddr1_dup)

        self.am.importAddr(mainAddr1_dup)

        self.assertEqual(mainAddr1_dup, lclAddr)
        self.assertEqual(lclAddr, mainAddr1_dup)
        self.assertEqual(mainAddr1_dup, mainAddr1)

    def testAssociatedAddressesDoNotMatchArbitraryStuff(self):
        lclAddr1, mainAddr1 = self._makeLocalAndAssociated()

        self.assertNotEqual(None, lclAddr1)
        self.assertNotEqual(id(self), lclAddr1)
        self.assertNotEqual(0, lclAddr1)
        self.assertNotEqual("hi", lclAddr1)
        self.assertNotEqual(unittest.TestCase, lclAddr1)

        self.assertNotEqual(None, mainAddr1)
        self.assertNotEqual(id(self), mainAddr1)
        self.assertNotEqual(0, mainAddr1)
        self.assertNotEqual("hi", mainAddr1)
        self.assertNotEqual(unittest.TestCase, mainAddr1)

        self.assertNotEqual(lclAddr1, None)
        self.assertNotEqual(lclAddr1, id(self))
        self.assertNotEqual(lclAddr1, 0)
        self.assertNotEqual(lclAddr1, "hi")
        self.assertNotEqual(lclAddr1, unittest.TestCase)

        self.assertNotEqual(mainAddr1, None)
        self.assertNotEqual(mainAddr1, id(self))
        self.assertNotEqual(mainAddr1, 0)
        self.assertNotEqual(mainAddr1, "hi")
        self.assertNotEqual(mainAddr1, unittest.TestCase)

    def testAssociatedAddressEqualityIsUnique(self):
        lclAddr1, mainAddr1 = self._makeLocalAndAssociated()
        print('Set 1: %s --> %s' % (str(lclAddr1), str(mainAddr1)))
        lclAddr2, mainAddr2 = self._makeLocalAndAssociated()
        print('Set 2: %s --> %s' % (str(lclAddr2), str(mainAddr2)))
        lclAddr3, mainAddr3 = self._makeLocalAndAssociated()
        print('Set 3: %s --> %s' % (str(lclAddr3), str(mainAddr3)))

        self.assertEqual(lclAddr1, lclAddr1)
        self.assertEqual(lclAddr2, lclAddr2)
        self.assertEqual(lclAddr3, lclAddr3)

        self.assertEqual(mainAddr1, mainAddr1)
        self.assertEqual(mainAddr2, mainAddr2)
        self.assertEqual(mainAddr3, mainAddr3)

        self.assertEqual(lclAddr1, mainAddr1)
        self.assertEqual(lclAddr2, mainAddr2)
        self.assertEqual(lclAddr3, mainAddr3)

        self.assertEqual(mainAddr1, lclAddr1)
        self.assertEqual(mainAddr2, lclAddr2)
        self.assertEqual(mainAddr3, lclAddr3)

        self.assertNotEqual(lclAddr1, lclAddr2)
        self.assertNotEqual(lclAddr2, lclAddr1)
        self.assertNotEqual(lclAddr3, lclAddr2)
        self.assertNotEqual(lclAddr2, lclAddr3)
        self.assertNotEqual(lclAddr3, lclAddr1)
        self.assertNotEqual(lclAddr1, lclAddr3)

        self.assertNotEqual(mainAddr1, mainAddr2)
        self.assertNotEqual(mainAddr2, mainAddr1)
        self.assertNotEqual(mainAddr3, mainAddr2)
        self.assertNotEqual(mainAddr2, mainAddr3)
        self.assertNotEqual(mainAddr3, mainAddr1)
        self.assertNotEqual(mainAddr1, mainAddr3)

        self.assertNotEqual(mainAddr1, lclAddr2)
        self.assertNotEqual(mainAddr2, lclAddr1)
        self.assertNotEqual(mainAddr3, lclAddr2)
        self.assertNotEqual(mainAddr2, lclAddr3)
        self.assertNotEqual(mainAddr3, lclAddr1)
        self.assertNotEqual(mainAddr1, lclAddr3)

        self.assertNotEqual(lclAddr1, mainAddr2)
        self.assertNotEqual(lclAddr2, mainAddr1)
        self.assertNotEqual(lclAddr3, mainAddr2)
        self.assertNotEqual(lclAddr2, mainAddr3)
        self.assertNotEqual(lclAddr3, mainAddr1)
        self.assertNotEqual(lclAddr1, mainAddr3)
Esempio n. 6
0
class TestAddressManagerLocalAddressAssociations(unittest.TestCase):
    scope='unit'

    def setUp(self):
        self.myAddress = 'me'
        self.am = ActorAddressManager(None, self.myAddress)

    def testMakeAssociation(self):
        lclAddr = self.am.createLocalAddress()
        mainAddr = ActorAddress(id(self))
        self.am.associateUseableAddress(self.myAddress,
                                        lclAddr.addressDetails.addressInstanceNum,
                                        mainAddr)
        # No exception thrown
        self.assertTrue(True)

    def _makeLocalAndAssociated(self):
        lclAddr = self.am.createLocalAddress()
        mainAddr = ActorAddress(id(lclAddr))
        self.am.associateUseableAddress(self.myAddress,
                                        lclAddr.addressDetails.addressInstanceNum,
                                        mainAddr)
        return lclAddr, mainAddr

    def testAssociationRemembered(self):
        lclAddr, mainAddr = self._makeLocalAndAssociated()
        self.assertEqual(mainAddr, self.am.sendToAddress(lclAddr))
        self.assertEqual(mainAddr, self.am.sendToAddress(mainAddr))

    def testAssociationUnique(self):
        self.testAssociationRemembered()
        lclAddr2 = self.am.createLocalAddress()
        self.assertIsNone(self.am.sendToAddress(lclAddr2))

    def testAssociationNotRequiredForUseableNonLocal(self):
        addr = ActorAddress(id(self))
        self.assertEqual(addr, self.am.sendToAddress(addr))

    def testAssociationEquality(self):
        lclAddr = self.am.createLocalAddress()
        mainAddr = ActorAddress(id(self))

        self.assertNotEqual(lclAddr, mainAddr)
        self.assertNotEqual(mainAddr, lclAddr)

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

        self.assertEqual(lclAddr, mainAddr)
        self.assertEqual(mainAddr, lclAddr)

    def testAssociationEqualityWithReconstitutedNonLocalAddress(self):
        lclAddr = self.am.createLocalAddress()
        mainAddr1 = ActorAddress(None)
        mainAddr2 = ActorAddress(9)
        self.assertNotEqual(mainAddr1, mainAddr2)

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

        self.assertEqual(lclAddr, mainAddr1)
        self.assertEqual(mainAddr1, lclAddr)

        self.assertNotEqual(lclAddr, mainAddr2)
        self.assertNotEqual(mainAddr2, lclAddr)

        mainAddr1_dup = ActorAddress(None)
        self.assertEqual(mainAddr1, mainAddr1_dup)

        self.assertNotEqual(mainAddr1_dup, lclAddr)
        self.assertEqual(lclAddr, mainAddr1_dup)

        self.am.importAddr(mainAddr1_dup)

        self.assertEqual(mainAddr1_dup, lclAddr)
        self.assertEqual(lclAddr, mainAddr1_dup)
        self.assertEqual(mainAddr1_dup, mainAddr1)

    def testAssociatedAddressesDoNotMatchArbitraryStuff(self):
        lclAddr1, mainAddr1 = self._makeLocalAndAssociated()

        self.assertNotEqual(None, lclAddr1)
        self.assertNotEqual(id(self), lclAddr1)
        self.assertNotEqual(0, lclAddr1)
        self.assertNotEqual("hi", lclAddr1)
        self.assertNotEqual(unittest.TestCase, lclAddr1)

        self.assertNotEqual(None, mainAddr1)
        self.assertNotEqual(id(self), mainAddr1)
        self.assertNotEqual(0, mainAddr1)
        self.assertNotEqual("hi", mainAddr1)
        self.assertNotEqual(unittest.TestCase, mainAddr1)

        self.assertNotEqual(lclAddr1, None)
        self.assertNotEqual(lclAddr1, id(self))
        self.assertNotEqual(lclAddr1, 0)
        self.assertNotEqual(lclAddr1, "hi")
        self.assertNotEqual(lclAddr1, unittest.TestCase)

        self.assertNotEqual(mainAddr1, None)
        self.assertNotEqual(mainAddr1, id(self))
        self.assertNotEqual(mainAddr1, 0)
        self.assertNotEqual(mainAddr1, "hi")
        self.assertNotEqual(mainAddr1, unittest.TestCase)

    def testAssociatedAddressEqualityIsUnique(self):
        lclAddr1, mainAddr1 = self._makeLocalAndAssociated()
        print('Set 1: %s --> %s'%(str(lclAddr1), str(mainAddr1)))
        lclAddr2, mainAddr2 = self._makeLocalAndAssociated()
        print('Set 2: %s --> %s'%(str(lclAddr2), str(mainAddr2)))
        lclAddr3, mainAddr3 = self._makeLocalAndAssociated()
        print('Set 3: %s --> %s'%(str(lclAddr3), str(mainAddr3)))

        self.assertEqual(lclAddr1, lclAddr1)
        self.assertEqual(lclAddr2, lclAddr2)
        self.assertEqual(lclAddr3, lclAddr3)

        self.assertEqual(mainAddr1, mainAddr1)
        self.assertEqual(mainAddr2, mainAddr2)
        self.assertEqual(mainAddr3, mainAddr3)

        self.assertEqual(lclAddr1, mainAddr1)
        self.assertEqual(lclAddr2, mainAddr2)
        self.assertEqual(lclAddr3, mainAddr3)

        self.assertEqual(mainAddr1, lclAddr1)
        self.assertEqual(mainAddr2, lclAddr2)
        self.assertEqual(mainAddr3, lclAddr3)

        self.assertNotEqual(lclAddr1, lclAddr2)
        self.assertNotEqual(lclAddr2, lclAddr1)
        self.assertNotEqual(lclAddr3, lclAddr2)
        self.assertNotEqual(lclAddr2, lclAddr3)
        self.assertNotEqual(lclAddr3, lclAddr1)
        self.assertNotEqual(lclAddr1, lclAddr3)

        self.assertNotEqual(mainAddr1, mainAddr2)
        self.assertNotEqual(mainAddr2, mainAddr1)
        self.assertNotEqual(mainAddr3, mainAddr2)
        self.assertNotEqual(mainAddr2, mainAddr3)
        self.assertNotEqual(mainAddr3, mainAddr1)
        self.assertNotEqual(mainAddr1, mainAddr3)

        self.assertNotEqual(mainAddr1, lclAddr2)
        self.assertNotEqual(mainAddr2, lclAddr1)
        self.assertNotEqual(mainAddr3, lclAddr2)
        self.assertNotEqual(mainAddr2, lclAddr3)
        self.assertNotEqual(mainAddr3, lclAddr1)
        self.assertNotEqual(mainAddr1, lclAddr3)

        self.assertNotEqual(lclAddr1, mainAddr2)
        self.assertNotEqual(lclAddr2, mainAddr1)
        self.assertNotEqual(lclAddr3, mainAddr2)
        self.assertNotEqual(lclAddr2, mainAddr3)
        self.assertNotEqual(lclAddr3, mainAddr1)
        self.assertNotEqual(lclAddr1, mainAddr3)