# HG changeset patch # User Sverre Rabbelier # Date 1235418735 0 # Node ID c724a6eda7ef03835928dfe17d6390700494f74d # Parent ef8e8de75ebb955ecd56508a2ccd22d3b622d3aa Update the test suite to match the new signature of the cache methods Patch by: Sverre Rabbelier diff -r ef8e8de75ebb -r c724a6eda7ef tests/app/soc/cache/test_base.py --- a/tests/app/soc/cache/test_base.py Mon Feb 23 19:51:41 2009 +0000 +++ b/tests/app/soc/cache/test_base.py Mon Feb 23 19:52:15 2009 +0000 @@ -47,10 +47,10 @@ memcache.flush_all() def get(self): - return memcache.get('answer_to_life') + return memcache.get('answer_to_life'), 'answer_to_life' - def put(self, answer): - memcache.add('answer_to_life', 42) + def put(self, answer, memcache_key): + memcache.add(memcache_key, 42) def testMemcache(self): """Sanity check to see if memcache is working. diff -r ef8e8de75ebb -r c724a6eda7ef tests/app/soc/cache/test_sidebar.py --- a/tests/app/soc/cache/test_sidebar.py Mon Feb 23 19:51:41 2009 +0000 +++ b/tests/app/soc/cache/test_sidebar.py Mon Feb 23 19:52:15 2009 +0000 @@ -35,6 +35,7 @@ def setUp(self): self.called = 0 self.user = users.get_current_user() + self.memcache_key = "sidebar_for_'id'" def tearDown(self): memcache.flush_all() @@ -56,34 +57,34 @@ """Test that get without setting something returns None. """ - self.assertEqual(None, sidebar.get('id', None)) + self.assertEqual((None, self.memcache_key), sidebar.get('id')) def testGetPut(self): """Test that getting after putting gives back what you put in. """ - sidebar.put(42, 'id', None) - self.assertEqual(42, sidebar.get('id', None)) + sidebar.put(42, self.memcache_key) + self.assertEqual((42, self.memcache_key), sidebar.get('id')) def testFlush(self): """Test that getting after putting and flushing returns None. """ - sidebar.put(42, 'id', None) + sidebar.put(42, self.memcache_key) sidebar.flush('id') - self.assertEqual(None, sidebar.get('id', None)) + self.assertEqual((None, self.memcache_key), sidebar.get('id')) def testCache(self): """Test that the result of a cached sidebar is cached. """ @sidebar.cache - def getAnswer(x, y): + def getAnswer(x): self.called = self.called + 1 return 42 - self.assertEqual(42, getAnswer('id', None)) - self.assertEqual(42, getAnswer('id', None)) + self.assertEqual(42, getAnswer('id')) + self.assertEqual(42, getAnswer('id')) self.assertEqual(self.called, 1)