Esempio n. 1
0
    def ImportFeed(self):

        view = self.view

        dir = os.path.dirname(os.path.abspath(__file__))
        path = os.path.join(dir, "osaf.blog.rss")

        data = file(path).read()

        channel = FeedChannel(itsView=view)
        count = channel.parse(data)

        self.assertEqual(channel.displayName, "OSAF News")
        self.assertEqual(5, len(channel))

        # Test successful lookup
        url = URL("http://www.osafoundation.org/archives/000966.html")
        item = indexes.valueLookup(channel, "link", "link", url)
        self.assertEqual(item.displayName, "OSAF Welcomes Priscilla Chung")

        # Test unsuccessful lookup
        nonExistent = URL("http://www.osafoundation.org/nonexistent/")
        item = indexes.valueLookup(channel, "link", "link", nonExistent)
        self.assertEqual(item, None)

        # Although the channels module doesn"t allow duplicate links, let"s
        # test the lookup mechanism"s ability to return dupes.  We"ll add a
        # duplicate, then pass the "multiple=True" arg to indexLookup.

        url = URL("http://www.osafoundation.org/archives/000964.html")
        item = FeedItem(itsView=view, link=url)
        channel.add(item)

        items = indexes.valueLookup(channel, "link", "link", url, multiple=True)
        self.assertEqual(len(items), 2)
Esempio n. 2
0
    def NonASCII(self):

        view = self.view

        dir = os.path.dirname(os.path.abspath(__file__))
        path = os.path.join(dir, "japanese.rdf")

        data = file(path).read()

        channel = FeedChannel(itsView=view)
        count = channel.parse(data)

        self.assertEqual(channel.displayName, u"\u8fd1\u85e4\u6df3\u4e5f\u306e\u65b0\u30cd\u30c3\u30c8\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u8ad6")

        self.assertEqual(14, len(channel))
        url = "http://blog.japan.cnet.com/kondo/archives/002364.html"
        item = indexes.valueLookup(channel, "link", "link", url)
        self.assertEqual(item.displayName, u"\u30b3\u30e2\u30f3\u30bb\u30f3\u30b9\u306e\u78ba\u8a8d")
Esempio n. 3
0
    def RemoteFeed(self):

        view = self.view
        Utility.initTwisted(view)

        url = u"http://blog.chandlerproject.org/rss2"
        url = str(url)
        view.refresh(notify=False)
        channel = FeedChannel(itsView=view)
        channel.displayName = url
        channel.url = channel.getAttributeAspect("url", "type").makeValue(url)
        view.commit()  # Make the channel available to feedsView
        status = blockUntil(channel.refresh)
        view.refresh()

        # Only bother checking if the fetch was successful.  If there is a
        # timeout or other network problem, that shouldn"t fail the test.
        if status == FETCH_UPDATED:
            self.assertEqual(channel.displayName, u"The Chandler Project Blog")
Esempio n. 4
0
    def RemoteFeed(self):


        view = self.view
        Utility.initTwisted(view)

        url = u"http://blog.chandlerproject.org/rss2"
        url = str(url)
        view.refresh(notify=False)
        channel = FeedChannel(itsView=view)
        channel.displayName = url
        channel.url = channel.getAttributeAspect("url", "type").makeValue(url)
        view.commit() # Make the channel available to feedsView
        status = blockUntil(channel.refresh)
        view.refresh()

        # Only bother checking if the fetch was successful.  If there is a
        # timeout or other network problem, that shouldn"t fail the test.
        if status == FETCH_UPDATED:
            self.assertEqual(channel.displayName,
                u"The Chandler Project Blog")
    def ImportFeed(self):

        view = self.view

        dir = os.path.dirname(os.path.abspath(__file__))
        path = os.path.join(dir, "osaf.blog.rss")

        data = file(path).read()

        channel = FeedChannel(itsView=view)
        count = channel.parse(data)

        self.assertEqual(channel.displayName, "OSAF News")
        self.assertEqual(5, len(channel))

        # Test successful lookup
        url = URL("http://www.osafoundation.org/archives/000966.html")
        item = indexes.valueLookup(channel, "link", "link", url)
        self.assertEqual(item.displayName, "OSAF Welcomes Priscilla Chung")

        # Test unsuccessful lookup
        nonExistent = URL("http://www.osafoundation.org/nonexistent/")
        item = indexes.valueLookup(channel, "link", "link", nonExistent)
        self.assertEqual(item, None)

        # Although the channels module doesn"t allow duplicate links, let"s
        # test the lookup mechanism"s ability to return dupes.  We"ll add a
        # duplicate, then pass the "multiple=True" arg to indexLookup.

        url = URL("http://www.osafoundation.org/archives/000964.html")
        item = FeedItem(itsView=view, link=url)
        channel.add(item)

        items = indexes.valueLookup(channel,
                                    "link",
                                    "link",
                                    url,
                                    multiple=True)
        self.assertEqual(len(items), 2)
Esempio n. 6
0
    def NonASCII(self):

        view = self.view

        dir = os.path.dirname(os.path.abspath(__file__))
        path = os.path.join(dir, "japanese.rdf")

        data = file(path).read()

        channel = FeedChannel(itsView=view)
        count = channel.parse(data)

        self.assertEqual(
            channel.displayName,
            u"\u8fd1\u85e4\u6df3\u4e5f\u306e\u65b0\u30cd\u30c3\u30c8\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\u8ad6"
        )

        self.assertEqual(14, len(channel))
        url = "http://blog.japan.cnet.com/kondo/archives/002364.html"
        item = indexes.valueLookup(channel, "link", "link", url)
        self.assertEqual(
            item.displayName,
            u"\u30b3\u30e2\u30f3\u30bb\u30f3\u30b9\u306e\u78ba\u8a8d")