test_cursors.py 964 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import unittest

from tweepy import API, Cursor

from config import create_auth

class TweepyCursorTests(unittest.TestCase):

    def setUp(self):
        self.api = API(create_auth())

    def testidcursoritems(self):
        items = list(Cursor(self.api.user_timeline).items(25))
        self.assertEqual(len(items), 25)

    def testidcursorpages(self):
        pages = list(Cursor(self.api.user_timeline).pages(5))
        self.assertEqual(len(pages), 5)

    def testcursorcursoritems(self):
21
22
        items = list(Cursor(self.api.friends_ids).items(10))
        self.assertEqual(len(items), 10)
23

24
25
        items = list(Cursor(self.api.followers_ids, 'twitter').items(10))
        self.assertEqual(len(items), 10)
26
27

    def testcursorcursorpages(self):
28
29
        pages = list(Cursor(self.api.friends_ids).pages(1))
        self.assert_(len(pages) == 1)
30

31
32
        pages = list(Cursor(self.api.followers_ids, 'twitter').pages(1))
        self.assert_(len(pages) == 1)
33