[GME-commit] GMESRC/Tests/GPyUnit/Regr/Mga tc1.py,NONE,1.1 tc2.py,NONE,1.1 tc3.py,NONE,1.1 tc4.py,NONE,1.1 tc5.py,NONE,1.1

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Fri Jun 10 22:25:49 CDT 2005


Update of /project/gme-repository/GMESRC/Tests/GPyUnit/Regr/Mga
In directory escher:/tmp/cvs-serv874/Regr/Mga

Added Files:
	tc1.py tc2.py tc3.py tc4.py tc5.py 
Log Message:
Testcases, utils.


CVS User: Zoltan Molnar, ISIS (zolmol)

--- NEW FILE: tc5.py ---
import unittest
import win32com.client
import win32ui
import pythoncom
import os
import utils.Builder
bd = utils.Builder


class TestCase5( unittest.TestCase ):
	"""
	avoid if possible the overriding of __init__, yet if you override use the following form:
	def __init__(self, methodName='runTest'):
		unittest.TestCase.__init__(self, methodName)
	"""

	def setUp( self ):		## hook method
		pass
		
	def tearDown( self ):		## hook method
		self.project.Close( 0 )
		pass


	"""
	def testA( self ):

		" ""    DESCRIPTION
			GetAbsMetaPath([in, out] BSTR *abspath)
			GetRelMetaPath([in] IMgaFCO *begfco, [in, out] BSTR *relpath, [in, defaultvalue(0)] IMgaFCOs *refs)
			
			RESU: relmetapath how can GetRelMetaPath be called from Python
		" ""
		
		pass
	"""

	def populate5B(self, p):
		folder1 = bd.newFolder( p, p.RootFolder, 'Folder')
		folder1.Name = 'Folder'

		compA1 = bd.newObjInFold( p, folder1, 'Compound')
		compA1.Name = 'CompoundA'

		ppM1 = bd.new( p, compA1, 'CompoundParts')
		ppM1.Name = 'CompoundPartsA'

		s1 = bd.new( p, ppM1, 'InputSignals')
		s1.Name = 'inSig'

		s2 = bd.new( p, ppM1, 'OutputSignals')
		s2.Name = 'ouSig'

	def testB( self ):

		"""    testB
			CreateCollection([in,out] IMgaFCOs **pVal)
		"""
		
		mganame = "_tc5_B_sf.mga"

		# create the project with the needed kinds
		project = bd.creaP( mganame, "SF")
		if not project:
			self.fail("Create failed")
		try:
			self.populate5B( project)
		except:
			bd.saveP( project)
			raise
		bd.saveP( project)

		self.project = project

		# open the created project
		project.Open( "MGA=" + mganame )

		terr = project.CreateTerritory( None, None, None)
		trans = project.BeginTransaction( terr)

		fco = bd.findInProj( project, "CompoundA")
		s1  = bd.findInProj( project, "inSig")
		s2  = bd.findInProj( project, "ouSig")
		
		coll = fco.CreateCollection()
		assert coll.Count == 1
		assert coll.Item( 1 ).Name == fco.Name
		
		coll.Append( fco)
		assert coll.Count == 2
		assert coll.Item( 1 ) == fco
		assert coll.Item( 2 ) == fco
		assert coll.Item( 1 ).Name == fco.Name
		assert coll.Item( 2 ).Name == coll.Item( 1 ).Name
		
		col2 = s1.CreateCollection()
		assert col2.Count == 1
		assert col2.Item( 1 ) == s1
		assert col2.Item( 1 ).Name == s1.Name
		
		col2.Append( s2)
		assert col2.Count == 2
		assert col2.Item( 1 ) == s1
		assert col2.Item( 2 ) == s2
		assert col2.Item( 1 ).Name == s1.Name
		assert col2.Item( 2 ).Name == s2.Name
		
		col2.Append( fco)
		assert col2.Count == 3
		assert col2.Item( 1 ) == s1
		assert col2.Item( 2 ) == s2
		assert col2.Item( 3 ) == fco
		assert col2.Item( 1 ).Name == s1.Name
		assert col2.Item( 2 ).Name == s2.Name
		assert col2.Item( 3 ).Name == fco.Name

		# abort trans (thus revert any changes)
		project.AbortTransaction()
		
		project.Save()
		project.Close(0)

		pass

	def populate5C(self, p):
		folder0 = bd.newFolder( p, p.RootFolder, 'Folder')
		folder0.Name = 'Folder0'

		comp0 = bd.newObjInFold( p, p.RootFolder, 'Compound')
		comp0.Name = 'Compound0'
		
		folder1 = bd.newFolder( p, folder0, 'Folder')
		folder1.Name = 'Folder1'

		folder2 = bd.newFolder( p, folder1, 'Folder')
		folder2.Name = 'Folder2'

		comp1 = bd.newObjInFold( p, folder0, 'Compound')
		comp1.Name = 'Compound1'

		comp2 = bd.newObjInFold( p, folder1, 'Compound')
		comp2.Name = 'Compound2'
		
		prim3 = bd.newObjInFold( p, folder2, 'Primitive')
		prim3.Name = 'Primitive3'

		pp3 = bd.new( p, comp2, 'CompoundParts')
		pp3.Name = 'CompoundParts3'

		is3 = bd.new( p, comp2, 'InputSignals')
		is3.Name = 'InSig3'
		
		pp4 = bd.new( p, pp3, 'CompoundParts')
		pp4.Name = 'CompoundParts4'

		ip4 = bd.new( p, pp3, 'InputParameters')
		ip4.Name = 'InPar4'

		pp5 = bd.new( p, pp4, 'CompoundParts')
		pp5.Name = 'CompoundParts5'

		os5 = bd.new( p, pp4, 'OutputSignals')
		os5.Name = 'OutSig5'
		
		is4 = bd.new( p, prim3, 'InputSignals')
		is4.Name = 'InputSig4'
		
		

	def testC( self ):

		"""    testC
			testing property of IMgaFCO
				RootFCO
			
			it should return the first object which is in the hierarchy ( below folders )
		"""
		
		mganame = "_tc5_C_sf.mga"
		# create the project with the needed kinds
		project = bd.creaP( mganame, "SF")
		if not project:
			self.fail("Create failed")
		try:
			self.populate5C( project)
		except:
			bd.saveP( project)
			raise
		bd.saveP( project)

		self.project = project

		# open the created project
		project.Open( "MGA=" + mganame )
		
		terr = project.CreateTerritory( None, None, None)
		trans = project.BeginTransaction( terr)
		
		cm0 = bd.findInProj( project, "Compound0")
		cm1 = bd.findInProj( project, "Compound1")
		cm2 = bd.findInProj( project, "Compound2")
		cm3 = bd.findInProj( project, "CompoundParts3")
		cm4 = bd.findInProj( project, "CompoundParts4")
		cm5 = bd.findInProj( project, "CompoundParts5")
		pm3 = bd.findInProj( project, "Primitive3")
		
		is3 = bd.findInProj( project, "InSig3")
		ip4 = bd.findInProj( project, "InPar4")
		os5 = bd.findInProj( project, "OutSig5")
		is4 = bd.findInProj( project, "InputSig4")
		
		assert cm0 == cm0.RootFCO
		assert cm1 == cm1.RootFCO
		assert cm2 == cm2.RootFCO
		assert cm2 == cm3.RootFCO
		assert cm2 == cm4.RootFCO
		assert cm2 == cm5.RootFCO
		
		assert cm2 == is3.RootFCO
		assert cm2 == ip4.RootFCO
		assert cm2 == os5.RootFCO

		assert pm3 == pm3.RootFCO
		assert pm3 == is4.RootFCO

		# the root objects are usually placed in folders
		assert cm1.ParentFolder		# it should be OK
		try:
		 assert cm1.ParentModel				# it should fail
		 self.fail("It should have failed")		# the previous line should have thrown an exception
		except:
		 #good, it doesn't have a model parent, so 'cm1.ParentModel' should be null
		 pass
		
		
		# their parents are folders
		assert cm2.ParentFolder
		assert pm3.ParentFolder
		
		# abort trans (thus revert any changes)
		project.AbortTransaction()
		
		project.Save()
		project.Close(0)

		pass


