예제 #1
0
class checkFaint(unittest.TestCase):
    """ Test cases of checkFaint """
    
    def  setUp(self):
        """ Build the Pkmn, Lock, and Precondition Checker for the test """
        self.user = BuildPokemonBattleWrapper()
        self.target = BuildPokemonBattleWrapper()
        self.environment = BattleEnvironment()
        
        self.actionLock = BuildActionLock(user = self.user)
        self.attack = AttackFactory.getAttackAsNew("TACKLE")
        self.preconditionChecker = PreconditionChecker(self.user, self.target, self.environment, self.attack)
        
    def fainted(self):
        """ Test that check faint returns correctly when the user has fainted  """
        self.user.faint()
        stop, messages = self.preconditionChecker.checkFaint()
        
        assert stop, "Should stop if the user is fainted"
        assert messages == [],  "Should receive the messages for the actual attack"
        
    def notFainted(self):
        """ Test that check faint returns correctly when the user has not fainted  """
        stop, messages = self.preconditionChecker.checkFaint()
        
        assert not stop, "Should not stop if the user is using its lock"
        assert messages == [], "Should not receive any messages"