1 | #!/usr/bin/env python
|
---|
2 | # encoding: utf-8
|
---|
3 | import unittest
|
---|
4 |
|
---|
5 | from django.utils.feedgenerator import Rss201rev2Feed
|
---|
6 |
|
---|
7 |
|
---|
8 | class Issue14202PatchTestCase(unittest.TestCase):
|
---|
9 | """
|
---|
10 | There is a bug in django.utils.feedgenerator.Rss201rev2Feed that has been
|
---|
11 | reported in #14202 before.
|
---|
12 |
|
---|
13 | http://code.djangoproject.com/ticket/14202
|
---|
14 |
|
---|
15 | The feed_url property is optional but was required later on to write the
|
---|
16 | atom:link attribute to the RSS-feed.
|
---|
17 |
|
---|
18 | It is perfectly fine to leave the feed_url property as optional since it
|
---|
19 | is not required by RSS (http://bit.ly/bAZpKT). Therefore the patch only
|
---|
20 | renders the atom:link attribute if a feed_url is given.
|
---|
21 | """
|
---|
22 |
|
---|
23 | def test_feed_without_feed_url_gets_rendered_without_atom_link(self):
|
---|
24 | feed = Rss201rev2Feed('title', '/link/', 'descr')
|
---|
25 | feed_content = feed.writeString('utf-8')
|
---|
26 |
|
---|
27 | self.assertEquals(feed.feed['feed_url'], None)
|
---|
28 | self.assertFalse('<atom:link href=' in feed_content)
|
---|
29 |
|
---|
30 | def test_feed_with_feed_url_gets_rendered_with_atom_link(self):
|
---|
31 | feed = Rss201rev2Feed('title', '/link/', 'descr', feed_url='/feed/')
|
---|
32 | feed_content = feed.writeString('utf-8')
|
---|
33 |
|
---|
34 | self.assertEquals(feed.feed['feed_url'], '/feed/')
|
---|
35 | self.assertTrue('<atom:link href="/feed/" rel="self"></atom:link>' in \
|
---|
36 | feed_content)
|
---|
37 |
|
---|
38 |
|
---|
39 | if __name__ == '__main__':
|
---|
40 | unittest.main()
|
---|