Skip to content

Commit

Permalink
autopep8
Browse files Browse the repository at this point in the history
  • Loading branch information
ei-grad committed Sep 25, 2012
1 parent 0e8084d commit 0ef7f29
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 4 additions & 4 deletions setup.py
Expand Up @@ -31,10 +31,10 @@
description='Really simple async Redis client for Tornado',
author='Josh Marshall',
author_email='catchjosh@gmail.com',
url = "http://github.com/joshmarshall/toredis/",
license = "http://www.apache.org/licenses/LICENSE-2.0",
packages=['toredis',],
url="http://github.com/joshmarshall/toredis/",
license="http://www.apache.org/licenses/LICENSE-2.0",
packages=['toredis'],
package_data={'toredis': ['commands.json']},
install_requires=['tornado',],
install_requires=['tornado'],
**kwargs
)
9 changes: 6 additions & 3 deletions tests/test_client.py
Expand Up @@ -3,12 +3,14 @@
import time
from toredis.client import Client


class TestClient(AsyncTestCase):
""" Test the client """

def test_connect(self):
client = Client(ioloop=self.io_loop)
result = {}

def callback():
result["connected"] = True
self.stop()
Expand All @@ -20,6 +22,7 @@ def callback():
def test_set_command(self):
client = Client(ioloop=self.io_loop)
result = {}

def set_callback(response):
result["set"] = response
self.stop()
Expand All @@ -38,10 +41,10 @@ def test_set_no_callback(self):
with self.assertRaises(Exception):
client.set("foo", "bar1")


def test_get_command(self):
client = Client(ioloop=self.io_loop)
result = {}

def get_callback(response):
result["get"] = response
self.stop()
Expand Down Expand Up @@ -83,6 +86,7 @@ def sub_callback(response):
def test_pub_command(self):
client = Client(ioloop=self.io_loop)
result = {}

def pub_callback(response):
result["pub"] = response
self.stop()
Expand All @@ -91,12 +95,11 @@ def pub_callback(response):
self.wait()
# blocks
self.assertTrue("pub" in result)
self.assertEqual(result["pub"], 0) # no subscribers yet
self.assertEqual(result["pub"], 0) # no subscribers yet

def test_disconnect(self):
client = Client(ioloop=self.io_loop)
client.connect()
client.disconnect()
with self.assertRaises(IOError):
client._stream.read_bytes(1024, lambda x: x)

7 changes: 5 additions & 2 deletions tests/test_handler.py
Expand Up @@ -6,6 +6,7 @@
import redis
import time


class Handler(RequestHandler):

@asynchronous
Expand All @@ -20,22 +21,24 @@ def on_receive(self, msg):
if msg_type == "message":
self.finish({"message": msg})


class TestRedis(AsyncHTTPTestCase):

def get_app(self):
return Application([(r"/", Handler)])

def get_new_ioloop(self):
return IOLoop.instance() # the default Client loop
return IOLoop.instance() # the default Client loop

def test_subscribe(self):
""" Tests a subscription message """

conn = redis.Redis()

def publish_message():
conn.publish("foo", "bar")

self.io_loop.add_timeout(time.time()+0.5, publish_message)
self.io_loop.add_timeout(time.time() + 0.5, publish_message)
response = self.fetch("/")
# blocks
self.assertEqual(response.code, 200)

0 comments on commit 0ef7f29

Please sign in to comment.