[commit] r1478 - in trunk/Tests/GPyUnit: . GME-297 GME-310 GME_297 GME_310 Regr/Mga Regr/Mga/utils util
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Tue Aug 23 16:51:43 CDT 2011
Author: ksmyth
Date: Tue Aug 23 16:51:43 2011
New Revision: 1478
Log:
Cleanup tests
Added:
trunk/Tests/GPyUnit/GME_297/
- copied from r1446, trunk/Tests/GPyUnit/GME-297/
trunk/Tests/GPyUnit/GME_297/__init__.py
- copied, changed from r1446, trunk/Tests/GPyUnit/GME-297/test.py
trunk/Tests/GPyUnit/GME_310/
- copied from r1446, trunk/Tests/GPyUnit/GME-310/
trunk/Tests/GPyUnit/GME_310/__init__.py
- copied, changed from r1446, trunk/Tests/GPyUnit/GME-310/test.py
trunk/Tests/GPyUnit/run_tests.py (contents, props changed)
trunk/Tests/GPyUnit/test_registrar.py (contents, props changed)
trunk/Tests/GPyUnit/util/
trunk/Tests/GPyUnit/util/__init__.py (contents, props changed)
Deleted:
trunk/Tests/GPyUnit/GME-297/
trunk/Tests/GPyUnit/GME-310/
trunk/Tests/GPyUnit/GME_297/test.py
trunk/Tests/GPyUnit/GME_310/test.py
trunk/Tests/GPyUnit/Regr/Mga/tc8.py
trunk/Tests/GPyUnit/unittest.py
Modified:
trunk/Tests/GPyUnit/GME_297/gme.py
trunk/Tests/GPyUnit/GME_297/mgadiff.py
trunk/Tests/GPyUnit/GME_310/gme.py
trunk/Tests/GPyUnit/GME_310/mgadiff.py
trunk/Tests/GPyUnit/Regr/Mga/tc1.py
trunk/Tests/GPyUnit/Regr/Mga/tc7.py
trunk/Tests/GPyUnit/Regr/Mga/utils/Builder.py
trunk/Tests/GPyUnit/Regr/Mga/utils/xme2mga.py
Copied and modified: trunk/Tests/GPyUnit/GME_297/__init__.py (from r1446, trunk/Tests/GPyUnit/GME-297/test.py)
==============================================================================
--- trunk/Tests/GPyUnit/GME-297/test.py Wed Jul 27 10:40:51 2011 (r1446, copy source)
+++ trunk/Tests/GPyUnit/GME_297/__init__.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -15,10 +15,14 @@
self.output_file = name + "-output.mga"
self.correct_file = name + "-correct.mga"
+
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(__file__), file)
# This script depends on late binding. win32com.client.dynamic.Dispatch forces late binding when creating an object,
# but early-bound objects may be returned from function calls. Disable late binding completely.
import win32com.client.gencache
@@ -26,7 +30,7 @@
win32com.client.gencache.GetClassForCLSID = lambda x: None
self.project = win32com.client.DispatchEx("Mga.MgaProject")
- self.project.Open("MGA=" + self.input_file)
+ self.project.Open("MGA=" + _adjacent_file(self.input_file))
self.territory = self.project.BeginTransactionInNewTerr()
fco_to_move = self.project.ObjectByPath(self.fco_to_move)
@@ -44,14 +48,14 @@
destination.MoveFCOs(tomove, None, None)
self.project.CommitTransaction()
- self.project.Save("MGA=" + self.output_file)
+ self.project.Save("MGA=" + _adjacent_file(self.output_file))
self.territory.Destroy()
win32com.client.gencache.GetClassForCLSID = _savedGetClassForCLSID
import mgadiff
- if not mgadiff.compare(self.correct_file, self.output_file):
+ 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))
- print "Reference file '%s' matches output '%s'" % (self.correct_file, self.output_file)
+ # print "Reference file '%s' matches output '%s'" % (self.correct_file, self.output_file)
def suite():
suite = unittest.TestSuite()
Modified: trunk/Tests/GPyUnit/GME_297/gme.py
==============================================================================
--- trunk/Tests/GPyUnit/GME-297/gme.py Wed Jul 27 10:40:51 2011 (r1446)
+++ trunk/Tests/GPyUnit/GME_297/gme.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -337,7 +337,7 @@
# KMS I'm not sure why gen_py lowercases these (for GME<VS2010). Create aliases:
if mga_module.IMgaReference._prop_map_get_.has_key("referred"):
mga_module.IMgaReference._prop_map_get_["Referred"] = mga_module.IMgaReference._prop_map_get_["referred"]
-mga_module.IMgaConnPoint._prop_map_get_["Target"] = mga_module.IMgaConnPoint._prop_map_get_["target"]
+#mga_module.IMgaConnPoint._prop_map_get_["Target"] = mga_module.IMgaConnPoint._prop_map_get_["target"]
# Make IMgaFolder behave more like IMgaFCO
mga_module.IMgaFolder._prop_map_get_["Meta"] = mga_module.IMgaFolder._prop_map_get_["MetaFolder"]
Modified: trunk/Tests/GPyUnit/GME_297/mgadiff.py
==============================================================================
--- trunk/Tests/GPyUnit/GME-297/mgadiff.py Wed Jul 27 10:40:51 2011 (r1446)
+++ trunk/Tests/GPyUnit/GME_297/mgadiff.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -48,7 +48,7 @@
connectionEndpointsEqual = True
if current1.ObjType == 4 and current2.ObjType == 4:
def mapConnpoints(conn):
- ret = map(lambda point: (point.ConnRole, [fco_path(point.target), map(fco_path, point.References)]), conn.ConnPoints)
+ ret = map(lambda point: (point.ConnRole, [fco_path(point.Target), map(fco_path, point.References)]), conn.ConnPoints)
return dict(ret)
connectionEndpointsEqual = mapConnpoints(current1) == mapConnpoints(current2)
# Debugging aid:
@@ -203,7 +203,7 @@
for index in range(len(current)):
array.append(dict())
for point in current[index]:
- array[index][point.ConnRole]="%s %s" % (point.target.Name,point.target.AbsPath)
+ array[index][point.ConnRole]="%s %s" % (point.Target.Name,point.Target.AbsPath)
for index in range(len(current)-1):
if(array[index] != array[index+1]):
Copied and modified: trunk/Tests/GPyUnit/GME_310/__init__.py (from r1446, trunk/Tests/GPyUnit/GME-310/test.py)
==============================================================================
--- trunk/Tests/GPyUnit/GME-310/test.py Wed Jul 27 10:40:51 2011 (r1446, copy source)
+++ trunk/Tests/GPyUnit/GME_310/__init__.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -19,6 +19,9 @@
'''
Regression test: given self.input_file, move self.folder_to_copy to self.destination_folder. Then check self.output_file against self.correct_file
'''
+ def _adjacent_file(file):
+ import os.path
+ return os.path.join(os.path.dirname(__file__), file)
# This script depends on late binding. win32com.client.dynamic.Dispatch forces late binding when creating an object,
# but early-bound objects may be returned from function calls. Disable late binding completely.
import win32com.client.gencache
@@ -26,7 +29,7 @@
win32com.client.gencache.GetClassForCLSID = lambda x: None
self.project = win32com.client.DispatchEx("Mga.MgaProject")
- self.project.Open("MGA=" + self.input_file)
+ self.project.Open("MGA=" + _adjacent_file(self.input_file))
self.territory = self.project.BeginTransactionInNewTerr()
modelb = self.project.ObjectByPath(self.folder_to_copy)
@@ -37,12 +40,12 @@
self.project.RootFolder.CopyFolders(tomove, None)
self.project.CommitTransaction()
- self.project.Save("MGA=" + self.output_file)
+ self.project.Save("MGA=" + _adjacent_file(self.output_file))
self.territory.Destroy()
win32com.client.gencache.GetClassForCLSID = _savedGetClassForCLSID
import mgadiff
- if not mgadiff.compare(self.correct_file, self.output_file):
+ 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))
#print "Reference file '%s' matches output '%s'" % (self.correct_file, self.output_file)
Modified: trunk/Tests/GPyUnit/GME_310/gme.py
==============================================================================
--- trunk/Tests/GPyUnit/GME-310/gme.py Wed Jul 27 10:40:51 2011 (r1446)
+++ trunk/Tests/GPyUnit/GME_310/gme.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -337,7 +337,7 @@
# KMS I'm not sure why gen_py lowercases these (for GME<VS2010). Create aliases:
if mga_module.IMgaReference._prop_map_get_.has_key("referred"):
mga_module.IMgaReference._prop_map_get_["Referred"] = mga_module.IMgaReference._prop_map_get_["referred"]
-mga_module.IMgaConnPoint._prop_map_get_["Target"] = mga_module.IMgaConnPoint._prop_map_get_["target"]
+#mga_module.IMgaConnPoint._prop_map_get_["Target"] = mga_module.IMgaConnPoint._prop_map_get_["target"]
# Make IMgaFolder behave more like IMgaFCO
mga_module.IMgaFolder._prop_map_get_["Meta"] = mga_module.IMgaFolder._prop_map_get_["MetaFolder"]
Modified: trunk/Tests/GPyUnit/GME_310/mgadiff.py
==============================================================================
--- trunk/Tests/GPyUnit/GME-310/mgadiff.py Wed Jul 27 10:40:51 2011 (r1446)
+++ trunk/Tests/GPyUnit/GME_310/mgadiff.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -48,7 +48,7 @@
connectionEndpointsEqual = True
if current1.ObjType == 4 and current2.ObjType == 4:
def mapConnpoints(conn):
- ret = map(lambda point: (point.ConnRole, [fco_path(point.target), map(fco_path, point.References)]), conn.ConnPoints)
+ ret = map(lambda point: (point.ConnRole, [fco_path(point.Target), map(fco_path, point.References)]), conn.ConnPoints)
return dict(ret)
connectionEndpointsEqual = mapConnpoints(current1) == mapConnpoints(current2)
# Debugging aid:
@@ -203,7 +203,7 @@
for index in range(len(current)):
array.append(dict())
for point in current[index]:
- array[index][point.ConnRole]="%s %s" % (point.target.Name,point.target.AbsPath)
+ array[index][point.ConnRole]="%s %s" % (point.Target.Name,point.Target.AbsPath)
for index in range(len(current)-1):
if(array[index] != array[index+1]):
Modified: trunk/Tests/GPyUnit/Regr/Mga/tc1.py
==============================================================================
--- trunk/Tests/GPyUnit/Regr/Mga/tc1.py Tue Aug 23 16:50:38 2011 (r1477)
+++ trunk/Tests/GPyUnit/Regr/Mga/tc1.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -6,6 +6,7 @@
import utils.Builder
bd = utils.Builder
+from util import dec_disable_early_binding
class TestCase1( unittest.TestCase ):
"""
@@ -50,6 +51,7 @@
ap2b.Referred = at2
+ @dec_disable_early_binding
def testA( self ):
""" testA References
testing getproperties of IMgaFCO
@@ -147,6 +149,7 @@
# atom2 added to aspect2
asp2.addMember(at2)
+ @dec_disable_early_binding
def testB( self ):
""" testB Sets
testing getproperties of IMgaFCO
@@ -286,6 +289,7 @@
raise
+ @dec_disable_early_binding
def testC( self ):
""" testC connections in MetaGME
testing getproperties of IMgaFCO
@@ -491,6 +495,7 @@
raise
pass
+ @dec_disable_early_binding
def testD( self ):
""" testD Connections in SF
testing getproperties of IMgaFCO
@@ -583,222 +588,6 @@
project.Save()
project.Close(0)
-
- pass
-
- def populateE(self, p):
- folder1 = p.RootFolder.CreateFolder( bd.folder( p, 'TOSFolder'))
- folder1.Name = 'TOSF_1'
-
- folder2 = p.RootFolder.CreateFolder( bd.folder( p, 'TOSFolder'))
- folder2.Name = 'TOSF_2'
-
- conf1 = folder1.CreateRootObject( bd.kind( p, 'configuration'))
- conf1.Name = 'Conf1'
-
- conf2 = folder2.CreateRootObject( bd.kind( p, 'configuration'))
- conf2.Name = 'Conf2'
-
- intf2 = folder2.CreateRootObject( bd.kind( p, 'interface'))
- intf2.Name = 'Intf2'
-
- modu2 = folder2.CreateRootObject( bd.kind( p, 'module'))
- modu2.Name = 'Modu2'
-
- cr1 = bd.new( p, conf1, 'configuration_ref')
- cr1.Name = 'cr1'
-
- ir1 = bd.new( p, conf1, 'interface_ref')
- ir1.Name = 'ir1'
-
- mr1 = bd.new( p, conf1, 'module_ref')
- mr1.Name = 'mr1'
-
- fbi1 = bd.new( p, conf2, 'FunctionByInterface')
- fbi1.Name = 'f1'
- fbi2 = bd.new( p, conf2, 'FunctionByInterface')
- fbi2.Name = 'f2'
-
- fbi3 = bd.new( p, modu2, 'FunctionByInterface')
- fbi3.Name = 'f3'
-
- iref1 = bd.new( p, conf2, 'interface_ref')
- iref1.Name = 'i1'
- iref2 = bd.new( p, conf2, 'interface_ref')
- iref2.Name = 'i2'
-
- iref3 = bd.new( p, modu2, 'interface_ref')
- iref3.Name = 'i3'
-
- cr1.Referred = conf2
- ir1.Referred = intf2
- mr1.Referred = modu2
-
- clf = bd.connectRefP( p, conf1, fbi1, fbi3, cr1, mr1, "LINK_Functions")
- clf.Name = 'LinkFunc_1_3'
-
- cef = bd.connectRefP( p, conf1, fbi2, fbi3, cr1, mr1, "EQUATE_Functions")
- cef.Name = 'EquateFunc_2_3'
-
- cei = bd.connectRefP( p, conf1, iref2, iref3, cr1, mr1, "EQUATE_Interfaces")
- cei.Name = 'EquateInt_2_3'
-
- cli = bd.connectRefP( p, conf1, iref1, iref3, cr1, mr1, "LINK_Interfaces")
- cli.Name = 'LinkIntA_1_3'
-
- # create a connection, where only one end is referenceport, that is why 0 is used
- cl2 = bd.connectRefP( p, conf1, ir1, iref3, 0, mr1, "LINK_Interfaces")
- cl2.Name = 'LinkIntB_1_3'
-
- pass
-
- def testE( self ):
- """ testE Connections in SF
- testing getproperties of IMgaFCO
- PartOfConns([out, retval] IMgaConnPoints **pVal)
-
- and getproperties of IMgaConnPoint
- Owner([out, retval] IMgaConnection **pVal)
- ConnRole([out, retval] BSTR *pVal)
- Target([out, retval] IMgaFCO **pVal)
- References([out, retval] IMgaFCOs **pVal)
- """
-
- mganame = "_tc1_E_gr.mga"
-
- # create the project with the needed kinds
- project = bd.creaP( mganame, "GRATISII")
- if not project:
- self.fail("Create failed")
- try:
- self.populateE( project)
- except:
- bd.saveP( project)
- raise
- bd.saveP( project)
-
-
- # open the created project
- self.project = project
- try:
- project.Open( "MGA=" + mganame )
- except:
- project.Close(0)
- raise
-
- terr = project.CreateTerritory( None, None, None)
- trans = project.BeginTransaction( terr)
-
- conf1 = bd.findInProj( project,'Conf1')
- conf2 = bd.findInProj( project,'Conf2')
- intf2 = bd.findInProj( project,'Intf2')
- modu2 = bd.findInProj( project,'Modu2')
- cr1 = bd.findInProj( project,'cr1')
- ir1 = bd.findInProj( project,'ir1')
- mr1 = bd.findInProj( project,'mr1')
- fbi1 = bd.findInProj( project,'f1')
- fbi2 = bd.findInProj( project,'f2')
- fbi3 = bd.findInProj( project,'f3')
- iref1 = bd.findInProj( project,'i1')
- iref2 = bd.findInProj( project,'i2')
- iref3 = bd.findInProj( project,'i3')
- clf = bd.findInProj( project,'LinkFunc_1_3')
- cef = bd.findInProj( project,'EquateFunc_2_3')
- cei = bd.findInProj( project,'EquateInt_2_3')
- cli = bd.findInProj( project,'LinkIntA_1_3')
- cl2 = bd.findInProj( project,'LinkIntB_1_3')
-
- # test cr1, mr1 with no conns
- assert cr1.PartOfConns.Count == 0
- assert mr1.PartOfConns.Count == 0
-
- # test the LinkIntB_1_3 connection
- # created like: cl2 = bd.connectRefP( p, conf1, ir1, iref3, 0, mr1, "LINK_Interfaces")
- assert ir1.PartOfConns.Count == 1
- assert ir1.PartOfConns.Item( 1 ).Target == ir1
- assert ir1.PartOfConns.Item( 1 ).Owner == cl2
- assert ir1.PartOfConns.Item( 1 ).Owner.Name == "LinkIntB_1_3"
- assert ir1.PartOfConns.Item( 1 ).ConnRole == "src"
- assert ir1.PartOfConns.Item( 1 ).References.Count == 0
-
- for cp in ir1.PartOfConns.Item( 1 ).Owner.ConnPoints:
- assert cp.Owner == cl2
- if cp.ConnRole == "src":
- assert cp.Target == ir1
- assert cp.References.Count == 0
- elif cp.ConnRole == "dst":
- assert cp.Target == iref3
- assert cp.References.Count == 1
- assert cp.References.Item( 1 ) == mr1
- else:
- self.fail("How?")
-
-
- # test 'LinkFunc_1_3'
- # created like:
- # clf = bd.connectRefP( p, conf1, fbi1, fbi3, cr1, mr1, "LINK_Functions")
- for cp in clf.ConnPoints:
- assert cp.Owner == clf
- assert cp.References.Count == 1
- if cp.ConnRole == "src":
- assert cp.Target == fbi1
- assert cp.References.Item( 1 ) == cr1
- elif cp.ConnRole == "dst":
- assert cp.Target == fbi3
- assert cp.References.Item( 1 ) == mr1
- else: self.fail("How?")
-
- # test 'EquateFunc_2_3'
- # created like:
- # cef = bd.connectRefP( p, conf1, fbi2, fbi3, cr1, mr1, "EQUATE_Functions")
- for cp in cef.ConnPoints:
- assert cp.Owner == cef
- assert cp.References.Count == 1
- if cp.ConnRole == "src":
- assert cp.Target == fbi2
- assert cp.References.Item( 1 ) == cr1
- elif cp.ConnRole == "dst":
- assert cp.Target == fbi3
- assert cp.References.Item( 1 ) == mr1
- else: self.fail("How?")
-
-
- # test 'EquateInt_2_3'
- # created like:
- # cei = bd.connectRefP( p, conf1, iref2, iref3, cr1, mr1, "EQUATE_Interfaces")
- for cp in cei.ConnPoints:
- assert cp.Owner == cei
- assert cp.References.Count == 1
- if cp.ConnRole == "src":
- assert cp.Target == iref2
- assert cp.References.Item( 1 ) == cr1
- elif cp.ConnRole == "dst":
- assert cp.Target == iref3
- assert cp.References.Item( 1 ) == mr1
- else: self.fail("How?")
-
- # test 'LinkIntA_1_3'
- # created like:
- # cli = bd.connectRefP( p, conf1, iref1, iref3, cr1, mr1, "LINK_Interfaces")
- for cp in cli.ConnPoints:
- assert cp.Owner == cli
- assert cp.References.Count == 1
- if cp.ConnRole == "src":
- assert cp.Target == iref1
- assert cp.References.Item( 1 ) == cr1
- elif cp.ConnRole == "dst":
- assert cp.Target == iref3
- assert cp.References.Item( 1 ) == mr1
- else: self.fail("How?")
-
-
- # abort trans (thus revert any changes)
- project.AbortTransaction()
-
- project.Save()
- project.Close(0)
-
- pass
"""
Let's produce the test suites
Modified: trunk/Tests/GPyUnit/Regr/Mga/tc7.py
==============================================================================
--- trunk/Tests/GPyUnit/Regr/Mga/tc7.py Tue Aug 23 16:50:38 2011 (r1477)
+++ trunk/Tests/GPyUnit/Regr/Mga/tc7.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -516,195 +516,6 @@
project.Close(0)
pass
-
- def populate7E(self, p):
- f = bd.newFolder( p, p.RootFolder, 'TOSFolder')
- f.Name = 'NewTOSFolder'
-
- cnf = bd.newObjInFold( p, f, 'configuration')
- cnf.Name = 'Newconfiguration'
-
- int = bd.newObjInFold( p, f, 'interface')
- int.Name = 'Newinterface'
-
- mod = bd.newObjInFold( p, f, 'module')
- mod.Name = 'Newmodule'
-
- e = bd.new( p, cnf, 'FunctionByInterface')
- e.Name = 'NewFunctionByInterface'
-
- e = bd.new( p, cnf, 'PreprocessorSet')
- e.Name = 'NewPreprocessorSet'
-
- e = bd.new( p, cnf, 'State')
- e.Name = 'NewState'
-
- e = bd.new( p, cnf, 'Transition')
- e.Name = 'NewTransition'
-
- e = bd.new( p, cnf, 'configuration_ref')
- e.Name = 'Newconfiguration_ref'
-
- e = bd.new( p, cnf, 'interface_ref')
- e.Name = 'Newinterface_ref'
-
- e = bd.new( p, cnf, 'module_ref')
- e.Name = 'Newmodule_ref'
-
- e = bd.new( p, int, 'State')
- e.Name = 'NewState'
-
- e = bd.new( p, int, 'Transition')
- e.Name = 'NewTransition'
-
- e = bd.new( p, int, 'event')
- e.Name = 'Newevent'
-
- e = bd.new( p, mod, 'FunctionByInterface')
- e.Name = 'NewFunctionByInterface'
-
- f = bd.new( p, e, 'Argument')
- f.Name = 'NewArgument'
-
- e = bd.new( p, mod, 'State')
- e.Name = 'NewState'
-
- e = bd.new( p, mod, 'task')
- e.Name = 'Newtask'
-
-
- def testE( self ):
- """ testE
- test properties of IMgaFCO such as
- AttributeByName -get/put
- BoolAttrByName -get/put
- ClearAttrByName
-
- first inquire the original values, then modify them
- inquire once again, revert back to the original ones
- then modify and inquire once again using the variant put/getter AttributeByName
- and then use ClearAttrByName to revert back to the "unset state"
- """
-
- mganame = "_tc7_E_gr.mga"
-
- # create the project with the needed kinds
- project = bd.creaP( mganame, "GRATISII")
- if not project:
- self.fail("Create failed")
- try:
- self.populate7E( project)
- except:
- bd.saveP( project)
- raise
- bd.saveP( project)
-
-
- # open the created project
- self.project = project
- try:
- project.Open( "MGA=" + mganame )
- except:
- project.Close(0)
- raise
-
- terr = project.CreateTerritory( None, None, None)
-
- trans = project.BeginTransaction( terr)
-
- to_find = "NewState"
- ns = self.findInProj( project, to_find)
-
- try:
- nnnname = ns.Name
- except:
- print "Caught 1"
- assert 0
-
- assert False == ns.BoolAttrByName( "IsInitial" )
- try:
- i = ns.IntAttrByName ( "IsInitial" ) # try if it works
- except:
- pass
- #print "Inquiring a bool attribute with IntAttributeByName failed, that should be OK"
-
-
- to_find = "Newevent"
- ne = self.findInProj( project, to_find)
-
- try:
- nnnname = ne.Name
- except:
- print "Caught 2"
- assert 0
-
-
- assert False == ne.BoolAttrByName( "Default" )
- assert False == ne.BoolAttrByName( "Async" )
-
- # modify attributes
- ns.SetBoolAttrByNameDisp( "IsInitial", True)
- ne.SetBoolAttrByNameDisp( "Default", True)
- ne.SetBoolAttrByNameDisp( "Async", True)
-
- assert True == ns.BoolAttrByName( "IsInitial" )
- try:
- assert -1 == ns.GetIntAttrByNameDisp ( "IsInitial" ) # try if it works
- except:
- pass
- #print "Inquiring a bool attribute with IntAttributeByName failed, that should be OK"
-
- assert True == ne.BoolAttrByName( "Default" )
- assert True == ne.BoolAttrByName( "Async" )
-
- # revert changes
- ns.SetBoolAttrByNameDisp( "IsInitial", False)
- ne.SetBoolAttrByNameDisp( "Default", False)
- ne.SetBoolAttrByNameDisp( "Async", False)
-
- assert False == ns.BoolAttrByName( "IsInitial" )
- assert False == ne.BoolAttrByName( "Default" )
- assert False == ne.BoolAttrByName( "Async" )
-
-
- # modify values using AttributeByName (test whether VARIANTS are interpreted all right)
-
- ns.SetAttributeByNameDisp( "IsInitial", True )
- ne.SetAttributeByNameDisp( "Default", True )
- ne.SetAttributeByNameDisp( "Async", True )
-
-
- # test whether VARIANTS are returning back good boolean values
-
- bVal1 = False # bool init, so that VARIANTs are converted to bool
- bVal2 = False
- bVal3 = False
- bVal1 = ns.GetAttributeByNameDisp( "IsInitial")
- bVal2 = ne.GetAttributeByNameDisp( "Default")
- bVal3 = ne.GetAttributeByNameDisp( "Async")
-
- assert bVal1 == True
- assert bVal2 == True
- assert bVal3 == True
-
- # reset the attribute to its default value and to its unset state
- ns.ClearAttrByName( "IsInitial" )
- ne.ClearAttrByName( "Default" )
- ne.ClearAttrByName( "Async" )
-
- # check once more the values
- assert False == ns.GetBoolAttrByNameDisp( "IsInitial" )
- assert False == ne.GetBoolAttrByNameDisp( "Default" )
- assert False == ne.GetBoolAttrByNameDisp( "Async" )
-
- # commit trans
- project.CommitTransaction()
-
- project.Save()
- project.Close(0)
-
- pass
-
def populate7F(self, p):
f = bd.newObjInFold( p, p.RootFolder, 'NewModel')
f.Name = 'NewNewModel'
@@ -788,318 +599,6 @@
pass
- def populate7G(self, p):
- f = bd.newFolder( p, p.RootFolder, 'TOSFolder')
- f.Name = 'NewTOSFolder'
-
- cnf = bd.newObjInFold( p, f, 'configuration')
- cnf.Name = 'Newconfiguration'
-
- int = bd.newObjInFold( p, f, 'interface')
- int.Name = 'Newinterface'
-
- e = bd.new( p, cnf, 'State')
- e.Name = 'NewState'
-
- e = bd.new( p, int, 'event')
- e.Name = 'Newevent'
-
-
- def testG( self ):
- """ testG
-
- test properties of IMgaFCO such as
- Attributes([out, retval] IMgaAttributes **pVal)
- Attribute([in] IMgaMetaAttribute *meta, [out, retval] IMgaAttribute **pVal)
-
- first inquire the attributes an fco may have based on its meta (using IMgaFCO.Meta.Attributes)
- then check if these attributes are the expected ones
- then inquire the value of the attributes using IMgaFCO.Attribute
- then check the properties of the IMgaAttribute returned like
- Status
- Value
- OrigValue
- HasChanged
- Meta
- """
-
- mganame = "_tc7_G_gr.mga"
-
- # create the project with the needed kinds
- project = bd.creaP( mganame, "GRATISII")
- if not project:
- self.fail("Create failed")
- try:
- self.populate7G( project)
- except:
- bd.saveP( project)
- raise
- bd.saveP( project)
-
- # open the created project
- self.project = project
- try:
- project.Open( "MGA=" + mganame )
- except:
- project.Close(0)
- raise
-
- terr = project.CreateTerritory( None, None, None)
-
- trans = project.BeginTransaction( terr)
-
- # a "State" object (empty)
- to_find = "NewState"
- ns = self.findInProj( project, to_find)
-
- # attributes of NewState
- attr_list = ns.Attributes
-
- # attributes defined for NewState in its meta (State) -> this returns all possible attributes of FCO (in contrast to DefinedAttributes which returns those which are locally defined in the FCO itself (between the begin-end xml tags of the fco) [see a tipical .xmp file])
- #attr_meta_list_unknown = list( ns.Meta.Attributes ) -> converting to a list will loose the information what kind of pointer is there
- #attr_meta_list = attr_meta_list_unknown # this is still a IUnknown collection
- attr_meta_list = ns.Meta.Attributes
-
- assert attr_list.Count == attr_meta_list.Count
- assert attr_list.Count == 1
-
- names_list = [ "IsInitial" ] # attribute name
- metarefs_list = [ 1010 ] # attribute metaref
-
- # for all attributes State may have
- for i in range( 1, attr_meta_list.Count + 1 ):
- try:
- a_index = metarefs_list.index( attr_meta_list.Item( i ).MetaRef ) # will not throw
- assert attr_meta_list.Item( i ).Name in names_list
-
- # inquire one specific attribute by providing its meta
- attr_i = ns.Attribute( attr_meta_list.Item( i ) )
-
- # the attribute must be present in the attribute list of ns
- assert attr_i in attr_list
- assert True == ( attr_i in attr_list ) # equivalent of the previous
-
- if a_index == 0: # "IsInitial" bool attribute
- bval = attr_i.BoolValue
- assert False == bval
- else:
- assert 0
- except:
- assert 0
-
- # do the same for the following "event" object (empty)
- to_find = "Newevent"
- ne = self.findInProj( project, to_find)
-
- try:
- nnnname = ne.Name
- except:
- print "Caught"
- assert 0
-
-
- # attributes of Newevent
- attr_list = ne.Attributes
-
- # attributes defined for NewEvent in its meta (Event)
- attr_meta_list = ne.Meta.Attributes
-
- assert attr_list.Count == 5
- assert attr_meta_list.Count == 5
-
- names_list = [ "Description", "Type", "TypeModifier", "Default", "Async" ] # attribute names
- metarefs_list = [ 1005, 1015, 1016, 1004, 1001 ] # attribute metarefs
- for i in range( 1, attr_meta_list.Count + 1 ):
-
- try:
- a_index = metarefs_list.index( attr_meta_list.Item( i ).MetaRef ) # will not throw
- assert attr_meta_list.Item( i ).Name in names_list
-
- # inquire one specific attribute by providing its meta
- attr_i = ne.Attribute( attr_meta_list.Item( i ))
-
- # the attribute must be present in the attribute list of ne
- assert attr_i in attr_list
- assert True == ( attr_i in attr_list )
-
- if a_index in [0, 1, 2]:
- assert "" == attr_i.StringValue
- assert "" == attr_i.Value
- assert 0 != attr_i.Status # 0: here
- assert attr_i.OrigValue == attr_i.Value
- assert attr_meta_list.Item( i ) == attr_i.Meta
- #TODO assert False == attr_i.HasChanged # RESU: why is true, it is the original unfilled value
- #assert not attr_i.HasChanged
-
- elif a_index in [3, 4]:
- assert False == attr_i.BoolValue
- assert False == attr_i.Value
- assert 0 != attr_i.Status # 0: here
- assert attr_i.OrigValue == attr_i.Value
- assert attr_meta_list.Item( i ) == attr_i.Meta
- #TODO assert False == attr_i.HasChanged # RESU: why is true?
- #assert not attr_i.HasChanged
-
- else:
- assert 0
- except:
- assert 0
-
- # commit trans
- project.CommitTransaction()
-
- project.Save()
- project.Close(0)
-
- pass
-
- def testHfindInProj( self ):
- """ testHfindInProj
- for testing the findInProj helper method (defined in this file)
- """
-
- mganame = "_tc7_G_gr.mga"
- self.project = project = win32com.client.Dispatch("Mga.MgaProject")
- try:
- project.Open( "MGA=" + mganame )
- except:
- project.Close(0)
- assert 0
-
- terr = project.CreateTerritory( None, None, None)
-
- trans = project.BeginTransaction( terr)
-
- # a "State" object (empty)
- to_find = "NewState"
- ns = self.findInProj( project, to_find)
-
- try:
- nnnname = ns.Name
- except:
- print "Exception Caught. Helper method not working properly. #1"
- assert 0
-
- # do the same for the following "event" object (empty)
- to_find = "Newevent"
- ne = self.findInProj( project, to_find)
-
- try:
- nnnname = ne.Name
- except:
- print "Exception Caught. Helper method not working properly. #2"
- assert 0
-
- # commit trans
- project.CommitTransaction()
-
- project.Save()
- project.Close(0)
-
- pass
-
- def populate7L(self, p):
- f = bd.newFolder( p, p.RootFolder, 'TOSFolder')
- f.Name = 'NewTOSFolder'
-
- mod = bd.newObjInFold( p, f, 'module')
- mod.Name = 'Newmodule'
-
- e = bd.new( p, mod, 'State')
- e.Name = 'NewState'
-
- def testL( self ):
- """ testL
- testing IMgaFCO properties like
- Registry get
- RegistryValue get/put
- RegistryNode get
- and IMgaRegNode property
- Value get/put
-
- inquire and modify values, finally commit transaction to preserve changes
- """
-
- mganame = "_tc7_L_gr.mga"
-
- # create the project with the needed kinds
- project = bd.creaP( mganame, "GRATISII")
- if not project:
- self.fail("Create failed")
- try:
- self.populate7L( project)
- except:
- bd.saveP( project)
- raise
- bd.saveP( project)
-
- # open the created project
- self.project = project
- try:
- project.Open( "MGA=" + mganame )
- except:
- project.Close(0)
- raise
-
- terr = project.CreateTerritory( None, None, None)
-
- trans = project.BeginTransaction( terr)
-
- # a "State" object (empty)
- to_find = "NewState"
- ns = self.findInProj( project, to_find)
-
- # it should return a collection of nodes
- rgnodesA = ns.Registry # virtual nodes too
- rgnodesB = ns.GetRegistryDisp( False ) # just the owned ones
-
- assert rgnodesA.Count == 0 # initally no nodes exist
- assert rgnodesB.Count == 0
-
- rgnod1 = ns.GetRegistryNodeDisp( "OneNode" ) # this step (though it is a Get) will create the named nodes
- rgnod2 = ns.GetRegistryNodeDisp( "AnoNode" )
-
- rgnod1.Value = '1one'
- rgnod2.Value = '2two'
-
- # now it should contain > 0 nodes
- rgnodesA = ns.Registry
- rgnodesB = ns.GetRegistryDisp( False)
-
- # the fresh node must be in the collection
- assert rgnod1 in rgnodesA
-
- assert rgnod1 in rgnodesA
- assert rgnod2 in rgnodesB
-
- assert "1one" == rgnod1.Value
- assert "2two" == rgnod2.Value
-
- assert "1one" == ns.GetRegistryValueDisp( "OneNode" )
- assert "2two" == ns.GetRegistryValueDisp( "AnoNode" )
-
- # modify through the IMgaFCO RegistryValue put-property
- ns.SetRegistryValueDisp( "OneNode", "one1-modified" )
-
- # check it
- assert "one1-modified" == rgnod1.Value
- assert "one1-modified" == ns.GetRegistryValueDisp( "OneNode" )
-
- # modify through the IMgaRegNode Value put-property
- rgnod2.Value = "two2-modified"
-
- # check it
- assert "two2-modified" == rgnod2.Value
- assert "two2-modified" == ns.GetRegistryValueDisp( "AnoNode" )
-
- project.CommitTransaction()
-
- project.Save()
- project.Close(0)
-
- pass
-
-
"""
Let's produce the test suites
"""
Modified: trunk/Tests/GPyUnit/Regr/Mga/utils/Builder.py
==============================================================================
--- trunk/Tests/GPyUnit/Regr/Mga/utils/Builder.py Tue Aug 23 16:50:38 2011 (r1477)
+++ trunk/Tests/GPyUnit/Regr/Mga/utils/Builder.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -122,12 +122,9 @@
# if os.path.isfile( mganame):
# os.remove( mganame)
- try:
- project.Create( "MGA=" + mganame, parad)
- project.BeginTransaction( project.CreateTerritory( None, None, None), 0)
- return project
- except:
- return 0
+ project.Create( "MGA=" + mganame, parad)
+ project.BeginTransaction( project.CreateTerritory( None, None, None), 0)
+ return project
def saveP(project):
try:
Modified: trunk/Tests/GPyUnit/Regr/Mga/utils/xme2mga.py
==============================================================================
--- trunk/Tests/GPyUnit/Regr/Mga/utils/xme2mga.py Tue Aug 23 16:50:38 2011 (r1477)
+++ trunk/Tests/GPyUnit/Regr/Mga/utils/xme2mga.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -55,8 +55,6 @@
p = j[ u + 1 : ]
if p == 'sf':
paradigm = "SF"
- elif p == 'gr':
- paradigm = "GRATISII"
elif p == 'fl':
paradigm = "FloatAttr"
elif p == 'me':
Added: trunk/Tests/GPyUnit/run_tests.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/Tests/GPyUnit/run_tests.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -0,0 +1,31 @@
+import unittest
+
+_tests = unittest.defaultTestLoader.loadTestsFromNames((
+ 'test_registrar',
+ 'GME_297.suite',
+ 'GME_310.suite',
+ 'Regr.Mga.tc1.TestCase1',
+))
+
+import sys
+sys.stdin.readline()
+
+if __name__=='__main__':
+ import optparse
+ parser = optparse.OptionParser()
+ parser.add_option("-x", "--xml", action="store_true", dest="xml")
+ parser.add_option("-v", action="store_true", dest="verbose")
+
+ (options, args) = parser.parse_args()
+ if options.xml:
+ import os.path
+ with open("tests.xml", "w") as output:
+ output.write("<testsuites>")
+ for test in suite(options, args)._tests:
+ runner = xmlrunner.XMLTestRunner(output)
+ runner.run(test)
+ output.write("</testsuites>")
+ else:
+ runner = unittest.TextTestRunner()
+ runner.run(_tests)
+
Added: trunk/Tests/GPyUnit/test_registrar.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/Tests/GPyUnit/test_registrar.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -0,0 +1,12 @@
+import unittest
+
+class TestRegistrar(unittest.TestCase):
+ def test_GetAssociatedParadigmsDisp(self):
+ import win32com.client
+ x = win32com.client.DispatchEx("MGA.MgaRegistrar")
+ self.assertEqual(x.GetAssociatedParadigmsDisp("MGA.Interpreter.MetaInterpreter", 1), (u'MetaGME',))
+
+#suite = (TestRegistrar(),)
+
+if __name__ == "__main__":
+ unittest.main()
Added: trunk/Tests/GPyUnit/util/__init__.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/Tests/GPyUnit/util/__init__.py Tue Aug 23 16:51:43 2011 (r1478)
@@ -0,0 +1,18 @@
+
+class disable_early_binding(object):
+ def __enter__(self):
+ import win32com.client.gencache
+ self._savedGetClassForCLSID = win32com.client.gencache.GetClassForCLSID
+ win32com.client.gencache.GetClassForCLSID = lambda x: None
+ return self
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ import win32com.client
+ win32com.client.gencache.GetClassForCLSID = self._savedGetClassForCLSID
+
+def dec_disable_early_binding(f):
+ def ret(*args, **kwargs):
+ with disable_early_binding():
+ f(*args, **kwargs)
+ ret.__name__ = f.__name__
+ return ret
More information about the gme-commit
mailing list