"""
	Let's produce the test suites
"""
# 1st way
def suites():
	suite = unittest.makeSuite(TestCase5,'test')
	return suite

# 2nd way
def suites3():
	suite = unittest.TestSuite()
	suite.addTest( TestCase5( "testA"))
	#suite.addTest( TestCase5( "testB"))
	#suite.addTest( TestCase5( "testC"))
	return suite

########
# main
########
if __name__ == "__main__":
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEST BEGINS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	
	######## 1st way
	unittest.main()

	######## 2nd way
	# unittest.main(defaultTest='TestCase5')
	
	######## 3rd way
	# all = suites3()
	# runner = unittest.TextTestRunner()
	# runner.run( all )

--- NEW FILE: tc4.py ---
import unittest
import win32com.client
import win32ui
import pythoncom
import os
import stat
import utils.Builder
bd = utils.Builder


class TestCase4( unittest.TestCase ):
	#avoid if possible the overriding of __init__, yet if you override use the following form:
	#def __init__(self, methodName='runTest'):
	#	unittest.TestCase.__init__(self, methodName)

	def setUp( self ):		## hook method
		pass

	def tearDown( self ):		## hook method
[...1620 lines suppressed...]
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEST BEGINS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	
	######## 1st way
	unittest.main()

	######## 2nd way
	# unittest.main(defaultTest='TestCase4')
	
	######## 3rd way
	# all = suites3()
	# runner = unittest.TextTestRunner()
	# runner.run( all )

