#NEWLINE# def test_workflow_init_to_finish( self ) : #NEWLINE# #INDENT# 'Tests the entire workflow cycle' #NEWLINE# request_args = { #NEWLINE# #INDENT# 'app_name' : 'tests' , #NEWLINE# 'model_name' : 'Foo' , #NEWLINE# 'pk' : 'Initial' , #NEWLINE# #UNINDENT# } #NEWLINE# for verb in ( 'get' , 'post' ) : #NEWLINE# #INDENT# response = getattr ( self . client , verb ) ( reverse ( 'create' , kwargs = request_args ) ) #NEWLINE# if ( verb == 'get' ) : #NEWLINE# #INDENT# self . assertFalse ( ( 'form' in response . context ) , 'User has no access to initiate workflow, still the system did not limit' ) #NEWLINE# self . submitter . user_set . add ( self . john_doe ) #NEWLINE# #UNINDENT# response = getattr ( self . client , verb ) ( reverse ( 'create' , kwargs = response ) ) #NEWLINE# self . assertEqual ( response . context [ 'form' ] . _meta . model , Foo , 'User has access to initiate workflow, still the context does not contain the required form instance' ) #NEWLINE# #UNINDENT# response = self . client . post ( reverse ( 'create' , kwargs = request_args ) , { #NEWLINE# #INDENT# 'subject' : 'test' , #NEWLINE# 'bar' : 'example - small e' , #NEWLINE# 'baz' : 'WL' , #NEWLINE# 'qux' : 'Nothing' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( response . status_code , 200 , 'Form post did not result in success' ) #NEWLINE# self . assertEqual ( Foo . objects . count ( ) , 0 , 'Validation errors still result in creation of initial activity instance' ) #NEWLINE# response = self . client . post ( reverse ( 'create' , kwargs = request_args ) , { #NEWLINE# #INDENT# 'subject' : 'test' , #NEWLINE# 'bar' : 'Example - small e' , #NEWLINE# 'baz' : 'WL' , #NEWLINE# 'qux' : 'Nothing' , #NEWLINE# #UNINDENT# } ) #NEWLINE# instances = Foo . objects . all ( ) #NEWLINE# instance = instances . first ( ) #NEWLINE# self . assertEqual ( instances . count ( ) , 1 , 'No validation errors, still initial activity instance did not get created' ) #NEWLINE# request_args = { #NEWLINE# #INDENT# 'app_name' : 'tests' , #NEWLINE# 'model_name' : 'Foo' , #NEWLINE# 'pk' : instance . id , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertRedirects ( response , reverse ( 'update' , kwargs = request_args ) , status_code = 302 , target_status_code = 200 ) #NEWLINE# for verb in ( 'get' , 'post' ) : #NEWLINE# #INDENT# response = getattr ( self . client , verb ) ( reverse ( 'update' , kwargs = request_args ) ) #NEWLINE# #UNINDENT# response = self . client . post ( reverse ( 'update' , kwargs = request_args ) , { #NEWLINE# #INDENT# 'subject' : 'test' , #NEWLINE# 'bar' : 'Example - small e' , #NEWLINE# 'baz' : 'WL' , #NEWLINE# 'qux' : 'Nothing' , #NEWLINE# 'save' : 'Save' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertRedirects ( response , reverse ( 'update' , kwargs = request_args ) ) #NEWLINE# response = self . client . post ( reverse ( 'update' , kwargs = request_args ) , { #NEWLINE# #INDENT# 'subject' : 'test' , #NEWLINE# 'bar' : 'Example' , #NEWLINE# 'baz' : 'WL' , #NEWLINE# 'qux' : 'Nothing' , #NEWLINE# 'submit' : 'corge_activity' , #NEWLINE# #UNINDENT# } ) #NEWLINE# final_task = instance . task . request . tasks . latest ( 'id' ) #NEWLINE# response = self . client . post ( reverse ( 'create' , kwargs = { #NEWLINE# #INDENT# 'app_name' : 'tests' , #NEWLINE# 'model_name' : 'Corge' , #NEWLINE# 'pk' : final_task . id , #NEWLINE# #UNINDENT# } ) , { #NEWLINE# #INDENT# 'grault' : 'Example - big E' , #NEWLINE# 'thud' : 23 , #NEWLINE# #UNINDENT# } ) #NEWLINE# instances = Corge . objects . all ( ) #NEWLINE# instance = instances . first ( ) #NEWLINE# self . assertEqual ( instances . count ( ) , 1 , 'Instance of final activity did not get created even after a successfull post' ) #NEWLINE# request_args = { #NEWLINE# #INDENT# 'app_name' : 'tests' , #NEWLINE# 'model_name' : 'Corge' , #NEWLINE# 'pk' : instance . id , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertRedirects ( response , reverse ( 'update' , kwargs = request_args ) , status_code = 302 , target_status_code = 200 ) #NEWLINE# response = self . client . post ( reverse ( 'update' , kwargs = request_args ) , { #NEWLINE# #INDENT# 'grault' : 'Example - big E' , #NEWLINE# 'thud' : 23 , #NEWLINE# 'finish' : 'Finish' , #NEWLINE# #UNINDENT# } ) #NEWLINE# response = self . client . get ( reverse ( 'view' , kwargs = request_args ) ) #NEWLINE# self . assertEqual ( response . status_code , 200 , 'Response did not result in success' ) #NEWLINE# response = self . client . post ( reverse ( 'delete' , kwargs = request_args ) ) #NEWLINE# self . assertEqual ( Corge . objects . all ( ) . count ( ) , 0 , 'Delete operation did not end up removing the instance' )