def test_rss2_feed(self):
    '\n        Test the structure and content of feeds generated by Rss201rev2Feed.\n        '
    response = self.client.get('/syndication/rss2/')
    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'), '2.0')
    chan_elem = feed.getElementsByTagName('channel')
    self.assertEqual(len(chan_elem), 1)
    chan = chan_elem[0]
    d = Entry.objects.latest('date').date
    ltz = tzinfo.LocalTimezone(d)
    last_build_date = rfc2822_date(d.replace(tzinfo=ltz))
    self.assertChildNodes(chan, ['title', 'link', 'description', 'language', 'lastBuildDate', 'item', 'atom:link', 'ttl', 'copyright', 'category'])
    self.assertChildNodeContent(chan, {'title': 'My blog', 'description': 'A more thorough description of my blog.', 'link': 'http://example.com/blog/', 'language': 'en', 'lastBuildDate': last_build_date, 'ttl': '600', 'copyright': 'Copyright (c) 2007, Sally Smith'})
    self.assertCategories(chan, ['python', 'django'])
    self.assertChildNodeContent(chan, {'title': 'My blog', 'link': 'http://example.com/blog/'})
    self.assertEqual(chan.getElementsByTagName('atom:link')[0].getAttribute('href'), 'http://example.com/syndication/rss2/')
    d = Entry.objects.get(pk=1).date
    ltz = tzinfo.LocalTimezone(d)
    pub_date = rfc2822_date(d.replace(tzinfo=ltz))
    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/', 'guid': 'http://example.com/blog/1/', 'pubDate': pub_date, 'author': 'example@example.com (Sally Smith)'})
    self.assertCategories(items[0], ['python', 'testing'])
    for item in items:
        self.assertChildNodes(item, ['title', 'link', 'description', 'guid', 'category', 'pubDate', 'author'])
Test the structure and content of feeds generated by Rss201rev2Feed.
def test_rss2_feed(self):
    '\n        \n        '
    response = self.client.get('/syndication/rss2/')
    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'), '2.0')
    chan_elem = feed.getElementsByTagName('channel')
    self.assertEqual(len(chan_elem), 1)
    chan = chan_elem[0]
    d = Entry.objects.latest('date').date
    ltz = tzinfo.LocalTimezone(d)
    last_build_date = rfc2822_date(d.replace(tzinfo=ltz))
    self.assertChildNodes(chan, ['title', 'link', 'description', 'language', 'lastBuildDate', 'item', 'atom:link', 'ttl', 'copyright', 'category'])
    self.assertChildNodeContent(chan, {'title': 'My blog', 'description': 'A more thorough description of my blog.', 'link': 'http://example.com/blog/', 'language': 'en', 'lastBuildDate': last_build_date, 'ttl': '600', 'copyright': 'Copyright (c) 2007, Sally Smith'})
    self.assertCategories(chan, ['python', 'django'])
    self.assertChildNodeContent(chan, {'title': 'My blog', 'link': 'http://example.com/blog/'})
    self.assertEqual(chan.getElementsByTagName('atom:link')[0].getAttribute('href'), 'http://example.com/syndication/rss2/')
    d = Entry.objects.get(pk=1).date
    ltz = tzinfo.LocalTimezone(d)
    pub_date = rfc2822_date(d.replace(tzinfo=ltz))
    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/', 'guid': 'http://example.com/blog/1/', 'pubDate': pub_date, 'author': 'example@example.com (Sally Smith)'})
    self.assertCategories(items[0], ['python', 'testing'])
    for item in items:
        self.assertChildNodes(item, ['title', 'link', 'description', 'guid', 'category', 'pubDate', 'author'])