| OLD | NEW |
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 DEPS = [ | 5 DEPS = [ |
| 6 'json', | 6 'json', |
| 7 'path', | 7 'path', |
| 8 'python', | 8 'python', |
| 9 'raw_io', | 9 'raw_io', |
| 10 'step', | 10 'step', |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 assert step_result.json.output == example_dict | 71 assert step_result.json.output == example_dict |
| 72 | 72 |
| 73 # invalid data gets rendered | 73 # invalid data gets rendered |
| 74 step_result = api.step('invalid json', [ | 74 step_result = api.step('invalid json', [ |
| 75 'python', api.resource('cool_script.py'), | 75 'python', api.resource('cool_script.py'), |
| 76 '{"here is some total\ngarbage', | 76 '{"here is some total\ngarbage', |
| 77 api.json.output(), | 77 api.json.output(), |
| 78 ]) | 78 ]) |
| 79 assert step_result.json.output is None | 79 assert step_result.json.output is None |
| 80 | 80 |
| 81 # empty json data is explicit |
| 82 step_result = api.step('empty json', [ |
| 83 'python', api.resource('cool_script.py'), |
| 84 '', |
| 85 api.json.output(), |
| 86 ]) |
| 87 assert step_result.json.output is None |
| 88 |
| 89 # empty json data is explicit |
| 90 step_result = api.step('None json', [ |
| 91 'python', api.resource('cool_script.py'), |
| 92 api.json.output(), |
| 93 ]) |
| 94 assert step_result.json.output is None |
| 95 |
| 81 | 96 |
| 82 def GenTests(api): | 97 def GenTests(api): |
| 83 yield ( | 98 yield ( |
| 84 api.test('basic') | 99 api.test('basic') |
| 85 + api.step_data('echo1', stdout=api.json.output([1, 2, 3])) | 100 + api.step_data('echo1', stdout=api.json.output([1, 2, 3])) |
| 86 + api.step_data( | 101 + api.step_data( |
| 87 'foo', | 102 'foo', |
| 88 api.json.output([1, 2, 3], name='1') + | 103 api.json.output([1, 2, 3], name='1') + |
| 89 api.json.output(['x', 'y', FULLWIDTH_Z], name='2'), | 104 api.json.output(['x', 'y', FULLWIDTH_Z], name='2'), |
| 90 ) | 105 ) |
| 91 + api.step_data( | 106 + api.step_data( |
| 92 'leaking json', | 107 'leaking json', |
| 93 api.json.output({'x': 1, 'y': 2}), | 108 api.json.output({'x': 1, 'y': 2}), |
| 94 ) | 109 ) |
| 95 + api.step_data( | 110 + api.step_data( |
| 96 'invalid json', | 111 'invalid json', |
| 97 api.json.invalid('{"here is some total\ngarbage'), | 112 api.json.invalid('{"here is some total\ngarbage'), |
| 98 ) | 113 ) |
| 114 + api.step_data( |
| 115 'empty json', |
| 116 api.json.invalid(''), |
| 117 ) |
| 99 ) | 118 ) |
| OLD | NEW |