Beispiel #1
0
    def testReflexive(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])
        
        endpint1 = xtuml.SingleAssociationLink('A', ids=['Id'], phrase='prev')
        endpint2 = xtuml.SingleAssociationLink('A', ids=['Next_Id'], phrase='next')
        self.metamodel.define_relation('R1', endpint1, endpint2)
        
        first = self.metamodel.new('A', Name="First")
        second = self.metamodel.new('A', Name="Second")

        self.assertTrue(xtuml.relate(first, second, 1, 'prev'))

        inst = xtuml.navigate_one(first).A[1, 'next']()
        self.assertEqual(inst.Name, second.Name)

        inst = xtuml.navigate_one(first).A[1, 'prev']()
        self.assertIsNone(inst)
        
        inst = xtuml.navigate_one(second).A[1, 'prev']()
        self.assertEqual(inst.Name, first.Name)
        
        inst = xtuml.navigate_one(second).A[1, 'next']()
        self.assertIsNone(inst)
Beispiel #2
0
    def test_reflexive(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])
        
        ass = self.metamodel.define_association(rel_id='R1', 
                                                source_kind='A', 
                                                source_keys=['Id'], 
                                                source_many=False, 
                                                source_conditional=False,
                                                source_phrase='prev',
                                                target_kind='A',
                                                target_keys=['Next_Id'],
                                                target_many=False,
                                                target_conditional=False,
                                                target_phrase='next')
        ass.formalize()
        
        first = self.metamodel.new('A', Name="First")
        second = self.metamodel.new('A', Name="Second")

        self.assertTrue(xtuml.relate(first, second, 1, 'prev'))

        inst = xtuml.navigate_one(first).A[1, 'prev']()
        self.assertEqual(inst.Name, second.Name)

        inst = xtuml.navigate_one(first).A[1, 'next']()
        self.assertIsNone(inst)
        
        inst = xtuml.navigate_one(second).A[1, 'next']()
        self.assertEqual(inst.Name, first.Name)
        
        inst = xtuml.navigate_one(second).A[1, 'prev']()
        self.assertIsNone(inst)
Beispiel #3
0
 def test_relate(self):
     s_edt = self.m.new('S_EDT')
     s_dt = self.m.new('S_DT')
     pe_pe = self.m.new('PE_PE')
     self.assertFalse(xtuml.navigate_one(s_dt).S_EDT[17]())
     self.assertTrue(xtuml.relate(s_dt, pe_pe, 8001))
     self.assertTrue(xtuml.relate(s_dt, s_edt, 17))
     self.assertEqual(s_edt, xtuml.navigate_one(s_dt).S_EDT[17]())
 def test_relate(self):
     s_edt = self.m.new('S_EDT')
     s_dt = self.m.new('S_DT')
     pe_pe = self.m.new('PE_PE')
     self.assertFalse(xtuml.navigate_one(s_dt).S_EDT[17]())
     self.assertTrue(xtuml.relate(s_dt, pe_pe, 8001))
     self.assertTrue(xtuml.relate(s_dt, s_edt, 17))
     self.assertEqual(s_edt, xtuml.navigate_one(s_dt).S_EDT[17]())
Beispiel #5
0
 def test_delete(self):
     inst = self.metamodel.select_any('S_DT', where(Name='void'))
     self.assertTrue(xtuml.navigate_one(inst).PE_PE[8001]())
     
     xtuml.delete(inst)
     self.assertFalse(xtuml.navigate_one(inst).PE_PE[8001]())
     
     inst = self.metamodel.select_any('S_DT', where(Name='void'))
     self.assertFalse(inst)
Beispiel #6
0
    def testRelateReflexive2(self):
        inst1 = self.metamodel.new('ACT_SMT')
        inst2 = self.metamodel.new('ACT_SMT')
        act_blk = self.metamodel.new('ACT_BLK')

        self.assertTrue(xtuml.relate(inst1, act_blk, 602))
        self.assertTrue(xtuml.relate(inst2, act_blk, 602))
        self.assertTrue(xtuml.relate(inst2, inst1, 661, 'succeeds'))
        self.assertEqual(inst2, xtuml.navigate_one(inst1).ACT_SMT[661, 'succeeds']())
        self.assertEqual(inst1, xtuml.navigate_one(inst2).ACT_SMT[661, 'precedes']())
    def test_relate_reflexive_one_to_other(self):
        inst1 = self.m.new('ACT_SMT')
        inst2 = self.m.new('ACT_SMT')
        act_blk = self.m.new('ACT_BLK')

        self.assertTrue(xtuml.relate(inst1, act_blk, 602))
        self.assertTrue(xtuml.relate(inst2, act_blk, 602))
        self.assertTrue(xtuml.relate(inst1, inst2, 661, 'succeeds'))
        self.assertEqual(inst2, xtuml.navigate_one(inst1).ACT_SMT[661, 'succeeds']())
        self.assertEqual(inst1, xtuml.navigate_one(inst2).ACT_SMT[661, 'precedes']())
