Skip to content

Commit afe19c2

Browse files
committed
Added HTTP replaying for pull requests
1 parent 8f1a430 commit afe19c2

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
httreplay==0.1.4

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#from distutils.core import setup
33
from setuptools import setup, find_packages
44
from tweepy import __version__
5+
from pip.req import parse_requirements
6+
7+
install_reqs = parse_requirements('requirements.txt')
8+
reqs = [str(req.req) for req in install_reqs]
59

610
setup(name="tweepy",
711
version=__version__,
@@ -11,5 +15,6 @@
1115
author_email="tweepy@googlegroups.com",
1216
url="http://github.com/tweepy/tweepy",
1317
packages = find_packages(),
18+
install_requires=reqs,
1419
keywords= "twitter library",
1520
zip_safe = True)

tests/test_api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
MemoryCache, FileCache)
1010

1111
from config import *
12+
from httreplay import start_replay, stop_replay
13+
from httreplay.utils import filter_headers_key
14+
import os
1215

1316
test_tweet_id = '266367358078169089'
1417

@@ -30,12 +33,17 @@ def testpickle(self):
3033
class TweepyAPITests(unittest.TestCase):
3134

3235
def setUp(self):
36+
if os.environ['TRAVIS_SECURE_ENV_VARS'] == 'false':
37+
start_replay('records/test.json', headers_key=filter_headers_key(['Authorization']))
3338
auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
3439
auth.set_access_token(oauth_token, oauth_token_secret)
3540
self.api = API(auth)
3641
self.api.retry_count = 2
3742
self.api.retry_delay = 5
3843

44+
def tearDown(self):
45+
stop_replay()
46+
3947
# TODO: Actually have some sort of better assertion
4048
def testgetoembed(self):
4149
data = self.api.get_oembed(test_tweet_id)

0 commit comments

Comments
 (0)