#NEWLINE# def testDispatchFullRange( self ) : #NEWLINE# #INDENT# dispatcher = GafferDispatch . Dispatcher . create ( 'LocalTest' ) #NEWLINE# dispatcher [ 'framesMode' ] . setValue ( GafferDispatch . Dispatcher . FramesMode . FullRange ) #NEWLINE# frameList = IECore . FrameList . parse ( '5-7' ) #NEWLINE# fileName = '/tmp/dispatcherTest/result.txt' #NEWLINE# def createWriter( text ) : #NEWLINE# #INDENT# node = GafferDispatchTest . TextWriter ( ) #NEWLINE# node [ 'mode' ] . setValue ( 'a' ) #NEWLINE# node [ 'fileName' ] . setValue ( fileName ) #NEWLINE# node [ 'text' ] . setValue ( ( text + ' on ${frame};' ) ) #NEWLINE# return node #NEWLINE# #UNINDENT# s = Gaffer . ScriptNode ( ) #NEWLINE# s [ 'frameRange' ] [ 'start' ] . setValue ( 5 ) #NEWLINE# s [ 'frameRange' ] [ 'end' ] . setValue ( 7 ) #NEWLINE# s [ 'n1' ] = createWriter ( 'n1' ) #NEWLINE# s [ 'n2' ] = createWriter ( 'n2' ) #NEWLINE# s [ 'n2a' ] = createWriter ( 'n2a' ) #NEWLINE# s [ 'n2b' ] = createWriter ( 'n2b' ) #NEWLINE# s [ 'n1' ] [ 'preTasks' ] [ 0 ] . setInput ( s [ 'n2' ] [ 'task' ] ) #NEWLINE# s [ 'n2' ] [ 'preTasks' ] [ 0 ] . setInput ( s [ 'n2a' ] [ 'task' ] ) #NEWLINE# s [ 'n2' ] [ 'preTasks' ] [ 1 ] . setInput ( s [ 'n2b' ] [ 'task' ] ) #NEWLINE# self . assertEqual ( os . path . isfile ( fileName ) , False ) #NEWLINE# dispatcher . dispatch ( [ s [ 'n1' ] ] ) #NEWLINE# self . assertEqual ( os . path . isfile ( fileName ) , True ) #NEWLINE# with file ( fileName , 'r' ) as f : #NEWLINE# #INDENT# text = f . read ( ) #NEWLINE# #UNINDENT# expectedText = '' #NEWLINE# for frame in frameList . asList ( ) : #NEWLINE# #INDENT# context = Gaffer . Context ( s . context ( ) ) #NEWLINE# context . setFrame ( frame ) #NEWLINE# expectedText += context . substitute ( 'n2a on ${frame};n2b on ${frame};n2 on ${frame};n1 on ${frame};' ) #NEWLINE# #UNINDENT# self . assertEqual ( text , expectedText ) #NEWLINE# os . remove ( fileName ) #NEWLINE# dispatcher . dispatch ( [ s [ 'n2b' ] ] ) #NEWLINE# self . assertEqual ( os . path . isfile ( fileName ) , True ) #NEWLINE# with file ( self , 'r' ) as f : #NEWLINE# #INDENT# text = f . read ( ) #NEWLINE# #UNINDENT# expectedText = '' #NEWLINE# for frame in frameList . asList ( ) : #NEWLINE# #INDENT# context = Gaffer . Context ( s . context ( ) ) #NEWLINE# context . setFrame ( frame ) #NEWLINE# expectedText += context . substitute ( 'n2b on ${frame};' ) #NEWLINE# #UNINDENT# self . assertEqual ( text , expectedText )