def testGetEntry(self): """Put an entry on top and retrieve its value""" cache = ActionCache() z1 = self.ArbitraryAction(1, 2) z2 = self.ArbitraryAction(1, 2) self.failUnless(cache.get(z1) == None) cache.append(z1) self.failUnless(cache.get(z1) == z1) cache.append(z2) self.failUnless(cache.get(z1) == z1) self.failIf(cache.get(z2) == z2)
def testPopEntry(self): """Pop an entry off the queue""" cache = ActionCache() z = self.ArbitraryAction('x', 'y') w= self.ArbitraryAction('x', 'y') cache.append(z) cache.append(w) self.failUnless(cache.pop(w) == z) self.failUnless(cache.get(w) == w) self.failUnless(cache.pop(z) == w) self.failUnless(cache.pop(z) == None) self.failIf(cache.contains(w))