コード例 #1
0
 def tearDown(self):
     self._rm_old_files()
     registrar = DispatchEx("Mga.MgaRegistrar")
     if self.old_reg_data is None:
         registrar.UnregisterParadigm("MetaGME", 1)
     else:
         registrar.RegisterParadigm(*self.old_reg_data)
コード例 #2
0
    def test_subtree_removal(self):
        from GPyUnit import util
        util.register_xmp('MetaGME')
        with util.disable_early_binding():
            self.project = DispatchEx("Mga.MgaProject")
            self.project.Create(self.connstr, "MetaGME")
            self.project.BeginTransactionInNewTerr()

            for i in range(
                    1, self.project.RootMeta.RootFolder.DefinedFCOs.Count + 1):
                if self.project.RootMeta.RootFolder.DefinedFCOs.Item(
                        i).Name == 'ParadigmSheet':
                    sheet_meta = self.project.RootMeta.RootFolder.DefinedFCOs.Item(
                        i)
            sheet = self.project.RootFolder.CreateRootObject(sheet_meta)
            #sys.stdin.readline()
            sheet.SetRegistryValueDisp('test123', 'test')
            sheet.SetRegistryValueDisp('test123/123', 'test')
            sheet.SetRegistryValueDisp('test123456', 'test')
            sheet.SetRegistryValueDisp('test123456/123', 'test')
            sheet.GetRegistryNodeDisp('test123').RemoveTree()
            ATTSTATUS_UNDEFINED = -2
            self.assertEqual(
                sheet.GetRegistryNodeDisp('test123').Status(),
                ATTSTATUS_UNDEFINED)
            self.assertEqual(
                sheet.GetRegistryNodeDisp('test123/123').Status(),
                ATTSTATUS_UNDEFINED)
            self.assertEqual(sheet.GetRegistryValueDisp('test123456'), 'test')
            self.assertEqual(sheet.GetRegistryValueDisp('test123456/123'),
                             'test')
            self.project.CommitTransaction()
            self.project.Save()
            self.project.Close()
コード例 #3
0
 def test_Exit(self):
     import win32com.client
     gme = DispatchEx("GME.Application")
     gme.Version
     gme.Exit()
     # under _DEBUG, GME.exe does not exit until Release()ed
     del (gme)
コード例 #4
0
    def test(self):
        from GPyUnit import util
        util.register_xmp('SF')
        with util.disable_early_binding():
            self.project = DispatchEx("Mga.MgaProject")
            self.project.Open("MGA=" + _adjacent_file('SFDemo_dup_guids.mga'))

            self.project.BeginTransactionInNewTerr(0)
            mga = self.project
            self.assertTrue(
                mga.ObjectByPath('/@Folder1').GetGuidDisp()
                == '{8ce2ca06-2729-4e4c-955f-fc88194782cc}'
                or mga.ObjectByPath('/@Folder2').GetGuidDisp()
                == '{8ce2ca06-2729-4e4c-955f-fc88194782cc}')
            self.assertTrue(
                mga.ObjectByPath('/@Folder1/@System').GetGuidDisp()
                == '{a57ca6b2-d95e-485c-a768-98c16fd30588}'
                or mga.ObjectByPath('/@Folder2/@System').GetGuidDisp()
                == '{a57ca6b2-d95e-485c-a768-98c16fd30588}')
            self.assertNotEqual(
                mga.ObjectByPath('/@Folder1').GetGuidDisp(),
                mga.ObjectByPath('/@Folder2').GetGuidDisp())
            self.assertNotEqual(
                mga.ObjectByPath('/@Folder1/@System').GetGuidDisp(),
                mga.ObjectByPath('/@Folder2/@System').GetGuidDisp())
            self.assertNotEqual(
                mga.ObjectByPath('/@Folder1/@System/@DBSetup1').GetGuidDisp(),
                mga.ObjectByPath('/@Folder2/@System/@DBSetup1').GetGuidDisp())
            self.project.AbortTransaction()
            self.project.Save("MGA=" + _adjacent_file(self.output_file), False)
            self.project.Close(True)
