@@ -699,7 +699,43 @@ def testLinkBoundTransformMismatch( self ) :
699
699
self .assertEqual ( parent .readTransformAtSample ( 0 ), transform )
700
700
self .failUnless ( LinkedSceneTest .compareBBox ( linked .readBoundAtSample ( 0 ), IECore .Box3d ( IECore .V3d ( 1 , 0 , 0 ), IECore .V3d ( 3 , 1 , 1 ) ) ) )
701
701
self .failUnless ( LinkedSceneTest .compareBBox ( linked .readBoundAtSample ( 0 ), linked .readBoundAtSample ( 1 ) ) )
702
-
702
+
703
+ def testMemoryIndexedIOReadWrite ( self ) :
704
+
705
+ # create inital file structure in memory:
706
+ mio = IECore .MemoryIndexedIO ( IECore .CharVectorData (), IECore .IndexedIO .OpenMode .Write )
707
+
708
+ # write to the actual linkedscene:
709
+ scc = IECore .SceneCache ( mio )
710
+ l = IECore .LinkedScene ( scc )
711
+
712
+ c0 = l .createChild ("child0" )
713
+ c1 = l .createChild ("child1" )
714
+
715
+ c0 .writeAttribute ( "testAttr" , IECore .StringData ("test0" ), 0 )
716
+ c1 .writeAttribute ( "testAttr" , IECore .StringData ("test1" ), 0 )
717
+
718
+ # write the "file" to memory
719
+ del l , scc , c0 , c1
720
+
721
+ # can we read it back again?
722
+ mioData = mio .buffer ()
723
+ mio = IECore .MemoryIndexedIO ( mioData , IECore .IndexedIO .OpenMode .Read )
724
+
725
+ scc = IECore .SceneCache ( mio )
726
+ l = IECore .LinkedScene ( scc )
727
+
728
+ self .assertEqual ( set ( l .childNames () ), set ( ["child0" , "child1" ] ) )
729
+
730
+ # no write access!
731
+ self .assertRaises ( RuntimeError , l .createChild , "child2" )
732
+
733
+ c0 = l .child ("child0" )
734
+ c1 = l .child ("child1" )
735
+
736
+ self .assertEqual ( c0 .readAttribute ( "testAttr" , 0 ), IECore .StringData ( "test0" ) )
737
+ self .assertEqual ( c1 .readAttribute ( "testAttr" , 0 ), IECore .StringData ( "test1" ) )
738
+
703
739
if __name__ == "__main__" :
704
740
unittest .main ()
705
741
0 commit comments