Alex Klein | 2008aee | 2019-08-20 16:25:27 -0600 | [diff] [blame] | 1 | # Copyright 2019 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 | """API Config unit tests.""" |
| 6 | |
Alex Klein | 2008aee | 2019-08-20 16:25:27 -0600 | [diff] [blame] | 7 | from chromite.api.api_config import ApiConfig |
| 8 | from chromite.lib import cros_test_lib |
| 9 | |
| 10 | |
| 11 | class ApiConfigTest(cros_test_lib.TestCase): |
| 12 | """ApiConfig tests.""" |
| 13 | |
Alex Klein | 2008aee | 2019-08-20 16:25:27 -0600 | [diff] [blame] | 14 | def test_do_validation(self): |
| 15 | """Sanity check for the do validation property being True.""" |
| 16 | # Should validate by default, and when only doing validation. |
| 17 | config = ApiConfig() |
| 18 | self.assertTrue(config.do_validation) |
Alex Klein | d815ca6 | 2020-01-10 12:21:30 -0700 | [diff] [blame] | 19 | config = ApiConfig(call_type=ApiConfig.CALL_TYPE_VALIDATE_ONLY) |
Alex Klein | 2008aee | 2019-08-20 16:25:27 -0600 | [diff] [blame] | 20 | self.assertTrue(config.do_validation) |
| 21 | |
| 22 | def test_no_do_validation(self): |
| 23 | """Sanity check for skipping validation for mock calls.""" |
Alex Klein | d815ca6 | 2020-01-10 12:21:30 -0700 | [diff] [blame] | 24 | config = ApiConfig(call_type=ApiConfig.CALL_TYPE_MOCK_SUCCESS) |
Alex Klein | 2008aee | 2019-08-20 16:25:27 -0600 | [diff] [blame] | 25 | self.assertFalse(config.do_validation) |
Alex Klein | d815ca6 | 2020-01-10 12:21:30 -0700 | [diff] [blame] | 26 | config = ApiConfig(call_type=ApiConfig.CALL_TYPE_MOCK_FAILURE) |
Alex Klein | 2008aee | 2019-08-20 16:25:27 -0600 | [diff] [blame] | 27 | self.assertFalse(config.do_validation) |