--- NEW FILE: tc3.py ---
import unittest
import win32com.client
import win32ui
import pythoncom
import os
import utils.Builder
bd = utils.Builder


class TestCase3( unittest.TestCase ):
	def setUp( self ):		## hook method
		pass

	def tearDown( self ):		## hook method
		pass

	def testA( self ):
		"""    testA

		Create				a project
		Close                           the project
		QueryProjectInfo
		
		"""

		# this file will be created:
		mganame = "_tc3_A_sf.mga"
		project = win32com.client.Dispatch("Mga.MgaProject")

		try:
			project.Create( "MGA=" + mganame, "SF")
		except:
			print "Project Create failed"
			raise
			
		project.Save()
		project.Close(0)

		t = list( project.QueryProjectInfo( "MGA=" + mganame))
		assert t[0] == 1	# mgaversion
		assert t[1] == "SF"	# par name
		assert t[2] == ""	# par version
		assert t[4] == 0	# readonly access ?
		
		t3_guid = list( t[3] )	# convert binary part to a list
		
		t3_cvd = map( ord, t3_guid)
		
		isnull = lambda i: (i == 0 and [True] or [False])[0]
		len1 = filter( isnull, t3_cvd)
		assert len(len1) != 16

		
	def testB( self ):
		"""    testB

		Create				a project
		Close                           the project
		Open				a project
		QueryProjectInfo
		
		"""

		# this file will be created:
		mganame = "_tc4_B_sf.mga"
		project = win32com.client.Dispatch("Mga.MgaProject")

		try:
			project.Create( "MGA=" + mganame, "SF")
		except:
			self.fail('Project create failed')
			print "Project Create failed"
			
		project.Save()
		project.Close(0)

		# now this file has to exist: mganame
		try:
			project.Open( "MGA=" + mganame)
		except:
			print "Project open failed"
			raise

		project.Save()
		project.Close(0)

		t = list( project.QueryProjectInfo( "MGA=" + mganame))
		assert t[0] == 1	# mgaversion
		assert t[1] == "SF"	# par name
		assert t[2] == ""	# par version
		assert t[4] == 0	# readonly access ?
		
		t3_guid = list( t[3] )	# convert binary part to a list
		
		t3_cvd = map( ord, t3_guid)
		
		isnull = lambda i: (i == 0 and [True] or [False])[0]
		len1 = filter( isnull, t3_cvd)
		assert len(len1) != 16 # it can be all null
		
		

"""
	Let's produce the test suites
"""
def suites():
	suite = unittest.makeSuite(TestCase3,'test')
	return suite

def suites2():
	suite = unittest.TestSuite()
	suite.addTest( TestCase3( "testA"))
	#suite.addTest( TestCase3( "testB"))
	#suite.addTest( TestCase3( "testC"))
	return suite

########
# main
########
if __name__ == "__main__":
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEST BEGINS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	
	######## 1st way
	unittest.main()

	######## 2nd way
	# unittest.main(defaultTest='TestCase3')
	
	######## 3rd way
	# all = suites3()
	# runner = unittest.TextTestRunner()
	# runner.run( all )

--- NEW FILE: tc2.py ---
import unittest
import win32com.client
import win32ui
import pythoncom
import os
import utils.Builder
bd = utils.Builder