Beispiel #8
0
    def test_relate_reflexive_other_to_one(self):
        inst1 = self.m.new('ACT_SMT')
        inst2 = self.m.new('ACT_SMT')
        act_blk = self.m.new('ACT_BLK')

        self.assertTrue(xtuml.relate(inst1, act_blk, 602))
        self.assertTrue(xtuml.relate(inst2, act_blk, 602))
        self.assertTrue(xtuml.relate(inst2, inst1, 661, 'precedes'))
        self.assertEqual(inst2,
                         xtuml.navigate_one(inst1).ACT_SMT[661, 'succeeds']())
        self.assertEqual(inst1,
                         xtuml.navigate_one(inst2).ACT_SMT[661, 'precedes']())
Beispiel #9
0
    def test_serialize_schema(self):
        schema = '''
            CREATE TABLE X (BOOLEAN BOOLEAN,
                            INTEGER INTEGER,
                            REAL REAL,
                            STRING STRING,
                            UNIQUE_ID UNIQUE_ID,
                            Next UNIQUE_ID);
                            
        CREATE ROP REF_ID R1 FROM 1C X ( Next ) PHRASE 'precedes'
                             TO   1C X ( UNIQUE_ID ) PHRASE 'succeeds';
        '''
        loader = xtuml.ModelLoader()
        loader.input(schema)
        m = loader.build_metamodel()
        x1 = m.new('X', Boolean=True, Integer=4, String='str')
        x2 = m.new('X', Boolean=True, Integer=4, String='str')
        xtuml.relate(x1, x2, 1, 'precedes')

        s = xtuml.serialize_schema(m)
        loader = xtuml.ModelLoader()
        loader.input(s)
        m = loader.build_metamodel()

        self.assertFalse(m.select_any('X'))

        x1 = m.new('X', Boolean=True, Integer=4, String='str')
        x2 = m.new('X', Boolean=True, Integer=4, String='str')
        xtuml.relate(x1, x2, 1, 'succeeds')

        self.assertTrue(xtuml.navigate_one(x1).X[1, 'succeeds']())
    def test_serialize_schema(self):
        schema = '''
            CREATE TABLE X (BOOLEAN BOOLEAN,
                            INTEGER INTEGER,
                            REAL REAL,
                            STRING STRING,
                            UNIQUE_ID UNIQUE_ID,
                            Next UNIQUE_ID);
                            
        CREATE ROP REF_ID R1 FROM 1C X ( Next ) PHRASE 'precedes'
                             TO   1C X ( UNIQUE_ID ) PHRASE 'succeeds';
        '''
        loader = xtuml.ModelLoader()
        loader.input(schema)
        m = loader.build_metamodel()
        x1 = m.new('X', Boolean=True, Integer=4, String='str')
        x2 = m.new('X', Boolean=True, Integer=4, String='str')
        xtuml.relate(x1, x2, 1, 'precedes')
        
        s = xtuml.serialize_schema(m)
        loader = xtuml.ModelLoader()
        loader.input(s)
        m = loader.build_metamodel()

        self.assertFalse(m.select_any('X'))

        x1 = m.new('X', Boolean=True, Integer=4, String='str')
        x2 = m.new('X', Boolean=True, Integer=4, String='str')
        xtuml.relate(x1, x2, 1, 'succeeds')

        self.assertTrue(xtuml.navigate_one(x1).X[1, 'succeeds']())
Beispiel #11
0
    def test_unrelate(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('B_Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id')])
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='B',
                                          source_keys=['B_Id'],
                                          target_keys=['Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='',
                                          target_phrase='')

        a = self.metamodel.new('A')
        b = self.metamodel.new('B')
        xtuml.relate(a, b, 1)

        text = '''
        .select any a from instances of A
        .select any b from instances of B
        .print "${a}"
        .print "${b}"
        .unrelate a from b across R1
        '''
        self.eval_text(text)

        a = self.metamodel.select_any('A')
        b = xtuml.navigate_one(a).B[1]()
        self.assertFalse(b)
