6 from testlib
import InnerModel
7 from testlib
import NestedModel
9 from cola
.model
import Model
11 class TestSaveRestore(unittest
.TestCase
):
13 testlib
.create_test_dir()
15 self
.nested
= NestedModel()
16 path
= os
.path
.join(testlib
.get_test_dir(), 'test.data')
18 self
.nested
.save(path
)
19 self
.clone
= Model
.instance(path
)
22 testdir
= testlib
.get_test_dir()
23 if os
.path
.exists(testdir
):
24 testlib
.remove_test_dir()
26 def testCloneToClass(self
):
27 self
.failUnless( str(NestedModel
) ==
28 str(self
.clone
.__class
__) )
30 def testClonedInnerToClass(self
):
31 self
.failUnless( str(InnerModel
) ==
32 str(self
.clone
.inner
.__class
__) )
34 def testClonedListAndParam(self
):
35 self
.failUnless( str(self
.clone
.inner
.__class
__) ==
36 str(self
.clone
.innerList
[0].__class
__) )
39 self
.failUnless( str(InnerModel
) ==
40 str(self
.clone
.innerList
[1][0].__class
__) )
42 def testListInList(self
):
43 self
.failUnless( str(InnerModel
) ==
44 str(self
.clone
.innerList
[2][0][0].__class
__))
46 def testListInListInList(self
):
47 self
.failUnless( str(InnerModel
) ==
48 str(self
.clone
.innerList
[3][0][0][0].__class
__))
50 def testDictInList(self
):
51 self
.failUnless( str(dict) ==
52 str(self
.clone
.innerList
[4].__class
__))
54 def testObjectInDictInList(self
):
55 self
.failUnless( str(InnerModel
) ==
56 str(self
.clone
.innerList
[-1]["foo"].__class
__))
58 if __name__
== '__main__':