Split up tests into modules.
authorJoshua Roesslein <jroesslein@gmail.com>
Sun, 19 May 2013 04:49:15 +0000 (21:49 -0700)
committerJoshua Roesslein <jroesslein@gmail.com>
Sun, 19 May 2013 04:49:15 +0000 (21:49 -0700)
  - Keep auth tests disabled in CI since they require user input.

.travis.yml
tests/__init__.py [new file with mode: 0644]
tests/config.py [new file with mode: 0644]
tests/test_api.py [moved from tests.py with 93% similarity]
tests/test_auth.py [new file with mode: 0644]

index 5919e7b26b625469b94a75053b7a51a874a4c71c..1f77e2ed04fe4d1b69d27980f5a8fed48ca7bcb4 100644 (file)
@@ -1,5 +1,5 @@
 ---
-script: nosetests -v tests:TweepyAPITests tests:TweepyCursorTests tests:TweepyCacheTests tests:TweepyErrorTests
+script: nosetests -v tests.test_api
 language: python
 env:
   global:
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/tests/config.py b/tests/config.py
new file mode 100644 (file)
index 0000000..67ee00a
--- /dev/null
@@ -0,0 +1,8 @@
+import os
+
+username = os.environ.get('TWITTER_USERNAME', '')
+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', '')
+
similarity index 93%
rename from tests.py
rename to tests/test_api.py
index e7db7a8a463ebcd694cbc5f58576a2c59838a105..65a37db78edd938436677c4f25ac6c13eb999f02 100644 (file)
--- a/tests.py
@@ -8,13 +8,7 @@ from nose import SkipTest
 from tweepy import (API, OAuthHandler, Friendship, Cursor,
                     MemoryCache, FileCache)
 
-"""Configurations"""
-# Must supply twitter account credentials for tests
-username = os.environ.get('TWITTER_USERNAME', '')
-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', '')
+from config import *
 
 test_tweet_id = '266367358078169089'
 
@@ -355,25 +349,6 @@ class TweepyCursorTests(unittest.TestCase):
         pages = list(Cursor(self.api.followers_ids, 'twitter').pages(5))
         self.assert_(len(pages) == 5)
 
-class TweepyAuthTests(unittest.TestCase):
-
-    def testoauth(self):
-        auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
-
-        # test getting access token
-        auth_url = auth.get_authorization_url()
-        print 'Please authorize: ' + auth_url
-        verifier = raw_input('PIN: ').strip()
-        self.assert_(len(verifier) > 0)
-        access_token = auth.get_access_token(verifier)
-        self.assert_(access_token is not None)
-
-        # build api object test using oauth
-        api = API(auth)
-        s = api.update_status('test %i' % random.randint(0, 1000))
-        api.destroy_status(s.id)
-
-
 class TweepyCacheTests(unittest.TestCase):
 
     timeout = 2.0
diff --git a/tests/test_auth.py b/tests/test_auth.py
new file mode 100644 (file)
index 0000000..bc37d36
--- /dev/null
@@ -0,0 +1,23 @@
+import unittest
+
+from config import *
+from tweepy import API, OAuthHandler
+
+class TweepyAuthTests(unittest.TestCase):
+
+    def testoauth(self):
+        auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
+
+        # test getting access token
+        auth_url = auth.get_authorization_url()
+        print 'Please authorize: ' + auth_url
+        verifier = raw_input('PIN: ').strip()
+        self.assert_(len(verifier) > 0)
+        access_token = auth.get_access_token(verifier)
+        self.assert_(access_token is not None)
+
+        # build api object test using oauth
+        api = API(auth)
+        s = api.update_status('test %i' % random.randint(0, 1000))
+        api.destroy_status(s.id)
+