Пример #1
0
def connectRefP(p, cont, s, d, r1, r2, role_str):
    """ Helper method connecting ports.
    s: source fco/port
    d: destination fco/port
    r1: modelreference, 'containing' s
    r2: modelreference, 'containing' d
    r1 or r2 might be 0, when that end of the connection is an fco or modelport (no reference involved)
    """
    z1 = DispatchEx("Mga.MgaFCOs")
    z2 = DispatchEx("Mga.MgaFCOs")
    if r1:
        z1.Append(r1)
    if r2:
        z2.Append(r2)
    return cont.CreateSimpleConn(role(p, cont, role_str), s, d, z1, z2)
Пример #2
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))
Пример #3
0
    def test(self):
        """
        Regression test: given self.input_file, move self.fco_to_move to self.destination_model. Then check self.output_file against self.correct_file
        """
        def _adjacent_file(file):
            import os.path
            return os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                file)

        from GPyUnit import util
        util.register_xmp(_adjacent_file('GME297ModelRefportTest.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()

            fco_to_move = self.project.ObjectByPath(self.fco_to_move)
            OBJTYPE_FOLDER = 6
            if fco_to_move.ObjType == OBJTYPE_FOLDER:
                tomove = DispatchEx("Mga.MgaFolders")
            else:
                tomove = DispatchEx("Mga.MgaFCOs")
            tomove.Append(fco_to_move)

            destination = self.project.ObjectByPath(self.destination_model)
            if destination.ObjType == OBJTYPE_FOLDER:
                destination.MoveFolderDisp(fco_to_move)
            else:
                self._move_fcos(destination, fco_to_move, tomove)
                #destination.MoveFCOs(tomove, None, None)

            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))