<s> import unittest <EOL> import IECore <EOL> import Gaffer <EOL> import GafferTest <EOL> import GafferScene <EOL> import GafferSceneTest <EOL> class SetFilterTest ( GafferSceneTest . SceneTestCase ) : <EOL> def test ( self ) : <EOL> p1 = GafferScene . Plane ( ) <EOL> p2 = GafferScene . Plane ( ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( p1 [ "<STR_LIT>" ] ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( p2 [ "<STR_LIT>" ] ) <EOL> s = GafferScene . Set ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( g [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> f = GafferScene . SetFilter ( ) <EOL> f [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> a = GafferScene . StandardAttributes ( ) <EOL> a [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] ) <EOL> a [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( True ) <EOL> a [ "<STR_LIT>" ] . setInput ( f [ "<STR_LIT>" ] ) <EOL> self . assertSceneValid ( a [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( "<STR_LIT>" in a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT>" not in a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT>" not in a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) ) <EOL> s [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> self . assertSceneValid ( a [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( "<STR_LIT>" not in a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT>" not in a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT>" in a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) ) <EOL> def testAffects ( self ) : <EOL> p1 = GafferScene . Plane ( ) <EOL> p2 = GafferScene . Plane ( ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( p1 [ "<STR_LIT>" ] ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( p2 [ "<STR_LIT>" ] ) <EOL> s = GafferScene . Set ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( g [ "<STR_LIT>" ] ) <EOL> a = GafferScene . StandardAttributes ( ) <EOL> a [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] ) <EOL> cs = GafferTest . CapturingSlot ( a . plugDirtiedSignal ( ) ) <EOL> s [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( a [ "<STR_LIT>" ] [ "<STR_LIT>" ] in set ( [ c [ <NUM_LIT:0> ] for c in cs ] ) ) <EOL> self . assertTrue ( a [ "<STR_LIT>" ] [ "<STR_LIT>" ] not in set ( [ c [ <NUM_LIT:0> ] for c in cs ] ) ) <EOL> f = GafferScene . SetFilter ( ) <EOL> a [ "<STR_LIT>" ] . setInput ( f [ "<STR_LIT>" ] ) <EOL> cs = GafferTest . CapturingSlot ( a . plugDirtiedSignal ( ) ) <EOL> s [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( a [ "<STR_LIT>" ] [ "<STR_LIT>" ] in set ( [ c [ <NUM_LIT:0> ] for c in cs ] ) ) <EOL> self . assertTrue ( a [ "<STR_LIT>" ] [ "<STR_LIT>" ] in set ( [ c [ <NUM_LIT:0> ] for c in cs ] ) ) <EOL> def testMultipleStreams ( self ) : <EOL> p1 = GafferScene . Plane ( ) <EOL> g1 = GafferScene . Group ( ) <EOL> g1 [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( p1 [ "<STR_LIT>" ] ) <EOL> s1 = GafferScene . Set ( ) <EOL> s1 [ "<STR_LIT>" ] . setInput ( g1 [ "<STR_LIT>" ] ) <EOL> s1 [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> p2 = GafferScene . Plane ( ) <EOL> g2 = GafferScene . Group ( ) <EOL> g2 [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( p2 [ "<STR_LIT>" ] ) <EOL> s2 = GafferScene . Set ( ) <EOL> s2 [ "<STR_LIT>" ] . setInput ( g2 [ "<STR_LIT>" ] ) <EOL> s2 [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> f = GafferScene . SetFilter ( ) <EOL> f [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> a1 = GafferScene . StandardAttributes ( ) <EOL> a1 [ "<STR_LIT>" ] . setInput ( s1 [ "<STR_LIT>" ] ) <EOL> a1 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( True ) <EOL> a1 [ "<STR_LIT>" ] . setInput ( f [ "<STR_LIT>" ] ) <EOL> a2 = GafferScene . StandardAttributes ( ) <EOL> a2 [ "<STR_LIT>" ] . setInput ( s2 [ "<STR_LIT>" ] ) <EOL> a2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( True ) <EOL> a2 [ "<STR_LIT>" ] . setInput ( f [ "<STR_LIT>" ] ) <EOL> self . assertSceneValid ( a1 [ "<STR_LIT>" ] ) <EOL> self . assertSceneValid ( a2 [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( "<STR_LIT>" in a1 [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT>" not in a1 [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT>" not in a2 [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) ) <EOL> self . assertTrue ( "<STR_LIT>" in a2 [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) ) <EOL> def testIsolate ( self ) : <EOL> p1 = GafferScene . Plane ( ) <EOL> p2 = GafferScene . Plane ( ) <EOL> g = GafferScene . Group ( ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( p1 [ "<STR_LIT>" ] ) <EOL> g [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( p2 [ "<STR_LIT>" ] ) <EOL> s1 = GafferScene . Set ( ) <EOL> s1 [ "<STR_LIT:name>" ] . setValue ( "<STR_LIT>" ) <EOL> s1 [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> s1 [ "<STR_LIT>" ] . setInput ( g [ "<STR_LIT>" ] ) <EOL> s2 = GafferScene . Set ( ) <EOL> s2 [ "<STR_LIT:name>" ] . setValue ( "<STR_LIT>" ) <EOL> s2 [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> s2 [ "<STR_LIT>" ] . setInput ( s1 [ "<STR_LIT>" ] ) <EOL> f = GafferScene . SetFilter ( ) <EOL> f [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> i = GafferScene . Isolate ( ) <EOL> i [ "<STR_LIT>" ] . setInput ( s2 [ "<STR_LIT>" ] ) <EOL> i [ "<STR_LIT>" ] . setInput ( f [ "<STR_LIT>" ] ) <EOL> self . assertSceneValid ( i [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( i [ "<STR_LIT>" ] . childNames ( "<STR_LIT>" ) , IECore . InternedStringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( i [ "<STR_LIT>" ] . set ( "<STR_LIT>" ) . value . paths ( ) , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( i [ "<STR_LIT>" ] . set ( "<STR_LIT>" ) . value . paths ( ) , [ "<STR_LIT>" ] ) <EOL> def testNonExistentSets ( self ) : <EOL> p = GafferScene . Plane ( ) <EOL> p [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> a = GafferScene . StandardAttributes ( ) <EOL> a [ "<STR_LIT>" ] . setInput ( p [ "<STR_LIT>" ] ) <EOL> a [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( True ) <EOL> self . assertTrue ( "<STR_LIT>" in a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) . keys ( ) ) <EOL> f = GafferScene . SetFilter ( ) <EOL> a [ "<STR_LIT>" ] . setInput ( f [ "<STR_LIT>" ] ) <EOL> self . assertFalse ( "<STR_LIT>" in a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) . keys ( ) ) <EOL> f [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> self . assertFalse ( "<STR_LIT>" in a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) . keys ( ) ) <EOL> f [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> self . assertTrue ( "<STR_LIT>" in a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) . keys ( ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
