File: test_streaming.py

package info (click to toggle)
twython 3.8.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 600 kB
  • sloc: python: 1,793; makefile: 148; sh: 49
file content (50 lines) | stat: -rw-r--r-- 1,735 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from twython import TwythonStreamer, TwythonStreamError

from .config import (
    app_key, app_secret, oauth_token, oauth_token_secret, unittest
)


class TwythonStreamTestCase(unittest.TestCase):
    def setUp(self):
        class MyStreamer(TwythonStreamer):
            def on_success(self, data):
                self.disconnect()

            def on_error(self, status_code, data):
                raise TwythonStreamError(data)

        self.api = MyStreamer(app_key, app_secret,
                              oauth_token, oauth_token_secret)

        client_args = {
            'headers': {
                'User-Agent': '__twython__ Stream Test'
            }
        }
        # Initialize with header for coverage checking for User-Agent
        self.api_with_header = MyStreamer(app_key, app_secret,
                                          oauth_token, oauth_token_secret,
                                          client_args=client_args)

    @unittest.skip('skipping non-updated test')
    def test_stream_status_filter(self):
        self.api.statuses.filter(track='twitter')

    @unittest.skip('skipping non-updated test')
    def test_stream_status_sample(self):
        self.api.statuses.sample()

    @unittest.skip('skipping non-updated test')
    def test_stream_status_firehose(self):
        self.assertRaises(TwythonStreamError, self.api.statuses.firehose,
                          track='twitter')

    @unittest.skip('skipping non-updated test')
    def test_stream_site(self):
        self.assertRaises(TwythonStreamError, self.api.site,
                          follow='twitter')

    @unittest.skip('skipping non-updated test')
    def test_stream_user(self):
        self.api.user(track='twitter')