Exemplo n.º 1
0
def test_parse_raw_data_unicode(rss_parser):
    item = rItem(
        title="Sample article",
        link="http://www.example.com/articles/1",
        description="A test description á",
        author="Testy McTesterson",
        guid=Guid("http://www.example.com/articles/1"),
        pubDate=datetime(2014, 12, 29, 10, 00),
    )

    feed = rFeed(
        title="Test Feed",
        link="http://www.example.com/rss",
        description="A test feed",
        language="en-US",
        lastBuildDate=datetime.now(),
        items=[item],
    )

    print(feed.rss())
    data = rss_parser.parse_raw_data(feed.rss())

    assert data is not None
    assert data["feed"]["title"] == "Test Feed"
    assert len(data["entries"]) == 1
Exemplo n.º 2
0
    def create_rss(self, url):
        """
        Creates an RSS feed of the author's entries.

        :param url: External url of the feed
        :type url: str
        :return: str
        """
        items = []
        for entry in self.entries[0:10]:
            items.append(entry.rss())

        rss = rFeed(
            title=self.name,
            link=url,
            description=u"RSS feed for {0}".format(self.name),
            lastBuildDate=datetime.utcnow(),
            language="en-US",
            items=items,
        )

        self.rss = rss.rss()
        return rss
Exemplo n.º 3
0
    def create_rss(self, entries, url):
        """
        Creates an RSS feed for the user.

        :param entries: Entries to add to feed
        :type entries: list
        :param url: External url for feed
        :type url: str
        :return: str
        """
        items = []
        for entry in entries:
            items.append(entry.rss())

        rss = rFeed(
            title=u'Custom feed for {0}'.format(self.email),
            link=url,
            description=u'Custom feed for {0}'.format(self.email),
            lastBuildDate=datetime.utcnow(),
            language='en-US',
            items=items)

        self.rss = rss.rss()
        return rss