Ticket #15378: 15378.1.diff

File 15378.1.diff, 3.2 KB (added by jbronn, 14 years ago)

Test case and data that reproduces the problem.

  • new file django/contrib/gis/tests/data/invalid/emptypoints.dbf

    diff --git a/django/contrib/gis/tests/data/invalid/emptypoints.dbf b/django/contrib/gis/tests/data/invalid/emptypoints.dbf
    new file mode 100644
    index 0000000000000000000000000000000000000000..aa2109047a4f7b5d4f7fdc372c065148aff5f8c7
    GIT binary patch
    literal 77
    mc${O7XP07RU|?`$;9<Z3;S3CJo-Qz+ABf;aQ^Ko&00sbtl>_ns
  • new file django/contrib/gis/tests/data/invalid/emptypoints.shp

    diff --git a/django/contrib/gis/tests/data/invalid/emptypoints.shp b/django/contrib/gis/tests/data/invalid/emptypoints.shp
    new file mode 100644
    index 0000000000000000000000000000000000000000..bdcfb83be42f71ecb07c7d395f4c40e13e6cde16
    GIT binary patch
    literal 112
    cc${NkQ0HR64lG_UGcYjXkR%a+j9~&X0Ck7~SpWb4
  • new file django/contrib/gis/tests/data/invalid/emptypoints.shx

    diff --git a/django/contrib/gis/tests/data/invalid/emptypoints.shx b/django/contrib/gis/tests/data/invalid/emptypoints.shx
    new file mode 100644
    index 0000000000000000000000000000000000000000..dea663eb087d4a778415da28a9ee226864363515
    GIT binary patch
    literal 108
    bc${NkQ0HR64$NLKGcYjXkR%Zp0WlK*aCZTS
  • django/contrib/gis/tests/layermap/models.py

    diff --git a/django/contrib/gis/tests/layermap/models.py b/django/contrib/gis/tests/layermap/models.py
    a b  
    4343class ICity2(ICity1):
    4444    dt_time = models.DateTimeField(auto_now=True)
    4545
     46class Invalid(models.Model):
     47    point = models.PointField()
     48
    4649# Mapping dictionaries for the models above.
    4750co_mapping = {'name' : 'Name',
    4851              'state' : {'name' : 'State'}, # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case).
  • django/contrib/gis/tests/layermap/tests.py

    diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py
    a b  
    44from django.utils.copycompat import copy
    55from django.utils.unittest import TestCase
    66
    7 from django.contrib.gis.gdal import DataSource
     7from django.contrib.gis.gdal import DataSource, OGRException
    88from django.contrib.gis.tests.utils import mysql
    99from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError, InvalidDecimal, MissingForeignKey
    1010
    11 from models import City, County, CountyFeat, Interstate, ICity1, ICity2, State, city_mapping, co_mapping, cofeat_mapping, inter_mapping
     11from models import \
     12    City, County, CountyFeat, Interstate, ICity1, ICity2, Invalid, State, \
     13    city_mapping, co_mapping, cofeat_mapping, inter_mapping
    1214
    1315shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir, 'data'))
    1416city_shp = os.path.join(shp_path, 'cities', 'cities.shp')
    1517co_shp = os.path.join(shp_path, 'counties', 'counties.shp')
    1618inter_shp = os.path.join(shp_path, 'interstates', 'interstates.shp')
     19invalid_shp = os.path.join(shp_path, 'invalid', 'emptypoints.shp')
    1720
    1821# Dictionaries to hold what's expected in the county shapefile.
    1922NAMES  = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo']
     
    265268
    266269        self.assertEqual(6, ICity1.objects.count())
    267270        self.assertEqual(3, ICity2.objects.count())
     271
     272    def test07_invalid_layer(self):
     273        "Tests LayerMapping on invalid geometries.  See #15378."
     274        invalid_mapping = {'point': 'POINT'}
     275        lm = LayerMapping(Invalid, invalid_shp, invalid_mapping,
     276                          source_srs=4326)
     277        lm.save()
Back to Top