TestUmlFrame.py :  » UML » Python-UML-Tool » pyut-1.4.0 » src » tests » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » UML » Python UML Tool 
Python UML Tool » pyut 1.4.0 » src » tests » TestUmlFrame.py
#!/usr/bin/env python

__version__ = "$Revision: 1.3 $"
__author__ = "EI6, eivd, Group Dutoit - Roux"
__date__ = "2002-05-22"

import sys
if ".." not in sys.path:
    sys.path.append("..") # access to the classes to test
import unittest

# Set lang function emulation
def _(x): return x
import __builtin__
__builtin__.__dict__['_'] = _

# Import pyut elements
import os
from wxPython.wx import *
from UmlFrame import UmlFrame
from ErrorManager import RAISE_ERROR_VIEW
from FileHandling import FileHandling
import mediator

##############################################################################
class App(wxApp):
    def OnInit(self):
        return true

class TestUmlFrame(unittest.TestCase):
    """
    This class do basic tests on UmlFrame :
    it creates classes, actors, notes, links, etc...
    @author C.Dutoit
    """

    #>------------------------------------------------------------------------

    def setUp(self):
        """
        Initialize.
        @author C.Dutoit
        """
        # Initialize mediator and error manager
        ctrl = mediator.getMediator()
        ctrl.setScriptMode()
        fileHandling = FileHandling(None, ctrl)
        ctrl.registerFileHandling(fileHandling)
        errorManager = ctrl.getErrorManager()
        errorManager.changeType(RAISE_ERROR_VIEW)

        # Create wx application
        app = App()


        # Create frame
        baseFrame = wxFrame(None, -1, "", size=(10, 10))
        umlFrame = UmlFrame(baseFrame, None)
        umlFrame.Show(true)
        self._umlFrame = umlFrame


    #>------------------------------------------------------------------------

    def testClassCreation(self):
        """
        Test Class Creation
        @author C.Dutoit
        """
        # Create a PyutClass
        try:
            pyutClass = self._umlFrame.createNewClass(10, 10)
        except:
            self.fail("Can't create a PyutClass")

        # Get the corresponding OglClass
        try:
            oglClass = [s for s in self._umlFrame.getDiagram().GetShapes()
                           if s.getPyutObject() is pyutClass][0]
        except:
            self.fail("Can't get OglClass")

        # Testing position
        try:
            x, y = oglClass.GetPosition()
        except:
            self.fail("Can't get OglClass position")
        self.failUnless(x==10 and y==10, "Wrong OglClass position !")


    #>------------------------------------------------------------------------

    def testNoteCreation(self):
        """
        Test Note Creation
        @author C.Dutoit
        """
        # PyutNote creation
        try:
            pyutNote = self._umlFrame.createNewNote(100, 10)
        except:
            self.fail("Can't create a PyutNote")

        # Get OglNote
        try:
            oglNote = [s for s in self._umlFrame.getDiagram().GetShapes()
                           if s.getPyutObject() is pyutNote][0]
        except:
            self.fail("Can't get OglNote")

        # Testing position
        try:
            x, y = oglNote.GetPosition()
        except:
            self.fail("Can't get OglNote position")
        self.failUnless(x==100 and y==10, "Wrong OglNote position !")

    #>------------------------------------------------------------------------

    def testActorCreation(self):
        """
        Test Actor Creation
        @author C.Dutoit
        """
        # Create a PyutActor
        try:
            pyutActor = self._umlFrame.createNewActor(100, 100)
        except:
            self.fail("Can't create a PyutActor")

        # Get the corresponding OglActor
        try:
            oglActor = [s for s in self._umlFrame.getDiagram().GetShapes()
                           if s.getPyutObject() is pyutActor][0]
        except:
            self.fail("Can't get OglActor")

        # Testing position
        try:
            x, y = oglActor.GetPosition()
        except:
            self.fail("Can't get OglActor position")
        self.failUnless(x==100 and y==100, "Wrong OglActor position !")



    #>------------------------------------------------------------------------

    def testUseCaseCreation(self):
        """
        Test UseCase Creation
        @author C.Dutoit
        """
        # Create a PyutUseCase
        try:
            pyutUseCase = self._umlFrame.createNewUseCase(10, 50)
        except:
            self.fail("Can't create a PyutUseCase")

        # Get the corresponding OglUseCase
        try:
            oglUseCase = [s for s in self._umlFrame.getDiagram().GetShapes()
                           if s.getPyutObject() is pyutUseCase][0]
        except:
            self.fail("Can't get OglUseCase")

        # Testing position
        try:
            x, y = oglUseCase.GetPosition()
        except:
            self.fail("Can't get OglUseCase position")
        self.failUnless(x==10 and y==50, "Wrong OglUseCase position !")




    #>------------------------------------------------------------------------

    def testInheritanceLinkCreation(self):
        """
        Test Inheritance link Creation
        @author C.Dutoit
        """
        # Create two PyutClass
        try:
            pyutClass1 = self._umlFrame.createNewClass(20, 10)
            pyutClass2 = self._umlFrame.createNewClass(30, 10)
        except:
            self.fail("Can't create two PyutClass")

        # Get OglObject
        try:
            oglClass1 = [s for s in self._umlFrame.getDiagram().GetShapes()
                           if s.getPyutObject() is pyutClass1][0]
            oglClass2 = [s for s in self._umlFrame.getDiagram().GetShapes()
                           if s.getPyutObject() is  pyutClass2][0]
        except:
            self.fail("Can't get the two OglClass")

        # Create the link
        try:
            self._umlFrame.createInheritanceLink(oglClass1, oglClass2)
        except:
            self.fail("Can't create a inheritance link")


    #>------------------------------------------------------------------------

    def testNewLinkCreation(self):
        """
        Test new link Creation
        @author C.Dutoit
        """
        # Create two PyutClass
        try:
            pyutClass1 = self._umlFrame.createNewClass(20, 20)
            pyutClass2 = self._umlFrame.createNewClass(30, 20)
        except:
            self.fail("Can't create two PyutClass")

        # Get OglObject
        try:
            oglClass1 = [s for s in self._umlFrame.getDiagram().GetShapes()
                           if s.getPyutObject() is pyutClass1][0]
            oglClass2 = [s for s in self._umlFrame.getDiagram().GetShapes()
                           if s.getPyutObject() is  pyutClass2][0]
        except:
            self.fail("Can't get the two OglClass")

        # Create the link
        try:
            self._umlFrame.createNewLink(oglClass1, oglClass2)
        except:
            self.fail("Can't create a new link")
#todo :createNEwLink(src, dst)

    #>------------------------------------------------------------------------

    def testClassCreation(self):
        """
        Test Class Creation
        @author C.Dutoit
        """
        pyutClass = self._umlFrame.createNewClass(10, 10)




def suite():
    """You need to change the name of the test class here also."""
    return unittest.makeSuite(TestUmlFrame)

def main():
    unittest.TextTestRunner().run(suite())

if __name__ == "__main__": main()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.