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): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 12 | """ApiConfig tests.""" |
Alex Klein | 2008aee | 2019-08-20 16:25:27 -0600 | [diff] [blame] | 13 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -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) |
| 19 | config = ApiConfig(call_type=ApiConfig.CALL_TYPE_VALIDATE_ONLY) |
| 20 | self.assertTrue(config.do_validation) |
Alex Klein | 2008aee | 2019-08-20 16:25:27 -0600 | [diff] [blame] | 21 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame] | 22 | def test_no_do_validation(self): |
| 23 | """Sanity check for skipping validation for mock calls.""" |
| 24 | config = ApiConfig(call_type=ApiConfig.CALL_TYPE_MOCK_SUCCESS) |
| 25 | self.assertFalse(config.do_validation) |
| 26 | config = ApiConfig(call_type=ApiConfig.CALL_TYPE_MOCK_FAILURE) |
| 27 | self.assertFalse(config.do_validation) |