[Modeling-cvs] ProjectModeling/Modeling/tests test_Relationship.py,1.3,1.4 test_RelationshipManipula
Status: Abandoned
Brought to you by:
sbigaret
|
From: <sbi...@us...> - 2003-07-24 17:02:39
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv14424/tests
Modified Files:
test_Relationship.py test_RelationshipManipulation.py
Log Message:
Fixed bug #776996: RelationshipManipulation methods misbehaving w/
inheritance. Implied fixing: Relationship.inverseRelationship().
Also added: entity.parentEntities()
Index: test_Relationship.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_Relationship.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_Relationship.py 10 Jan 2003 10:45:45 -0000 1.3
--- test_Relationship.py 24 Jul 2003 17:02:34 -0000 1.4
***************
*** 28,34 ****
--- 28,36 ----
if __name__ == "__main__":
import utils, sys
+ utils.disable_model_cache()
utils.fixpath()
from Modeling import ModelSet
+ import StoreEmployees
# load the model
***************
*** 117,123 ****
--- 119,165 ----
rel_da.validateValue([A(), A(), A()])
+
+
+ class TestRelationship_n_Inheritance(unittest.TestCase):
+ "Tests the relationships in inheritance "
+ model=ModelSet.defaultModelSet().modelNamed('StoreEmployees')
+ employee=model.entityNamed('Employee')
+ executive=model.entityNamed('Executive')
+ salesclerk=model.entityNamed('SalesClerk')
+ address=model.entityNamed('Address')
+
+ def test_01_inverseRelationship(self):
+ "[Relationship/Inheritance] inverseRelationship"
+ ## Add PersonalAddress, stupid subentity for Address
+ from Modeling.Entity import externalNameForInternalName
+ paddress=self.address.clone('PersonalAddress', model)
+ self.address.addSubEntity(paddress)
+ paddress.setClassName('AuthorBooks.PersonalAddress') # does not exist
+ paddress.setExternalName(externalNameForInternalName('PersonalAddress'))
+
+ ###
+ self.perso_address=model.entityNamed('PersonalAddress')
+
+ emp_toAddr=self.employee.relationshipNamed('toAddresses')
+ ex_toAddr=self.executive.relationshipNamed('toAddresses')
+ sc_toAddr=self.salesclerk.relationshipNamed('toAddresses')
+
+ addr_toEmp=self.address.relationshipNamed('toEmployee')
+ paddr_toEmp=self.perso_address.relationshipNamed('toEmployee')
+
+ emp_toAddr_inverse=emp_toAddr.inverseRelationship()
+ self.failUnless(emp_toAddr_inverse)
+ self.assertEqual(ex_toAddr.inverseRelationship(), emp_toAddr_inverse)
+ self.assertEqual(sc_toAddr.inverseRelationship(), emp_toAddr_inverse)
+
+ addr_toEmp_inverse=addr_toEmp.inverseRelationship()
+ paddr_toEmp_inverse=paddr_toEmp.inverseRelationship()
+ self.assertEqual(addr_toEmp_inverse, emp_toAddr)
+ self.assertEqual(paddr_toEmp_inverse, emp_toAddr)
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestRelationship, "test_"))
+ suite.addTest(unittest.makeSuite(TestRelationship_n_Inheritance, "test_"))
return suite
Index: test_RelationshipManipulation.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_RelationshipManipulation.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_RelationshipManipulation.py 10 Jan 2003 10:45:45 -0000 1.2
--- test_RelationshipManipulation.py 24 Jul 2003 17:02:34 -0000 1.3
***************
*** 286,292 ****
--- 286,316 ----
+ class TestRelationshipManipulation_n_Inheritance(unittest.TestCase):
+ "Tests for RelationshipManipulation in an inheritance environment"
+ def test_01_addToBothSideOfRelationshipWithKey_one_to_many(self):
+ "[RelationshipManipulation/Inheritance] addObjToBothSide() one-to-many"
+ from StoreEmployees import Employee, Executive, SalesClerk, Address
+ emp=Employee.Employee()
+ a=Address.Address()
+ emp.addObjectToBothSidesOfRelationshipWithKey(a, 'toAddresses')
+ self.failUnless(a in emp.getToAddresses())
+ self.failUnless(emp == a.getToEmployee())
+
+ ex=Executive.Executive()
+ a=Address.Address()
+ ex.addObjectToBothSidesOfRelationshipWithKey(a, 'toAddresses')
+ self.failUnless(a in ex.getToAddresses())
+ self.failUnless(ex == a.getToEmployee())
+
+ sc=SalesClerk.SalesClerk()
+ a=Address.Address()
+ sc.addObjectToBothSidesOfRelationshipWithKey(a, 'toAddresses')
+ self.failUnless(a in sc.getToAddresses())
+ self.failUnless(sc == a.getToEmployee())
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestRelationshipManipulation, "test_"))
+ suite.addTest(unittest.makeSuite(TestRelationshipManipulation_n_Inheritance, "test_"))
return suite
|