"""
tests properties of IMgaProject
"""
class TestCase2( unittest.TestCase ):
	m_errors = 0


	def setUp( self ):		## hook method: creates a new mga file all the times, and deletes one if existing
		self.project = win32com.client.Dispatch("Mga.MgaProject")
		
		self.mganame = "_tc2_all_sf.mga"

		try:
			os.remove( self.mganame)
		except:
			pass

		try:
			self.project.Create( "MGA=" + self.mganame, "SF")
		except:
			print "Project Create failed"
			raise
			
		self.terr = self.project.CreateTerritory( None, None, None)
		
		self.trans = self.project.BeginTransaction( self.terr, 0) # TRANSACTION_GENERAL
		
	def tearDown( self ):		## hook method
		#print "Project status is " + str( self.project.ProjectStatus())
		self.project.CommitTransaction()
		
		self.project.Save()
		self.project.Close(0)

	def testA( self ):		## test case 1
		proj_name = self.project.Name
		proj_name = proj_name + "_new"
		self.project.Name = proj_name
		assert self.project.Name == proj_name

	def testB( self ):		
		proj_vers = self.project.Version
		proj_vers = proj_vers + ".1"
		self.project.Version = proj_vers
		assert self.project.Version == proj_vers
		
	def testC( self ):
		proj_meta_name = self.project.MetaName
		assert proj_meta_name == "SF"
		
	def testD( self ):
		proj_meta_guid = list( self.project.MetaGUID )
		guid_conv = []
		all_zero = True
		for i in proj_meta_guid:
			guid_conv.append( hex( ord( i)))
			all_zero = all_zero and i == 0

		assert all_zero == False
		pass
		
	def testE( self ):
		proj_meta_vers = self.project.MetaVersion
		assert proj_meta_vers == ""
		
	def testF( self ):
		proj_create_time = self.project.CreateTime
		assert proj_create_time != ""
		
	def testG( self ):
		proj_change_time = self.project.ChangeTime
		assert proj_change_time != ""
		
	def testH( self ):
		proj_author = "GmeTest::TestCase2"
		self.project.Author = proj_author
		assert proj_author == self.project.Author
		
	def testI( self ):
		proj_comment = "created from python script"
		self.project.Comment = proj_comment
		assert proj_comment == self.project.Comment
		
	def testJ( self ):
		proj_conn_str = self.project.ProjectConnStr
		assert proj_conn_str.find("MGA=") == 0
		assert proj_conn_str.find( self.mganame) != -1
		
	def testK( self ):
		parad_conn_str = self.project.ParadigmConnStr
		assert parad_conn_str.find( "SF") != -1
		
	def testL( self ):
		# the rootfolder has always 1000 as metaref
		rootfld = self.project.MetaObj( 1000 )
		assert rootfld.Name == "RootFolder"
		assert rootfld.MetaRef == 1000
		
		metafld = self.project.MetaObj( 1053 )
		assert metafld.Name == "Folder"
		assert metafld.MetaRef == 1053
	

"""
	Let's produce the test suites
"""
def suites():
	suite = unittest.makeSuite(TestCase2,'test')
	return suite

def suites2():
	suite = unittest.TestSuite()
	suite.addTest( TestCase2( "testA"))
	#suite.addTest( TestCase2( "testB"))
	return suite

########
# main
########
if __name__ == "__main__":
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEST BEGINS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	
	######## 1st way
	# unittest.main()

	######## 2nd way
	unittest.main(defaultTest='TestCase2')
	
	######## 3rd way
	# all = suites3()
	# runner = unittest.TextTestRunner()
        # runner.run( all )

--- NEW FILE: tc1.py ---
import unittest
import win32com.client
import win32ui
import pythoncom
import os
import utils.Builder
bd = utils.Builder


