File tree Expand file tree Collapse file tree 3 files changed +2768
-21
lines changed Expand file tree Collapse file tree 3 files changed +2768
-21
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
+ from unittest import TestCase
3
+
4
+ from httreplay import start_replay , stop_replay
5
+ from httreplay .utils import filter_headers_key
2
6
3
7
from tweepy .auth import OAuthHandler
8
+ from tweepy .api import API
4
9
5
10
username = os .environ .get ('TWITTER_USERNAME' , '' )
6
11
oauth_consumer_key = os .environ .get ('CONSUMER_KEY' , '' )
7
12
oauth_consumer_secret = os .environ .get ('CONSUMER_SECRET' , '' )
8
13
oauth_token = os .environ .get ('ACCESS_KEY' , '' )
9
14
oauth_token_secret = os .environ .get ('ACCESS_SECRET' , '' )
15
+ use_replay = os .environ .get ('USE_REPLAY' , False )
16
+
17
+ class TweepyTestCase (TestCase ):
18
+
19
+ def setUp (self ):
20
+ self .auth = create_auth ()
21
+ self .api = API (self .auth )
22
+ self .api .retry_count = 2
23
+ self .api .retry_delay = 5
24
+
25
+ if use_replay :
26
+ start_replay ('tests/record.json' ,
27
+ headers_key = filter_headers_key (['Authorization' ]))
28
+
29
+ def tearDown (self ):
30
+ if use_replay :
31
+ stop_replay ()
10
32
11
33
def create_auth ():
12
34
auth = OAuthHandler (oauth_consumer_key , oauth_consumer_secret )
You can’t perform that action at this time.
0 commit comments