Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv5376/tests
Modified Files:
test_Model.py test_Relationship.py
Log Message:
Added Relationship.anyInverseRelationship() --plus entity Holidays in test
model StoreEmployees, with a toMany rel. Employee-->Holidays having no
inverse. This is the first step towards the removal of the constraint on
to-many relationships that should have an inverse toOne rel. for the moment
being.
Index: test_Model.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_Model.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** test_Model.py 24 Jul 2003 16:46:36 -0000 1.5
--- test_Model.py 25 Jul 2003 15:39:04 -0000 1.6
***************
*** 35,39 ****
def checkStoreEmployee(self, model):
"Minimum checking of model StoreEmployees"
! entities=('Store','Employee','Executive','SalesClerk','Mark','Address')
self.assertEqual(len(model.entities()), len(entities))
for e in entities:
--- 35,39 ----
def checkStoreEmployee(self, model):
"Minimum checking of model StoreEmployees"
! entities=('Store','Employee','Executive','SalesClerk','Mark','Address','Holidays')
self.assertEqual(len(model.entities()), len(entities))
for e in entities:
Index: test_Relationship.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_Relationship.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_Relationship.py 24 Jul 2003 17:02:34 -0000 1.4
--- test_Relationship.py 25 Jul 2003 15:39:04 -0000 1.5
***************
*** 25,28 ****
--- 25,30 ----
"""Tests for module Relationship"""
+ from __future__ import nested_scopes
+
import unittest
if __name__ == "__main__":
***************
*** 128,131 ****
--- 130,134 ----
salesclerk=model.entityNamed('SalesClerk')
address=model.entityNamed('Address')
+ holidays=model.entityNamed('Holidays')
def test_01_inverseRelationship(self):
***************
*** 158,161 ****
--- 161,203 ----
self.assertEqual(paddr_toEmp_inverse, emp_toAddr)
+ def test_02_anyInverseRelationship(self):
+ "[Relationship/Inheritance] anyInverseRelationship"
+ emp_toAddr=self.employee.relationshipNamed('toAddresses')
+ ex_toAddr=self.executive.relationshipNamed('toAddresses')
+ sc_toAddr=self.salesclerk.relationshipNamed('toAddresses')
+
+ emp_holidays=self.employee.relationshipNamed('holidays')
+ ex_holidays=self.executive.relationshipNamed('holidays')
+ sc_holidays=self.salesclerk.relationshipNamed('holidays')
+
+ # relationship 'toAddresses' has inverse defined in the model
+ self.assertEqual(emp_toAddr.anyInverseRelationship(),
+ emp_toAddr.inverseRelationship())
+ self.assertEqual(ex_toAddr.anyInverseRelationship(),
+ ex_toAddr.inverseRelationship())
+ self.assertEqual(sc_toAddr.anyInverseRelationship(),
+ sc_toAddr.inverseRelationship())
+ # relationships 'toHolidays' has no inverse defined in the model
+ self.assertEqual(emp_holidays.inverseRelationship(), None)
+
+ def check_inverse(inverse):
+ self.failIf(inverse is None)
+ self.failIf(inverse in self.holidays.relationships())
+ self.assertEqual(inverse.entity(), self.holidays)
+ self.failUnless(inverse.isToOne())
+ self.assertEqual(inverse.entity(), self.holidays)
+ self.assertEqual(inverse.destinationEntity(), self.employee)
+ self.assertEqual(inverse.inverseRelationship(), emp_holidays)
+
+ any_inv_emp_holidays=emp_holidays.anyInverseRelationship()
+ check_inverse(any_inv_emp_holidays)
+
+ any_inv_ex_holidays=ex_holidays.anyInverseRelationship()
+ check_inverse(any_inv_ex_holidays)
+
+ any_inv_sc_holidays=sc_holidays.anyInverseRelationship()
+ check_inverse(any_inv_sc_holidays)
+
+
def test_suite():
suite = unittest.TestSuite()
|