def testActionEmpty(self): a = Action(name=None,prereqs=None,outcomes=None,cost=None) #no-prereqs, any value OK self.assertTrue(a.satisfied(None)) self.assertTrue( a.satisfied({'dog':True}) ) self.assertEqual(a.cost(),0, 'None is a 0 cost') self.assertEqual(str(a), 'Action(untitled action)')
def testActionSimple(self): timePre = Prereq(int.__ge__, 30) a = Action('work', {'time': timePre}, ([{'cash': 100}], [1.])) self.assertTrue( a.satisfied({'time':50}) ) self.assertFalse( a.satisfied({'dog':True}) ) #no satisfying time entry self.assertFalse( a.satisfied(None) ) #robsut check self.assertEqual(a.cost(), 1) self.assertEqual(str(a), 'Action(work)')