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

def test_rss091_feed(self):

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