Exemplo n.º 1
0
    def testTerritoryDestroy(self):
        project = DispatchEx('Mga.MgaProject')
        project.Create(self.connstr, 'MetaGME')
        paradigmSheet = project.RootMeta.RootFolder.DefinedFCOByName(
            'ParadigmSheet', True)
        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
        project.CommitTransaction()
        project.Close(False)

        project = DispatchEx('Mga.MgaProject')
        project.Open(self.connstr)

        assert project.UndoRedoSize() == (0, 0)

        oldpref = project.Preferences
        project.Preferences = 0x00000080
        terr = project.BeginTransactionInNewTerr()
        base = project.GetObjectByID(base_id)
        derived = base.DerivedObjects.Item(2)
        base.SetRegistryValueDisp('random', 'asdf')
        base.Name = 'super'
        project.CommitTransaction()
        project.Preferences = oldpref

        terr2 = project.BeginTransactionInNewTerr()
        terr.Destroy(
        )  # puts locking in a bad state pre-r2234 (before CoreTerritory gutting)
        derived = terr2.OpenFCO(derived)
        derived.DestroyObject()
        project.AbortTransaction()

        terr3 = project.BeginTransactionInNewTerr()
        base = terr3.OpenFCO(base)
        base.DestroyObject()
        project.CommitTransaction(
        )  # crashes here pre-r2234 (before CoreTerritory gutting)
        project.Close(True)
Exemplo n.º 2
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)