00001 import unittest
00002 import win32com.client
00003 import win32ui
00004 import pythoncom
00005 import os
00006 import utils.Builder
00007 from GPyUnit.util import DispatchEx
00008 bd = utils.Builder
00009
00010 def _adjacent_file(file):
00011 import os.path
00012 return os.path.join(os.path.dirname(os.path.abspath(__file__)), file)
00013
00014 class TestCase3( unittest.TestCase ):
00015 def setUp( self ):
00016 pass
00017
00018 def tearDown( self ):
00019 pass
00020
00021 def testA( self ):
00022 """ testA
00023
00024 Create a project
00025 Close the project
00026 QueryProjectInfo
00027
00028 """
00029
00030
00031 mganame = _adjacent_file("_tc3_A_sf.mga")
00032 project = DispatchEx("Mga.MgaProject")
00033
00034 try:
00035 project.Create( "MGA=" + mganame, "SF")
00036 except:
00037 print "Project Create failed"
00038 raise
00039
00040 project.Save()
00041 project.Close(0)
00042
00043 t = list( project.QueryProjectInfo( "MGA=" + mganame))
00044 self.assertEqual(t[0], 2)
00045 assert t[1] == "SF"
00046 assert t[2] == ""
00047 assert t[4] == 0
00048
00049 t3_guid = list( t[3] )
00050
00051 t3_cvd = map( ord, t3_guid)
00052
00053 isnull = lambda i: (i == 0 and [True] or [False])[0]
00054 len1 = filter( isnull, t3_cvd)
00055 assert len(len1) != 16
00056
00057
00058 def testB( self ):
00059 """ testB
00060
00061 Create a project
00062 Close the project
00063 Open a project
00064 QueryProjectInfo
00065
00066 """
00067
00068
00069 mganame = _adjacent_file("_tc4_B_sf.mga")
00070 project = DispatchEx("Mga.MgaProject")
00071
00072 try:
00073 project.Create( "MGA=" + mganame, "SF")
00074 except:
00075 self.fail('Project create failed')
00076 print "Project Create failed"
00077
00078 project.Save()
00079 project.Close(0)
00080
00081
00082 try:
00083 project.Open( "MGA=" + mganame)
00084 except:
00085 print "Project open failed"
00086 raise
00087
00088 project.Save()
00089 project.Close(0)
00090
00091 t = list( project.QueryProjectInfo( "MGA=" + mganame))
00092 self.assertEqual(t[0], 2)
00093 assert t[1] == "SF"
00094 assert t[2] == ""
00095 assert t[4] == 0
00096
00097 t3_guid = list( t[3] )
00098
00099 t3_cvd = map( ord, t3_guid)
00100
00101 isnull = lambda i: (i == 0 and [True] or [False])[0]
00102 len1 = filter( isnull, t3_cvd)
00103 assert len(len1) != 16
00104
00105
00106
00107 """
00108 Let's produce the test suites
00109 """
00110 def suites():
00111 suite = unittest.makeSuite(TestCase3,'test')
00112 return suite
00113
00114 def suites2():
00115 suite = unittest.TestSuite()
00116 suite.addTest( TestCase3( "testA"))
00117
00118
00119 return suite
00120
00121
00122
00123
00124 if __name__ == "__main__":
00125 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00126 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00127 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00128 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00129 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00130 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEST BEGINS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00131 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00132 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00133 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00134 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00135 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
00136
00137
00138 unittest.main()
00139
00140
00141
00142
00143
00144
00145
00146