OLD | NEW |
(Empty) | |
| 1 from slave import recipe_api |
| 2 |
| 3 from .util import TestResults |
| 4 |
| 5 class JsonTestApi(recipe_api.RecipeTestApi): |
| 6 @staticmethod |
| 7 def output(data): |
| 8 return {'json': {'output': data}} |
| 9 |
| 10 @staticmethod |
| 11 def test_output_object(): |
| 12 return TestResults() |
| 13 |
| 14 def canned_test_output(self, good, passes=9001): |
| 15 """Produces a 'json test results' compatible object with some canned tests. |
| 16 Args: |
| 17 good - Determines if this test result is passing or not. |
| 18 passes - The number of (theoretically) passing tests. |
| 19 """ |
| 20 bad = lambda fail_val: None if good else fail_val |
| 21 t = self.test_output_object() |
| 22 t.raw['num_passes'] = passes |
| 23 t.add_result('good/totally-awesome.html', 'PASS') |
| 24 t.add_result('flake/totally-flakey.html', 'PASS', bad('TIMEOUT PASS')) |
| 25 t.add_result('tricky/totally-maybe-not-awesome.html', 'PASS', bad('FAIL')) |
| 26 t.add_result('bad/totally-bad-probably.html', 'PASS', bad('FAIL')) |
| 27 return {'json': {'test_results': t.as_jsonish()}} |
OLD | NEW |