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