Beispiel #12
0
    def test_relate(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('B_Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id')])
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='B',
                                          source_keys=['B_Id'],
                                          target_keys=['Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='',
                                          target_phrase='')
        text = '''
        .create object instance a of A
        .create object instance b of B
        .relate a to b across R1
        '''
        self.eval_text(text)

        a = self.metamodel.select_any('A')
        b = xtuml.navigate_one(a).B[1]()
        self.assertTrue(b)
Beispiel #13
0
    def test_relate_reflexive(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])

        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='A',
                                          source_keys=['Id'],
                                          target_keys=['Next_Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='prev',
                                          target_phrase='next')

        text = '''
        .create object instance a1 of A
        .create object instance a2 of A
        .assign a1.Name = "First"
        .assign a2.Name = "Second"
        .relate a2 to a1 across R1.'next'
        '''

        self.eval_text(text)
        a1 = self.metamodel.select_any('A', lambda sel: sel.Name == "First")
        a2 = xtuml.navigate_one(a1).A[1, 'prev']()
        self.assertTrue(a2)
        self.assertEqual(a2.Name, 'Second')
Beispiel #14
0
    def test_unrelate_reflexive(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])

        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='A',
                                          source_keys=['Id'],
                                          target_keys=['Next_Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='prev',
                                          target_phrase='next')

        first = self.metamodel.new('A', Name="First")
        second = self.metamodel.new('A', Name="Second")
        xtuml.relate(first, second, 1, 'prev')

        text = '''
        .select any first_inst from instances of A where (selected.Name == "First")
        .select one second_inst related by first_inst->A[R1.'next']
        .unrelate first_inst from second_inst across R1.'prev'
        '''

        self.eval_text(text)
        a1 = self.metamodel.select_any('A', lambda sel: sel.Name == "First")
        a2 = xtuml.navigate_one(a1).A[1, 'next']()
        self.assertFalse(a2)
Beispiel #15
0
 def testRelateInvertedOrder(self):
     s_edt = self.metamodel.new('S_EDT')
     s_dt = self.metamodel.new('S_DT')
     pe_pe = self.metamodel.new('PE_PE')
     self.assertTrue(xtuml.relate(pe_pe, s_dt, 8001))
     self.assertTrue(xtuml.relate(s_edt, s_dt, 17))
     self.assertEqual(s_edt, xtuml.navigate_one(s_dt).S_EDT[17]())