コード例 #5
0
    def register_old_sf_par(self):
        curdir = os.path.abspath(os.path.curdir)
        #curdir = ''
        par_conn_str = "MGA=" + curdir + "used_paradigms\\SF\\SF_older.mta"
        par_con2_str = "XML=" + curdir + "used_paradigms\\SF\\SF_older.xmp"
        ori_conn_str = "MGA=" + curdir + "used_paradigms\\SF\\SF_orig.mta"

        registrar = DispatchEx("Mga.MgaRegistrar")

        # 1: user registry
        # 2: system registry
        register_in = 1
        newname = registrar.RegisterParadigmFromData(par_conn_str, None,
                                                     register_in)

        # maybe we have to register the original sf.mta file once again
        newname = registrar.RegisterParadigmFromData(ori_conn_str, None,
                                                     register_in)

        # {5D6FF99D-D6C2-46A5-9208-CCA15D5FA16C} guid of the SF_older.xmp
        #
        char_guid = [
            '0x9d', '0xf9', '0x6f', '0x5d', '0xc2', '0xd6', '0xa5', '0x46',
            '0x92', '0x08', '0xcc', '0xa1', '0x5d', '0x5f', '0xa1', '0x6c'
        ]
        bin_guid = [
            0x9d, 0xf9, 0x6f, 0x5d, 0xc2, 0xd6, 0xa5, 0x46, 0x92, 0x08, 0xcc,
            0xa1, 0x5d, 0x5f, 0xa1, 0x6c
        ]

        #return char_guid
        return bin_guid
コード例 #6
0
    def test(self):
        from GPyUnit import util
        util.register_xmp(_adjacent_file('GME310ModelRefportTest.xmp'))

        with util.disable_early_binding():
            self.project = DispatchEx("Mga.MgaProject")
            self.project.Open("MGA=" + _adjacent_file("test1.mga"))
            self.territory = self.project.BeginTransactionInNewTerr()

            a = self.project.ObjectByPath("/Test1/Folder1/A")
            b = self.project.ObjectByPath("/Test1/Folder1/A/B")
            kindAtom = self.project.ObjectByPath("/Test1/Folder1/A/B/KindAtom")
            self.assertTrue(kindAtom)
            bref = self.project.ObjectByPath("/Test1/Folder1/A/BRef")
            brefref = self.project.ObjectByPath("/Test1/Folder1/A/BRefRef")
            kindConnection = [
                c for c in a.ChildFCOs if c.Name == "KindConnection"
            ][0]
            c = a.CreateSimpleConnDisp(kindConnection.MetaRole, kindAtom,
                                       kindAtom, None, None)
            c = a.CreateSimpleConnDisp(kindConnection.MetaRole, kindAtom,
                                       kindAtom, bref, brefref)

            self.project.CommitTransaction()
            self.project.Save("MGA=" + _adjacent_file("TestRefportAPI.mga"))
            self.territory.Destroy()
            self.project.Close()
コード例 #7
0
    def test(self):
        """
        Regression test: given self.input_file, move self.folder_to_copy to self.destination_folder. Then check self.output_file against self.correct_file
        """
        from GPyUnit import util
        util.register_xmp(_adjacent_file('GME310ModelRefportTest.xmp'))

        with util.disable_early_binding():
            self.project = DispatchEx("Mga.MgaProject")
            self.project.Open("MGA=" + _adjacent_file(self.input_file))
            self.territory = self.project.BeginTransactionInNewTerr()

            modelb = self.project.ObjectByPath(self.folder_to_copy)
            modelb.Name
            tomove = DispatchEx("Mga.MgaFolders")
            tomove.Append(modelb)
            #self.project.ObjectByPath(self.destination_folder).CopyFolders(tomove, None)
            self.project.RootFolder.CopyFolderDisp(modelb)

            self.project.CommitTransaction()
            self.project.Save("MGA=" + _adjacent_file(self.output_file))
            self.territory.Destroy()
            self.project.Close()

        import GPyUnit.util.mgadiff as mgadiff
        if not mgadiff.compare(_adjacent_file(self.correct_file),
                               _adjacent_file(self.output_file)):
            self.fail("Reference file '%s' does not match output '%s'" %
                      (self.correct_file, self.output_file))
