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