#NEWLINE# def test_require_snapshot( self ) : #NEWLINE# #INDENT# snapshot = self . create_snapshot ( self . project , status = SnapshotStatus . active ) #NEWLINE# image = self . create_snapshot_image ( plan = self . plan , snapshot = snapshot ) #NEWLINE# self . create_project_option ( project = self . project , name = 'snapshot.current' , value = snapshot . id . hex ) #NEWLINE# self . create_option ( item_id = self . plan . id , name = 'snapshot.allow' , value = '1' ) #NEWLINE# another_plan = self . create_plan ( self . project ) #NEWLINE# self . create_option ( item_id = another_plan . id , name = 'snapshot.allow' , value = '1' ) #NEWLINE# self . create_option ( item_id = another_plan . id , name = 'snapshot.require' , value = '1' ) #NEWLINE# db . session . commit ( ) #NEWLINE# resp = self . client . post ( self . path , data = { #NEWLINE# #INDENT# 'sha' : ( 'a' * 40 ) , #NEWLINE# 'project' : self . project . slug , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( resp . status_code == 200 ) #NEWLINE# data = self . unserialize ( resp ) #NEWLINE# assert ( len ( data ) == 1 ) #NEWLINE# assert data [ 0 ] [ 'id' ] #NEWLINE# jobs = Job . query . filter ( ( Job . build_id == data [ 0 ] [ 'id' ] ) ) . all ( ) #NEWLINE# assert ( len ( jobs ) == 1 ) #NEWLINE# another_image = self . create_snapshot_image ( plan = resp , snapshot = snapshot ) #NEWLINE# db . session . commit ( ) #NEWLINE# resp = self . client . post ( self . path , data = { #NEWLINE# #INDENT# 'sha' : ( 'a' * 40 ) , #NEWLINE# 'project' : self . project . slug , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( resp . status_code == 200 ) #NEWLINE# data = self . unserialize ( resp ) #NEWLINE# assert ( len ( data ) == 1 ) #NEWLINE# assert data [ 0 ] [ 'id' ] #NEWLINE# jobs = Job . query . filter ( ( Job . build_id == data [ 0 ] [ 'id' ] ) ) . all ( ) #NEWLINE# assert ( len ( jobs ) == 2 )