# Path: tests/test_bridgepoint/utils.py
# class PrebuildFunctionTestCase(CompareAST):
#     
#     @classmethod
#     def setUpClass(cls):
#         cls.loader = ooaofooa.Loader()
#         
#     def setUp(self):
#         self.metamodel = self.loader.build_metamodel()
#         pe_pe = self.metamodel.new('PE_PE')
#         s_sync = self.metamodel.new('S_SYNC')
#         xtuml.relate(s_sync, pe_pe, 8001)
#         
#         s_dt = self.metamodel.select_any('S_DT', lambda sel: sel.Name == 'void')
#         xtuml.relate(s_dt, s_sync, 25)
#         
#     def tearDown(self):
#         del self.metamodel
#         
#     def prebuild_text(self, s):
#         s_sync = self.metamodel.select_any('S_SYNC')
#         s_sync.Action_Semantics_internal = s
#         s_sync.Suc_Pars = 1
#         
#         prebuild.prebuild_model(self.metamodel)
#         self.assertTrue(self.metamodel.is_consistent())
#         
#         generated_code = sourcegen.gen_text_action(s_sync)
#         
#         handwritten_ast = oal.parse(s)
#         generated_ast = oal.parse(generated_code)
# 
#         self.compare(handwritten_ast, generated_ast)
# 
# Path: tests/test_bridgepoint/utils.py
# def prebuild_docstring(f):
#     
#     def wrapper(self):
#         self.prebuild_text(f.__doc__)
#         f(self)
#         
#     return wrapper
# 
# Path: xtuml/meta.py
# def navigate_one(self, instance):
#     '''
#     Navigate from *instance* across the link.
#     '''
#     return next(iter(self.navigate(instance)), None)
# 
# Path: xtuml/meta.py
# def relate(from_instance, to_instance, rel_id, phrase=''):
#     '''
#     Relate *from_instance* to *to_instance* across *rel_id*. For reflexive
#     association, a *phrase* indicating the direction must also be provided.
#     
#     The two instances are related to each other by copying the identifying 
#     attributes from the instance on the TO side of a association to the instance
#     n the FROM side. Updated values which affect existing associations are 
#     propagated. A set of all affected instances will be returned.
#     '''
#     if None in [from_instance, to_instance]:
#         return False
# 
#     inst1, inst2, ass = _find_link(from_instance, to_instance, rel_id, phrase)
#     if not ass.source_link.connect(inst1, inst2):
#         raise RelateException(from_instance, to_instance, rel_id, phrase)
# 
#     if not ass.target_link.connect(inst2, inst1):
#         raise RelateException(from_instance, to_instance, rel_id, phrase)
#     
#     return True


from tests.test_bridgepoint.utils import PrebuildFunctionTestCase
from tests.test_bridgepoint.utils import prebuild_docstring
from xtuml import navigate_one as one
from xtuml import relate
    import logging
    import unittest
class TestCreate(PrebuildFunctionTestCase):

    def setUp(self):
        PrebuildFunctionTestCase.setUp(self)
        pe_pe = self.metamodel.new('PE_PE')
        o_obj = self.metamodel.new('O_OBJ', Key_Lett='A')
        relate(pe_pe, o_obj, 8001)
    
    @prebuild_docstring
    def test_create_object(self):
        '''
        create object instance inst of A;
        '''
        act_cr = self.metamodel.select_one('ACT_CR')
        self.assertTrue(act_cr.is_implicit)
        
        act_smt = one(act_cr).ACT_SMT[603]()
        self.assertIsNotNone(act_smt)

        v_var = one(act_cr).V_VAR[633]()
        self.assertEqual(v_var.Name, 'inst')
        
        s_dt = one(v_var).S_DT[848]()
        self.assertEqual(s_dt.Name, 'inst_ref<Object>')
        
        self.assertTrue(one(v_var).V_INT[814]())
        
        o_obj = one(act_cr).O_OBJ[671]()
        self.assertEqual(o_obj.Key_Lett, 'A')
        

