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"
def setUp(self): """ Build the Action for the test """ pkmn1 = BuildPokemonBattleWrapper() pkmn2 = BuildPokemonBattleWrapper() pkmn1.setStat("SPD", 30) pkmn2.setStat("SPD", 20) self.fastAction = BuildBattleAction(user = pkmn1) self.slowAction = BuildBattleAction(user = pkmn2) self.usedRandRange = False
class getHeal(unittest.TestCase): """ Test that getHeal returns the right amount to heal """ def setUp(self): """ Builds the heal """ self.pkmn = BuildPokemonBattleWrapper() self.heal = PeriodicHeal("") self.hp = 32 def heal(self): """ Test the heal returns the proper ratio """ self.pkmn.setStat("HP", self.hp) heal = self.heal.getHeal(self.pkmn) assert heal == self.hp / PeriodicHeal.ratio, "Heal should be a sixteenth of the targets health"
class getHeal(unittest.TestCase): """ Test that getHeal returns the right amount to heal """ def setUp(self): """ Builds the heal """ self.pkmn = BuildPokemonBattleWrapper() self.heal = PeriodicHeal("") self.hp = 32 def heal(self): """ Test the heal returns the proper ratio """ self.pkmn.setStat("HP", self.hp) heal = self.heal.getHeal(self.pkmn) assert heal == self.hp/PeriodicHeal.ratio, "Heal should be a sixteenth of the targets health"
class getDamage(unittest.TestCase): """ Test that getDamage returns the right amount of damage """ def setUp(self): """ Builds the Paralysis status""" self.pkmn = BuildPokemonBattleWrapper() self.trap = Trap(None, "", "") self.hp = 32.0 def damage(self): """ Test the damage returns the proper ratio """ self.pkmn.setStat("HP", self.hp) damage = self.trap.getDamage(self.pkmn) assert damage == self.hp/Trap.ratio, "Damage should be a sixteenth of the targets health"
class getAmount(unittest.TestCase): """ Test that getAmount returns the right amount to heal """ def setUp(self): """ Builds the Pkmn and Leech """ self.pkmn = BuildPokemonBattleWrapper() self.pkmn2 = BuildPokemonBattleWrapper() self.leech = Leech(self.pkmn2, "") self.hp = 32 def amount(self): """ Test the heal returns the proper ratio """ self.pkmn.setStat("HP", self.hp) amount = self.leech.getAmount(self.pkmn) assert amount == self.hp / Leech.ratio, "Amount should be a sixteenth of the targets health"
class getAmount(unittest.TestCase): """ Test that getAmount returns the right amount to heal """ def setUp(self): """ Builds the Pkmn and Leech """ self.pkmn = BuildPokemonBattleWrapper() self.pkmn2 = BuildPokemonBattleWrapper() self.leech = Leech(self.pkmn2, "") self.hp = 32 def amount(self): """ Test the heal returns the proper ratio """ self.pkmn.setStat("HP", self.hp) amount = self.leech.getAmount(self.pkmn) assert amount == self.hp/Leech.ratio, "Amount should be a sixteenth of the targets health"
class getDamage(unittest.TestCase): """ Test that immune returns correctly """ def setUp(self): """ Builds the ToxicPoison status""" self.status = ToxicPoison() self.pkmn = BuildPokemonBattleWrapper() #Pokemon("BULBASAUR") self.hp = 64.0 self.pkmn.setStat("HP", self.hp) def damage1stTurn(self): """ Test if 1st turn damage is correct""" self.status.counter = 1 damage = self.status.getDamage(self.pkmn) assert damage == self.hp / ToxicPoison.ratio, "Damage should be hp/ratio" def damage2ndTurn(self): """ Test if it can correctly identify when the target is immune """ self.status.counter = 2 damage = self.status.getDamage(self.pkmn) assert damage == 2 * self.hp / ToxicPoison.ratio, "Damage should be double hp/ratio"
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"
class getDamage(unittest.TestCase): """ Test that immune returns correctly """ def setUp(self): """ Builds the ToxicPoison status""" self.status = ToxicPoison() self.pkmn = BuildPokemonBattleWrapper() #Pokemon("BULBASAUR") self.hp = 64.0 self.pkmn.setStat("HP", self.hp) def damage1stTurn(self): """ Test if 1st turn damage is correct""" self.status.counter = 1 damage = self.status.getDamage(self.pkmn) assert damage == self.hp/ToxicPoison.ratio, "Damage should be hp/ratio" def damage2ndTurn(self): """ Test if it can correctly identify when the target is immune """ self.status.counter = 2 damage = self.status.getDamage(self.pkmn) assert damage == 2*self.hp/ToxicPoison.ratio, "Damage should be double hp/ratio"