From: Josh Roesslein Date: Wed, 14 Oct 2009 18:17:27 +0000 (-0500) Subject: Add tests for Cursors. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1add26e62cf51c50d9c0747514f6ff0fe9bbc814;p=tweepy.git Add tests for Cursors. --- diff --git a/CHANGES b/CHANGES index c060a7f..6ea745d 100644 --- a/CHANGES +++ b/CHANGES @@ -20,7 +20,7 @@ during upgrade will be listed here. + Fix search result 'source' parsing to properly unescape html and extract source + Cursor Added the Cursor object to help with pagination within the API. - Please see the pagination tutorial for more details. + Please see the pagination tutorial for more details (tutorial/t6). This is the recommended way for using the 'page' and 'cursor' parameters. + Update OAuth bundled library. - Logging removed. Having our own mini-logging system just feels like overkill. diff --git a/tests.py b/tests.py index 1b1f080..4c30a6a 100644 --- a/tests.py +++ b/tests.py @@ -203,6 +203,40 @@ class TweepyAPITests(unittest.TestCase): self.api.trends_daily() self.api.trends_weekly() +class TweepyCursorTests(unittest.TestCase): + + def setUp(self): + self.api = API(BasicAuthHandler(username, password)) + self.api.retry_count = 2 + self.api.retry_delay = 5 + + def testpagecursoritems(self): + items = list(Cursor(self.api.user_timeline).items()) + self.assert_(len(items) > 0) + + items = list(Cursor(self.api.user_timeline, 'twitter').items(30)) + self.assert_(len(items) == 30) + + def testpagecursorpages(self): + pages = list(Cursor(self.api.user_timeline).pages()) + self.assert_(len(pages) > 0) + + pages = list(Cursor(self.api.user_timeline, 'twitter').pages(5)) + self.assert_(len(pages) == 5) + + def testcursorcursoritems(self): + items = list(Cursor(self.api.friends).items()) + self.assert_(len(items) > 0) + + items = list(Cursor(self.api.followers, 'twitter').items(30)) + self.assert_(len(items) == 30) + + def testcursorcursorpages(self): + pages = list(Cursor(self.api.friends).pages()) + self.assert_(len(pages) > 0) + + pages = list(Cursor(self.api.followers, 'twitter').pages(5)) + self.assert_(len(pages) == 5) class TweepyAuthTests(unittest.TestCase):