summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-09-12 10:30:45 +0200
committerClaude Paroz <claude@2xlibre.net>2013-09-12 10:30:45 +0200
commitc82f6c2227f1b86df8726293e8d6d59449b0ab93 (patch)
treee864b1bf0efaeea71dc955c160024b0c363a87ae
parent37faf12e66a74642d73639569225c95e400bbae2 (diff)
Add a test for the geo-enabled inspectdb command
-rw-r--r--django/contrib/gis/tests/inspectapp/models.py1
-rw-r--r--django/contrib/gis/tests/inspectapp/tests.py18
2 files changed, 19 insertions, 0 deletions
diff --git a/django/contrib/gis/tests/inspectapp/models.py b/django/contrib/gis/tests/inspectapp/models.py
index 0f1b0d4e61..e4c0f542a9 100644
--- a/django/contrib/gis/tests/inspectapp/models.py
+++ b/django/contrib/gis/tests/inspectapp/models.py
@@ -9,5 +9,6 @@ class AllOGRFields(models.Model):
f_datetime = models.DateTimeField()
f_time = models.TimeField()
geom = models.PolygonField()
+ point = models.PointField()
objects = models.GeoManager()
diff --git a/django/contrib/gis/tests/inspectapp/tests.py b/django/contrib/gis/tests/inspectapp/tests.py
index 4b7c5ff21d..ea4ed3caca 100644
--- a/django/contrib/gis/tests/inspectapp/tests.py
+++ b/django/contrib/gis/tests/inspectapp/tests.py
@@ -3,11 +3,13 @@ from __future__ import unicode_literals
import os
from unittest import skipUnless
+from django.core.management import call_command
from django.db import connections
from django.test import TestCase
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.geometry.test_data import TEST_DATA
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
+from django.utils.six import StringIO
if HAS_GDAL:
from django.contrib.gis.gdal import Driver
@@ -17,6 +19,22 @@ if HAS_GDAL:
@skipUnless(HAS_GDAL and HAS_SPATIAL_DB, "GDAL and spatial db are required.")
+class InspectDbTests(TestCase):
+ def test_geom_columns(self):
+ """
+ Test the geo-enabled inspectdb command.
+ """
+ out = StringIO()
+ call_command('inspectdb',
+ table_name_filter=lambda tn:tn.startswith('inspectapp_'),
+ stdout=out)
+ output = out.getvalue()
+ self.assertIn('geom = models.PolygonField()', output)
+ self.assertIn('point = models.PointField()', output)
+ self.assertIn('objects = models.GeoManager()', output)
+
+
+@skipUnless(HAS_GDAL and HAS_SPATIAL_DB, "GDAL and spatial db are required.")
class OGRInspectTest(TestCase):
maxDiff = 1024