# Description: Fix some incompatibilities with Django 1.4.
# Author: Bernhard Reiter <ockham@raz.or.at>
# Forwarded: http://code.google.com/p/django-voting/issues/detail?id=35

--- a/voting/tests/settings.py
+++ b/voting/tests/settings.py
@@ -2,8 +2,12 @@
 
 DIRNAME = os.path.dirname(__file__)
 
-DATABASE_ENGINE = 'sqlite3'
-DATABASE_NAME = os.path.join(DIRNAME, 'database.db')
+DATABASES = {
+    'default' : {
+        'ENGINE' : 'django.db.backends.sqlite3',
+        'NAME' : os.path.join(DIRNAME, 'database.db'),
+    }
+}
 
 #DATABASE_ENGINE = 'mysql'
 #DATABASE_NAME = 'tagging_test'
--- a/voting/tests/runtests.py
+++ b/voting/tests/runtests.py
@@ -1,8 +1,9 @@
 import os, sys
 os.environ['DJANGO_SETTINGS_MODULE'] = 'voting.tests.settings'
 
-from django.test.simple import run_tests
+from django.test.simple import DjangoTestSuiteRunner
 
-failures = run_tests(None, verbosity=9)
+runner = DjangoTestSuiteRunner(verbosity=9)
+failures = runner.run_tests(None)
 if failures:
     sys.exit(failures)
--- a/voting/managers.py
+++ b/voting/managers.py
@@ -138,7 +138,7 @@
         # MySQL has issues with re-using the aggregate function in the
         # HAVING clause, so we alias the score and use this alias for
         # its benefit.
-        if settings.DATABASE_ENGINE == 'mysql':
+        if settings.DATABASES['default']['ENGINE'] == 'mysql':
             having_score = connection.ops.quote_name('score')
         else:
             having_score = 'SUM(vote)'
