summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Schorr <info@thomasschorr.de>2017-09-19 09:41:40 +0000
committerTim Graham <timograham@gmail.com>2017-09-20 21:03:14 -0400
commit52eb5b289e9a0c2dc2302437b9590d0ce5ae0455 (patch)
tree886c8293d79690fc76ab80c459a6879e4d33d28c /tests
parentdf41b5a05d4e00e80e73afe629072e37873e767a (diff)
Fixed #28617 -- Made ogrinspect output pep8 compliant.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/inspectapp/tests.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/gis_tests/inspectapp/tests.py b/tests/gis_tests/inspectapp/tests.py
index 8a058d6a8e..6dec48cc73 100644
--- a/tests/gis_tests/inspectapp/tests.py
+++ b/tests/gis_tests/inspectapp/tests.py
@@ -70,6 +70,7 @@ class OGRInspectTest(TestCase):
'# This is an auto-generated Django model module created by ogrinspect.',
'from django.contrib.gis.db import models',
'',
+ '',
'class MyModel(models.Model):',
' float = models.FloatField()',
' int = models.{}()'.format('BigIntegerField' if GDAL_VERSION >= (2, 0) else 'FloatField'),
@@ -96,6 +97,7 @@ class OGRInspectTest(TestCase):
'# This is an auto-generated Django model module created by ogrinspect.',
'from django.contrib.gis.db import models',
'',
+ '',
'class City(models.Model):',
' name = models.CharField(max_length=80)',
' population = models.{}()'.format('BigIntegerField' if GDAL_VERSION >= (2, 0) else 'FloatField'),
@@ -126,6 +128,7 @@ class OGRInspectTest(TestCase):
'# This is an auto-generated Django model module created by ogrinspect.\n'
'from django.contrib.gis.db import models\n'
'\n'
+ '\n'
'class Measurement(models.Model):\n'
))
@@ -148,6 +151,24 @@ class OGRInspectTest(TestCase):
output = out.getvalue()
self.assertIn('class City(models.Model):', output)
+ def test_mapping_option(self):
+ expected = (
+ " geom = models.PointField(srid=-1)\n"
+ "\n"
+ "\n"
+ "# Auto-generated `LayerMapping` dictionary for City model\n"
+ "city_mapping = {\n"
+ " 'name': 'Name',\n"
+ " 'population': 'Population',\n"
+ " 'density': 'Density',\n"
+ " 'created': 'Created',\n"
+ " 'geom': 'POINT',\n"
+ "}\n")
+ shp_file = os.path.join(TEST_DATA, 'cities', 'cities.shp')
+ out = StringIO()
+ call_command('ogrinspect', shp_file, '--mapping', 'City', stdout=out)
+ self.assertIn(expected, out.getvalue())
+
def get_ogr_db_string():
"""