Dan Jacques | 2bcefd2 | 2015-05-18 14:57:00 -0700 | [diff] [blame] | 1 | # Copyright 2015 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Unittests for cros_show_waterfall_layout.""" |
| 6 | |
| 7 | from __future__ import print_function |
| 8 | |
| 9 | import json |
| 10 | import os |
| 11 | |
| 12 | from chromite.cbuildbot import constants |
| 13 | from chromite.lib import cros_test_lib |
| 14 | from chromite.scripts import cros_show_waterfall_layout |
| 15 | |
| 16 | # pylint: disable=protected-access |
| 17 | |
| 18 | |
| 19 | class JsonDumpTest(cros_test_lib.OutputTestCase): |
| 20 | """Test the json dumping functionality of cbuildbot_view_config.""" |
| 21 | |
| 22 | def setUp(self): |
| 23 | bin_name = os.path.basename(__file__).rstrip('_unittest.py') |
| 24 | self.bin_path = os.path.join(constants.CHROMITE_BIN_DIR, bin_name) |
| 25 | |
| 26 | def testJSONDumpLoadable(self): |
| 27 | """Make sure config export functionality works.""" |
| 28 | with self.OutputCapturer() as output: |
| 29 | cros_show_waterfall_layout.main(['--format', 'json']) |
| 30 | layout = json.loads(output.GetStdout()) |
| 31 | self.assertFalse(not layout) |
| 32 | |
| 33 | def testTextDump(self): |
| 34 | """Make sure text dumping is capable of being produced.""" |
| 35 | with self.OutputCapturer() as output: |
| 36 | cros_show_waterfall_layout.main(['--format', 'text']) |
| 37 | self.assertFalse(not output.GetStdout()) |