コード例 #8
0
    def test_derived(self):
        from GPyUnit import util
        util.register_xmp('MetaGME')
        with util.disable_early_binding():
            self.project = DispatchEx("Mga.MgaProject")
            self.project.Create(self.connstr, "MetaGME")
            self.project.BeginTransactionInNewTerr()

            for i in range(
                    1, self.project.RootMeta.RootFolder.DefinedFCOs.Count + 1):
                if self.project.RootMeta.RootFolder.DefinedFCOs.Item(
                        i).Name == 'ParadigmSheet':
                    sheet_meta = self.project.RootMeta.RootFolder.DefinedFCOs.Item(
                        i)
            sheet = self.project.RootFolder.CreateRootObject(sheet_meta)
            sheet.SetRegistryValueDisp('testcreation', 'testcreate')
            sheet2 = self.project.RootFolder.DeriveRootObject(sheet, False)
            sheet3 = self.project.RootFolder.DeriveRootObject(sheet2, False)
            sheet4 = self.project.RootFolder.DeriveRootObject(sheet3, False)

            sheet.SetRegistryValueDisp('test123', 'test')
            self.assertEqual(sheet4.GetRegistryValueDisp('test123'), 'test')
            sheet3.DetachFromArcheType()
            self.assertEqual(sheet4.GetRegistryValueDisp('test123'), 'test')
            self.assertEqual(sheet.GetRegistryDisp(False).Count, 2)
            self.assertEqual(sheet4.GetRegistryDisp(False).Count, 0)
            self.assertEqual(sheet3.GetRegistryDisp(False).Count,
                             3)  # detaching adds a regnode "_detachedFrom"
            self.assertEqual(sheet4.GetRegistryDisp(False).Count, 0)
            self.assertEqual(sheet4.GetRegistryDisp(False).Count, 0)
            self.project.CommitTransaction()
            self.project.Save()
            self.project.Close()
コード例 #9
0
def is_registered(paradigm):
	registrar = DispatchEx("Mga.MgaRegistrar")
	paradigms = []
	# REGACCESS_USER = 1
	paradigms.extend(registrar.GetParadigmsDisp(1))
	# REGACCESS_SYSTEM = 2
	paradigms.extend(registrar.GetParadigmsDisp(2))
	return filter(lambda p: p == paradigm, paradigms)
コード例 #10
0
def _regxmp(xmpfile, regaccess):
	REG_USER = 1
	REG_SYSTEM = 2
	REG_BOTH = 3
	registrar = DispatchEx("Mga.MgaRegistrar")
	if os.path.splitext(xmpfile)[1].lower() == ".xmp":
		registrar.RegisterParadigmFromData("XML=" + os.path.abspath(xmpfile), "", regaccess)
	else:
		registrar.RegisterParadigmFromData("MGA=" + os.path.abspath(xmpfile), "", regaccess)
コード例 #11
0
	def run_interpreter(self, interpreter, focusobj=None, selectedobj=None, param=0):
		if not selectedobj:
			selectedobj=DispatchEx("Mga.MgaFCOs")
		self.commit_transaction()
		try:
			launcher = DispatchEx("Mga.MgaLauncher")
			launcher.RunComponent(interpreter, self.project, focusobj, selectedobj, param)
		finally:
			self.begin_transaction()
コード例 #12
0
    def runDecorators(self, xme_file):
        mga = GPyUnit.util.parse_xme(self.connstr, xme_file)
        mga.Save()
        mga.Close()

        self.gme = DispatchEx("GME.Application")
        self.gme.OpenProject(self.connstr)
        dumpwmf = DispatchEx("MGA.DumpWMF")
        dumpwmf.DumpWMFs(self.outdir, self.gme)
