Package teamwork :: Package test :: Package math :: Module testKeys
[hide private]
[frames] | no frames]

Source Code for Module teamwork.test.math.testKeys

 1  from teamwork.action.PsychActions import * 
 2  from teamwork.math.Keys import * 
 3   
 4  import unittest 
 5   
6 -class TestKeys(unittest.TestCase):
7 - def setUp(self):
8 self.action = Action({'actor':'Bill', 9 'type':'picksOn', 10 'object':'Victor'})
11
12 - def testStateKey(self):
13 key = makeStateKey('actor','power') 14 self.assertEqual(str(key),"actor's power") 15 newKey = key.instantiate(self.action) 16 self.assert_(isinstance(newKey,list)) 17 self.assertEqual(len(newKey),1) 18 newKey = newKey[0] 19 self.assertEqual(newKey.__class__,key.__class__) 20 self.assertEqual(str(newKey),"Bill's power")
21
22 - def testXML(self):
23 key = makeStateKey('actor','power') 24 doc = key.__xml__() 25 newKey = Key() 26 newKey = newKey.parse(doc.documentElement) 27 self.assertEqual(key,newKey)
28
29 - def testRelationKey(self):
30 key = RelationshipKey({'relater':'object', 31 'feature':'_likes', 32 'relatee':'actor'}) 33 newKey = key.instantiate(self.action) 34 self.assert_(isinstance(newKey,list)) 35 self.assertEqual(len(newKey),1) 36 newKey = newKey[0] 37 self.assertEqual(str(newKey),'Victor _likes Bill')
38 39 if __name__ == '__main__': 40 unittest.main() 41