Пример #1
0
    def test_feed(self):
        self.user.first_name = 'Admin'
        self.user.last_name = 'User'
        self.user.save()
        pages = self.get_pages()
        posts = self.get_posts()
        posts[0].tags.add('tag 1', 'tag 2', 'tag 3', 'tag 4')
        posts[0].author = self.user
        posts[0].save()
        posts[1].tags.add('tag 6', 'tag 2', 'tag 5', 'tag 8')
        posts[1].save()
        posts[0].set_current_language('en')

        with smart_override('en'):
            with switch_language(posts[0], 'en'):

                request = self.get_page_request(
                    pages[1], self.user, path=posts[0].get_absolute_url())

                feed = LatestEntriesFeed()
                feed.namespace, feed.config = get_app_instance(request)
                self.assertEqual(list(feed.items()), [posts[0]])
                self.reload_urlconf()
                xml = feed(request)
                self.assertContains(xml, posts[0].get_absolute_url())
                self.assertContains(xml, 'Blog articles on example.com')
                self.assertContains(xml, 'Admin User</dc:creator>')

        with smart_override('it'):
            with switch_language(posts[0], 'it'):
                feed = LatestEntriesFeed()
                feed.namespace, feed.config = get_app_instance(request)
                self.assertEqual(list(feed.items()), [posts[0]])
                request = self.get_page_request(
                    pages[1], self.user, path=posts[0].get_absolute_url())
                xml = feed(request)
                self.assertContains(xml, posts[0].get_absolute_url())
                self.assertContains(xml, 'Articoli del blog su example.com')

                feed = TagFeed()
                feed.namespace = self.app_config_1.namespace
                feed.config = self.app_config_1
                self.assertEqual(list(feed.items('tag-2')), [posts[0]])
Пример #2
0
    def test_feed(self):
        self.user.first_name = "Admin"
        self.user.last_name = "User"
        self.user.save()
        pages = self.get_pages()
        posts = self.get_posts()
        posts[0].tags.add("tag 1", "tag 2", "tag 3", "tag 4")
        posts[0].author = self.user
        posts[0].save()
        posts[1].tags.add("tag 6", "tag 2", "tag 5", "tag 8")
        posts[1].save()
        posts[0].set_current_language("en")

        with smart_override("en"):
            with switch_language(posts[0], "en"):

                request = self.get_page_request(
                    pages[1], self.user, path=posts[0].get_absolute_url())

                feed = LatestEntriesFeed()
                feed.namespace, feed.config = get_app_instance(request)
                self.assertEqual(list(feed.items()), [posts[0]])
                self.reload_urlconf()
                xml = feed(request)
                self.assertContains(xml, posts[0].get_absolute_url())
                self.assertContains(xml, "Blog articles on example.com")
                self.assertContains(xml, "Admin User</dc:creator>")

        with smart_override("it"):
            with switch_language(posts[0], "it"):
                feed = LatestEntriesFeed()
                feed.namespace, feed.config = get_app_instance(request)
                self.assertEqual(list(feed.items()), [posts[0]])
                request = self.get_page_request(
                    pages[1], self.user, path=posts[0].get_absolute_url())
                xml = feed(request)
                self.assertContains(xml, posts[0].get_absolute_url())
                self.assertContains(xml, "Articoli del blog su example.com")

                feed = TagFeed()
                feed.namespace = self.app_config_1.namespace
                feed.config = self.app_config_1
                self.assertEqual(list(feed.items("tag-2")), [posts[0]])
Пример #3
0
    def test_feed(self):
        self.user.first_name = 'Admin'
        self.user.last_name = 'User'
        self.user.save()
        posts = self.get_posts()
        pages = self.get_pages()
        posts[0].tags.add('tag 1', 'tag 2', 'tag 3', 'tag 4')
        posts[0].author = self.user
        posts[0].save()
        posts[1].tags.add('tag 6', 'tag 2', 'tag 5', 'tag 8')
        posts[1].save()
        posts[0].set_current_language('en')

        with smart_override('en'):
            with switch_language(posts[0], 'en'):

                request = self.get_page_request(pages[1], self.user, path=posts[0].get_absolute_url())

                feed = LatestEntriesFeed()
                feed.namespace, feed.config = get_app_instance(request)
                self.assertEqual(list(feed.items()), [posts[0]])
                self.reload_urlconf()
                xml = feed(request)
                self.assertContains(xml, posts[0].get_absolute_url())
                self.assertContains(xml, 'Blog articles on example.com')
                self.assertContains(xml, 'Admin User</dc:creator>')

        with smart_override('it'):
            with switch_language(posts[0], 'it'):
                feed = LatestEntriesFeed()
                feed.namespace, feed.config = get_app_instance(request)
                self.assertEqual(list(feed.items()), [posts[0]])
                request = self.get_page_request(pages[1], self.user, path=posts[0].get_absolute_url())
                xml = feed(request)
                self.assertContains(xml, posts[0].get_absolute_url())
                self.assertContains(xml, 'Articoli del blog su example.com')

                feed = TagFeed()
                feed.namespace = self.app_config_1.namespace
                feed.config = self.app_config_1
                self.assertEqual(list(feed.items('tag-2')), [posts[0]])