def testGetIsMod(self): mod = ModParser.parse("is x >= 3".split(" "), self.attributes) self.assertEqual({ "attribute": "x", "comparison": ">=", "against": "3" }, mod.args) self.assertEqual("has_attribute", mod.method)
def testApplyHasModFails(self): mod = ModParser.parse("has a 3".split(" "), self.attributes) result = mod.apply(self.story_cache) self.assertFalse(result)
def testApplyHasModMultipleQuantity(self): mod = ModParser.parse("has a 2".split(" "), self.attributes) result = mod.apply(self.story_cache) self.assertTrue(result)
def testGetHasMod(self): mod = ModParser.parse("has a 12".split(" "), self.attributes) self.assertEqual({"item_type": "a", "amount": "12"}, mod.args) self.assertEqual("has_item", mod.method)
def testApplyRndMod(self): mod = ModParser.parse("random 100".split(" "), self.attributes) result = mod.apply(self.story_cache) self.assertTrue(result)
def testGetRndMod(self): mod = ModParser.parse("random 33".split(" "), self.attributes) self.assertEqual({"percentage": "33"}, mod.args) self.assertEqual("rnd", mod.method)
def testApplyIsModSuccessSmallerOrEqualThan(self): mod = ModParser.parse("is x <= 3".split(" "), self.attributes) result = mod.apply(self.story_cache) self.assertTrue(result)
def testApplyIsModFailsBiggerThan(self): mod = ModParser.parse("is x > 3".split(" "), self.attributes) result = mod.apply(self.story_cache) self.assertFalse(result)
def testApplyIsModSuccessBiggerThan(self): mod = ModParser.parse("is x > 2".split(" "), self.attributes) result = mod.apply(self.story_cache) self.assertTrue(result)
def testGetIsMod(self): mod = ModParser.parse("is x >= 3".split(" "), self.attributes) self.assertEqual({"attribute": "x", "comparison": ">=", "against": "3"}, mod.args) self.assertEqual("has_attribute", mod.method)
def testApplyIsModFailsSmallerEqualThan(self): mod = ModParser.parse("is x =< 2".split(" "), self.attributes) result = mod.apply(self.story_cache) self.assertFalse(result)