From 05e83c5231320c4a6a511281f6d23c714437f608 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Mon, 14 Nov 2011 14:18:21 +0100 Subject: [PATCH] Add a very minor beginning to the test cases. --- tests/test_rq.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/test_rq.py b/tests/test_rq.py index 8cc1200f..d962be49 100644 --- a/tests/test_rq.py +++ b/tests/test_rq.py @@ -1,24 +1,42 @@ import unittest from blinker import signal from redis import Redis - -testconn = Redis() +import rq +from rq import Queue class RQTestCase(unittest.TestCase): def setUp(self): super(RQTestCase, self).setUp() - testconn.flushdb() + + rq.push_connection(Redis()) + self.conn = rq.current_connection() + + self.conn.flushdb() signal('setup').send(self) def tearDown(self): signal('teardown').send(self) - testconn.flushdb() + + self.conn.flushdb() + conn = rq.pop_connection() + assert conn == self.conn + super(RQTestCase, self).tearDown() -class TestRQ(RQTestCase): - def test_math(self): - assert 1 + 2 == 3 +class TestQueue(RQTestCase): + def test_create_queue(self): + """Creating queues.""" + q = Queue('my-queue') + self.assertEquals(q.name, 'my-queue') + + def test_queue_empty(self): + """Detecting empty queues.""" + q = Queue('my-queue') + self.assertEquals(q.empty, True) + + self.conn.rpush('rq:my-queue', 'some val') + self.assertEquals(q.empty, False) if __name__ == '__main__':