class applyEffect(unittest.TestCase): """ Test cases of applyEffect """ def setUp(self): """ Build the Effect and Pkmn for the test """ self.stat1 = "ATK" self.stat2 = "DEF" self.val1 = 50 self.val2 = 20 self.user = BuildPokemonBattleWrapper() self.delegate = SwapStatDelegate(self.stat1, self.stat2) def swapped(self): """ Test that the stats are swapped """ self.user.setStat(self.stat1, self.val1) self.user.setStat(self.stat2, self.val2) self.delegate.applyEffect(self.user, None, None) assert self.user.getStat( self.stat1) == self.val2, "Stat 1 should get Stat 2's value" assert self.user.getStat( self.stat2) == self.val1, "Stat 2 should get Stat 1's value" def message(self): """ Test that the message is returned correctly """ messages = self.delegate.applyEffect(self.user, None, None) message = SwapStatDelegate.message % (self.user.getHeader(), self.stat1, self.stat2) assert messages == [ message ], "Message should say the user had its two stats swapped"
class applyEffect(unittest.TestCase): """ Test cases of applyEffect """ def setUp(self): """ Build the Effect and Pkmn for the test """ self.stat1 = "ATK" self.stat2 = "DEF" self.val1 = 50 self.val2 = 20 self.user = BuildPokemonBattleWrapper() self.delegate = SwapStatDelegate(self.stat1, self.stat2) def swapped(self): """ Test that the stats are swapped """ self.user.setStat(self.stat1, self.val1) self.user.setStat(self.stat2, self.val2) self.delegate.applyEffect(self.user, None, None) assert self.user.getStat(self.stat1) == self.val2, "Stat 1 should get Stat 2's value" assert self.user.getStat(self.stat2) == self.val1, "Stat 2 should get Stat 1's value" def message(self): """ Test that the message is returned correctly """ messages = self.delegate.applyEffect(self.user, None, None) message = SwapStatDelegate.message % (self.user.getHeader(), self.stat1, self.stat2) assert messages == [message], "Message should say the user had its two stats swapped"
class heal(unittest.TestCase): """ Test cases of heal """ def setUp(self): """ Build the Pkmn and Delegate for the test """ self.pkmn = BuildPokemonBattleWrapper() self.ratio = 2 self.delegate = HealByHPRatioDelegate(self.ratio) def heal(self): """ Test that it heals by the ratio of the damage done """ self.pkmn.setCurrHP(0) self.delegate.heal(self.pkmn) hp = self.pkmn.getCurrHP() heal = self.pkmn.getStat("HP") / self.ratio assert hp == heal, "Should be healed by the ratio of the user's health"
class afterTurn(unittest.TestCase): """ Test that afterTurn works correctly """ def setUp(self): """ Builds the Paralysis status""" self.status = Burn() self.pkmn = BuildPokemonBattleWrapper() def damage(self): """ Test that the damage is done correctly """ self.pkmn.setStat("HP", 32) self.pkmn.setCurrHP(32) self.status.afterTurn(self.pkmn) damage = self.pkmn.getStat("HP") - self.pkmn.getCurrHP() assert damage == self.pkmn.getRatioOfHealth(Burn.ratio), "Damage should be Burn Ratio of Health" def message(self): """ Test that the message is returned correctly """ messages = self.status.afterTurn(self.pkmn) message = self.pkmn.getHeader() + Burn.intermittent assert len(messages) == 1, "Should get one message" assert messages[0] == message, "Message should be that the Pkmn was damaged by the Burn"
class afterTurn(unittest.TestCase): """ Test that afterTurn works correctly """ def setUp(self): """ Builds the Paralysis status""" self.status = Burn() self.pkmn = BuildPokemonBattleWrapper() def damage(self): """ Test that the damage is done correctly """ self.pkmn.setStat("HP", 32) self.pkmn.setCurrHP(32) self.status.afterTurn(self.pkmn) damage = self.pkmn.getStat("HP") - self.pkmn.getCurrHP() assert damage == self.pkmn.getRatioOfHealth( Burn.ratio), "Damage should be Burn Ratio of Health" def message(self): """ Test that the message is returned correctly """ messages = self.status.afterTurn(self.pkmn) message = self.pkmn.getHeader() + Burn.intermittent assert len(messages) == 1, "Should get one message" assert messages[ 0] == message, "Message should be that the Pkmn was damaged by the Burn"