class checkCurable(unittest.TestCase): """ Test that checkCurable actually cures a status when possible """ def setUp(self): """ Builds the delegate and pkmn for use in the tests """ self.pkmn = BuildPokemonBattleWrapper() self.statusAbbr = "PAR" self.status = Paralysis() self.statusAbbr2 = "FRZ" self.delegate = CureStatusDelegate(self.statusAbbr, 1) self.delegate2 = CureStatusDelegate(self.statusAbbr2, 1) def isCurable(self): """ Tests if checkCurable cures the status when it can """ self.pkmn.setStatus(self.status) self.delegate.checkCurable(self.pkmn) assert self.pkmn.getStatus() != self.status, "Status should be cured" def notCurable(self): """ Tests if checkCurable cures the status when it can """ self.pkmn.setStatus(self.status) self.delegate2.checkCurable(self.pkmn) assert self.pkmn.getStatus( ) == self.status, "Status should not be cured"
class checkCurable(unittest.TestCase): """ Test that checkCurable actually cures a status when possible """ def setUp(self): """ Builds the delegate and pkmn for use in the tests """ self.pkmn = BuildPokemonBattleWrapper() self.statusAbbr = "PAR" self.status = Paralysis() self.statusAbbr2 = "FRZ" self.delegate = CureStatusDelegate(self.statusAbbr, 1) self.delegate2 = CureStatusDelegate(self.statusAbbr2, 1) def isCurable(self): """ Tests if checkCurable cures the status when it can """ self.pkmn.setStatus(self.status) self.delegate.checkCurable(self.pkmn) assert self.pkmn.getStatus() != self.status, "Status should be cured" def notCurable(self): """ Tests if checkCurable cures the status when it can """ self.pkmn.setStatus(self.status) self.delegate2.checkCurable(self.pkmn) assert self.pkmn.getStatus() == self.status, "Status should not be cured"
class coreDamage(unittest.TestCase): """ Test that core damage is calculated correctly """ def setUp(self): """ Setup the attack and Pokemon to use the attack """ self.user = BuildPokemonBattleWrapper() self.target = BuildPokemonBattleWrapper() regDelegate = DamageDelegate(None, 50, 1) self.core = regDelegate.coreDamage(self.user, self.target) self.delegate = BoostDamageOnStatusDelegate(None, 50, 1) def noStatus(self): """ Test that damage is core when the target has no status """ self.target.setStatus(Status()) damage = self.delegate.coreDamage(self.user, self.target) assert damage == self.core, "Damage should be the core when target has no status" def status(self): """ Test that damage is double the core when the target has a status """ self.target.setStatus(Burn()) damage = self.delegate.coreDamage(self.user, self.target) assert damage == 2 * self.core, "Damage should double when target has a status"
class coreDamage(unittest.TestCase): """ Test that core damage is calculated correctly """ def setUp(self): """ Setup the attack and Pokemon to use the attack """ self.user = BuildPokemonBattleWrapper() self.target = BuildPokemonBattleWrapper() regDelegate = DamageDelegate(None, 50, 1) self.core = regDelegate.coreDamage(self.user, self.target) self.delegate = BoostDamageOnStatusDelegate(None, 50, 1) def noStatus(self): """ Test that damage is core when the target has no status """ self.target.setStatus(Status()) damage = self.delegate.coreDamage(self.user, self.target) assert damage == self.core, "Damage should be the core when target has no status" def status(self): """ Test that damage is double the core when the target has a status """ self.target.setStatus(Burn()) damage = self.delegate.coreDamage(self.user, self.target) assert damage == 2*self.core, "Damage should double when target has a status"
class checkStatusAlready(unittest.TestCase): """ Test that checkStatusAlready returns correctly """ def setUp(self): """ Builds the delegate and pkmn for use in the tests """ self.pkmn = BuildPokemonBattleWrapper() self.status = "PAR" attack = Attack() attack.type = "" self.delegate = ApplyStatusDelegate(attack, self.status, 1) def hasStatusAlready(self): """ Tests checkStatusAlready returns correctly if the pkmn has a status already """ self.pkmn.setStatus(Paralysis()) assert self.delegate.checkStatusAlready(self.pkmn), "Should have a status already" def hasNoStatusAlready(self): """ Tests checkStatusAlready returns correctly if the pkmn has a status already """ self.pkmn.setStatus(Status()) assert not self.delegate.checkStatusAlready(self.pkmn), "Should not have a status already"
class checkStatusAlready(unittest.TestCase): """ Test that checkStatusAlready returns correctly """ def setUp(self): """ Builds the delegate and pkmn for use in the tests """ self.pkmn = BuildPokemonBattleWrapper() self.status = "PAR" attack = Attack() attack.type = "" self.delegate = ApplyStatusDelegate(attack, self.status, 1) def hasStatusAlready(self): """ Tests checkStatusAlready returns correctly if the pkmn has a status already """ self.pkmn.setStatus(Paralysis()) assert self.delegate.checkStatusAlready( self.pkmn), "Should have a status already" def hasNoStatusAlready(self): """ Tests checkStatusAlready returns correctly if the pkmn has a status already """ self.pkmn.setStatus(Status()) assert not self.delegate.checkStatusAlready( self.pkmn), "Should not have a status already"
class immobilized(unittest.TestCase): """ Test that immobilized performs correctly """ def setUp(self): """ Builds the Sleep status""" self.status = Sleep() self.pkmn = BuildPokemonBattleWrapper() self.pkmn.setStatus(self.status) self.turns = 1 def notDone(self): """ Test if immobilized returns correctly when it is not done """ self.status.turns = self.turns immobilized, messages = self.status.immobilized(self.pkmn) assert immobilized, "Should be immobilized" assert messages == [self.pkmn.getHeader() + Sleep.intermittent],\ "Should return Sleep's intermittent message" assert self.status.turns == self.turns - 1, "Turns should be decremented" def done(self): """ Test if immobilized returns correctly when it is done """ self.status.turns = 0 assert self.pkmn.getStatus( ) == self.status, "Should have status to start" immobilized, messages = self.status.immobilized(self.pkmn) assert not immobilized, "Should not be immobilized" assert len(messages) == 2, "Should have two messages" assert messages[0] == self.pkmn.getHeader() + Sleep.intermittent,\ "Should return Sleep's intermittent message" assert messages[1] == self.pkmn.getHeader() + Sleep.done,\ "Should return Sleep's done message" assert self.pkmn.getStatus() != self.status, "Status should be removed"
class immune(unittest.TestCase): """ Test that immune returns the correct values """ def setUp(self): """ Build side for use in test cases """ self.pkmn = BuildPokemonBattleWrapper() self.parent = Attack() self.parent.type = "NORMAL" def buildDelegate(self, effect): """ Builds a staushit delegate and its parent attack """ self.parent.effectDelegates = [effect] self.delegate = StatusHitDelegate(self.parent, 100) def notImmune(self): """ Test an effect that is not immune returns correctly """ status = Status() self.pkmn.setStatus(status) effect = ApplyStatusDelegate(self.parent, "PAR", 1) self.buildDelegate(effect) assert not self.delegate.immune(self.pkmn, None), "Should not be immune" def immune(self): """ Test an effect that is immune will result in a miss """ status, message = StatusFactory.buildStatusFromAbbr("PAR") self.pkmn.setStatus(status) effect = ApplyStatusDelegate(self.parent, "PAR", 1) self.buildDelegate(effect) assert self.delegate.immune(self.pkmn, None), "Should be immune" def noImmune(self): """ Test an effect that has no immune function isn't immune """ effect = StatModDelegate("ATK", 1, 1) self.buildDelegate(effect) assert not self.delegate.immune(self.pkmn, None), "Should never be immune"
class immobilized(unittest.TestCase): """ Test that immobilized performs correctly """ def setUp(self): """ Builds the Sleep status""" self.status = Sleep() self.pkmn = BuildPokemonBattleWrapper() self.pkmn.setStatus(self.status) self.turns = 1 def notDone(self): """ Test if immobilized returns correctly when it is not done """ self.status.turns = self.turns immobilized, messages = self.status.immobilized(self.pkmn) assert immobilized, "Should be immobilized" assert messages == [self.pkmn.getHeader() + Sleep.intermittent],\ "Should return Sleep's intermittent message" assert self.status.turns == self.turns - 1, "Turns should be decremented" def done(self): """ Test if immobilized returns correctly when it is done """ self.status.turns = 0 assert self.pkmn.getStatus() == self.status, "Should have status to start" immobilized, messages = self.status.immobilized(self.pkmn) assert not immobilized, "Should not be immobilized" assert len(messages) == 2, "Should have two messages" assert messages[0] == self.pkmn.getHeader() + Sleep.intermittent,\ "Should return Sleep's intermittent message" assert messages[1] == self.pkmn.getHeader() + Sleep.done,\ "Should return Sleep's done message" assert self.pkmn.getStatus() != self.status, "Status should be removed"
class immune(unittest.TestCase): """ Test that immune returns the correct values """ def setUp(self): """ Build side for use in test cases """ self.pkmn = BuildPokemonBattleWrapper() self.parent = Attack() self.parent.type ="NORMAL" def buildDelegate(self, effect): """ Builds a staushit delegate and its parent attack """ self.parent.effectDelegates = [effect] self.delegate = StatusHitDelegate(self.parent, 100) def notImmune(self): """ Test an effect that is not immune returns correctly """ status = Status() self.pkmn.setStatus(status) effect = ApplyStatusDelegate(self.parent, "PAR", 1) self.buildDelegate(effect) assert not self.delegate.immune(self.pkmn, None), "Should not be immune" def immune(self): """ Test an effect that is immune will result in a miss """ status, message = StatusFactory.buildStatusFromAbbr("PAR") self.pkmn.setStatus(status) effect = ApplyStatusDelegate(self.parent, "PAR", 1) self.buildDelegate(effect) assert self.delegate.immune(self.pkmn, None), "Should be immune" def noImmune(self): """ Test an effect that has no immune function isn't immune """ effect = StatModDelegate("ATK", 1, 1) self.buildDelegate(effect) assert not self.delegate.immune(self.pkmn, None), "Should never be immune"