Beispiel #16
0
    def test_clone(self):
        s_ee = self.metamodel.new('S_EE',
                                  Name='Test',
                                  Descrip='test',
                                  Key_Lett='TEST')
        pe_pe = self.metamodel.new('PE_PE')
        self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))

        m = ooaofooa.empty_model()
        self.assertNotEqual(pe_pe, m.clone(pe_pe))
        self.assertNotEqual(s_ee, m.clone(s_ee))

        s_ee_clone = m.select_any('S_EE', where(Name='Test'))
        self.assertNotEqual(s_ee, s_ee_clone)
        self.assertEqual(s_ee_clone.EE_ID, s_ee.EE_ID)
        self.assertEqual(s_ee_clone.Name, s_ee.Name)
        self.assertEqual(s_ee_clone.Descrip, s_ee.Descrip)
        self.assertEqual(s_ee_clone.Key_Lett, s_ee.Key_Lett)

        pe_pe_clone = xtuml.navigate_one(s_ee_clone).PE_PE[8001]()
        self.assertTrue(pe_pe_clone)
        self.assertNotEqual(pe_pe, pe_pe_clone)
        self.assertEqual(pe_pe_clone.Element_ID, pe_pe.Element_ID)
        self.assertEqual(pe_pe_clone.Visibility, pe_pe.Visibility)
        self.assertEqual(pe_pe_clone.Package_ID, pe_pe.Package_ID)
        self.assertEqual(pe_pe_clone.Component_ID, pe_pe.Component_ID)
        self.assertEqual(pe_pe_clone.type, pe_pe.type)
    def test_unrelate(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'), ('B_Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id')])
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='B',
                                          source_keys=['B_Id'],
                                          target_keys=['Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='',
                                          target_phrase='')

        a = self.metamodel.new('A')
        b = self.metamodel.new('B')
        xtuml.relate(a, b, 1)

        text = '''
        .select any a from instances of A
        .select any b from instances of B
        .print "${a}"
        .print "${b}"
        .unrelate a from b across R1
        '''
        self.eval_text(text)
        
        a = self.metamodel.select_any('A')
        b = xtuml.navigate_one(a).B[1]()
        self.assertFalse(b)
    def test_unrelate_reflexive(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'),
                                          ('Next_Id', 'unique_id'),
                                          ('Name', 'string')])
        
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='A',
                                          source_keys=['Id'],
                                          target_keys=['Next_Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='prev',
                                          target_phrase='next')

        first = self.metamodel.new('A', Name="First")
        second = self.metamodel.new('A', Name="Second")
        xtuml.relate(first, second, 1, 'prev')
        
        text = '''
        .select any first_inst from instances of A where (selected.Name == "First")
        .select one second_inst related by first_inst->A[R1.'next']
        .unrelate first_inst from second_inst across R1.'prev'
        '''
        
        self.eval_text(text)
        a1 = self.metamodel.select_any('A', lambda sel: sel.Name == "First")
        a2 = xtuml.navigate_one(a1).A[1, 'next']()
        self.assertFalse(a2)
 def test_relate_reflexive(self):
     self.metamodel.define_class('A', [('Id', 'unique_id'),
                                       ('Next_Id', 'unique_id'),
                                       ('Name', 'string')])
     
     self.metamodel.define_association(rel_id='R1',
                                       source_kind='A',
                                       target_kind='A',
                                       source_keys=['Id'],
                                       target_keys=['Next_Id'],
                                       source_many=False,
                                       target_many=False,
                                       source_conditional=True,
                                       target_conditional=True,
                                       source_phrase='prev',
                                       target_phrase='next')
     
     text = '''
     .create object instance a1 of A
     .create object instance a2 of A
     .assign a1.Name = "First"
     .assign a2.Name = "Second"
     .relate a2 to a1 across R1.'next'
     '''
     
     self.eval_text(text)
     a1 = self.metamodel.select_any('A', lambda sel: sel.Name == "First")
     a2 = xtuml.navigate_one(a1).A[1, 'prev']()
     self.assertTrue(a2)
     self.assertEqual(a2.Name, 'Second')
Beispiel #20
0
    def accept_SelectRelatedNode(self, node):
        handle = self.accept(node.handle).fget()
        if node.cardinality == 'many':
            chain = xtuml.navigate_many(handle)
        else:
            chain = xtuml.navigate_one(handle)

        for step in self.accept(node.navigation_chain):
            chain = step(chain)

        self.symtab.install_symbol(node.variable_name, chain())
Beispiel #21
0
 def accept_SelectRelatedNode(self, node):
     handle = self.accept(node.handle).fget()
     if node.cardinality == 'many':
         chain = xtuml.navigate_many(handle)
     else:
         chain = xtuml.navigate_one(handle)
         
     for step in self.accept(node.navigation_chain):
         chain = step(chain)
     
     self.symtab.install_symbol(node.variable_name, chain())
Beispiel #22
0
 def testOneToMany(self):
     self.metamodel.define_class('A', [('Id', 'unique_id')])
     self.metamodel.define_class('B', [('Id', 'unique_id'), ('A_Id', 'unique_id')])
     a_endpint = xtuml.SingleAssociationLink('A', ids=['Id'])
     b_endpint = xtuml.ManyAssociationLink('B', ids=['A_Id'])
     
     self.metamodel.define_relation(1, a_endpint, b_endpint)
     
     a = self.metamodel.new('A')
     b = self.metamodel.new('B')
     self.assertTrue(xtuml.relate(a, b, 1))
     
     self.assertEqual(a, xtuml.navigate_one(b).A[1]())
Beispiel #23
0
    def test_rop_without_identifier_sequence(self, m):
        '''
        CREATE TABLE X  ();
        CREATE TABLE Y ();
        
        CREATE ROP REF_ID R1 FROM MC X ()
                             TO   MC Y ();
                             
        INSERT INTO X VALUES ();
        INSERT INTO Y VALUES ();
        '''
        x = m.select_any('X')
        self.assertTrue(x is not None)

        y = xtuml.navigate_one(x).Y[1]()
        self.assertTrue(y is not None)