コード例 #13
0
    def test_run(self):
        mga = GPyUnit.util.parse_xme(
            "MGA=" + _adjacent_file("BidirConnection.mga"),
            _adjacent_file("BidirConnection.xme"))
        print self.connstr
        try:
            mga.Save()
            selectedobj = DispatchEx("Mga.MgaFCOs")
            launcher = DispatchEx("Mga.MgaLauncher")
            #launcher.RunComponent("Mga.Interpreter.MetaInterpreter", mga, None, selectedobj, 128)
            launcher.RunComponent("Mga.Interpreter.CSharpDSMLGenerator", mga,
                                  None, selectedobj, 128)
        finally:
            mga.Close()
        self.assertTrue(
            os.path.isfile(
                os.path.join(self.outdir(),
                             "ISIS.GME.Dsml.BidirConnection.Classes.cs")))
        self.assertTrue(
            os.path.isfile(
                os.path.join(self.outdir(),
                             "ISIS.GME.Dsml.BidirConnection.dll")))

        mga = GPyUnit.util.parse_xme(
            self.connstr, _adjacent_file("BidirConnectionModel.xme"))
        mga.Save()
        mga.BeginTransactionInNewTerr()
        try:
            self.assertEqual(
                mga.ObjectByPath("/@NewModel/@Child1").PartOfConns.Count, 2)
            self.assertEqual(
                set([
                    x.ConnRole
                    for x in mga.ObjectByPath("/@NewModel/@Child1").PartOfConns
                ]), set(['src', 'dst']))
            self.assertEqual(
                set([
                    x.ConnRole
                    for x in mga.ObjectByPath("/@NewModel/@Child2").PartOfConns
                ]), set(['src', 'dst']))
        finally:
            mga.AbortTransaction()
            mga.Close()

        import subprocess
        subprocess.check_call(
            [_adjacent_file(r"DsmlGeneratorTest\.nuget\NuGet.exe"), "restore"],
            cwd=_adjacent_file("DsmlGeneratorTest"))
        subprocess.check_call([
            r"c:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe",
            _adjacent_file(r"DsmlGeneratorTest\DsmlGeneratorTest.sln")
        ])
        subprocess.check_call([
            _adjacent_file(
                r"DsmlGeneratorTest\bin\Debug\DsmlGeneratorTest.exe"),
            self.connstr
        ])
コード例 #14
0
 def xxxtestupgrade(self):
     from GPyUnit import util
     util.register_xmp('MetaGME')
     with util.disable_early_binding():
         self.project = DispatchEx("Mga.MgaProject")
         self.project.Open(
             "MGA=" +
             r"C:\Users\ksmyth\Documents\META\meta\CyPhyML\CyPhyML.mga")
         self.project.BeginTransactionInNewTerr()
         self.project.RootFolder.ChildFolders
コード例 #15
0
 def test_run(self):
     mga = GPyUnit.util.parse_xme(self.connstr)
     try:
         mga.Save()
         selectedobj = DispatchEx("Mga.MgaFCOs")
         launcher = DispatchEx("Mga.MgaLauncher")
         launcher.RunComponent("Mga.Interpreter.MetaInterpreter", mga, None, selectedobj, 128)
         launcher.RunComponent("Mga.Interpreter.CSharpDSMLGenerator", mga, None, selectedobj, 128)
     finally:
         mga.Close()
     self.assertTrue(os.path.isfile(os.path.join(self.outdir(), "ISIS.GME.Dsml.MetaGME.Classes.cs")))
     self.assertTrue(os.path.isfile(os.path.join(self.outdir(), "ISIS.GME.Dsml.MetaGME.dll")))
コード例 #16
0
def creaP(mganame, parad):
    from GPyUnit import util
    util.register_xmp(parad)
    project = DispatchEx("Mga.MgaProject")

    # may delete old file if exists
    # if os.path.isfile( mganame):
    #    os.remove( mganame)

    project.Create("MGA=" + mganame, parad)
    project.BeginTransactionInNewTerr(0)
    return project
コード例 #17
0
def get_paradigm_file(paradigm, regaccess=3):
	"Returns the .mta file for a given registered paradigm"
	registrar = DispatchEx("Mga.MgaRegistrar")
	guid = registrar.GetParadigmGUIDStringDisp(regaccess, paradigm)
	import uuid
	if platform.system() != 'Java':
		buf = buffer(uuid.UUID(guid).bytes_le, 0, 16)
	else:
		buf = str(uuid.UUID(guid).bytes_le[0:16])
	(connstr, guid) = registrar.QueryParadigm(paradigm, None, buf, regaccess)
	# >>> constr
	# "MGA=....mta"
	return connstr[4:]
コード例 #18
0
 def testCloseWithOpenTx(self):
     project = DispatchEx('Mga.MgaProject')
     project.Create(self.connstr, 'MetaGME')
     paradigmSheet = project.RootMeta.RootFolder.DefinedFCOByName(
         'ParadigmSheet', True)
     terr = project.BeginTransactionInNewTerr()
     base = project.RootFolder.CreateRootObject(paradigmSheet)
     base.CreateChildObject(paradigmSheet.RoleByName('Atom'))
     for i in range(8):
         base.ParentFolder.DeriveRootObject(base, True)
     base_id = base.ID
     # don't: project.CommitTransaction()
     project.Close(True)
     del (terr)
