web/lib/django/contrib/gis/tests/geoapp/test_regress.py
changeset 38 77b6da96e6f1
equal deleted inserted replaced
37:8d941af65caf 38:77b6da96e6f1
       
     1 import os, unittest
       
     2 from django.contrib.gis.tests.utils import no_mysql, no_oracle, no_postgis, no_spatialite
       
     3 from django.contrib.gis.shortcuts import render_to_kmz
       
     4 from models import City
       
     5 
       
     6 class GeoRegressionTests(unittest.TestCase):
       
     7 
       
     8     def test01_update(self):
       
     9         "Testing GeoQuerySet.update(), see #10411."
       
    10         pnt = City.objects.get(name='Pueblo').point
       
    11         bak = pnt.clone()
       
    12         pnt.y += 0.005
       
    13         pnt.x += 0.005
       
    14 
       
    15         City.objects.filter(name='Pueblo').update(point=pnt)
       
    16         self.assertEqual(pnt, City.objects.get(name='Pueblo').point)
       
    17         City.objects.filter(name='Pueblo').update(point=bak)
       
    18         self.assertEqual(bak, City.objects.get(name='Pueblo').point)
       
    19 
       
    20     def test02_kmz(self):
       
    21         "Testing `render_to_kmz` with non-ASCII data, see #11624."
       
    22         name = '\xc3\x85land Islands'.decode('iso-8859-1')
       
    23         places = [{'name' : name,
       
    24                   'description' : name,
       
    25                   'kml' : '<Point><coordinates>5.0,23.0</coordinates></Point>'
       
    26                   }]
       
    27         kmz = render_to_kmz('gis/kml/placemarks.kml', {'places' : places})
       
    28 
       
    29     @no_spatialite
       
    30     @no_mysql
       
    31     def test03_extent(self):
       
    32         "Testing `extent` on a table with a single point, see #11827."
       
    33         pnt = City.objects.get(name='Pueblo').point
       
    34         ref_ext = (pnt.x, pnt.y, pnt.x, pnt.y)
       
    35         extent = City.objects.filter(name='Pueblo').extent()
       
    36         for ref_val, val in zip(ref_ext, extent):
       
    37             self.assertAlmostEqual(ref_val, val, 4)