Пример #1
0
class comparePrioirty(unittest.TestCase):
    """ Test cases of comparePrioirty """
    
    def  setUp(self):
        """ Build the Action for the test """
        self.highPriorityAction = BuildBattleAction(priority = 1)
        self.lowPriorityAction = BuildBattleAction(priority = 0)
        self.lowPriorityAction.compareSpeed = self.compareSpeed
        
        self.calledCompareSpeed = False
        
    def less(self):
        """ Test that lower priorities return correctly """
        cmp = self.lowPriorityAction.comparePriority(self.highPriorityAction)
        assert cmp == -1, "Should return -1 when the priority is less"
        
    def more(self):
        """ Test that higher priorities return correctly """
        cmp = self.highPriorityAction.comparePriority(self.lowPriorityAction)
        assert cmp == 1, "Should return 1 when the priority is more"
        
    def tie(self):
        """ Test that lower priorities return correctly """
        cmp = self.lowPriorityAction.comparePriority(self.lowPriorityAction)
        assert self.calledCompareSpeed, "Should have compared based on speed"
        
    def compareSpeed(self, other):
        self.calledCompareSpeed = True