コード例 #19
0
	def create(mgafile, paradigm):
		project = DispatchEx("Mga.MgaProject")
		create_project(project, "MGA=" + mgafile, paradigm)
		p = Project(project)
		p.filename = mgafile
		p.mgafile = mgafile
		return p
コード例 #20
0
	def save(self, filename=None):
		if not filename:
			filename = self.file
		self.project.CommitTransaction()
		if self.territory:
			self.territory.Destroy()
			self.territory = None

		extension = os.path.splitext(filename)[1]
		if extension == ".mga":
			self.project.Save("MGA=" + filename)
		elif extension == ".xme":
			dumper = DispatchEx("Mga.MgaDumper")
			dumper.DumpProject(self.project, filename)
		else:
			raise Exception("Don't know how to save '%s'" % filename)
		self.territory = self.project.BeginTransactionInNewTerr()
コード例 #21
0
    def testB(self):
        """    testB

		Create				a project
		Close                           the project
		Open				a project
		QueryProjectInfo
		
		"""

        # this file will be created:
        mganame = _adjacent_file("_tc4_B_sf.mga")
        project = DispatchEx("Mga.MgaProject")

        try:
            project.Create("MGA=" + mganame, "SF")
        except:
            self.fail('Project create failed')
            print "Project Create failed"

        project.Save()
        project.Close(0)

        # now this file has to exist: mganame
        try:
            project.Open("MGA=" + mganame)
        except:
            print "Project open failed"
            raise

        project.Save()
        project.Close(0)

        t = list(project.QueryProjectInfo("MGA=" + mganame))
        self.assertEqual(t[0], 2)  # mgaversion
        assert t[1] == "SF"  # par name
        assert t[2] == ""  # par version
        assert t[4] == 0  # readonly access ?

        t3_guid = list(t[3])  # convert binary part to a list

        t3_cvd = map(ord, t3_guid)

        isnull = lambda i: (i == 0 and [True] or [False])[0]
        len1 = filter(isnull, t3_cvd)
        assert len(len1) != 16  # it can be all null
コード例 #22
0
class TestMgaOpen(unittest.TestCase):
    def __init__(self, name, **kwds):
        super(TestMgaOpen, self).__init__(name, **kwds)
        self.output_file = "test_mga_open-output.mga"
        self.project = None

    def tearDown(self):
        if not self.project is None:
            self.project.Close(True)

    def test(self):
        from GPyUnit import util
        util.register_xmp('SF')
        with util.disable_early_binding():
            self.project = DispatchEx("Mga.MgaProject")
            self.project.Open("MGA=" + _adjacent_file('SFDemo_dup_guids.mga'))

            self.project.BeginTransactionInNewTerr(0)
            mga = self.project
            self.assertTrue(
                mga.ObjectByPath('/@Folder1').GetGuidDisp()
                == '{8ce2ca06-2729-4e4c-955f-fc88194782cc}'
                or mga.ObjectByPath('/@Folder2').GetGuidDisp()
                == '{8ce2ca06-2729-4e4c-955f-fc88194782cc}')
            self.assertTrue(
                mga.ObjectByPath('/@Folder1/@System').GetGuidDisp()
                == '{a57ca6b2-d95e-485c-a768-98c16fd30588}'
                or mga.ObjectByPath('/@Folder2/@System').GetGuidDisp()
                == '{a57ca6b2-d95e-485c-a768-98c16fd30588}')
            self.assertNotEqual(
                mga.ObjectByPath('/@Folder1').GetGuidDisp(),
                mga.ObjectByPath('/@Folder2').GetGuidDisp())
            self.assertNotEqual(
                mga.ObjectByPath('/@Folder1/@System').GetGuidDisp(),
                mga.ObjectByPath('/@Folder2/@System').GetGuidDisp())
            self.assertNotEqual(
                mga.ObjectByPath('/@Folder1/@System/@DBSetup1').GetGuidDisp(),
                mga.ObjectByPath('/@Folder2/@System/@DBSetup1').GetGuidDisp())
            self.project.AbortTransaction()
            self.project.Save("MGA=" + _adjacent_file(self.output_file), False)
            self.project.Close(True)
