|
1 import os, unittest |
|
2 from django.contrib.gis.db.backend import SpatialBackend |
|
3 from django.contrib.gis.tests.utils import no_mysql, no_oracle, no_postgis, no_spatialite |
|
4 from django.contrib.gis.shortcuts import render_to_kmz |
|
5 from models import City |
|
6 |
|
7 class GeoRegressionTests(unittest.TestCase): |
|
8 |
|
9 def test01_update(self): |
|
10 "Testing GeoQuerySet.update(), see #10411." |
|
11 pnt = City.objects.get(name='Pueblo').point |
|
12 bak = pnt.clone() |
|
13 pnt.y += 0.005 |
|
14 pnt.x += 0.005 |
|
15 |
|
16 City.objects.filter(name='Pueblo').update(point=pnt) |
|
17 self.assertEqual(pnt, City.objects.get(name='Pueblo').point) |
|
18 City.objects.filter(name='Pueblo').update(point=bak) |
|
19 self.assertEqual(bak, City.objects.get(name='Pueblo').point) |
|
20 |
|
21 def test02_kmz(self): |
|
22 "Testing `render_to_kmz` with non-ASCII data, see #11624." |
|
23 name = '\xc3\x85land Islands'.decode('iso-8859-1') |
|
24 places = [{'name' : name, |
|
25 'description' : name, |
|
26 'kml' : '<Point><coordinates>5.0,23.0</coordinates></Point>' |
|
27 }] |
|
28 kmz = render_to_kmz('gis/kml/placemarks.kml', {'places' : places}) |
|
29 |
|
30 @no_spatialite |
|
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 self.assertEqual(ref_ext, City.objects.filter(name='Pueblo').extent()) |