<s> import IECore <EOL> import Gaffer <EOL> import GafferTest <EOL> class NodeAlgoTest ( GafferTest . TestCase ) : <EOL> def test ( self ) : <EOL> node = GafferTest . AddNode ( ) <EOL> self . assertEqual ( node [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> self . assertFalse ( Gaffer . NodeAlgo . hasUserDefault ( node [ "<STR_LIT>" ] ) ) <EOL> Gaffer . Metadata . registerPlugValue ( GafferTest . AddNode . staticTypeId ( ) , "<STR_LIT>" , "<STR_LIT>" , IECore . IntData ( <NUM_LIT:7> ) ) <EOL> self . assertTrue ( Gaffer . NodeAlgo . hasUserDefault ( node [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( Gaffer . NodeAlgo . isSetToUserDefault ( node [ "<STR_LIT>" ] ) ) <EOL> Gaffer . NodeAlgo . applyUserDefaults ( node ) <EOL> self . assertEqual ( node [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:7> ) <EOL> self . assertTrue ( Gaffer . NodeAlgo . isSetToUserDefault ( node [ "<STR_LIT>" ] ) ) <EOL> node2 = GafferTest . AddNode ( ) <EOL> self . assertEqual ( node2 [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> Gaffer . NodeAlgo . applyUserDefaults ( node2 ) <EOL> self . assertEqual ( node2 [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:7> ) <EOL> node2 [ "<STR_LIT>" ] . setValue ( <NUM_LIT:1> ) <EOL> Gaffer . NodeAlgo . applyUserDefault ( node2 [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( node2 [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:7> ) <EOL> node3 = GafferTest . AddNode ( ) <EOL> Gaffer . Metadata . registerPlugValue ( GafferTest . AddNode . staticTypeId ( ) , "<STR_LIT>" , "<STR_LIT>" , None ) <EOL> self . assertFalse ( Gaffer . NodeAlgo . hasUserDefault ( node3 [ "<STR_LIT>" ] ) ) <EOL> Gaffer . NodeAlgo . applyUserDefaults ( node3 ) <EOL> self . assertEqual ( node3 [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> self . assertFalse ( Gaffer . NodeAlgo . isSetToUserDefault ( node [ "<STR_LIT>" ] ) ) <EOL> def testCompoundPlug ( self ) : <EOL> node = GafferTest . CompoundPlugNode ( ) <EOL> self . assertEqual ( node [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> Gaffer . Metadata . registerPlugValue ( GafferTest . CompoundPlugNode . staticTypeId ( ) , "<STR_LIT>" , "<STR_LIT>" , IECore . StringData ( "<STR_LIT>" ) ) <EOL> self . assertFalse ( Gaffer . NodeAlgo . isSetToUserDefault ( node [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] ) ) <EOL> Gaffer . NodeAlgo . applyUserDefaults ( node ) <EOL> self . assertEqual ( node [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertTrue ( Gaffer . NodeAlgo . isSetToUserDefault ( node [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] ) ) <EOL> Gaffer . Metadata . registerPlugValue ( node [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] , "<STR_LIT>" , IECore . StringData ( "<STR_LIT>" ) ) <EOL> self . assertFalse ( Gaffer . NodeAlgo . isSetToUserDefault ( node [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] ) ) <EOL> Gaffer . NodeAlgo . applyUserDefaults ( node ) <EOL> self . assertEqual ( node [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertTrue ( Gaffer . NodeAlgo . isSetToUserDefault ( node [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] ) ) <EOL> node2 = GafferTest . CompoundPlugNode ( ) <EOL> self . assertFalse ( Gaffer . NodeAlgo . isSetToUserDefault ( node2 [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] ) ) <EOL> Gaffer . NodeAlgo . applyUserDefaults ( node2 ) <EOL> self . assertEqual ( node2 [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertTrue ( Gaffer . NodeAlgo . isSetToUserDefault ( node2 [ "<STR_LIT:p>" ] [ "<STR_LIT:s>" ] ) ) <EOL> def testSeveral ( self ) : <EOL> node = GafferTest . AddNode ( ) <EOL> node2 = GafferTest . AddNode ( ) <EOL> self . assertEqual ( node [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( node2 [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> Gaffer . Metadata . registerPlugValue ( GafferTest . AddNode . staticTypeId ( ) , "<STR_LIT>" , "<STR_LIT>" , IECore . IntData ( <NUM_LIT:1> ) ) <EOL> Gaffer . Metadata . registerPlugValue ( node2 [ "<STR_LIT>" ] , "<STR_LIT>" , IECore . IntData ( <NUM_LIT:2> ) ) <EOL> Gaffer . NodeAlgo . applyUserDefaults ( [ node , node2 ] ) <EOL> self . assertEqual ( node [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( node2 [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:2> ) <EOL> def testPresets ( self ) : <EOL> node = GafferTest . AddNode ( ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . presets ( node [ "<STR_LIT>" ] ) , [ ] ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . currentPreset ( node [ "<STR_LIT>" ] ) , None ) <EOL> Gaffer . Metadata . registerPlugValue ( node [ "<STR_LIT>" ] , "<STR_LIT>" , <NUM_LIT:1> ) <EOL> Gaffer . Metadata . registerPlugValue ( node [ "<STR_LIT>" ] , "<STR_LIT>" , <NUM_LIT:2> ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . presets ( node [ "<STR_LIT>" ] ) , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . currentPreset ( node [ "<STR_LIT>" ] ) , None ) <EOL> Gaffer . NodeAlgo . applyPreset ( node [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> self . assertEqual ( node [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . currentPreset ( node [ "<STR_LIT>" ] ) , "<STR_LIT>" ) <EOL> Gaffer . NodeAlgo . applyPreset ( node [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> self . assertEqual ( node [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . currentPreset ( node [ "<STR_LIT>" ] ) , "<STR_LIT>" ) <EOL> def testPresetsArray ( self ) : <EOL> node = GafferTest . AddNode ( ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . presets ( node [ "<STR_LIT>" ] ) , [ ] ) <EOL> Gaffer . Metadata . registerPlugValue ( <EOL> node [ "<STR_LIT>" ] , "<STR_LIT>" , <EOL> IECore . StringVectorData ( [ "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:c>" ] ) <EOL> ) <EOL> Gaffer . Metadata . registerPlugValue ( <EOL> node [ "<STR_LIT>" ] , "<STR_LIT>" , <EOL> IECore . IntVectorData ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . presets ( node [ "<STR_LIT>" ] ) , [ "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:c>" ] ) <EOL> Gaffer . NodeAlgo . applyPreset ( node [ "<STR_LIT>" ] , "<STR_LIT:a>" ) <EOL> self . assertEqual ( node [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . currentPreset ( node [ "<STR_LIT>" ] ) , "<STR_LIT:a>" ) <EOL> Gaffer . NodeAlgo . applyPreset ( node [ "<STR_LIT>" ] , "<STR_LIT:b>" ) <EOL> self . assertEqual ( node [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . currentPreset ( node [ "<STR_LIT>" ] ) , "<STR_LIT:b>" ) <EOL> Gaffer . NodeAlgo . applyPreset ( node [ "<STR_LIT>" ] , "<STR_LIT:c>" ) <EOL> self . assertEqual ( node [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . currentPreset ( node [ "<STR_LIT>" ] ) , "<STR_LIT:c>" ) <EOL> Gaffer . Metadata . registerPlugValue ( node [ "<STR_LIT>" ] , "<STR_LIT>" , <NUM_LIT:10> ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . currentPreset ( node [ "<STR_LIT>" ] ) , None ) <EOL> Gaffer . NodeAlgo . applyPreset ( node [ "<STR_LIT>" ] , "<STR_LIT:c>" ) <EOL> self . assertEqual ( node [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( Gaffer . NodeAlgo . currentPreset ( node [ "<STR_LIT>" ] ) , "<STR_LIT:c>" ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
