From 1add26e62cf51c50d9c0747514f6ff0fe9bbc814 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Wed, 14 Oct 2009 13:17:27 -0500 Subject: [PATCH] Add tests for Cursors. --- CHANGES | 2 +- tests.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) 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): -- 2.25.1