11import unittest
2+ import sys
3+ import os
4+
5+ # Add the project root to Python's module search path
6+ sys .path .append (os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." )))
7+
28import aika
39
410class MyTestCase (unittest .TestCase ):
511 def test_something (self ):
612 self .assertEqual (True , False ) # add assertion here
713
814 def testSubtraction (self ):
15+ print ("Module 'aika' was loaded from:" , aika .__file__ )
16+
917 TEST_RELATION_FROM = aika .RelationOne (1 , "TEST_FROM" )
1018 TEST_RELATION_TO = aika .RelationOne (2 , "TEST_TO" )
1119 TEST_RELATION_TO .setReversed (TEST_RELATION_FROM )
1220 TEST_RELATION_FROM .setReversed (TEST_RELATION_TO )
1321
22+ assert isinstance (TEST_RELATION_FROM , aika .Relation )
23+ assert isinstance (TEST_RELATION_TO , aika .Relation )
24+
1425 registry = aika .TypeRegistry ()
1526
1627 typeA = aika .TestType (registry , "A" )
@@ -20,31 +31,22 @@ def testSubtraction(self):
2031 b = typeB .inputField ("b" )
2132
2233 c = typeB .sub ("c" )
23- c .in (TEST_RELATION_FROM , a , 0 )
24- c .in (TEST_RELATION_FROM , b , 1 )
25-
26- registry .flattenTypeHierarchy ()
2734
28- oa = typeA .instantiate ()
29- ob = typeB .instantiate ()
30-
31- if (linkingPos == 0 )
32- linkObjects (oa , ob )
33- ob .initFields ()
35+ print ("Type of c:" , type (c ))
36+ print ("Type of TEST_RELATION_FROM:" , type (TEST_RELATION_FROM ))
37+ print ("Type of a:" , type (a ))
3438
35- oa .setFieldValue (a , 50.0 )
39+ assert isinstance (a , aika .FieldDefinition )
40+ assert isinstance (c , aika .FieldDefinition )
3641
37- if (linkingPos == 1 )
38- linkObjects (oa , ob )
39- ob .initFields ()
42+ c .input (TEST_RELATION_FROM , a , 0 )
43+ c .input (TEST_RELATION_FROM , b , 1 )
4044
41- oa . setFieldValue ( b , 20.0 )
45+ registry . flattenTypeHierarchy ( )
4246
43- if (linkingPos == 2 )
44- linkObjects (oa , ob )
45- ob .initFields ()
47+ oa = typeA .instantiate ()
48+ ob = typeB .instantiate ()
4649
47- Assertions .assertEquals (30.0 , ob .getFieldOutput (c ).getValue ())
4850
4951if __name__ == '__main__' :
5052 unittest .main ()
0 commit comments