Commits

Jannis Leidel  committed ff79989

Updated johnny-cache tests to run on Django 1.4.

  • Participants
  • Parent commits 08b67e1

Comments (0)

Files changed (5)

File johnny/cache.py

     cls = None
     if django.VERSION[:2] == (1, 1):
         cls = QueryCacheBackend11
-    if django.VERSION[:2] in ((1, 2), (1, 3)):
+    if django.VERSION[:2] > (1, 1):
         cls = QueryCacheBackend
     if cls is None:
         raise ImproperlyConfigured("Johnny doesn't work on this version of django.")

File johnny/tests/cache.py

 
 """Tests for the QueryCache functionality of johnny."""
 
+import django
 from django.conf import settings
 from django.db import connection
 from johnny import middleware
         from django.db import transaction
         from testapp.models import Genre, Publisher
         from johnny import cache
-        if settings.DATABASE_ENGINE == 'sqlite3':
-            print "\n  Skipping test requiring multiple threads."
-            return
+
+        if django.VERSION[:2] < (1, 3):
+            if settings.DATABASE_ENGINE == 'sqlite3':
+                print "\n  Skipping test requiring multiple threads."
+                return
+        else:
+            if settings.DATABASES.get('default', {}).get('ENGINE', '').endswith('sqlite3'):
+                print "\n  Skipping test requiring multiple threads."
+                return
 
         self.failUnless(transaction.is_managed() == False)
         self.failUnless(transaction.is_dirty() == False)
         from django.db import transaction
         from testapp.models import Genre, Publisher
         from johnny import cache
-        if settings.DATABASE_ENGINE == 'sqlite3':
-            print "\n  Skipping test requiring multiple threads."
-            return
+        if django.VERSION[:2] < (1, 3):
+            if settings.DATABASE_ENGINE == 'sqlite3':
+                print "\n  Skipping test requiring multiple threads."
+                return
+        else:
+            if settings.DATABASES.get('default', {}).get('ENGINE', '').endswith('sqlite3'):
+                print "\n  Skipping test requiring multiple threads."
+                return
 
         self.failUnless(transaction.is_managed() == False)
         self.failUnless(transaction.is_dirty() == False)

File johnny/tests/testapp/fixtures/books.json

       "pages": 250,
       "publisher" : 1,
       "published" : "2007-11-25",
-      "genre": [1]
+      "genre": [1],
+      "created": "2011-06-09 18:43:54",
+      "modified": "2011-06-10 22:17:12"
     }
   },
   {
       "isbn": "9780307266934",
       "pages": 1296,
       "published" : "2007-10-16",
-      "genre": [3]
+      "genre": [3],
+      "created": "2011-06-09 18:43:54",
+      "modified": "2011-06-11 11:01:45"
     }
   }
 ]

File johnny/tests/web.py

         """Verify that doing the same request w/o a db write twice does not
         populate the cache properly."""
         # it seems that django 1.3 doesn't exhibit this bug!
-        if django.VERSION[:2] == (1, 3):
+        if django.VERSION[:2] >= (1, 3):
             return
         connection.queries = []
         q = base.message_queue()

File johnny/transaction.py

             del self.local['trans_sids']
 
     def has_multi_db(self):
-        if django.VERSION[:2] in ((1, 2), (1, 3)):
+        if django.VERSION[:2] > (1, 1):
             return True
         return False
 
             original()
             self._flush(commit=commit)
 
-        if django.VERSION[:2] == (1,1):
+        if django.VERSION[:2] == (1, 1):
             return newfun11
-        elif django.VERSION[:2] in ((1,2), (1,3)):
+        elif django.VERSION[:2] > (1, 1):
             return newfun
         return original