script/lib/tweetstream/tests/test_tweetstream.py
changeset 15 5d552b6a0e55
parent 12 4daf47fcf792
child 207 621fa6caec0c
--- a/script/lib/tweetstream/tests/test_tweetstream.py	Tue Jan 18 18:25:18 2011 +0100
+++ b/script/lib/tweetstream/tests/test_tweetstream.py	Thu Jan 20 10:44:04 2011 +0100
@@ -6,6 +6,7 @@
 from nose.tools import assert_raises
 from tweetstream import TweetStream, FollowStream, TrackStream
 from tweetstream import ConnectionError, AuthenticationError
+from tweetstream import auth
 
 from servercontext import test_server
 
@@ -20,13 +21,13 @@
 
     with test_server(handler=auth_denied, methods=("post", "get"),
                      port="random") as server:
-        stream = TweetStream("foo", "bar", url=server.baseurl)
+        stream = TweetStream(auth.BasicAuthHandler("foo", "bar"), url=server.baseurl)
         assert_raises(AuthenticationError, stream.next)
 
-        stream = FollowStream("foo", "bar", [1, 2, 3], url=server.baseurl)
+        stream = FollowStream(auth.BasicAuthHandler("foo", "bar"), [1, 2, 3], url=server.baseurl)
         assert_raises(AuthenticationError, stream.next)
 
-        stream = TrackStream("foo", "bar", ["opera"], url=server.baseurl)
+        stream = TrackStream(auth.BasicAuthHandler("foo", "bar"), ["opera"], url=server.baseurl)
         assert_raises(AuthenticationError, stream.next)
 
 
@@ -38,13 +39,13 @@
 
     with test_server(handler=not_found, methods=("post", "get"),
                      port="random") as server:
-        stream = TweetStream("foo", "bar", url=server.baseurl)
+        stream = TweetStream(auth.BasicAuthHandler("foo", "bar"), url=server.baseurl)
         assert_raises(ConnectionError, stream.next)
 
-        stream = FollowStream("foo", "bar", [1, 2, 3], url=server.baseurl)
+        stream = FollowStream(auth.BasicAuthHandler("foo", "bar"), [1, 2, 3], url=server.baseurl)
         assert_raises(ConnectionError, stream.next)
 
-        stream = TrackStream("foo", "bar", ["opera"], url=server.baseurl)
+        stream = TrackStream(auth.BasicAuthHandler("foo", "bar"), ["opera"], url=server.baseurl)
         assert_raises(ConnectionError, stream.next)
 
 
@@ -61,7 +62,7 @@
     def do_test(klass, *args):
         with test_server(handler=bad_content, methods=("post", "get"),
                          port="random") as server:
-            stream = klass("foo", "bar", *args, url=server.baseurl)
+            stream = klass(auth.BasicAuthHandler("foo", "bar"), *args, url=server.baseurl)
             for tweet in stream:
                 pass
 
@@ -82,7 +83,7 @@
     def do_test(klass, *args):
         with test_server(handler=bad_content, methods=("post", "get"),
                          port="random") as server:
-            stream = klass("foo", "bar", *args, url=server.baseurl)
+            stream = klass(auth.BasicAuthHandler("foo", "bar"), *args, url=server.baseurl)
             for tweet in stream:
                 pass
 
@@ -93,13 +94,13 @@
 
 def test_bad_host():
     """Test behaviour if we can't connect to the host"""
-    stream = TweetStream("foo", "bar", url="http://bad.egewdvsdswefdsf.com/")
+    stream = TweetStream(auth.BasicAuthHandler("foo", "bar"), url="http://bad.egewdvsdswefdsf.com/")
     assert_raises(ConnectionError, stream.next)
 
-    stream = FollowStream("foo", "bar", [1, 2, 3], url="http://zegwefdsf.com/")
+    stream = FollowStream(auth.BasicAuthHandler("foo", "bar"), [1, 2, 3], url="http://zegwefdsf.com/")
     assert_raises(ConnectionError, stream.next)
 
-    stream = TrackStream("foo", "bar", ["foo"], url="http://aswefdsews.com/")
+    stream = TrackStream(auth.BasicAuthHandler("foo", "bar"), ["foo"], url="http://aswefdsews.com/")
     assert_raises(ConnectionError, stream.next)
 
 
@@ -114,7 +115,7 @@
     def do_test(klass, *args):
         with test_server(handler=tweetsource,
                          methods=("post", "get"), port="random") as server:
-            stream = klass("foo", "bar", *args, url=server.baseurl)
+            stream = klass(auth.BasicAuthHandler("foo", "bar"), *args, url=server.baseurl)
             for tweet in stream:
                 if stream.count == total:
                     break
@@ -145,7 +146,7 @@
     def do_test(klass, *args):
         with test_server(handler=tweetsource, methods=("post", "get"),
                          port="random") as server:
-            stream = klass("foo", "bar", *args, url=server.baseurl)
+            stream = klass(auth.BasicAuthHandler("foo", "bar"), *args, url=server.baseurl)
             try:
                 for tweet in stream:
                     pass
@@ -178,7 +179,7 @@
     def do_test(klass, *args):
         with test_server(handler=tweetsource, methods=("post", "get"),
                          port="random") as server:
-            stream = klass("foo", "bar", *args, url=server.baseurl)
+            stream = klass(auth.BasicAuthHandler("foo", "bar"), *args, url=server.baseurl)
 
             start = time.time()
             stream.next()