Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add a test for the geo-enabled inspectdb command

  • Loading branch information...
commit c82f6c2227f1b86df8726293e8d6d59449b0ab93 1 parent 37faf12
Claude Paroz authored September 12, 2013
1  django/contrib/gis/tests/inspectapp/models.py
@@ -9,5 +9,6 @@ class AllOGRFields(models.Model):
9 9
     f_datetime = models.DateTimeField()
10 10
     f_time = models.TimeField()
11 11
     geom = models.PolygonField()
  12
+    point = models.PointField()
12 13
 
13 14
     objects = models.GeoManager()
18  django/contrib/gis/tests/inspectapp/tests.py
@@ -3,11 +3,13 @@
3 3
 import os
4 4
 from unittest import skipUnless
5 5
 
  6
+from django.core.management import call_command
6 7
 from django.db import connections
7 8
 from django.test import TestCase
8 9
 from django.contrib.gis.gdal import HAS_GDAL
9 10
 from django.contrib.gis.geometry.test_data import TEST_DATA
10 11
 from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
  12
+from django.utils.six import StringIO
11 13
 
12 14
 if HAS_GDAL:
13 15
     from django.contrib.gis.gdal import Driver
@@ -17,6 +19,22 @@
17 19
 
18 20
 
19 21
 @skipUnless(HAS_GDAL and HAS_SPATIAL_DB, "GDAL and spatial db are required.")
  22
+class InspectDbTests(TestCase):
  23
+    def test_geom_columns(self):
  24
+        """
  25
+        Test the geo-enabled inspectdb command.
  26
+        """
  27
+        out = StringIO()
  28
+        call_command('inspectdb',
  29
+                 table_name_filter=lambda tn:tn.startswith('inspectapp_'),
  30
+                 stdout=out)
  31
+        output = out.getvalue()
  32
+        self.assertIn('geom = models.PolygonField()', output)
  33
+        self.assertIn('point = models.PointField()', output)
  34
+        self.assertIn('objects = models.GeoManager()', output)
  35
+
  36
+
  37
+@skipUnless(HAS_GDAL and HAS_SPATIAL_DB, "GDAL and spatial db are required.")
20 38
 class OGRInspectTest(TestCase):
21 39
     maxDiff = 1024
22 40
 

0 notes on commit c82f6c2

Please sign in to comment.
Something went wrong with that request. Please try again.