App Engine Python SDK version 1.7.4 (2)
[gae.git] / python / lib / django_1_4 / django / contrib / gis / tests / geoapp / feeds.py
blobf53431c24d86f30fe7ea06a952882a0bfca376a2
1 from __future__ import absolute_import
3 from django.contrib.gis import feeds
5 from .models import City
8 class TestGeoRSS1(feeds.Feed):
9 link = '/city/'
10 title = 'Test GeoDjango Cities'
12 def items(self):
13 return City.objects.all()
15 def item_link(self, item):
16 return '/city/%s/' % item.pk
18 def item_geometry(self, item):
19 return item.point
21 class TestGeoRSS2(TestGeoRSS1):
22 def geometry(self, obj):
23 # This should attach a <georss:box> element for the extent of
24 # of the cities in the database. This tuple came from
25 # calling `City.objects.extent()` -- we can't do that call here
26 # because `extent` is not implemented for MySQL/Oracle.
27 return (-123.30, -41.32, 174.78, 48.46)
29 def item_geometry(self, item):
30 # Returning a simple tuple for the geometry.
31 return item.point.x, item.point.y
33 class TestGeoAtom1(TestGeoRSS1):
34 feed_type = feeds.GeoAtom1Feed
36 class TestGeoAtom2(TestGeoRSS2):
37 feed_type = feeds.GeoAtom1Feed
39 def geometry(self, obj):
40 # This time we'll use a 2-tuple of coordinates for the box.
41 return ((-123.30, -41.32), (174.78, 48.46))
43 class TestW3CGeo1(TestGeoRSS1):
44 feed_type = feeds.W3CGeoFeed
46 # The following feeds are invalid, and will raise exceptions.
47 class TestW3CGeo2(TestGeoRSS2):
48 feed_type = feeds.W3CGeoFeed
50 class TestW3CGeo3(TestGeoRSS1):
51 feed_type = feeds.W3CGeoFeed
53 def item_geometry(self, item):
54 from django.contrib.gis.geos import Polygon
55 return Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)))
57 # The feed dictionary to use for URLs.
58 feed_dict = {
59 'rss1' : TestGeoRSS1,
60 'rss2' : TestGeoRSS2,
61 'atom1' : TestGeoAtom1,
62 'atom2' : TestGeoAtom2,
63 'w3cgeo1' : TestW3CGeo1,
64 'w3cgeo2' : TestW3CGeo2,
65 'w3cgeo3' : TestW3CGeo3,