def testIter(self): """Replay all actions""" cache = ActionCache() z1 = BaseAction(1) z2 = BaseAction(1) w1 = BaseAction(2) all = Set([z1, z2, w1]) self.failIf(list(cache)) [cache.append(x) for x in all] self.failUnless(Set(cache) == all)
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))
def testPutEntry(self): """Put an entry in and check for its existance""" cache = ActionCache() action = BaseAction('x') cache.append(action) self.failUnless(cache.contains(action))
def testHasEntry(self): """Ensure we can tell if an entry exists""" cache = ActionCache() self.failIf(cache.contains(BaseAction('x')))