예제 #1
0
class checkFlinch(unittest.TestCase):
    """ Test cases of checkFlinch """
    
    def  setUp(self):
        """ Build the Pkmn and Precondition Checker for the test """
        self.user = BuildPokemonBattleWrapper()
        self.target = BuildPokemonBattleWrapper()
        self.environment = BattleEnvironment()
        
        attack = AttackFactory.getAttackAsNew("TACKLE")
        self.preconditionChecker = PreconditionChecker(self.user, self.target, self.environment, attack)
        
    def flinching(self):
        """ Test that check flinch returns correctly when the user has is flinching """
        self.user.flinching = True
        stop, messages = self.preconditionChecker.checkFlinch()
        
        message = [self.user.getHeader() + " flinched."]
        
        assert stop, "Should stop if the user flinches"
        assert messages == message, "Should have flinching message"
        
    def notFlinching(self):
        """ Test that check flinch returns correctly when the user is not flinching """
        self.user.flinching = False
        stop, messages = self.preconditionChecker.checkLock()
        
        assert not stop, "Should not stop if the user isn't flinching"
        assert messages == [], "Should not receive any messages"