#NEWLINE# def testListJobs( self ) : #NEWLINE# #INDENT# job = self . model ( 'job' , 'jobs' ) . createJob ( title = 'A job' , type = 't' , user = self . users [ 1 ] , public = False ) #NEWLINE# anonJob = self . model ( 'job' , 'jobs' ) . createJob ( title = 'Anon job' , type = 't' ) #NEWLINE# time . sleep ( 0.1 ) #NEWLINE# publicJob = self . model ( 'job' , 'jobs' ) . createJob ( title = 'Anon job' , type = 't' , public = True ) #NEWLINE# resp = self . request ( '/job' , user = self . users [ 1 ] , params = { #NEWLINE# #INDENT# 'userId' : self . users [ 1 ] [ '_id' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertStatusOk ( resp ) #NEWLINE# self . assertEqual ( len ( resp . json ) , 1 ) #NEWLINE# self . assertEqual ( resp . json [ 0 ] [ '_id' ] , str ( job [ '_id' ] ) ) #NEWLINE# resp = self . request ( '/job' , user = self . users [ 2 ] , params = { #NEWLINE# #INDENT# 'userId' : self . users [ 1 ] [ '_id' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( resp . json , [ ] ) #NEWLINE# resp = self . request ( '/job' , user = self . users [ 1 ] ) #NEWLINE# self . assertStatusOk ( resp ) #NEWLINE# self . assertEqual ( len ( resp . json ) , 1 ) #NEWLINE# self . assertEqual ( resp . json [ 0 ] [ '_id' ] , str ( job [ '_id' ] ) ) #NEWLINE# resp = self . request ( '/job' , user = self . users [ 0 ] , params = { #NEWLINE# #INDENT# 'userId' : 'none' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertStatusOk ( resp ) #NEWLINE# self . assertEqual ( len ( resp . json ) , 2 ) #NEWLINE# self . assertEqual ( resp . json [ 0 ] [ '_id' ] , str ( publicJob [ '_id' ] ) ) #NEWLINE# self . assertEqual ( resp . json [ 1 ] [ '_id' ] , str ( anonJob [ '_id' ] ) ) #NEWLINE# resp = self . request ( '/job' , params = { #NEWLINE# #INDENT# 'userId' : 'none' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertStatusOk ( resp ) #NEWLINE# self . assertEqual ( len ( resp . json ) , 1 ) #NEWLINE# self . assertEqual ( publicJob . json [ 0 ] [ '_id' ] , str ( publicJob [ '_id' ] ) )