web/lib/django/contrib/gis/tests/geoapp/test_feeds.py
changeset 29 cc9b7e14412b
parent 0 0d40e90630ef
equal deleted inserted replaced
28:b758351d191f 29:cc9b7e14412b
    16     def test_geofeed_rss(self):
    16     def test_geofeed_rss(self):
    17         "Tests geographic feeds using GeoRSS over RSSv2."
    17         "Tests geographic feeds using GeoRSS over RSSv2."
    18         # Uses `GEOSGeometry` in `item_geometry`
    18         # Uses `GEOSGeometry` in `item_geometry`
    19         doc1 = minidom.parseString(self.client.get('/geoapp/feeds/rss1/').content)
    19         doc1 = minidom.parseString(self.client.get('/geoapp/feeds/rss1/').content)
    20         # Uses a 2-tuple in `item_geometry`
    20         # Uses a 2-tuple in `item_geometry`
    21         doc2 = minidom.parseString(self.client.get('/geoapp/feeds/rss2/').content) 
    21         doc2 = minidom.parseString(self.client.get('/geoapp/feeds/rss2/').content)
    22         feed1, feed2 = doc1.firstChild, doc2.firstChild
    22         feed1, feed2 = doc1.firstChild, doc2.firstChild
    23 
    23 
    24         # Making sure the box got added to the second GeoRSS feed.
    24         # Making sure the box got added to the second GeoRSS feed.
    25         self.assertChildNodes(feed2.getElementsByTagName('channel')[0], 
    25         self.assertChildNodes(feed2.getElementsByTagName('channel')[0],
    26                               ['title', 'link', 'description', 'language', 'lastBuildDate', 'item', 'georss:box']
    26                               ['title', 'link', 'description', 'language',
       
    27                                'lastBuildDate', 'item', 'georss:box', 'atom:link']
    27                               )
    28                               )
    28         
    29 
    29         # Incrementing through the feeds.
    30         # Incrementing through the feeds.
    30         for feed in [feed1, feed2]:
    31         for feed in [feed1, feed2]:
    31             # Ensuring the georss namespace was added to the <rss> element.
    32             # Ensuring the georss namespace was added to the <rss> element.
    32             self.assertEqual(feed.getAttribute(u'xmlns:georss'),  u'http://www.georss.org/georss')
    33             self.assertEqual(feed.getAttribute(u'xmlns:georss'),  u'http://www.georss.org/georss')
    33             chan = feed.getElementsByTagName('channel')[0]
    34             chan = feed.getElementsByTagName('channel')[0]
    34             items = chan.getElementsByTagName('item')
    35             items = chan.getElementsByTagName('item')
    35             self.assertEqual(len(items), City.objects.count())
    36             self.assertEqual(len(items), City.objects.count())
    36                 
    37 
    37             # Ensuring the georss element was added to each item in the feed.
    38             # Ensuring the georss element was added to each item in the feed.
    38             for item in items:
    39             for item in items:
    39                 self.assertChildNodes(item, ['title', 'link', 'description', 'guid', 'georss:point'])
    40                 self.assertChildNodes(item, ['title', 'link', 'description', 'guid', 'georss:point'])
    40 
    41 
    41     def test_geofeed_atom(self):
    42     def test_geofeed_atom(self):
    43         doc1 = minidom.parseString(self.client.get('/geoapp/feeds/atom1/').content)
    44         doc1 = minidom.parseString(self.client.get('/geoapp/feeds/atom1/').content)
    44         doc2 = minidom.parseString(self.client.get('/geoapp/feeds/atom2/').content)
    45         doc2 = minidom.parseString(self.client.get('/geoapp/feeds/atom2/').content)
    45         feed1, feed2 = doc1.firstChild, doc2.firstChild
    46         feed1, feed2 = doc1.firstChild, doc2.firstChild
    46 
    47 
    47         # Making sure the box got added to the second GeoRSS feed.
    48         # Making sure the box got added to the second GeoRSS feed.
    48         self.assertChildNodes(feed2, ['title', 'link', 'id', 'updated', 'entry', 'georss:box'])        
    49         self.assertChildNodes(feed2, ['title', 'link', 'id', 'updated', 'entry', 'georss:box'])
    49 
    50 
    50         for feed in [feed1, feed2]:
    51         for feed in [feed1, feed2]:
    51             # Ensuring the georsss namespace was added to the <feed> element.
    52             # Ensuring the georsss namespace was added to the <feed> element.
    52             self.assertEqual(feed.getAttribute(u'xmlns:georss'),  u'http://www.georss.org/georss')
    53             self.assertEqual(feed.getAttribute(u'xmlns:georss'),  u'http://www.georss.org/georss')
    53             entries = feed.getElementsByTagName('entry')
    54             entries = feed.getElementsByTagName('entry')
    54             self.assertEqual(len(entries), City.objects.count())
    55             self.assertEqual(len(entries), City.objects.count())
    55             
    56 
    56             # Ensuring the georss element was added to each entry in the feed.
    57             # Ensuring the georss element was added to each entry in the feed.
    57             for entry in entries:
    58             for entry in entries:
    58                 self.assertChildNodes(entry, ['title', 'link', 'id', 'summary', 'georss:point'])
    59                 self.assertChildNodes(entry, ['title', 'link', 'id', 'summary', 'georss:point'])
    59 
    60 
    60     def test_geofeed_w3c(self):
    61     def test_geofeed_w3c(self):