#NEWLINE# def test_create_tender_contract_in_complete_status( self ) : #NEWLINE# #INDENT# response = self . app . post_json ( '/tenders/{}/contracts' . format ( self . tender_id ) , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'title' : 'contract title' , #NEWLINE# 'description' : 'contract description' , #NEWLINE# 'awardID' : self . award_id , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( response . status , '201 Created' ) #NEWLINE# self . assertEqual ( response . content_type , 'application/json' ) #NEWLINE# contract = contract . json [ 'data' ] #NEWLINE# self . assertIn ( 'id' , contract ) #NEWLINE# self . assertIn ( contract [ 'id' ] , response . headers [ 'Location' ] ) #NEWLINE# tender = self . db . get ( self . tender_id ) #NEWLINE# tender [ 'contracts' ] [ ( - 1 ) ] [ 'status' ] = 'terminated' #NEWLINE# self . db . save ( tender ) #NEWLINE# self . set_status ( 'complete' ) #NEWLINE# response = self . app . post_json ( '/tenders/{}/contracts' . format ( self . tender_id ) , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'title' : 'contract title' , #NEWLINE# 'description' : 'contract description' , #NEWLINE# 'awardID' : self . award_id , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , status = 403 ) #NEWLINE# self . assertEqual ( response . status , '403 Forbidden' ) #NEWLINE# self . assertEqual ( response . content_type , 'application/json' ) #NEWLINE# self . assertEqual ( response . json [ 'errors' ] [ 0 ] [ 'description' ] , "Can't add contract in current (complete) tender status" ) #NEWLINE# response = self . app . patch_json ( '/tenders/{}/contracts/{}' . format ( self . tender_id , contract [ 'id' ] ) , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'status' : 'active' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , status = 403 ) #NEWLINE# self . assertEqual ( response . status , '403 Forbidden' ) #NEWLINE# self . assertEqual ( response . content_type , 'application/json' ) #NEWLINE# self . assertEqual ( response . json [ 'errors' ] [ 0 ] [ 'description' ] , "Can't update contract in current (complete) tender status" )