def do_dry_run(validations, publishers): """Print which validations will be published by which publishers. Assume all validations fail and list the messages that would have been published. :param validations: List of :py:class:`~.validation.Validation` objects that Alarmageddon would perform. :param publishers: List of :py:class:`~.publisher.Publisher` objects that Alarmageddon would publish validation results to. """ dry_run = _compute_dry_run(validations, publishers) publishers = dry_run.keys() for publisher in sorted( publishers, reverse=True, key=lambda x: x.priority_threshold): print("Publisher: %s (threshold: %s)" % ( publisher.name(), Priority.string(publisher.priority_threshold))) for validation in dry_run[publisher]: print(" %s (priority: %s)" % ( validation.name, Priority.string(validation.priority)))
def test_priority_string(): assert Priority.string(Priority.LOW) == "low" assert Priority.string(Priority.NORMAL) == "normal" assert Priority.string(Priority.CRITICAL) == "critical" assert "unknown" in Priority.string(-1) assert "unknown" in Priority.string("low")