MCPcopy Create free account
hub / github.com/ImageEngine/cortex / test

Method test

test/IECore/FileSequenceParameter.py:61–99  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

59 self.touch( os.path.join( directory, f ) )
60
61 def test( self ) :
62
63 s = IECore.FileSequence( "a.#.tif", IECore.FrameRange( 1, 10 ) )
64 self.mkSequence( s )
65
66 p = IECore.FileSequenceParameter( name = "n", description = "d", check = IECore.FileSequenceParameter.CheckType.MustExist )
67 # should raise because it's not a valid sequence string
68 self.assertRaises( RuntimeError, p.setValidatedValue, IECore.StringData( "hello" ) )
69 # should raise because it doesn't exist
70 self.assertRaises( RuntimeError, p.setValidatedValue, IECore.StringData( "hello.###.tif" ) )
71 p.setValidatedValue( IECore.StringData( os.path.join( "test", "sequences", "parameterTest", "a.#.tif" ) ) )
72
73 p = IECore.FileSequenceParameter( name = "n", description = "d", check = IECore.FileSequenceParameter.CheckType.MustNotExist )
74 # should raise because it's not a valid sequence string
75 self.assertRaises( RuntimeError, p.setValidatedValue, IECore.StringData( "hello" ) )
76 # should be fine because it's a valid string and no sequence like that exists
77 p.setValidatedValue( IECore.StringData( "hello.###.tif" ) )
78 # should raise because the sequence exists
79 self.assertRaises( RuntimeError, p.setValidatedValue, IECore.StringData( os.path.join( "test", "sequences", "parameterTest", "a.#.tif" ) ) )
80
81 p = IECore.FileSequenceParameter( name = "n", description = "d", check = IECore.FileSequenceParameter.CheckType.DontCare )
82 # should raise because it's not a valid sequence string
83 self.assertRaises( RuntimeError, p.setValidatedValue, IECore.StringData( "hello" ) )
84 p.setValidatedValue( IECore.StringData( "hello.###.tif" ) )
85 p.setValidatedValue( IECore.StringData( os.path.join( "test", "sequences", "parameterTest", "a.#.tif" ) ) )
86 # for MustNotExist and DontCare, the getFileSequenceValue does not check the file system. It returns a FileSequence with EmptyFrameList.
87 self.assertEqual( p.getFileSequenceValue().frameList, IECore.EmptyFrameList() )
88
89 p = IECore.FileSequenceParameter( name = "n", description = "d", check = IECore.FileSequenceParameter.CheckType.MustExist )
90 p.setValidatedValue( IECore.StringData( os.path.join( "test", "sequences", "parameterTest", "a.#.tif" ) ) )
91 # for MustExist getFileSequence should use ls internally.
92 self.assertEqual( p.getFileSequenceValue(), IECore.ls( os.path.join( "test", "sequences", "parameterTest", "a.#.tif" ) ) )
93 self.assertEqual( p.getFileSequenceValue( IECore.StringData( os.path.join( "test", "sequences", "parameterTest", "a.#.tif" ) ) ), IECore.ls( os.path.join( "test", "sequences", "parameterTest", "a.#.tif" ) ) )
94
95 p.setFileSequenceValue( IECore.FileSequence( os.path.join( "test", "sequences", "parameterTest", "a.#.tif" ), IECore.FrameRange( 1, 10 ) ) )
96 # Setting a frame range should reflect on the parameter value.
97 self.assertEqual( p.getValue(), IECore.StringData( os.path.join( "test", "sequences", "parameterTest", "a.#.tif 1-10" ) ) )
98 self.assertEqual( p.getFileSequenceValue(), IECore.ls( os.path.join( "test", "sequences", "parameterTest", "a.#.tif" ) ) )
99 self.assertEqual( p.getFileSequenceValue( IECore.StringData( os.path.join( "test", "sequences", "parameterTest", "a.#.tif 1-10" ) ) ), IECore.ls( os.path.join( "test", "sequences", "parameterTest", "a.#.tif" ) ) )
100
101 def testMinSequenceSize( self ):
102

Callers

nothing calls this directly

Calls 11

mkSequenceMethod · 0.95
getFileSequenceValueMethod · 0.95
setFileSequenceValueMethod · 0.95
FileSequenceMethod · 0.80
FrameRangeMethod · 0.80
FileSequenceParameterMethod · 0.80
setValidatedValueMethod · 0.80
joinMethod · 0.80
EmptyFrameListMethod · 0.80
lsMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected