mirror of https://github.com/django/django.git
Fixed #29462 -- Fixed ogrinspect test failures with GDAL 2.2.
This commit is contained in:
parent
b18650a263
commit
55f4eee75d
|
@ -60,6 +60,7 @@ class InspectDbTests(TestCase):
|
|||
INSTALLED_APPS={'append': 'django.contrib.gis'},
|
||||
)
|
||||
class OGRInspectTest(TestCase):
|
||||
expected_srid = 'srid=-1' if GDAL_VERSION < (2, 2) else ''
|
||||
maxDiff = 1024
|
||||
|
||||
def test_poly(self):
|
||||
|
@ -75,7 +76,7 @@ class OGRInspectTest(TestCase):
|
|||
' float = models.FloatField()',
|
||||
' int = models.{}()'.format('BigIntegerField' if GDAL_VERSION >= (2, 0) else 'FloatField'),
|
||||
' str = models.CharField(max_length=80)',
|
||||
' geom = models.PolygonField(srid=-1)',
|
||||
' geom = models.PolygonField(%s)' % self.expected_srid,
|
||||
]
|
||||
|
||||
self.assertEqual(model_def, '\n'.join(expected))
|
||||
|
@ -83,7 +84,7 @@ class OGRInspectTest(TestCase):
|
|||
def test_poly_multi(self):
|
||||
shp_file = os.path.join(TEST_DATA, 'test_poly', 'test_poly.shp')
|
||||
model_def = ogrinspect(shp_file, 'MyModel', multi_geom=True)
|
||||
self.assertIn('geom = models.MultiPolygonField(srid=-1)', model_def)
|
||||
self.assertIn('geom = models.MultiPolygonField(%s)' % self.expected_srid, model_def)
|
||||
# Same test with a 25D-type geometry field
|
||||
shp_file = os.path.join(TEST_DATA, 'gas_lines', 'gas_leitung.shp')
|
||||
model_def = ogrinspect(shp_file, 'MyModel', multi_geom=True)
|
||||
|
@ -103,7 +104,7 @@ class OGRInspectTest(TestCase):
|
|||
' population = models.{}()'.format('BigIntegerField' if GDAL_VERSION >= (2, 0) else 'FloatField'),
|
||||
' density = models.FloatField()',
|
||||
' created = models.DateField()',
|
||||
' geom = models.PointField(srid=-1)',
|
||||
' geom = models.PointField(%s)' % self.expected_srid,
|
||||
]
|
||||
|
||||
self.assertEqual(model_def, '\n'.join(expected))
|
||||
|
@ -153,7 +154,7 @@ class OGRInspectTest(TestCase):
|
|||
|
||||
def test_mapping_option(self):
|
||||
expected = (
|
||||
" geom = models.PointField(srid=-1)\n"
|
||||
" geom = models.PointField(%s)\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"# Auto-generated `LayerMapping` dictionary for City model\n"
|
||||
|
@ -163,7 +164,7 @@ class OGRInspectTest(TestCase):
|
|||
" 'density': 'Density',\n"
|
||||
" 'created': 'Created',\n"
|
||||
" 'geom': 'POINT',\n"
|
||||
"}\n")
|
||||
"}\n" % self.expected_srid)
|
||||
shp_file = os.path.join(TEST_DATA, 'cities', 'cities.shp')
|
||||
out = StringIO()
|
||||
call_command('ogrinspect', shp_file, '--mapping', 'City', stdout=out)
|
||||
|
|
Loading…
Reference in New Issue