Commits

John Chandler committed 7944919

Added code and tests for urlargs

  • Participants
  • Parent commits c042efd

Comments (0)

Files changed (2)

File fluidproxy/django_fluidproxy.py

 # THE SOFTWARE.
 
 import hashlib
+import pickle
 
 from django.core.cache import cache
 from fom.session       import Fluid
     """ Returns a key suitable for calls to cache """
     h = hashlib.sha1()
     h.update( path )
+    if urlargs:
+        h.update( pickle.dumps(urlargs) )
     
     return "fluidproxy:%s" % h.hexdigest()
     
         key   = generate_cache_key( path, urlargs )
         value = cache.get( key )
         if not value:
-            value = self.fluid.db( "GET", path ).value
+            value = self.fluid.db( "GET", path, urlargs ).value
             cache.set( key, value, CACHE_TIMEOUT )
         return value
 

File fluidproxy/tests.py

 
         self.assertEqual( cache.get(key), value )
 
+    def test_preload_path_and_urlargs( self ):
+        """ Tests preloading cache for a path with urlargs """
+        key   = "fluidproxy:38c544d820c304b0d6da2ec5900c4d6217dd84e4"
+        value = 1234
+        
+        self.proxy.preload( "/metaljoe/test/foo", urlargs={ "query": 'metaljoe/test/bar = "wibble"' }, value=value )
+
+        self.assertEqual( cache.get(key), value )
+
     def test_unload_path( self ):
         """ Tests unloading cache for a simple path """
         key   = "fluidproxy:a16b1ac35cb8cf6d6e2939d12fe68cee5860d9bc"
 
         self.assertEqual( cache.get(key), None )
 
+    def test_unload_path_and_urlargs( self ):
+        """ Tests unloading cache for a path with urlargs """
+        key   = "fluidproxy:38c544d820c304b0d6da2ec5900c4d6217dd84e4"
+        value = 1234
+
+        cache.set( key, value )
+        self.proxy.unload( "/metaljoe/test/foo", urlargs={ "query": 'metaljoe/test/bar = "wibble"' } )
+
+        self.assertEqual( cache.get(key), None )
+
     def test_get_path( self ):
         """ Tests retrieving a simple, cached path """
         path  = "/metaljoe/test/foo"