Beispiel #24
0
    def test_rop_without_identifier_sequence(self, m):
        '''
        CREATE TABLE X  ();
        CREATE TABLE Y ();
        
        CREATE ROP REF_ID R1 FROM MC X ()
                             TO   MC Y ();
                             
        INSERT INTO X VALUES ();
        INSERT INTO Y VALUES ();
        '''
        x = m.select_any('X')
        self.assertTrue(x is not None)

        y = xtuml.navigate_one(x).Y[1]()
        self.assertTrue(y is not None)
Beispiel #25
0
    def test_rop_named_as_cardinality(self, m):
        '''
        CREATE TABLE M  (Id INTEGER, MC_Id INTEGER);
        CREATE TABLE MC (Id INTEGER);
        
        CREATE ROP REF_ID R1 FROM M M ( MC_Id )
                             TO   1 MC ( Id );
                             
        INSERT INTO MC VALUES (2);
        INSERT INTO M  VALUES (1, 2);
        '''
        val = m.select_any('M')
        self.assertTrue(val is not None)
        self.assertEqual(val.Id, 1)

        val = xtuml.navigate_one(val).MC[1]()
        self.assertTrue(val is not None)
        self.assertEqual(val.Id, 2)
Beispiel #26
0
    def accept_SelectRelatedWhereNode(self, node):
        def where(selected):
            self.symtab.enter_block()
            self.symtab.install_symbol('selected', selected)
            value = self.accept(node.where_clause)
            self.symtab.leave_block()
            return value.fget()

        handle = self.accept(node.handle).fget()
        if node.cardinality == 'many':
            chain = xtuml.navigate_many(handle)
        else:
            chain = xtuml.navigate_one(handle)

        for step in self.accept(node.navigation_chain):
            chain = step(chain)

        self.symtab.install_symbol(node.variable_name, chain(where))
Beispiel #27
0
 def test_rop_named_as_cardinality(self, m):
     '''
     CREATE TABLE M  (Id INTEGER, MC_Id INTEGER);
     CREATE TABLE MC (Id INTEGER);
     
     CREATE ROP REF_ID R1 FROM M M ( MC_Id )
                          TO   1 MC ( Id );
                          
     INSERT INTO MC VALUES (2);
     INSERT INTO M  VALUES (1, 2);
     '''
     val = m.select_any('M')
     self.assertTrue(val is not None)
     self.assertEqual(val.Id, 1) 
     
     val = xtuml.navigate_one(val).MC[1]()
     self.assertTrue(val is not None)
     self.assertEqual(val.Id, 2) 
Beispiel #28
0
 def accept_SelectRelatedWhereNode(self, node):
     def where(selected):
         self.symtab.enter_block()
         self.symtab.install_symbol('selected', selected)
         value = self.accept(node.where_clause)
         self.symtab.leave_block()
         return value.fget()
     
     handle = self.accept(node.handle).fget()
     if node.cardinality == 'many':
         chain = xtuml.navigate_many(handle)
     else:
         chain = xtuml.navigate_one(handle)
         
     for step in self.accept(node.navigation_chain):
         chain = step(chain)
     
     self.symtab.install_symbol(node.variable_name, chain(where))
Beispiel #29
0
    def test_case_sensitivity(self):
        self.metamodel.define_class('Aa', [('Id', 'unique_id')])

        self.metamodel.new('AA')

        self.assertTrue(self.metamodel.select_any('aA'))
        self.assertTrue(self.metamodel.select_any('AA'))
        self.assertTrue(self.metamodel.select_any('Aa'))
        self.assertTrue(self.metamodel.select_any('aa'))

        self.metamodel.new('Aa')
        self.metamodel.new('aA')
        self.metamodel.new('aa')
        
        self.assertEqual(len(self.metamodel.select_many('aA')), 4)
        self.assertEqual(len(self.metamodel.select_many('AA')), 4)
        self.assertEqual(len(self.metamodel.select_many('Aa')), 4)
        self.assertEqual(len(self.metamodel.select_many('aa')), 4)
        
        metaclass = self.metamodel.find_metaclass('aa')
        metaclass.append_attribute('Next_Id', 'unique_id')
        
        ass = self.metamodel.define_association(rel_id='R1', 
                                                source_kind='AA', 
                                                source_keys=['ID'], 
                                                source_many=False, 
                                                source_conditional=False,
                                                source_phrase='prev',
                                                target_kind='aa',
                                                target_keys=['next_id'],
                                                target_many=False,
                                                target_conditional=False,
                                                target_phrase='next')
        next_id = None
        for inst in self.metamodel.select_many('aa'):
            inst.next_ID = next_id
            next_id = inst.Id
        
        ass.batch_relate()
        ass.formalize()
            
        self.assertTrue(xtuml.navigate_one(inst).aa[1, 'next'].AA[1, 'next']())
