"""Tests the cache_mgr module."""

from django.test import TransactionTestCase
from apps.managers.cache_mgr import cache_mgr


class BaseUnitTestCase(TransactionTestCase):
    """basic setting test"""
    def testCache(self):
        """Tests basic cache operations."""
        self.assertTrue(cache_mgr.info() is not None,
                         "Test that info() return something.")
        self.assertEqual(len(cache_mgr.keys()), 0,
                         "Test that the current cache is empty.")

        cache_mgr.set_cache('test_key', 'test_value')
        self.assertEqual(len(cache_mgr.keys()), 1,
                         "Test that the current cache is not empty after set.")

        self.assertEqual(cache_mgr.get_cache('test_key'), 'test_value',
                         "Test get the correct value from cache.")

        cache_mgr.get_cache('test_key_2', 'default_value')
        self.assertEqual(len(cache_mgr.keys()), 2,
                         "Test that the current cache after get default.")

        cache_mgr.delete('test_key')
        self.assertEqual(len(cache_mgr.keys()), 1,
                         "Test delete from cache.")

        cache_mgr.clear()
        self.assertEqual(len(cache_mgr.keys()), 0,
                         "Test that the current cache is empty after clear.")

@@ -72,16 +72,26 @@
 estCase%0A
+import os%0A
 from app
@@ -690,24 +690,152 @@
 ter set.%22)%0A%0A
+        if 'MAKAHIKI_MEMCACHED_ENABLED' in os.environ and %5C%0A            os.environ%5B'MAKAHIKI_MEMCACHED_ENABLED'%5D == %22True%22:%0A    
         self
@@ -894,16 +894,20 @@
 value',%0A
+    
         
@@ -1076,16 +1076,20 @@
 ()), 2,%0A
+    
         

fix cache test to don't check cache if memcache is not enable