'Test the structure and content of feeds generated by RssUserland091Feed.'

def test_rss091_feed(self):

    response = self.client.get('/syndication/rss091/')
    doc = minidom.parseString(response.content)
    feed_elem = doc.getElementsByTagName('rss')
    self.assertEqual(len(feed_elem), 1)
    feed = feed_elem[0]
    self.assertEqual(feed.getAttribute('version'), '0.91')
    chan_elem = feed.getElementsByTagName('channel')
    self.assertEqual(len(chan_elem), 1)
    chan = chan_elem[0]
    self.assertChildNodes(chan, ['title', 'link', 'description', 'language', 'lastBuildDate', 'item', 'atom:link', 'ttl', 'copyright', 'category'])
    self.assertChildNodeContent(chan, {'title': 'My    blog', 'link': 'http://example.com/blog/'})
    self.assertCategories(chan, ['python', 'django'])
    self.assertEqual(chan.getElementsByTagName('atom:link')[0].getAttribute('href'), 'http://example.com/syndication/rss091/')
    items = chan.getElementsByTagName('item')
    self.assertEqual(len(items), Entry.objects.count())
    self.assertChildNodeContent(items[0], {'title': 'My    first    entry', 'description': 'Overridden    description:    My    first    entry', 'link': 'http://example.com/blog/1/'})
    for item in items:
        self.assertChildNodes(item, ['title', 'link', 'description'])
        self.assertCategories(item, [])