# Path: tests/test_bridgepoint/utils.py
# class PrebuildFunctionTestCase(CompareAST):
#     
#     @classmethod
#     def setUpClass(cls):
#         cls.loader = ooaofooa.Loader()
#         
#     def setUp(self):
#         self.metamodel = self.loader.build_metamodel()
#         pe_pe = self.metamodel.new('PE_PE')
#         s_sync = self.metamodel.new('S_SYNC')
#         xtuml.relate(s_sync, pe_pe, 8001)
#         
#         s_dt = self.metamodel.select_any('S_DT', lambda sel: sel.Name == 'void')
#         xtuml.relate(s_dt, s_sync, 25)
#         
#     def tearDown(self):
#         del self.metamodel
#         
#     def prebuild_text(self, s):
#         s_sync = self.metamodel.select_any('S_SYNC')
#         s_sync.Action_Semantics_internal = s
#         s_sync.Suc_Pars = 1
#         
#         prebuild.prebuild_model(self.metamodel)
#         self.assertTrue(self.metamodel.is_consistent())
#         
#         generated_code = sourcegen.gen_text_action(s_sync)
#         
#         handwritten_ast = oal.parse(s)
#         generated_ast = oal.parse(generated_code)
# 
#         self.compare(handwritten_ast, generated_ast)
# 
# Path: tests/test_bridgepoint/utils.py
# def prebuild_docstring(f):
#     
#     def wrapper(self):
#         self.prebuild_text(f.__doc__)
#         f(self)
#         
#     return wrapper
# 
# Path: xtuml/meta.py
# def navigate_one(self, instance):
#     '''
#     Navigate from *instance* across the link.
#     '''
#     return next(iter(self.navigate(instance)), None)
# 
# Path: xtuml/meta.py
# def relate(from_instance, to_instance, rel_id, phrase=''):
#     '''
#     Relate *from_instance* to *to_instance* across *rel_id*. For reflexive
#     association, a *phrase* indicating the direction must also be provided.
#     
#     The two instances are related to each other by copying the identifying 
#     attributes from the instance on the TO side of a association to the instance
#     n the FROM side. Updated values which affect existing associations are 
#     propagated. A set of all affected instances will be returned.
#     '''
#     if None in [from_instance, to_instance]:
#         return False
# 
#     inst1, inst2, ass = _find_link(from_instance, to_instance, rel_id, phrase)
#     if not ass.source_link.connect(inst1, inst2):
#         raise RelateException(from_instance, to_instance, rel_id, phrase)
# 
#     if not ass.target_link.connect(inst2, inst1):
#         raise RelateException(from_instance, to_instance, rel_id, phrase)
#     
#     return True


# Path: tests/test_bridgepoint/test_create.py
from tests.test_bridgepoint.utils import PrebuildFunctionTestCase
from tests.test_bridgepoint.utils import prebuild_docstring
from xtuml import navigate_one as one
from xtuml import relate
    import logging
    import unittest

class TestCreate(PrebuildFunctionTestCase):

    def setUp(self):
        PrebuildFunctionTestCase.setUp(self)
        pe_pe = self.metamodel.new('PE_PE')
        o_obj = self.metamodel.new('O_OBJ', Key_Lett='A')
        relate(pe_pe, o_obj, 8001)
    
    @prebuild_docstring
    def test_create_object(self):
        '''
        create object instance inst of A;
        '''
        act_cr = self.metamodel.select_one('ACT_CR')
        self.assertTrue(act_cr.is_implicit)
        
        act_smt = one(act_cr).ACT_SMT[603]()
        self.assertIsNotNone(act_smt)

        v_var = one(act_cr).V_VAR[633]()
        self.assertEqual(v_var.Name, 'inst')
        
        s_dt = one(v_var).S_DT[848]()
        self.assertEqual(s_dt.Name, 'inst_ref<Object>')
        
        self.assertTrue(one(v_var).V_INT[814]())
        
        o_obj = one(act_cr).O_OBJ[671]()
        self.assertEqual(o_obj.Key_Lett, 'A')
        

    @prebuild_docstring