Example #1
0
def feed_export_opml(request, download: T.bool.default(False)):
    """export feeds to OPML file"""
    total, user_feeds, __ = UnionFeed.query_by_user(request.user.id)
    content = render_opml(user_feeds)
    response = HttpResponse(content, content_type='text/xml')
    if download:
        response['Content-Disposition'] = 'attachment;filename="rssant.opml"'
    return response
Example #2
0
    def test_export_opml(self):
        imports = [
            FeedImportItem(title='测试1',
                           group=None,
                           url='https://blog.example.com/feed1.xml'),
            FeedImportItem(title='测试2',
                           group='',
                           url='https://blog.example.com/feed2.xml'),
            FeedImportItem(title='测试3',
                           group='品读',
                           url='https://blog.example.com/feed3.xml'),
            FeedImportItem(title='测试4',
                           group='设计',
                           url='https://blog.example.com/feed4.xml'),
        ]
        self._import_feeds(imports)
        self.assertEqual(Feed.objects.count(), 4)

        feeds = self._query_user_feeds()
        self.assertEqual(len(feeds), 4)
        content = render_opml(feeds)
        raw_imports = import_feed_from_text(content)
        self.assertEqual(len(raw_imports), 4)