2013-09-24 12:22:50 +02:00
|
|
|
from unittest import skip
|
|
|
|
|
2008-08-05 20:13:06 +02:00
|
|
|
from django.conf import settings
|
2009-12-22 16:18:51 +01:00
|
|
|
from django.db import DEFAULT_DB_ALIAS
|
2008-08-05 20:13:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
def no_backend(test_func, backend):
|
|
|
|
"Use this decorator to disable test on specified backend."
|
2009-12-22 16:18:51 +01:00
|
|
|
if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1] == backend:
|
2013-09-24 12:22:50 +02:00
|
|
|
@skip("This test is skipped on '%s' backend" % backend)
|
|
|
|
def inner():
|
|
|
|
pass
|
|
|
|
return inner
|
2008-08-05 20:13:06 +02:00
|
|
|
else:
|
|
|
|
return test_func
|
|
|
|
|
2013-11-02 18:18:46 +01:00
|
|
|
|
2008-08-05 20:13:06 +02:00
|
|
|
# Decorators to disable entire test functions for specific
|
|
|
|
# spatial backends.
|
2013-10-17 10:17:41 +02:00
|
|
|
def no_oracle(func):
|
|
|
|
return no_backend(func, 'oracle')
|
|
|
|
|
2013-11-02 18:18:46 +01:00
|
|
|
|
2008-08-05 20:13:06 +02:00
|
|
|
# Shortcut booleans to omit only portions of tests.
|
2009-12-22 16:18:51 +01:00
|
|
|
_default_db = settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1]
|
2013-10-22 15:31:43 +02:00
|
|
|
oracle = _default_db == 'oracle'
|
2009-12-22 16:18:51 +01:00
|
|
|
postgis = _default_db == 'postgis'
|
2013-10-22 15:31:43 +02:00
|
|
|
mysql = _default_db == 'mysql'
|
2009-12-22 16:18:51 +01:00
|
|
|
spatialite = _default_db == 'spatialite'
|
2012-06-17 11:39:02 +02:00
|
|
|
|
2014-08-21 18:47:57 +02:00
|
|
|
# MySQL spatial indices can't handle NULL geometries.
|
|
|
|
gisfield_may_be_null = not mysql
|
|
|
|
|
2012-10-27 17:10:41 +02:00
|
|
|
if oracle and 'gis' in settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE']:
|
2014-06-08 09:54:35 +02:00
|
|
|
from django.contrib.gis.db.backends.oracle.models import OracleSpatialRefSys as SpatialRefSys
|
2012-06-17 11:39:02 +02:00
|
|
|
elif postgis:
|
2014-06-08 09:54:35 +02:00
|
|
|
from django.contrib.gis.db.backends.postgis.models import PostGISSpatialRefSys as SpatialRefSys
|
2012-06-17 11:39:02 +02:00
|
|
|
elif spatialite:
|
2014-06-08 09:54:35 +02:00
|
|
|
from django.contrib.gis.db.backends.spatialite.models import SpatialiteSpatialRefSys as SpatialRefSys
|
2012-06-17 11:39:02 +02:00
|
|
|
else:
|
|
|
|
SpatialRefSys = None
|