Permalink
Browse files

Resurrect test suite for 2.7

This puts back the app engine helper but mainly
just for testing. It's pretty hacky but this at least
lets the test suite run.
  • Loading branch information...
1 parent a750681 commit c2aee270bc49ab80744526543491f88ba1cebac7 @kumar303 kumar303 committed Jan 21, 2013
Showing with 29 additions and 3 deletions.
  1. +1 −1 appengine_django/tests/db_test.py
  2. +9 −0 main.py
  3. +14 −1 manage.py
  4. +5 −1 settings.py
@@ -20,7 +20,7 @@
import unittest
from django.db import connection
-from django.db.backends.appengine.base import DatabaseWrapper
+from appengine_django.db.base import DatabaseWrapper
from appengine_django import appid
from appengine_django.db import base
View
@@ -20,9 +20,18 @@
"""
import os
+import sys
ROOT = os.path.dirname(__file__)
+if not os.environ.get('IN_MANAGE'):
+ # manage.py is only used for testing.
+ # When not testing (i.e. production) this configures
+ # app engine helper so that it doesn't try to set up the
+ # datastore for testing.
+ import appengine_django
+ appengine_django.have_appserver = True
+
# Import the part of Django that we use here.
import django.core.handlers.wsgi
View
@@ -12,12 +12,22 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
import sys
# WARNING: This script is not run in production.
# See main.py for that.
-# installs app engine django
+# manage.py is only used for testing.
+# This will set a flag so that main.py knows we are testing
+os.environ['IN_MANAGE'] = '1'
+
+# Install the old app engine *only* for testing.
+# This sets up datastore stubs and clears data.
+from appengine_django import InstallAppengineHelperForDjango
+InstallAppengineHelperForDjango('1.3')
+
+# Loads the production app.
import main
from django.core.management import execute_manager
@@ -34,5 +44,8 @@
if 'test' in sys.argv:
import devlib
devlib.activate()
+ else:
+ raise NotImplementedError('Use dev_appserver.py for non-test '
+ 'commands.')
execute_manager(settings)
View
@@ -33,7 +33,10 @@
MANAGERS = ADMINS
-DATABASES = {}
+# Tell Django to use the app engine helper DB.
+# This isn't really used anywhere except for testing (setup/teardown).
+# The google.appengine.db models are used directly instead.
+DATABASES = {'default': {'ENGINE': 'appengine_django.db'}}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
@@ -112,6 +115,7 @@
)
INSTALLED_APPS = (
+ 'appengine_django',
'auth',
'common',
'djdb',

0 comments on commit c2aee27

Please sign in to comment.