def setUp(self): """ Build the BattleSides and weather for the test """ self.message = "Some Message" self.weather = Weather() self.weather.betweenRoundsMessage = self.message self.playerSide = BuildBattleSide() self.opponentSide = BuildBattleSide()
def withMessage(self): """ Test that addRoundMessage adds the Weather's between rounds message """ messages = [] message = "Some Message" weather = Weather() weather.betweenRoundsMessage = message weather.addRoundMessage(messages) assert messages == [message], "Should receive the weather's betweenRoundsMessage"
def withMessage(self): """ Test that addRoundMessage adds the Weather's between rounds message """ messages = [] message = "Some Message" weather = Weather() weather.betweenRoundsMessage = message weather.addRoundMessage(messages) assert messages == [ message ], "Should receive the weather's betweenRoundsMessage"
def performWeatherEffectOnPokemon(self, pokemon): """ Performs the weather's effect on the Pokemon """ messages = [] if not self.immune(pokemon): messages.append("{0} was buffeted by the hail.".format(pokemon.getName())) messages += pokemon.takeRatioOfHealthAsDamage(16) messages += Weather.performWeatherEffectOnPokemon(self, pokemon) return messages
def performWeatherEffectOnPokemon(self, pokemon): """ Performs the weather's effect on the Pokemon """ messages = [] if not self.immune(pokemon): messages.append("{0} was buffeted by the hail.".format( pokemon.getName())) messages += pokemon.takeRatioOfHealthAsDamage(16) messages += Weather.performWeatherEffectOnPokemon(self, pokemon) return messages
class performWeatherEffectOnPokemon(unittest.TestCase): """ Test cases of performWeatherEffectOnPokemon """ def setUp(self): """ Build the Pokemon Battle Wrapper and weather for the test """ self.weather = Weather() self.pkmn = BuildPokemonBattleWrapper() def performWeatherEffectOnPokemonMessage(self): """ Test that performWeatherEffectOnPokemon returns the Weather's between turns message """ messages = self.weather.performWeatherEffectOnPokemon(self.pkmn) assert messages == [], "Should receive an empty between turn message for each Pokemon"
class over(unittest.TestCase): """ Test cases of over """ def setUp(self): """ Build the BattleSides and weather for the test """ self.weather = Weather() def noTurnsLeft(self): """ Test that over returns true when there are no turns left """ self.weather.forever = False self.weather.turnsLeft = 0 assert self.weather.over( ), "Weather should be over when there are no turns left" def noTurnsLeftAfterDecrement(self): """ Test that over returns true when there are no turns left """ self.weather.forever = False self.weather.turnsLeft = 1 assert self.weather.over( ), "Weather should be over when there are no turns left" def turnsLeft(self): """ Test that over returns false when there are turns left """ self.weather.forever = False self.weather.turnsLeft = 3 assert not self.weather.over( ), "Weather should not be over when there are turns left" def foreverAndTurnsLeft(self): """ Test that over returns false when forever is set and there are still turns left """ self.weather.forever = True self.weather.turnsLeft = 4 assert not self.weather.over( ), "Weather should not be over when it is set to last forever" def foreverAndNoTurnsLeft(self): """ Test that over returns false when forever is set and there are no turns left """ self.weather.forever = True self.weather.turnsLeft = 0 assert not self.weather.over( ), "Weather should not be over when it is set to last forever"
class over(unittest.TestCase): """ Test cases of over """ def setUp(self): """ Build the BattleSides and weather for the test """ self.weather = Weather() def noTurnsLeft(self): """ Test that over returns true when there are no turns left """ self.weather.forever = False self.weather.turnsLeft = 0 assert self.weather.over(), "Weather should be over when there are no turns left" def noTurnsLeftAfterDecrement(self): """ Test that over returns true when there are no turns left """ self.weather.forever = False self.weather.turnsLeft = 1 assert self.weather.over(), "Weather should be over when there are no turns left" def turnsLeft(self): """ Test that over returns false when there are turns left """ self.weather.forever = False self.weather.turnsLeft = 3 assert not self.weather.over(), "Weather should not be over when there are turns left" def foreverAndTurnsLeft(self): """ Test that over returns false when forever is set and there are still turns left """ self.weather.forever = True self.weather.turnsLeft = 4 assert not self.weather.over(), "Weather should not be over when it is set to last forever" def foreverAndNoTurnsLeft(self): """ Test that over returns false when forever is set and there are no turns left """ self.weather.forever = True self.weather.turnsLeft = 0 assert not self.weather.over(), "Weather should not be over when it is set to last forever"
class betweenRounds(unittest.TestCase): """ Test cases of betweenRounds """ def setUp(self): """ Build the BattleSides and weather for the test """ self.message = "Some Message" self.weather = Weather() self.weather.betweenRoundsMessage = self.message self.playerSide = BuildBattleSide() self.opponentSide = BuildBattleSide() def betweenRoundsMessage(self): """ Test that betweenRounds returns the Weather's between rounds message """ messages = self.weather.betweenRounds(self.playerSide, self.opponentSide) assert messages == [self.message], "Should receive the weather's betweenRounds message"
class betweenRounds(unittest.TestCase): """ Test cases of betweenRounds """ def setUp(self): """ Build the BattleSides and weather for the test """ self.message = "Some Message" self.weather = Weather() self.weather.betweenRoundsMessage = self.message self.playerSide = BuildBattleSide() self.opponentSide = BuildBattleSide() def betweenRoundsMessage(self): """ Test that betweenRounds returns the Weather's between rounds message """ messages = self.weather.betweenRounds(self.playerSide, self.opponentSide) assert messages == [ self.message ], "Should receive the weather's betweenRounds message"
def setUp(self): """ Build the Pokemon Battle Wrapper and weather for the test """ self.weather = Weather() self.pkmn = BuildPokemonBattleWrapper()
def __init__(self, overCallbackFunction=None, turns=-1, forever=True): """ Build the Hail Weather """ Weather.__init__(self, overCallbackFunction=overCallbackFunction, turns=turns, forever=forever)
def noMessage(self): """ Test that addRoundMessage does not add a message when the Weather has no between rounds message """ messages = [] weather = Weather() weather.addRoundMessage(messages) assert messages == [], "Should receive no message when the Weather object has no message"
def setUp(self): """ Build the BattleSides and weather for the test """ self.weather = Weather()
def noMessage(self): """ Test that addOverMessage does not add a message when the Weather has no between rounds message """ messages = [] weather = Weather() weather.addOverMessage(messages) assert messages == [], "Should receive no message when the Weather object has no message"