Commit 5c05b173 authored by Joshua Roesslein's avatar Joshua Roesslein
Browse files

Merge pull request #333.

Made a few changes and setup Travis config.
parents 8f1a430f c9da4203
---
script: nosetests -v tests.test_api tests.test_streaming tests.test_cursors
language: python
python:
- "2.7"
install:
- pip install -r test_requirements.txt
script: ./run_tests.sh
env:
global:
- TWITTER_USERNAME="tweepytest"
......@@ -20,8 +24,4 @@ env:
nKkytraqLGUm33K1GpwkjOyxACDHYw4GMvOGyDwVTX7VNwqxbkUojB7qXYoQ
JjlEyFWS487IFteR87U9pt18qongJJIphaBdT9/lDVLsMWZ0Jh5ZLQfX+2jS
aF2UwsrYkzBUMrqMqYCc2+X6CuswLEZTVXDAlNh+emvhxZ5faMI=
python:
- "2.7"
branches:
only:
- master
#! /usr/bin/env bash
if [[ $TRAVIS_SECURE_ENV_VARS == "false" ]]; then
USE_REPLAY=1 nosetests -v tests.test_api
else
nosetests -v tests.test_api tests.test_streaming tests.test_cursors
fi
import os
from unittest import TestCase
from httreplay import start_replay, stop_replay
from httreplay.utils import filter_headers_key
from tweepy.auth import OAuthHandler
from tweepy.api import API
username = os.environ.get('TWITTER_USERNAME', '')
username = os.environ.get('TWITTER_USERNAME', 'tweepytest')
oauth_consumer_key = os.environ.get('CONSUMER_KEY', '')
oauth_consumer_secret = os.environ.get('CONSUMER_SECRET', '')
oauth_token = os.environ.get('ACCESS_KEY', '')
oauth_token_secret = os.environ.get('ACCESS_SECRET', '')
use_replay = os.environ.get('USE_REPLAY', False)
class TweepyTestCase(TestCase):
def setUp(self):
self.auth = create_auth()
self.api = API(self.auth)
self.api.retry_count = 2
self.api.retry_delay = 5
if use_replay:
start_replay('tests/record.json',
headers_key=filter_headers_key(['Authorization']))
def tearDown(self):
if use_replay:
stop_replay()
def create_auth():
auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
......
This diff is collapsed.
......@@ -5,12 +5,11 @@ import os
from nose import SkipTest
from tweepy import (API, OAuthHandler, Friendship, Cursor,
MemoryCache, FileCache)
from config import *
from tweepy import Friendship, MemoryCache, FileCache
from config import TweepyTestCase, username, use_replay
test_tweet_id = '266367358078169089'
tweet_text = 'testing 1000'
"""Unit tests"""
......@@ -27,14 +26,7 @@ class TweepyErrorTests(unittest.TestCase):
self.assertEqual(e.reason, e2.reason)
self.assertEqual(e.response, e2.response)
class TweepyAPITests(unittest.TestCase):
def setUp(self):
auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
auth.set_access_token(oauth_token, oauth_token_secret)
self.api = API(auth)
self.api.retry_count = 2
self.api.retry_delay = 5
class TweepyAPITests(TweepyTestCase):
# TODO: Actually have some sort of better assertion
def testgetoembed(self):
......@@ -67,7 +59,7 @@ class TweepyAPITests(unittest.TestCase):
def testupdateanddestroystatus(self):
# test update
text = 'testing %i' % random.randint(0, 1000)
text = tweet_text if use_replay else 'testing %i' % random.randint(0, 1000)
update = self.api.update_status(status=text)
self.assertEqual(update.text, text)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment