def test_version_at_creation(self): comment = Comment.objects.latest() comment.like_it() version_cache_key = cache_token_key_for_record(comment) # the cache version token should be zero as we've just created the record # by loading the fixtures. At creation the cache version should be # zero self.assertEquals(cache.get(version_cache_key), 0)
def test_version_after_save(self): # get the comment we want to invalidate the cache for comment = Comment.objects.latest() # get the version key for this comment version_cache_key = cache_token_key_for_record(comment) # get the original version, should be zero original_version = cache.get(version_cache_key, None) # change the comment & save, should increment the version value in # memcached comment.like_it() # get the new version value for the comment new_version = cache.get(version_cache_key) self.assertNotEquals(original_version, new_version)