1
1
import 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
+
2
8
import aika
3
9
4
10
class MyTestCase (unittest .TestCase ):
5
11
def test_something (self ):
6
12
self .assertEqual (True , False ) # add assertion here
7
13
8
14
def testSubtraction (self ):
15
+ print ("Module 'aika' was loaded from:" , aika .__file__ )
16
+
9
17
TEST_RELATION_FROM = aika .RelationOne (1 , "TEST_FROM" )
10
18
TEST_RELATION_TO = aika .RelationOne (2 , "TEST_TO" )
11
19
TEST_RELATION_TO .setReversed (TEST_RELATION_FROM )
12
20
TEST_RELATION_FROM .setReversed (TEST_RELATION_TO )
13
21
22
+ assert isinstance (TEST_RELATION_FROM , aika .Relation )
23
+ assert isinstance (TEST_RELATION_TO , aika .Relation )
24
+
14
25
registry = aika .TypeRegistry ()
15
26
16
27
typeA = aika .TestType (registry , "A" )
@@ -20,31 +31,22 @@ def testSubtraction(self):
20
31
b = typeB .inputField ("b" )
21
32
22
33
c = typeB .sub ("c" )
23
- c .in (TEST_RELATION_FROM , a , 0 )
24
- c .in (TEST_RELATION_FROM , b , 1 )
25
-
26
- registry .flattenTypeHierarchy ()
27
34
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 ))
34
38
35
- oa .setFieldValue (a , 50.0 )
39
+ assert isinstance (a , aika .FieldDefinition )
40
+ assert isinstance (c , aika .FieldDefinition )
36
41
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 )
40
44
41
- oa . setFieldValue ( b , 20.0 )
45
+ registry . flattenTypeHierarchy ( )
42
46
43
- if (linkingPos == 2 )
44
- linkObjects (oa , ob )
45
- ob .initFields ()
47
+ oa = typeA .instantiate ()
48
+ ob = typeB .instantiate ()
46
49
47
- Assertions .assertEquals (30.0 , ob .getFieldOutput (c ).getValue ())
48
50
49
51
if __name__ == '__main__' :
50
52
unittest .main ()
0 commit comments