def feeds_export(request): """ Export the user's feed list as OPML. """ response = HttpResponse( utils.export_opml(request.user), mimetype='application/xml', ) response['Content-Disposition'] = 'attachment; filename="feeds.opml"' return response
def test_empty(self): """ An empty OPML document is generated for a user with no feeds. """ expected = ('<opml version="1.0">' '<head>' '<title>test subscriptions</title>' '</head>' '<body/>' '</opml>') self.assert_equal_xml(expected, export_opml(self.user))
def test_unicode_title(self): self.user.feed_set.create(title=u'\u2042', feed_url='http://example.com/feed.xml') expected = (u'<opml version="1.0">' '<head>' '<title>test subscriptions</title>' '</head>' '<body>' '<outline type="rss" xmlUrl="http://example.com/feed.xml"' u' title="\u2042" text="\u2042" />' '</body>' '</opml>').encode('utf-8') self.assert_equal_xml(expected, export_opml(self.user))
def test_single_feed(self): self.user.feed_set.create(title=u'Feed 1', feed_url='http://example.com/feed.xml') expected = ('<opml version="1.0">' '<head>' '<title>test subscriptions</title>' '</head>' '<body>' '<outline type="rss" xmlUrl="http://example.com/feed.xml"' ' title="Feed 1" text="Feed 1" />' '</body>' '</opml>') self.assert_equal_xml(expected, export_opml(self.user))
def test_empty(self): """ An empty OPML document is generated for a user with no feeds. """ expected = ( '<opml version="1.0">' '<head>' '<title>test subscriptions</title>' '</head>' '<body/>' '</opml>' ) self.assert_equal_xml(expected, export_opml(self.user))
def test_unicode_title(self): self.user.feed_set.create(title=u'\u2042', feed_url='http://example.com/feed.xml') expected = ( u'<opml version="1.0">' '<head>' '<title>test subscriptions</title>' '</head>' '<body>' '<outline type="rss" xmlUrl="http://example.com/feed.xml"' u' title="\u2042" text="\u2042" />' '</body>' '</opml>' ).encode('utf-8') self.assert_equal_xml(expected, export_opml(self.user))
def test_single_feed(self): self.user.feed_set.create(title=u'Feed 1', feed_url='http://example.com/feed.xml') expected = ( '<opml version="1.0">' '<head>' '<title>test subscriptions</title>' '</head>' '<body>' '<outline type="rss" xmlUrl="http://example.com/feed.xml"' ' title="Feed 1" text="Feed 1" />' '</body>' '</opml>' ) self.assert_equal_xml(expected, export_opml(self.user))
def test_unicode_title(self): self.user.feed_set.create( title=u"\u2042", feed_url="http://example.com/feed.xml" ) expected = ( u'<opml version="1.0">' "<head>" "<title>test subscriptions</title>" "</head>" "<body>" '<outline type="rss" xmlUrl="http://example.com/feed.xml"' u' title="\u2042" text="\u2042" />' "</body>" "</opml>" ).encode("utf-8") self.assert_equal_xml(expected, export_opml(self.user))
def test_site_url(self): self.user.feed_set.create( title=u"Example", feed_url="http://example.com/feed.xml", site_url="http://example.com/", ) expected = ( '<opml version="1.0">' "<head>" "<title>test subscriptions</title>" "</head>" "<body>" '<outline type="rss" xmlUrl="http://example.com/feed.xml"' ' htmlUrl="http://example.com/"' ' title="Example" text="Example" />' "</body>" "</opml>" ) self.assert_equal_xml(expected, export_opml(self.user))