コード例 #23
0
    def test_ParseMetaGME(self):
        testdir = os.path.dirname(os.path.abspath(__file__))
        inputfile = os.environ[
            'GME_ROOT'] + r"\Paradigms\MetaGME\MetaGME-model.xme"
        xme = DispatchEx("Mga.MgaParser")
        (paradigm, parversion, parguid, basename,
         ver) = xme.GetXMLInfo(inputfile)
        mga = DispatchEx("Mga.MgaProject")

        mga.Create("MGA=tmp.mga", paradigm)
        terr = mga.BeginTransactionInNewTerr()
        # GME-371: this would crash
        self.assertRaises(com_error, xme.ParseProject, mga, inputfile)
        return
        mga.CommitTransaction()
        terr.Destroy()
        mga.Save()
        mga.Close()
        del (terr)
        del (mga)
        del (xme)
コード例 #24
0
    def test_copy(self):
        from GPyUnit import util
        util.register_xmp('MetaGME')
        with util.disable_early_binding():
            self.project = DispatchEx("Mga.MgaProject")
            self.project.Create(self.connstr, "MetaGME")
            self.project.BeginTransactionInNewTerr()

            for i in range(
                    1, self.project.RootMeta.RootFolder.DefinedFCOs.Count + 1):
                if self.project.RootMeta.RootFolder.DefinedFCOs.Item(
                        i).Name == 'ParadigmSheet':
                    sheet_meta = self.project.RootMeta.RootFolder.DefinedFCOs.Item(
                        i)
            sheet = self.project.RootFolder.CreateRootObject(sheet_meta)
            sheet.SetRegistryValueDisp('test123', 'test')
            sheet2 = self.project.RootFolder.CopyFCODisp(sheet)
            self.assertEqual(sheet2.GetRegistryValueDisp('test123'), 'test')
            self.project.CommitTransaction()
            self.project.Save()
            self.project.Close()
コード例 #25
0
class TestDecorators(unittest.TestCase):
    def test_MetaGME(self):
        self.runDecorators(os.environ['GME_ROOT'] +
                           r"\Paradigms\MetaGME\MetaGME-model.xme")

    def test_UML(self):
        self.runDecorators(os.environ['GME_ROOT'] +
                           r"\Paradigms\UML\UMLMeta.xme")

    def runDecorators(self, xme_file):
        mga = GPyUnit.util.parse_xme(self.connstr, xme_file)
        mga.Save()
        mga.Close()

        self.gme = DispatchEx("GME.Application")
        self.gme.OpenProject(self.connstr)
        dumpwmf = DispatchEx("MGA.DumpWMF")
        dumpwmf.DumpWMFs(self.outdir, self.gme)

    outdir = None
    gme = None

    def tearDown(self):
        if self.gme:
            self.gme.Exit()
            del (self.gme)
        import glob
        if self.outdir:
            for file in glob.glob(self.outdir + '/*'):
                os.unlink(file)

    def setUp(self):
        outdir = _adjacent_file("TestDecoratorsOutput")
        if not os.path.isdir(outdir):
            os.mkdir(outdir)
        self.outdir = outdir

    @property
    def connstr(self):
        return "MGA=" + _adjacent_file("TestDecorators.mga")
コード例 #26
0
    def test_RemoveArchetypeConnpoint(self):
        self.project = GPyUnit.util.parse_xme(self.connstr)
        self.project.BeginTransactionInNewTerr()
        aspects = self.project.RootFolder.GetObjectByPathDisp("/@Aspects")
        allproxy = self.project.RootFolder.GetObjectByPathDisp(
            "/@Aspects/@AllRef")
        subtype = self.project.RootFolder.DeriveRootObject(aspects, False)
        allrefNew = subtype.CreateChildObject(allproxy.MetaRole)
        stc = aspects.GetObjectByPathDisp("@SourceToConnector")
        model = aspects.GetObjectByPathDisp("@Model")
        stc.SetSrc(DispatchEx("Mga.MgaFCOs"), model)

        self.project.CommitTransaction()
コード例 #27
0
    def setUp(
        self
    ):  ## hook method: creates a new mga file all the times, and deletes one if existing
        self.project = DispatchEx("Mga.MgaProject")

        self.mganame = _adjacent_file("_tc2_all_sf.mga")

        try:
            os.remove(self.mganame)
        except:
            pass

        try:
            self.project.Create("MGA=" + self.mganame, "SF")
        except:
            print "Project Create failed"
            raise

        self.terr = self.project.CreateTerritory(None, None, None)

        self.trans = self.project.BeginTransaction(self.terr,
                                                   0)  # TRANSACTION_GENERAL
