#NEWLINE# def test_raw_exception( worker ) : #NEWLINE# #INDENT# p_queue = 'testexception_raw' #NEWLINE# worker . start ( flags = '--greenlets 10 --config tests/fixtures/config-raw1.py' , queues = p_queue ) #NEWLINE# jobs_collection = worker . mongodb_jobs . mrq_jobs #NEWLINE# assert ( jobs_collection . count ( ) == 0 ) #NEWLINE# assert ( Queue ( p_queue ) . size ( ) == 0 ) #NEWLINE# worker . send_raw_tasks ( p_queue , [ 'msg1' ] , block = True ) #NEWLINE# failjob = list ( jobs_collection . find ( ) ) [ 0 ] #NEWLINE# assert ( Queue ( 'default' ) . size ( ) == 0 ) #NEWLINE# assert ( Queue ( p_queue ) . size ( ) == 0 ) #NEWLINE# assert ( jobs_collection . count ( ) == 1 ) #NEWLINE# assert ( failjob [ 'status' ] == 'failed' ) #NEWLINE# worker . stop ( deps = False ) #NEWLINE# worker . start ( deps = False , flags = '--greenlets 10 --config tests/fixtures/config-raw1.py' , queues = 'default' ) #NEWLINE# worker . send_task ( 'mrq.basetasks.utils.JobAction' , { #NEWLINE# #INDENT# 'id' : failjob [ '_id' ] , #NEWLINE# 'action' : 'requeue' , #NEWLINE# #UNINDENT# } , block = True ) #NEWLINE# assert ( Queue ( 'default' ) . size ( ) == 0 ) #NEWLINE# assert ( Queue ( p_queue ) . size ( ) == 0 ) #NEWLINE# assert ( Queue ( 'testx' ) . size ( ) == 1 ) #NEWLINE# assert ( jobs_collection . count ( ) == 2 ) #NEWLINE# assert ( list ( jobs_collection . find ( { #NEWLINE# #INDENT# '_id' : failjob [ '_id' ] , #NEWLINE# #UNINDENT# } ) ) [ 0 ] [ 'status' ] == 'queued' ) #NEWLINE# assert ( list ( jobs_collection . find ( { #NEWLINE# #INDENT# '_id' : { #NEWLINE# #INDENT# '$ne' : failjob [ '_id' ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) ) [ 0 ] [ 'status' ] == 'success' ) #NEWLINE# worker . stop ( deps = False ) #NEWLINE# worker . start ( deps = False , flags = '--greenlets 10 --config tests/fixtures/config-raw1.py' , queues = 'default testx' ) #NEWLINE# time . sleep ( 2 ) #NEWLINE# assert ( Queue ( p_queue ) . size ( ) == 0 ) #NEWLINE# assert ( jobs_collection . count ( ) == 2 ) #NEWLINE# assert ( Queue ( 'testx' ) . size ( ) == 0 ) #NEWLINE# assert ( list ( jobs_collection . find ( { #NEWLINE# #INDENT# '_id' : p_queue [ '_id' ] , #NEWLINE# #UNINDENT# } ) ) [ 0 ] [ 'status' ] == 'failed' )