mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Replaced HAS_SPATIALREFSYS by a database feature
This commit is contained in:
parent
c7fa27d702
commit
46c7707e50
@ -11,6 +11,7 @@ from django.utils.encoding import python_2_unicode_compatible
|
|||||||
|
|
||||||
class BaseSpatialFeatures(object):
|
class BaseSpatialFeatures(object):
|
||||||
gis_enabled = True
|
gis_enabled = True
|
||||||
|
has_spatialrefsys_table = True
|
||||||
|
|
||||||
|
|
||||||
class BaseSpatialOperations(object):
|
class BaseSpatialOperations(object):
|
||||||
|
@ -9,7 +9,7 @@ from django.contrib.gis.db.backends.mysql.operations import MySQLOperations
|
|||||||
|
|
||||||
|
|
||||||
class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
|
class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
|
||||||
pass
|
has_spatialrefsys_table = False
|
||||||
|
|
||||||
|
|
||||||
class DatabaseWrapper(MySQLDatabaseWrapper):
|
class DatabaseWrapper(MySQLDatabaseWrapper):
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from django.contrib.gis.gdal import HAS_GDAL
|
from django.contrib.gis.gdal import HAS_GDAL
|
||||||
from django.contrib.gis.tests.utils import (no_mysql, oracle, postgis,
|
from django.contrib.gis.tests.utils import (oracle, postgis, spatialite,
|
||||||
spatialite, HAS_SPATIALREFSYS, SpatialRefSys)
|
SpatialRefSys)
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
|
from django.test import skipUnlessDBFeature
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
|
||||||
|
|
||||||
@ -34,11 +35,10 @@ test_srs = ({'srid': 4326,
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(HAS_GDAL and HAS_SPATIALREFSYS,
|
@unittest.skipUnless(HAS_GDAL, "SpatialRefSysTest needs gdal support")
|
||||||
"SpatialRefSysTest needs gdal support and a spatial database")
|
@skipUnlessDBFeature("has_spatialrefsys_table")
|
||||||
class SpatialRefSysTest(unittest.TestCase):
|
class SpatialRefSysTest(unittest.TestCase):
|
||||||
|
|
||||||
@no_mysql
|
|
||||||
def test_retrieve(self):
|
def test_retrieve(self):
|
||||||
"""
|
"""
|
||||||
Test retrieval of SpatialRefSys model objects.
|
Test retrieval of SpatialRefSys model objects.
|
||||||
@ -61,7 +61,6 @@ class SpatialRefSysTest(unittest.TestCase):
|
|||||||
self.assertTrue(srs.wkt.startswith(sd['srtext']))
|
self.assertTrue(srs.wkt.startswith(sd['srtext']))
|
||||||
six.assertRegex(self, srs.proj4text, sd['proj4_re'])
|
six.assertRegex(self, srs.proj4text, sd['proj4_re'])
|
||||||
|
|
||||||
@no_mysql
|
|
||||||
def test_osr(self):
|
def test_osr(self):
|
||||||
"""
|
"""
|
||||||
Test getting OSR objects from SpatialRefSys model objects.
|
Test getting OSR objects from SpatialRefSys model objects.
|
||||||
@ -85,7 +84,6 @@ class SpatialRefSysTest(unittest.TestCase):
|
|||||||
if not spatialite or connection.ops.spatial_version[0] >= 4:
|
if not spatialite or connection.ops.spatial_version[0] >= 4:
|
||||||
self.assertTrue(srs.wkt.startswith(sd['srtext']))
|
self.assertTrue(srs.wkt.startswith(sd['srtext']))
|
||||||
|
|
||||||
@no_mysql
|
|
||||||
def test_ellipsoid(self):
|
def test_ellipsoid(self):
|
||||||
"""
|
"""
|
||||||
Test the ellipsoid property.
|
Test the ellipsoid property.
|
||||||
@ -102,7 +100,6 @@ class SpatialRefSysTest(unittest.TestCase):
|
|||||||
for i in range(3):
|
for i in range(3):
|
||||||
self.assertAlmostEqual(ellps1[i], ellps2[i], prec[i])
|
self.assertAlmostEqual(ellps1[i], ellps2[i], prec[i])
|
||||||
|
|
||||||
@no_mysql
|
|
||||||
def test_add_entry(self):
|
def test_add_entry(self):
|
||||||
"""
|
"""
|
||||||
Test adding a new entry in the SpatialRefSys model using the
|
Test adding a new entry in the SpatialRefSys model using the
|
||||||
|
@ -39,7 +39,6 @@ postgis = _default_db == 'postgis'
|
|||||||
mysql = _default_db == 'mysql'
|
mysql = _default_db == 'mysql'
|
||||||
spatialite = _default_db == 'spatialite'
|
spatialite = _default_db == 'spatialite'
|
||||||
|
|
||||||
HAS_SPATIALREFSYS = True
|
|
||||||
if oracle and 'gis' in settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE']:
|
if oracle and 'gis' in settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE']:
|
||||||
from django.contrib.gis.db.backends.oracle.models import OracleSpatialRefSys as SpatialRefSys
|
from django.contrib.gis.db.backends.oracle.models import OracleSpatialRefSys as SpatialRefSys
|
||||||
elif postgis:
|
elif postgis:
|
||||||
@ -47,5 +46,4 @@ elif postgis:
|
|||||||
elif spatialite:
|
elif spatialite:
|
||||||
from django.contrib.gis.db.backends.spatialite.models import SpatialiteSpatialRefSys as SpatialRefSys
|
from django.contrib.gis.db.backends.spatialite.models import SpatialiteSpatialRefSys as SpatialRefSys
|
||||||
else:
|
else:
|
||||||
HAS_SPATIALREFSYS = False
|
|
||||||
SpatialRefSys = None
|
SpatialRefSys = None
|
||||||
|
@ -980,7 +980,7 @@ def skipIfDBFeature(feature):
|
|||||||
"""
|
"""
|
||||||
Skip a test if a database has the named feature
|
Skip a test if a database has the named feature
|
||||||
"""
|
"""
|
||||||
return _deferredSkip(lambda: getattr(connection.features, feature),
|
return _deferredSkip(lambda: getattr(connection.features, feature, False),
|
||||||
"Database has feature %s" % feature)
|
"Database has feature %s" % feature)
|
||||||
|
|
||||||
|
|
||||||
@ -988,7 +988,7 @@ def skipUnlessDBFeature(feature):
|
|||||||
"""
|
"""
|
||||||
Skip a test unless a database has the named feature
|
Skip a test unless a database has the named feature
|
||||||
"""
|
"""
|
||||||
return _deferredSkip(lambda: not getattr(connection.features, feature),
|
return _deferredSkip(lambda: not getattr(connection.features, feature, False),
|
||||||
"Database doesn't support feature %s" % feature)
|
"Database doesn't support feature %s" % feature)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user