コード例 #28
0
    def testNestedTxRollback(self):
        from pythoncom import com_error
        project = DispatchEx('Mga.MgaProject')
        project.Create(self.connstr, 'MetaGME')
        paradigmSheet = project.RootMeta.RootFolder.DefinedFCOByName(
            'ParadigmSheet', True)
        project.BeginTransactionInNewTerr()
        model = project.RootFolder.CreateRootObject(paradigmSheet)
        atom = model.CreateChildObject(paradigmSheet.RoleByName('Atom'))
        conn = model.CreateChildObject(paradigmSheet.RoleByName('Connection'))
        conn.Name = 'Connection'
        connProxy = model.CreateChildObject(
            paradigmSheet.RoleByName('ConnectionProxy'))
        connProxy.Name = 'ConnectionProxy'
        connProxy.Referred = conn
        self.assertRaises(com_error, setattr, connProxy, 'Referred',
                          atom)  # this triggers a nested tx rollback
        atom.Name = 'Atom'
        project.CommitTransaction()

        def check():
            terr = project.BeginTransactionInNewTerr()
            atom_ = terr.OpenFCO(atom)
            self.assertEqual('Atom', atom_.Name)
            conn_ = terr.OpenFCO(conn)
            self.assertEqual('Connection', conn_.Name)
            connProxy_ = terr.OpenFCO(connProxy)
            self.assertEqual('ConnectionProxy', connProxy_.Name)
            self.assertEqual(conn_, connProxy_.Referred)
            project.CommitTransaction()

        check()

        terr = project.BeginTransactionInNewTerr()
        model = terr.OpenFCO(model)
        atom = terr.OpenFCO(atom)
        atom.Name = ''
        self.assertRaises(com_error, getattr(model, 'CreateSimpleConnDisp'),
                          paradigmSheet.RoleByName('ReferTo'), atom, atom,
                          None, None)
        atom.Name = 'Atom'
        project.CommitTransaction()

        check()

        project.Close(False)
        del (terr)
コード例 #29
0
 def createLibProject():
     lib_project = DispatchEx("Mga.MgaProject")
     lib_project.Create(lib_path, "MetaGME")
     paradigmSheet = lib_project.RootMeta.RootFolder.DefinedFCOByName(
         'ParadigmSheet', True)
     lib_project.BeginTransactionInNewTerr()
     base = lib_project.RootFolder.CreateRootObject(paradigmSheet)
     base.Name = "PS"
     atom = base.CreateChildObject(paradigmSheet.RoleByName('Atom'))
     atom.Name = "Atom"
     lib_project.CommitTransaction()
     lib_project.Save()
     lib_project.Close()
コード例 #30
0
    def test_AttributeOrdering(self):
        mga = GPyUnit.util.parse_xme(self.connstr)
        try:
            mga.Save()
            selectedobj = DispatchEx("Mga.MgaFCOs")
            launcher = DispatchEx("Mga.MgaLauncher")
            launcher.RunComponent("Mga.Interpreter.MetaInterpreter", mga, None, selectedobj, 128)
        finally:
            mga.Close()

        with open(os.path.join(self.outdir(), "MetaGME.xmp")) as xmp:
            lines = xmp.readlines()
            atomattributes = "IsAbstract InRootFolder GeneralPreferences DisplayedName IsTypeShown Icon IsNameEnabled PortIcon SubTypeIcon NamePosition InstanceIcon Decorator NameWrapNum IsHotspotEnabled IsResizable AutoRouterPref HelpURL IsGradientFillEnabled GradientFillColor GradientFillDirection IsShadowCastEnabled ShadowColor ShadowThickness ShadowDirection IsRoundRectangleEnabled RoundRectangleRadius"
            self.assertTrue(atomattributes in "".join(lines), filter(lambda x: '<atom name = "Atom"' in x, lines))
        
        metaproj = DispatchEx("Mga.MgaMetaProject")
        metaproj.Open("MGA=" + os.path.join(self.outdir(), "MetaGME.mta"))
        try:
            atomattrs = [attr.Name for attr in metaproj.RootFolder.DefinedFCOByName("Atom", True).Attributes]
            self.assertEqual(atomattrs, list(atomattributes.split()))
        finally:
            metaproj.Close()