Beispiel #30
0
 def test_one_to_many(self):
     self.metamodel.define_class('A', [('Id', 'unique_id')])
     self.metamodel.define_class('B', [('Id', 'unique_id'), ('A_Id', 'unique_id')])
     
     ass = self.metamodel.define_association(rel_id=1, 
                                             source_kind='A', 
                                             source_keys=['Id'], 
                                             source_many=False, 
                                             source_conditional=False,
                                             source_phrase='',
                                             target_kind='B',
                                             target_keys=['A_Id'],
                                             target_many=True,
                                             target_conditional=False,
                                             target_phrase='')
     ass.formalize()
     a = self.metamodel.new('A')
     b = self.metamodel.new('B')
     self.assertTrue(xtuml.relate(a, b, 1))
     
     self.assertEqual(a, xtuml.navigate_one(b).A[1]())
    def test_relate(self):
        self.metamodel.define_class('A', [('Id', 'unique_id'), ('B_Id', 'unique_id')])
        self.metamodel.define_class('B', [('Id', 'unique_id')])
        self.metamodel.define_association(rel_id='R1',
                                          source_kind='A',
                                          target_kind='B',
                                          source_keys=['B_Id'],
                                          target_keys=['Id'],
                                          source_many=False,
                                          target_many=False,
                                          source_conditional=True,
                                          target_conditional=True,
                                          source_phrase='',
                                          target_phrase='')
        text = '''
        .create object instance a of A
        .create object instance b of B
        .relate a to b across R1
        '''
        self.eval_text(text)

        a = self.metamodel.select_any('A')
        b = xtuml.navigate_one(a).B[1]()
        self.assertTrue(b)
 def test_clone(self):
     s_ee = self.metamodel.new('S_EE', Name='Test', Descrip='test', Key_Lett='TEST')
     pe_pe = self.metamodel.new('PE_PE')
     self.assertTrue(xtuml.relate(s_ee, pe_pe, 8001))
     
     m = ooaofooa.empty_model()
     self.assertNotEqual(pe_pe, m.clone(pe_pe))
     self.assertNotEqual(s_ee, m.clone(s_ee))
     
     s_ee_clone = m.select_any('S_EE', where(Name='Test'))
     self.assertNotEqual(s_ee, s_ee_clone)
     self.assertEqual(s_ee_clone.EE_ID, s_ee.EE_ID)
     self.assertEqual(s_ee_clone.Name, s_ee.Name)
     self.assertEqual(s_ee_clone.Descrip, s_ee.Descrip)
     self.assertEqual(s_ee_clone.Key_Lett, s_ee.Key_Lett)
     
     pe_pe_clone = xtuml.navigate_one(s_ee_clone).PE_PE[8001]()
     self.assertTrue(pe_pe_clone)
     self.assertNotEqual(pe_pe, pe_pe_clone)
     self.assertEqual(pe_pe_clone.Element_ID, pe_pe.Element_ID)
     self.assertEqual(pe_pe_clone.Visibility, pe_pe.Visibility)
     self.assertEqual(pe_pe_clone.Package_ID, pe_pe.Package_ID)
     self.assertEqual(pe_pe_clone.Component_ID, pe_pe.Component_ID)
     self.assertEqual(pe_pe_clone.type, pe_pe.type)
Beispiel #33
0
 def testNavigateInvalidHandle(self):
     self.assertIsNone(xtuml.navigate_one('test')())
Beispiel #34
0
 def testNavigateNone(self):
     self.assertIsNone(xtuml.navigate_one(None)())
     self.assertEqual(len(xtuml.navigate_many(None)()), 0)
Beispiel #35
0
 def testRelateInvalidRelId(self):
     s_edt = self.metamodel.new('S_EDT')
     s_dt = self.metamodel.new('S_DT')
     xtuml.relate(s_edt, s_dt, 0)
     self.assertEqual(s_edt, xtuml.navigate_one(s_dt).S_EDT[17]())
Beispiel #36
0
 def testNavOne(self):
     m = self.metamodel
     s_dt = m.select_any('S_DT',  where(Name='void'))
     pe_pe = xtuml.navigate_one(s_dt).PE_PE[8001](lambda inst: True)
     self.assertEqual(s_dt.DT_ID, pe_pe.Element_ID)