From 2ca6a5d0388cf60643ac799d3f21a6102c27cd7a Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Jun 20 2017 02:01:47 +0000 Subject: fix summary wording for the case where only *some* results are missing --- diff --git a/greenwave/policies.py b/greenwave/policies.py index ebb9c52..5767524 100644 --- a/greenwave/policies.py +++ b/greenwave/policies.py @@ -92,9 +92,11 @@ def summarize_answers(answers): failure_count = len([answer for answer in answers if isinstance(answer, TestResultFailed)]) if failure_count: return ('{} of {} required tests failed'.format(failure_count, len(answers))) - if all(isinstance(answer, TestResultMissing) for answer in answers): + missing_count = len([answer for answer in answers if isinstance(answer, TestResultMissing)]) + if missing_count == len(answers): return 'no test results found' - # XXX need to handle some missing but others passing + elif missing_count: + return '{} of {} required tests not found'.format(missing_count, len(answers)) return 'inexplicable result' diff --git a/greenwave/tests/test_policies.py b/greenwave/tests/test_policies.py index 3f7d953..0948126 100644 --- a/greenwave/tests/test_policies.py +++ b/greenwave/tests/test_policies.py @@ -14,6 +14,5 @@ def test_summarize_answers(): assert summarize_answers([TestResultMissing('item', 'test'), TestResultFailed('item', 'test', 'id')]) == \ '1 of 2 required tests failed' - # XXX fix this one assert summarize_answers([TestResultMissing('item', 'test'), RuleSatisfied()]) == \ - 'inexplicable result' + '1 of 2 required tests not found'