@ -35,6 +35,21 @@ class TestScheduledJobRegistry(RQTestCase):
self . assertEqual ( registry . get_jobs_to_enqueue ( timestamp + 20 ) ,
self . assertEqual ( registry . get_jobs_to_enqueue ( timestamp + 20 ) ,
[ ' foo ' , ' bar ' ] )
[ ' foo ' , ' bar ' ] )
def test_get_jobs_to_schedule_with_chunk_size ( self ) :
""" Max amount of jobs returns by get_jobs_to_schedule() equal to chunk_size """
queue = Queue ( connection = self . testconn )
registry = ScheduledJobRegistry ( queue = queue )
timestamp = current_timestamp ( )
chunk_size = 5
for index in range ( 0 , chunk_size * 2 ) :
self . testconn . zadd ( registry . key , { ' foo_ {} ' . format ( index ) : 1 } )
self . assertEqual ( len ( registry . get_jobs_to_schedule ( timestamp , chunk_size ) ) ,
chunk_size )
self . assertEqual ( len ( registry . get_jobs_to_schedule ( timestamp , chunk_size * 2 ) ) ,
chunk_size * 2 )
def test_get_scheduled_time ( self ) :
def test_get_scheduled_time ( self ) :
""" get_scheduled_time() returns job ' s scheduled datetime """
""" get_scheduled_time() returns job ' s scheduled datetime """
queue = Queue ( connection = self . testconn )
queue = Queue ( connection = self . testconn )
@ -102,7 +117,6 @@ class TestScheduledJobRegistry(RQTestCase):
self . assertEqual ( self . testconn . zscore ( registry . key , job . id ) ,
self . assertEqual ( self . testconn . zscore ( registry . key , job . id ) ,
1546300800 + 14400 ) # 2019-01-01 UTC in Unix timestamp
1546300800 + 14400 ) # 2019-01-01 UTC in Unix timestamp
# Score is always stored in UTC even if datetime is in a different tz
# Score is always stored in UTC even if datetime is in a different tz
tz = timezone ( timedelta ( hours = 7 ) )
tz = timezone ( timedelta ( hours = 7 ) )
job = Job . create ( ' myfunc ' , connection = self . testconn )
job = Job . create ( ' myfunc ' , connection = self . testconn )