class TestCase1( unittest.TestCase ):
	"""
	avoid if possible the overriding of __init__, yet if you override use the following form:
	def __init__(self, methodName='runTest'):
		unittest.TestCase.__init__(self, methodName)
	"""

	def setUp( self ):		## hook method
		pass

	def tearDown( self ):		## hook method
		pass

	def populateA(self, p):
		folder1 = p.RootFolder.CreateFolder( bd.folder( p, 'SheetFolder'))
		folder1.Name = 'SheetFolder1'
		
		parsh1 = folder1.CreateRootObject( bd.kind( p, 'ParadigmSheet'))
		parsh1.Name = 'ParadigmSheet1'
		
		at1 = bd.new( p, parsh1, 'Atom')
		at1.Name = 'Atom1'

		at2 = bd.new( p, parsh1, 'Atom')
		at2.Name = 'Atom2'
		
		at3 = bd.new( p, parsh1, 'Atom')
		at3.Name = 'Atom3'

		ap1 = bd.new( p, parsh1, 'AtomProxy')
		ap1.Name = 'AtomProx1'

		ap2a = bd.new( p, parsh1, 'AtomProxy')
		ap2a.Name = 'AtomProx2a'
		
		ap2b = bd.new( p, parsh1, 'AtomProxy')
		ap2b.Name = 'AtomProx2b'

		ap1.Referred = at1
		ap2a.Referred = at2
		ap2b.Referred = at2
		

	def testA( self ):
		"""    testA References
			testing getproperties of IMgaFCO
			 ReferencedBy([out, retval] IMgaFCOs **pVal)
		"""
		
		mganame = "_tc1_A_me.mga"

		# create the project with the needed kinds
		project = bd.creaP( mganame, "MetaGME")
		if not project:
			self.fail("Create failed")
		try:
			self.populateA( 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)
		
		at1 = bd.findInProj( project, "Atom1")
		at2 = bd.findInProj( project, "Atom2")
		at3 = bd.findInProj( project, "Atom3")
		atp1 = bd.findInProj( project, "AtomProx1")
		atp2a = bd.findInProj( project, "AtomProx2a")
		atp2b = bd.findInProj( project, "AtomProx2b")
		
		# test at1 with one reference
		assert at1.ReferencedBy.Count == 1
		assert at1.ReferencedBy.Item( 1 ) == atp1
		assert at1.ReferencedBy[0] == atp1

		# test at2 with two references
		refcoll = at2.ReferencedBy
		assert refcoll.Count == 2
		exp_refs = ( atp2a, atp2b )
		assert refcoll.Item( 1 ) in exp_refs
		assert refcoll.Item( 2 ) in exp_refs
		assert refcoll[0] in exp_refs
		assert refcoll[1] in exp_refs
		

		# test at3 with no references
		assert at3.ReferencedBy.Count == 0
		
		# abort trans (thus revert any changes)
		project.AbortTransaction()
		
		project.Save()
		project.Close(0)
		
		pass

	def populateB(self, p):
		folder1 = p.RootFolder.CreateFolder( bd.folder( p, 'SheetFolder'))
		folder1.Name = 'SheetFolder1'
		
		parsh1 = folder1.CreateRootObject( bd.kind( p, 'ParadigmSheet'))
		parsh1.Name = 'ParadigmSheet1'
		
		at1 = bd.new( p, parsh1, 'Atom')
		at1.Name = 'Atom1'

		at2 = bd.new( p, parsh1, 'Atom')
		at2.Name = 'Atom2'
		
		at3 = bd.new( p, parsh1, 'Atom')
		at3.Name = 'Atom3'

		asp1 = bd.new( p, parsh1, 'Aspect')
		asp1.Name = 'Aspect1'

		asp2 = bd.new( p, parsh1, 'Aspect')
		asp2.Name = 'Aspect2'
		
		asp3 = bd.new( p, parsh1, 'Aspect')
		asp3.Name = 'Aspect3'

		# atom1 added to all three aspects
		asp1.AddMember(at1)
		asp2.AddMember(at1)
		asp3.AddMember(at1)
		
		# atom2 added to aspect2
		asp2.addMember(at2)

	def testB( self ):
		"""    testB Sets
			testing getproperties of IMgaFCO
			 MemberOfSets([out, retval] IMgaFCOs **pVal)
		"""
		
		mganame = "_tc1_B_me.mga"

		# create the project with the needed kinds
		project = bd.creaP( mganame, "MetaGME")
		if not project:
			self.fail("Create failed")
		try:
			self.populateB( project)
		except:
			bd.saveP( project)
			raise

		bd.saveP( project)


		# open
		self.project = project
		try:
			project.Open( "MGA=" + mganame )
		except:
			project.Close(0)
			raise

		terr = project.CreateTerritory( None, None, None)
		trans = project.BeginTransaction( terr)
		
		as1 = bd.findInProj( project, "Aspect1")
		as2 = bd.findInProj( project, "Aspect2")
		as3 = bd.findInProj( project, "Aspect3")
		at1 = bd.findInProj( project, "Atom1")
		at2 = bd.findInProj( project, "Atom2")
		at3 = bd.findInProj( project, "Atom3")
		
		# test at3 with no membership
		assert at3.MemberOfSets.Count == 0

		# test at2 with one membership
		assert at2.MemberOfSets.Count == 1
		assert at2.MemberOfSets.Item( 1 ) == as2
		assert at2.MemberOfSets[0] == as2

		# test at1 with 3 memberships
		sets = at1.MemberOfSets
		assert sets.Count == 3
		exp_sets = ( as1, as2, as3 )
		assert sets.Item( 1 ) in exp_sets
		assert sets.Item( 2 ) in exp_sets
		assert sets.Item( 3 ) in exp_sets
		assert sets[0] in exp_sets
		assert sets[1] in exp_sets
		assert sets[2] in exp_sets
		
		# abort trans (thus revert any changes)
		project.AbortTransaction()
		
		project.Save()
		project.Close(0)
		
		pass

	def populateC(self, p):
		folder1 = p.RootFolder.CreateFolder( bd.folder( p, 'SheetFolder'))
		folder1.Name = 'SheetFolder1'
		
		parsh1 = folder1.CreateRootObject( bd.kind( p, 'ParadigmSheet'))
		parsh1.Name = 'ParadigmSheet1'
		
		mo1   = bd.new( p, parsh1, 'Model')
		mo1.Name = 'Model1'
		
		at1 = bd.new( p, parsh1, 'Atom')
		at1.Name = 'Atom1'

		at2 = bd.new( p, parsh1, 'Atom')
		at2.Name = 'Atom2'
		
		at3 = bd.new( p, parsh1, 'Atom')
		at3.Name = 'Atom3'

		# create a connection kind
		connection1 = bd.new( p, parsh1, 'Connection')
		connection1.Name = 'AssocClass1'
		
		# create a connector kind
		connector1 = bd.new( p, parsh1, 'Connector')
		connector1.Name = 'ConnPoint1'
		
		#HRESULT CreateSimpleConn([in] IMgaMetaRole *meta, [in] IMgaFCO *src, [in] IMgaFCO *dst,
		#			 [in] IMgaFCOs *srcrefs, [in] IMgaFCOs *dstrefs, [out] IMgaFCO **newobj);
		
		# this dummy collection will be used for those connections which do not involve connections
		z0 = win32com.client.Dispatch("Mga.MgaFCOs")
		
		try:
		 # create a containment relation between atom1 and model1
		 cc1 = parsh1.CreateSimpleConn( bd.role(p, parsh1, 'Containment'), at1, mo1, z0, z0)
		 cc1.Name = 'Containment_a1_to_m'
		except:
		 print 'Could not create containment1'
		 raise
		
		try:
		 # create a containment relation between atom2 and model1
		 cc2 = parsh1.CreateSimpleConn( bd.role(p, parsh1, 'Containment'), at2, mo1, z0, z0)
		 cc2.Name = 'Containment_a2_to_m'
		except:
		 print 'Could not create containment2'
		 raise
		
		try:
		 # create a 'source2conn' relation between at2 and connector
		 sc = parsh1.CreateSimpleConn( bd.role(p, parsh1, 'SourceToConnector'), at1, connector1, z0, z0)
		 sc.Name = 'SourceToConnector_to_cp'
		except:
		 print 'Could not create source2conn'
		 raise

		try:
		 # create a 'conn2dest' relation between connector and at2
		 dc = parsh1.CreateSimpleConn( bd.role(p, parsh1, 'ConnectorToDestination'), connector1, at1, z0, z0)
		 dc.Name = 'ConnectorToDestination_from_cp'
		except:
		 print 'Could not create conn2dest'
		 raise
		
		try:
		 ac = parsh1.CreateSimpleConn( bd.role(p, parsh1, 'AssociationClass'), connection1, connector1, z0, z0)
		 ac.Name = 'AssocLink' 
		except:
		 print 'Could not create assoc'
		 raise


	def testC( self ):
		"""    testC connections in MetaGME
			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_C_me.mga"

		# create the project with the needed kinds
		project = bd.creaP( mganame, "MetaGME")
		if not project:
			self.fail("Create failed")
		try:
			self.populateC( project)
		except:
			bd.saveP( project)
			raise

		bd.saveP( project)

		# open
		self.project = project
		try:
			project.Open( "MGA=" + mganame )
		except:
			project.Close(0)
			raise
					
		terr = project.CreateTerritory( None, None, None)
		trans = project.BeginTransaction( terr)
		
		mo1 = bd.findInProj( project, "Model1")
		at1 = bd.findInProj( project, "Atom1")
		at2 = bd.findInProj( project, "Atom2")
		at3 = bd.findInProj( project, "Atom3")
		cp1 = bd.findInProj( project, "ConnPoint1")
		
		# test at3 with no conns
		assert at3.PartOfConns.Count == 0

		# test at2 with one connection

		self.failUnless( at2.PartOfConns.Count == 1, 'Bad count:' +  str( at2.PartOfConns.Count))
		assert at2.PartOfConns.Item( 1 ).Target == at2
		assert at2.PartOfConns.Item( 1 ).Owner.Name == "Containment_a2_to_m"
		assert at2.PartOfConns.Item( 1 ).ConnRole == "src"
		assert at2.PartOfConns.Item( 1 ).References.Count == 0

		# test at1 with 3 connections
		cps = at1.PartOfConns		# RESU: Win32 exception releasing IUnknown
		self.failUnless( cps.Count == 3, 'Bad count:' + str( cps.Count))

		conn_name_a = "Containment_a1_to_m"
		conn_name_b = "SourceToConnector_to_cp"
		conn_name_c = "ConnectorToDestination_from_cp"

		conn_a = bd.findInProj( project, conn_name_a)
		conn_b = bd.findInProj( project, conn_name_b)
		conn_c = bd.findInProj( project, conn_name_c)
		
		# conn tuple a1 is expected to be part of
		exp_conns = ( conn_a, conn_b, conn_c )
		exp_conn_names = ( conn_name_a, conn_name_b, conn_name_c)

		# dict of [Name, Role]s ; the roles a1 is expected to participate in the connections
		exp_conn_role = { conn_name_a:"src", conn_name_b:"src", conn_name_c:"dst" }

		# check
		for cp in cps:
			assert cp.References.Count == 0
			assert cp.Target == at1		# "Atom1" is the target of the connection point
			assert cp.Owner in exp_conns	# the connections
			#assert cp.Owner.Name in exp_conn_names	# like above

			assert exp_conn_role.has_key( cp.Owner.Name )
			assert exp_conn_role[ cp.Owner.Name ] == cp.ConnRole

		
		# test the connectionpoint and its links
		cps = cp1.PartOfConns

		conn_name_a = "AssocLink"
		conn_name_b = "SourceToConnector_to_cp"
		conn_name_c = "ConnectorToDestination_from_cp"

		conn_a = bd.findInProj( project, conn_name_a)
		conn_b = bd.findInProj( project, conn_name_b)
		conn_c = bd.findInProj( project, conn_name_c)
		
		# conn tuple cp1 is expected to be part of
		exp_conns = ( conn_a, conn_b, conn_c )
		exp_conn_names = ( conn_name_a, conn_name_b, conn_name_c)

		# dict of [Name, Role]s ; the roles cp1 is expected to participate in the connections
		exp_conn_role = { conn_name_a:"dst", conn_name_b:"dst", conn_name_c:"src" }

		# check
		for cp in cps:
			assert cp.References.Count == 0
			assert cp.Target == cp1		# cp1 is the target of the connection point
			assert cp.Owner in exp_conns	# the connections
			#assert cp.Owner.Name in exp_conn_names	# like above

			assert exp_conn_role.has_key( cp.Owner.Name )
			self.failUnless( exp_conn_role[ cp.Owner.Name ] == cp.ConnRole, 'Got: ' + cp.ConnRole + ' Expected: ' + exp_conn_role[ cp.Owner.Name ] )


		
		# abort trans (thus revert any changes)
		project.AbortTransaction()
		
		project.Save()
		project.Close(0)

		
		pass

	def populateD(self, p):
		folder1 = p.RootFolder.CreateFolder( bd.folder( p, 'Folder'))
		folder1.Name = 'Folder1'
		
		folder2 = p.RootFolder.CreateFolder( bd.folder( p, 'Folder'))
		folder2.Name = 'Folder2'

		comp1 = p.RootFolder.CreateRootObject( bd.kind( p, 'Compound'))
		comp1.Name = 'Compound1'
		
		comp2 = p.RootFolder.CreateRootObject( bd.kind( p, 'Compound'))
		comp2.Name = 'Compound2'
		
		is1 = bd.new( p, comp1, 'InputSignals')
		is1.Name = 'Is'

		os1 = bd.new( p, comp1, 'OutputSignals')
		os1.Name = 'Os'

		compA = bd.new( p, comp1, 'CompoundParts')
		compA.Name = 'CompoundPartsA'

		compB = bd.new( p, comp1, 'CompoundParts')
		compB.Name = 'CompoundPartsB'
		
		portIsA = bd.new( p, compA, 'InputSignals')
		portIsA.Name = 'IsA1'
		portOsA = bd.new( p, compA, 'OutputSignals')
		portOsA.Name = 'OsA1'

		portIpA = bd.new( p, compA, 'InputParameters')
		portIpA.Name = 'IpA1'
		portOpA = bd.new( p, compA, 'OutputParameters')
		portOpA.Name = 'OpA1'

		portIsB = bd.new( p, compB, 'InputSignals')
		portIsB.Name = 'IsB1'
		portOsB = bd.new( p, compB, 'OutputSignals')
		portOsB.Name = 'OsB1'

		portIpB = bd.new( p, compB, 'InputParameters')
		portIpB.Name = 'IpB1'
		portOpB = bd.new( p, compB, 'OutputParameters')
		portOpB.Name = 'OpB1'

		# this dummy collection will be used for those connections which do not involve connections
		z0 = win32com.client.Dispatch("Mga.MgaFCOs")
		
		try:
		 # create a DFC relation between is1 and os1
		 dfc0 = comp1.CreateSimpleConn( bd.role(p, comp1, 'DFC'), is1, os1, z0, z0)
		 dfc0.Name = 'DFC0'
		except:
		 print 'Could not create DFC0'
		 raise

		try:
		 # create a DFC relation between portIsA and portOsB
		 dfc1 = comp1.CreateSimpleConn( bd.role(p, comp1, 'DFC'), portIsA, portOsB, z0, z0)
		 dfc1.Name = 'DFC1'

		 # create a DFC relation between portIsB and portOsA
		 dfc2 = comp1.CreateSimpleConn( bd.role(p, comp1, 'DFC'), portIsB, portOsA, z0, z0)
		 dfc2.Name = 'DFC2'
		except:
		 print 'Could not create DFC1, DFC2'
		 raise
		
		try:
		 # create a PC relation between portIpA and portOpB
		 pc1 = comp1.CreateSimpleConn( bd.role(p, comp1, 'PC'), portIpA, portOpB, z0, z0)
		 pc1.Name = 'PC1'

		 # create a PC relation between portIpB and portOpA using connect method of builder.py
		 # we could use: comp1.CreateSimpleConn( bd.role(p, comp1, 'PC'), portIpB, portOpA, z0, z0)
		 pc2 = bd.connect( p, comp1, portIpB, portOpA, 'PC')
		 pc2.Name = 'PC2'
		except:
		 print 'Could not create PC1, PC2'
		 raise
		pass

	def testD( self ):
		"""    testD 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_D_sf.mga"

		# create the project with the needed kinds
		project = bd.creaP( mganame, "SF")
		if not project:
			self.fail("Create failed")
		try:
			self.populateD( 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)
		
		mo1 = bd.findInProj( project, "Compound1")
		is1 = bd.findInProj( project, "Is")
		os1 = bd.findInProj( project, "Os")
		dc0 = bd.findInProj( project, "DFC0")
		
		pISA = bd.findInProj( project, "IsA1")
		pOSA = bd.findInProj( project, "OsA1")
		pISB = bd.findInProj( project, "IsB1")
		pOSB = bd.findInProj( project, "OsB1")
		dc1 = bd.findInProj( project, "DFC1")
		dc2 = bd.findInProj( project, "DFC2")
		
		# test mo1 with no conns
		assert mo1.PartOfConns.Count == 0

		# test is1,os1 with one connection
		assert is1.PartOfConns.Count == 1
		assert os1.PartOfConns.Count == 1
		
		assert is1.PartOfConns.Item( 1 ).Target == is1
		assert is1.PartOfConns.Item( 1 ).Owner.Name == "DFC0"
		assert is1.PartOfConns.Item( 1 ).ConnRole == "src"
		assert is1.PartOfConns.Item( 1 ).References.Count == 0

		assert os1.PartOfConns.Item( 1 ).Target == os1
		assert os1.PartOfConns.Item( 1 ).Owner.Name == "DFC0"
		assert os1.PartOfConns.Item( 1 ).ConnRole == "dst"
		assert os1.PartOfConns.Item( 1 ).References.Count == 0

		assert len( dc1.ConnPoints) == 2
		for cp in dc1.ConnPoints:
			assert cp.Owner == dc1
			assert cp.References.Count == 0
			
			if cp.ConnRole == 'src':
				assert cp.Target == pISA
			elif cp.ConnRole == 'dst':
				assert cp.Target == pOSB

		assert len( dc2.ConnPoints) == 2
		for cp in dc2.ConnPoints:
			assert cp.Owner == dc2
			assert cp.References.Count == 0
			
			if cp.ConnRole == 'src':
				assert cp.Target == pISB
			elif cp.ConnRole == 'dst':
				assert cp.Target == pOSA


		# abort trans (thus revert any changes)
		project.AbortTransaction()
		
		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
"""
# 1st way
def suites():
	suite = unittest.makeSuite(TestCase1,'test')
	return suite

# 2nd way
def suites2():
	suite = unittest.TestSuite()
	#suite.addTest( TestCase1( "testB"))
	#suite.addTest( TestCase1( "testC"))
	return suite

########
# main
########
if __name__ == "__main__":
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TEST BEGINS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	
	######## 1st way
	unittest.main()

	######## 2nd way
	# unittest.main(defaultTest='TestCase1')
	
	######## 3rd way
	#all = suites2()
	#runner = unittest.TextTestRunner()
	#runner.run( all )



More information about the GME-commit mailing list