@ -62,17 +62,17 @@ class TestRegistry(RQTestCase):
def test_get_job_ids ( self ) :
""" Getting job ids from StartedJobRegistry. """
timestamp = current_timestamp ( )
self . testconn . zadd ( self . registry . key , timestamp + 10 , ' foo ' )
self . testconn . zadd ( self . registry . key , timestamp + 20 , ' bar ' )
self . testconn . zadd ( self . registry . key , { ' foo ' : timestamp + 10 } )
self . testconn . zadd ( self . registry . key , { ' bar ' : timestamp + 20 } )
self . assertEqual ( self . registry . get_job_ids ( ) , [ ' foo ' , ' bar ' ] )
def test_get_expired_job_ids ( self ) :
""" Getting expired job ids form StartedJobRegistry. """
timestamp = current_timestamp ( )
self . testconn . zadd ( self . registry . key , 1 , ' foo ' )
self . testconn . zadd ( self . registry . key , timestamp + 10 , ' bar ' )
self . testconn . zadd ( self . registry . key , timestamp + 30 , ' baz ' )
self . testconn . zadd ( self . registry . key , { ' foo ' : 1 } )
self . testconn . zadd ( self . registry . key , { ' bar ' : timestamp + 10 } )
self . testconn . zadd ( self . registry . key , { ' baz ' : timestamp + 30 } )
self . assertEqual ( self . registry . get_expired_job_ids ( ) , [ ' foo ' ] )
self . assertEqual ( self . registry . get_expired_job_ids ( timestamp + 20 ) ,
@ -86,7 +86,7 @@ class TestRegistry(RQTestCase):
queue = Queue ( connection = self . testconn )
job = queue . enqueue ( say_hello )
self . testconn . zadd ( self . registry . key , 2 , job . id )
self . testconn . zadd ( self . registry . key , { job . id : 2 } )
self . registry . cleanup ( 1 )
self . assertNotIn ( job . id , failed_queue . job_ids )
@ -142,8 +142,8 @@ class TestRegistry(RQTestCase):
def test_get_job_count ( self ) :
""" StartedJobRegistry returns the right number of job count. """
timestamp = current_timestamp ( ) + 10
self . testconn . zadd ( self . registry . key , timestamp , ' foo ' )
self . testconn . zadd ( self . registry . key , timestamp , ' bar ' )
self . testconn . zadd ( self . registry . key , { ' foo ' : timestamp } )
self . testconn . zadd ( self . registry . key , { ' bar ' : timestamp } )
self . assertEqual ( self . registry . count , 2 )
self . assertEqual ( len ( self . registry ) , 2 )
@ -153,10 +153,10 @@ class TestRegistry(RQTestCase):
queue = Queue ( connection = self . testconn )
finished_job_registry = FinishedJobRegistry ( connection = self . testconn )
self . testconn . zadd ( finished_job_registry . key , 1 , ' foo ' )
self . testconn . zadd ( finished_job_registry . key , { ' foo ' : 1 } )
started_job_registry = StartedJobRegistry ( connection = self . testconn )
self . testconn . zadd ( started_job_registry . key , 1 , ' foo ' )
self . testconn . zadd ( started_job_registry . key , { ' foo ' : 1 } )
clean_registries ( queue )
self . assertEqual ( self . testconn . zcard ( finished_job_registry . key ) , 0 )
@ -175,9 +175,9 @@ class TestFinishedJobRegistry(RQTestCase):
def test_cleanup ( self ) :
""" Finished job registry removes expired jobs. """
timestamp = current_timestamp ( )
self . testconn . zadd ( self . registry . key , 1 , ' foo ' )
self . testconn . zadd ( self . registry . key , timestamp + 10 , ' bar ' )
self . testconn . zadd ( self . registry . key , timestamp + 30 , ' baz ' )
self . testconn . zadd ( self . registry . key , { ' foo ' : 1 } )
self . testconn . zadd ( self . registry . key , { ' bar ' : timestamp + 10 } )
self . testconn . zadd ( self . registry . key , { ' baz ' : timestamp + 30 } )
self . registry . cleanup ( )
self . assertEqual ( self . registry . get_job_ids ( ) , [ ' bar ' , ' baz ' ] )