Commits

Anonymous committed 5b81e66

Fix tests to use the new caching

  • Participants
  • Parent commits a4e8be1

Comments (0)

Files changed (2)

dragoman/lib/client.py

 from urllib import urlencode
 
 from dragoman.lib.urltemplate import Url
+from dragoman.lib.httpcache import BsddbCache
 
 class RequestFailure(Exception):
     def __init__(self, msg, resp, content):
             return self._h
         if not hasattr(self, '_cache_name'):
             self._cache_name = '.dragoman_client_cache'
-        self._h = httplib2.Http(self._cache_name)
+
+		# thread safe cache using bsddb
+        cache = BsddbCache(self._cache_name)
+        self._h = httplib2.Http(cache)
         return self._h
 
 
 
         # clear out the directory
         if os.path.exists(self._cache_name):
-            for f in os.listdir(self._cache_name):
-                os.remove(os.path.join(self._cache_name, f))
-            # we don't remove the cache directory b/c it breaks out
-            # http object
-            # os.rmdir(self._cache_name)
-
+			os.remove(self._cache_name)
 
 
 class Service(ClientMixin):

dragoman/lib/test/test_api.py

 
 class TestRawCatalogApi(object):
     def setup_class(self):
+        # clear the cache b/c the client will make one
+        cache = '.dragoman_client_cache'
+        for f in os.listdir(cache):
+            os.remove(os.path.join(cache, f))
+        os.rmdir(cache)
+        
         self.base = '%s/api' % server.base_url
         self.conn = DMConn('%s/api' % server.base_url)
         self.h = httplib2.Http()