diff options
| author | Octavio <octaperi@gmail.com> | 2020-10-12 22:53:49 -0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-10-13 07:16:07 +0200 |
| commit | 746bb13ceb72d4f5f0e7131cd79a20f669f1d4f6 (patch) | |
| tree | 4f3d259ecb579f3788a82bedd3458d78ea9cfb50 /tests/syndication_tests/tests.py | |
| parent | e92971ccb06a7909b9e48d5f71c42d4f22b95b10 (diff) | |
Fixed #22490 -- Added tests for Feed.get_object().
Diffstat (limited to 'tests/syndication_tests/tests.py')
| -rw-r--r-- | tests/syndication_tests/tests.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/syndication_tests/tests.py b/tests/syndication_tests/tests.py index b763bba6cb..35b68e849b 100644 --- a/tests/syndication_tests/tests.py +++ b/tests/syndication_tests/tests.py @@ -38,7 +38,12 @@ class FeedTestCase(TestCase): title='My last entry', updated=datetime.datetime(2013, 1, 20, 0, 0), published=datetime.datetime(2013, 3, 25, 20, 0) ) - cls.a1 = Article.objects.create(title='My first article', entry=cls.e1) + cls.a1 = Article.objects.create( + title='My first article', + entry=cls.e1, + updated=datetime.datetime(1986, 11, 21, 9, 12, 18), + published=datetime.datetime(1986, 10, 21, 9, 12, 18), + ) def assertChildNodes(self, elem, expected): actual = {n.nodeName for n in elem.childNodes} @@ -522,3 +527,22 @@ class SyndicationFeedTest(FeedTestCase): for prefix in prefix_domain_mapping: with self.subTest(prefix=prefix): self.assertEqual(views.add_domain(*prefix[0]), prefix[1]) + + def test_get_object(self): + response = self.client.get('/syndication/rss2/articles/%s/' % self.e1.pk) + doc = minidom.parseString(response.content) + feed = doc.getElementsByTagName('rss')[0] + chan = feed.getElementsByTagName('channel')[0] + items = chan.getElementsByTagName('item') + + self.assertChildNodeContent(items[0], { + 'comments': '/blog/1/article/1/comments', + 'description': 'Article description: My first article', + 'link': 'http://example.com/blog/1/article/1/', + 'title': 'Title: My first article', + 'pubDate': rfc2822_date(timezone.make_aware(self.a1.published, TZ)), + }) + + def test_get_non_existent_object(self): + response = self.client.get('/syndication/rss2/articles/0/') + self.assertEqual(response.status_code, 404) |
