def test_failed_primary_health_check(self): """Verifies that a secondary health check is not invoked when a primary check fails""" task = self.create_task(0, 'a') self._health_check_a.health(task).AndReturn(NotRetriable.dead()) self._health_check_a.health(task).AndReturn(Retriable.dead()) health_check = ChainedHealthCheck(self._health_check_a, self._health_check_b) self.replay() assert health_check.health(task) == NotRetriable.dead() assert health_check.health(task) == Retriable.dead() self.verify()
def test_health_statuses(self): """Verfies that the health status tuple (health, retry_status) are as expected""" assert Retriable.alive() == (True, True) assert Retriable.dead() == (False, True) assert NotRetriable.alive() == (True, False) assert NotRetriable.dead() == (False, False)
def test_changed_task_id(self): """Verifes that an instance with a different task id causes the health check to fail""" task_a = self.create_task(0, 'a') task_b = self.create_task(0, 'b') assert self._status_health_check.health(task_a) == Retriable.alive() assert self._status_health_check.health(task_b) == NotRetriable.dead()