Exemple #1
0
    def test_facade(self):
        mtc = TestC( )
        mtc_f = Facade( mtc )

        self.assertEquals( mtc.methoda( ), mtc_f.methoda( ) )
        self.assertEquals( mtc.methodb( ), mtc_f.methodb( ) )
        self.assertEquals( mtc_f.methoda( ), "a" )

        self.assertEquals( mtc_f.increment( ), 1 )
        self.assertEquals( mtc_f.increment( ), 2 )
        self.assertEquals( mtc_f.increment( ), 3 )
        self.assertEquals( mtc_f.increment( ), 4 )
    def test_facade(self):
        mtc = TestC()
        mtc_f = Facade(mtc)

        self.assertEquals(mtc.methoda(), mtc_f.methoda())
        self.assertEquals(mtc.methodb(), mtc_f.methodb())
        self.assertEquals(mtc_f.methoda(), "a")

        self.assertEquals(mtc_f.increment(), 1)
        self.assertEquals(mtc_f.increment(), 2)
        self.assertEquals(mtc_f.increment(), 3)
        self.assertEquals(mtc_f.increment(), 4)
Exemple #3
0
    def test_recache(self):
        mtc = TestC( )
        mtc_f = Facade( mtc )

        hashes = []

        self.assertEquals( mtc.methoda( ), mtc_f.methoda( ) )
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append( mtc_f.last_cached )
        self.assertEquals( mtc.methodb( ), mtc_f.methodb( ) )
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append( mtc_f.last_cached )
        self.assertEquals( mtc_f.methoda( ), "a" )
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append( mtc_f.last_cached )

        self.assertEquals( mtc_f.increment( ), 1 )
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append( mtc_f.last_cached )
        self.assertEquals( mtc_f.increment( ), 2 )
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append( mtc_f.last_cached )
        self.assertEquals( mtc_f.increment( ), 3 )
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append( mtc_f.last_cached )
        self.assertEquals( mtc_f.increment( ), 4 )
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append( mtc_f.last_cached )

        # Ensure hashes are now in db:
        for hash in hashes:
            self.assertIsNotNone(hash, "Hash is none. whoops.")
            cd = fetch( hash )
            self.assertTrue( cd is not None, "%s was not found" % hash )
            self.assertEquals( cd.hash, hash, "%s was not found" % hash )

        # Delete some:
        caliendo.util.recache( 'methodb', 'caliendo_test.py' )
        caliendo.util.recache( 'methoda', 'caliendo_test.py' )

        # Ensure they're gone:
        methodb = hashes[0]
        methoda = hashes[1]
        cd = fetch( methodb )

        self.assertIsNone( cd, "Method b failed to recache." )
        cd = fetch( methoda )

        self.assertIsNone( cd, "Method a failed to recache." )

        # Ensure the rest are there:
        hashes = hashes[3:]
        for hash in hashes:
            cd = fetch( hash )
            self.assertEquals( cd.hash, hash )

        # Delete them ALL:
        caliendo.util.recache()

        #Ensure they're all gone:
        for hash in hashes:
            cd = fetch( hash )
            self.assertIsNone( cd )
    def test_recache(self):
        mtc = TestC()
        mtc_f = Facade(mtc)

        hashes = []

        self.assertEquals(mtc.methoda(), mtc_f.methoda())
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append(mtc_f.last_cached)
        self.assertEquals(mtc.methodb(), mtc_f.methodb())
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append(mtc_f.last_cached)
        self.assertEquals(mtc_f.methoda(), "a")
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append(mtc_f.last_cached)

        self.assertEquals(mtc_f.increment(), 1)
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append(mtc_f.last_cached)
        self.assertEquals(mtc_f.increment(), 2)
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append(mtc_f.last_cached)
        self.assertEquals(mtc_f.increment(), 3)
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append(mtc_f.last_cached)
        self.assertEquals(mtc_f.increment(), 4)
        self.assertIsNotNone(mtc_f.last_cached)
        hashes.append(mtc_f.last_cached)

        # Ensure hashes are now in db:
        for hash in hashes:
            self.assertIsNotNone(hash, "Hash is none. whoops.")
            cd = fetch(hash)
            self.assertTrue(cd is not None, "%s was not found" % hash)
            self.assertEquals(cd.hash, hash, "%s was not found" % hash)

        # Delete some:
        caliendo.util.recache('methodb', 'caliendo_test.py')
        caliendo.util.recache('methoda', 'caliendo_test.py')

        # Ensure they're gone:
        methodb = hashes[0]
        methoda = hashes[1]
        cd = fetch(methodb)

        self.assertIsNone(cd, "Method b failed to recache.")
        cd = fetch(methoda)

        self.assertIsNone(cd, "Method a failed to recache.")

        # Ensure the rest are there:
        hashes = hashes[3:]
        for hash in hashes:
            cd = fetch(hash)
            self.assertEquals(cd.hash, hash)

        # Delete them ALL:
        caliendo.util.recache()

        #Ensure they're all gone:
        for hash in hashes:
            cd = fetch(hash)
            self.assertIsNone(cd)