Home | Trees | Indices | Help |
|
---|
|
1 from teamwork.action.PsychActions import * 2 import unittest 3132 133 if __name__ == '__main__': 134 unittest.main() 1356 self.verbs = ['Listen','OpenLeft','OpenRight'] 7 self.players = ['Player 1','Player 2'] 8 self.joints = [] 9 for index in range(pow(len(self.verbs),len(self.players))): 10 joint = {} 11 for player in self.players: 12 subIndex = index % len(self.verbs) 13 joint[player] = [Action({'actor': player, 14 'type': self.verbs[subIndex]})] 15 index /= len(self.verbs) 16 self.joints.append(joint)1719 condition = ActionCondition() 20 # Test adding 21 for index in range(len(self.verbs)): 22 condition.addCondition(self.verbs[index]) 23 self.assertEqual(len(condition),index+1) 24 # Test for no duplication 25 for index in range(len(self.verbs)): 26 condition.addCondition(self.verbs[index]) 27 self.assertEqual(len(condition),len(self.verbs)) 28 # Test deleting 29 for index in range(len(self.verbs)): 30 condition.delCondition(self.verbs[index]) 31 self.assertEqual(len(condition),len(self.verbs)-index-1)3234 """@return: test condition on "OL and OR" 35 """ 36 condition = ActionCondition() 37 condition.addCondition('OpenLeft') 38 condition.addCondition('OpenRight') 39 return condition4042 """ 43 @return: test condition on only "Listen"s 44 """ 45 condition = ActionCondition(True) 46 condition.addCondition('Listen') 47 return condition48 4951 """ 52 @return: test condition on number of "Listen"s 53 """ 54 condition = ActionCondition(False,True) 55 condition.addCondition('Listen') 56 return condition5759 """ 60 Verifies a condition on OpenLeft+OpenRight 61 """ 62 for joint in self.joints: 63 verbs = map(lambda o: o[0]['type'],joint.values()) 64 if condition.match(joint): 65 self.assertNotEqual(verbs[0],verbs[1]) 66 self.assertNotEqual(verbs[0],'Listen') 67 self.assertNotEqual('Listen',verbs[1]) 68 else: 69 self.assert_('Listen' in verbs or verbs[0] == verbs[1])7072 """ 73 Verifies a condition on OpenLeft 74 """ 75 for joint in self.joints: 76 verbs = map(lambda o: o[0]['type'],joint.values()) 77 if condition.match(joint): 78 self.assert_('OpenLeft' in verbs) 79 else: 80 self.assertNotEqual(verbs[0],'OpenLeft') 81 self.assertNotEqual(verbs[1],'OpenLeft')8284 """ 85 Verifies a condition on only Listen 86 """ 87 for joint in self.joints: 88 verbs = map(lambda o: o[0]['type'],joint.values()) 89 if condition.match(joint): 90 self.assertEqual(verbs[0],'Listen') 91 self.assertEqual(verbs[1],'Listen') 92 else: 93 self.assert_(verbs[0] != 'Listen' or verbs[1] != 'Listen')9496 # Test condition on "OL" + "OR" 97 condition = self.createOLOR() 98 self.verifyOLOR(condition) 99 # Test condition on "OL" 100 condition.delCondition('OpenRight') 101 self.verifyOL(condition) 102 # Test condition on only "Listen"s 103 condition = self.createListen() 104 self.verifyListen(condition)105107 # Test condition on Listen counts 108 condition = self.createListenCount() 109 for joint in self.joints: 110 verbs = map(lambda o: o[0]['type'],joint.values()) 111 self.assertEqual(verbs.count('Listen'),condition.match(joint))112114 # Test condition on "OL" + "OR" 115 condition = self.createOLOR() 116 doc = condition.__xml__() 117 condition = ActionCondition() 118 condition.parse(doc.documentElement) 119 self.verifyOLOR(condition) 120 # Test condition on "OL" 121 condition.delCondition('OpenRight') 122 doc = condition.__xml__() 123 condition = ActionCondition() 124 condition.parse(doc.documentElement) 125 self.verifyOL(condition) 126 # Test condition on only "Listen"s 127 condition = self.createListen() 128 doc = condition.__xml__() 129 condition = ActionCondition() 130 condition.parse(doc.documentElement) 131 self.verifyListen(condition)
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Aug 19 16:49:12 2009 | http://epydoc.sourceforge.net |