<s> import unittest <EOL> import IECore <EOL> import Gaffer <EOL> import GafferScene <EOL> import GafferSceneTest <EOL> class PointsTypeTest ( GafferSceneTest . SceneTestCase ) : <EOL> def test ( self ) : <EOL> points = IECore . PointsPrimitive ( <NUM_LIT:1> ) <EOL> points [ "<STR_LIT:P>" ] = IECore . PrimitiveVariable ( <EOL> IECore . PrimitiveVariable . Interpolation . Vertex , <EOL> IECore . V3fVectorData ( [ IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ] ) , <EOL> ) <EOL> objectToScene = GafferScene . ObjectToScene ( ) <EOL> objectToScene [ "<STR_LIT:object>" ] . setValue ( points ) <EOL> group = GafferScene . Group ( ) <EOL> group [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( objectToScene [ "<STR_LIT>" ] ) <EOL> filter = GafferScene . PathFilter ( ) <EOL> filter [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT>" ] ) ) <EOL> pointsType = GafferScene . PointsType ( ) <EOL> pointsType [ "<STR_LIT>" ] . setInput ( group [ "<STR_LIT>" ] ) <EOL> pointsType [ "<STR_LIT>" ] . setInput ( filter [ "<STR_LIT>" ] ) <EOL> def assertExpectedOutput ( type , unchanged ) : <EOL> self . assertSceneValid ( pointsType [ "<STR_LIT>" ] ) <EOL> if type is not None : <EOL> self . assertEqual ( pointsType [ "<STR_LIT>" ] . object ( "<STR_LIT>" ) [ "<STR_LIT:type>" ] . data . value , type ) <EOL> else : <EOL> self . assertFalse ( "<STR_LIT:type>" in pointsType [ "<STR_LIT>" ] . object ( "<STR_LIT>" ) ) <EOL> if unchanged : <EOL> self . assertScenesEqual ( pointsType [ "<STR_LIT>" ] , group [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( pointsType [ "<STR_LIT>" ] . object ( "<STR_LIT>" ) , group [ "<STR_LIT>" ] . object ( "<STR_LIT>" ) ) <EOL> self . assertTrue ( <EOL> pointsType [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) . isSame ( group [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) ) <EOL> ) <EOL> assertExpectedOutput ( type = None , unchanged = True ) <EOL> points [ "<STR_LIT:type>" ] = IECore . PrimitiveVariable ( IECore . PrimitiveVariable . Interpolation . Constant , IECore . StringData ( "<STR_LIT>" ) ) <EOL> objectToScene [ "<STR_LIT:object>" ] . setValue ( points ) <EOL> assertExpectedOutput ( type = "<STR_LIT>" , unchanged = True ) <EOL> pointsType [ "<STR_LIT:type>" ] . setValue ( "<STR_LIT>" ) <EOL> assertExpectedOutput ( type = "<STR_LIT>" , unchanged = True ) <EOL> pointsType [ "<STR_LIT:type>" ] . setValue ( "<STR_LIT>" ) <EOL> assertExpectedOutput ( type = "<STR_LIT>" , unchanged = False ) <EOL> pointsType [ "<STR_LIT:type>" ] . setValue ( "<STR_LIT>" ) <EOL> assertExpectedOutput ( type = "<STR_LIT>" , unchanged = False ) <EOL> def testNonPrimitiveObject ( self ) : <EOL> c = GafferScene . Camera ( ) <EOL> p = GafferScene . PointsType ( ) <EOL> p [ "<STR_LIT>" ] . setInput ( c [ "<STR_LIT>" ] ) <EOL> self . assertSceneValid ( p [ "<STR_LIT>" ] ) <EOL> self . failUnless ( isinstance ( p [ "<STR_LIT>" ] . object ( "<STR_LIT>" ) , IECore . Camera ) ) <EOL> self . assertEqual ( p [ "<STR_LIT>" ] . object ( "<STR_LIT>" ) , c [ "<STR_LIT>" ] . object ( "<STR_LIT>" ) ) <EOL> self . assertTrue ( <EOL> p [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) . isSame ( c [ "<STR_LIT>" ] . object ( "<STR_LIT>" , _copy = False ) ) <EOL> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
