2008-08-06 02:13:06 +08:00
|
|
|
from django.conf import settings
|
2009-12-22 23:18:51 +08:00
|
|
|
from django.db import DEFAULT_DB_ALIAS
|
2008-08-06 02:13:06 +08:00
|
|
|
|
|
|
|
# function that will pass a test.
|
|
|
|
def pass_test(*args): return
|
|
|
|
|
|
|
|
def no_backend(test_func, backend):
|
|
|
|
"Use this decorator to disable test on specified backend."
|
2009-12-22 23:18:51 +08:00
|
|
|
if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1] == backend:
|
2008-08-06 02:13:06 +08:00
|
|
|
return pass_test
|
|
|
|
else:
|
|
|
|
return test_func
|
|
|
|
|
|
|
|
# Decorators to disable entire test functions for specific
|
|
|
|
# spatial backends.
|
|
|
|
def no_oracle(func): return no_backend(func, 'oracle')
|
2009-12-22 23:18:51 +08:00
|
|
|
def no_postgis(func): return no_backend(func, 'postgis')
|
2008-08-06 02:13:06 +08:00
|
|
|
def no_mysql(func): return no_backend(func, 'mysql')
|
2009-12-22 23:18:51 +08:00
|
|
|
def no_spatialite(func): return no_backend(func, 'spatialite')
|
2008-08-06 02:13:06 +08:00
|
|
|
|
|
|
|
# Shortcut booleans to omit only portions of tests.
|
2009-12-22 23:18:51 +08:00
|
|
|
_default_db = settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1]
|
|
|
|
oracle = _default_db == 'oracle'
|
|
|
|
postgis = _default_db == 'postgis'
|
|
|
|
mysql = _default_db == 'mysql'
|
|
|
|
spatialite = _default_db == 'spatialite'
|