diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_subcmds_sync.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_subcmds_sync.py b/tests/test_subcmds_sync.py new file mode 100644 index 00000000..c1d1758e --- /dev/null +++ b/tests/test_subcmds_sync.py | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | # Copyright (C) 2022 The Android Open Source Project | ||
| 2 | # | ||
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | # you may not use this file except in compliance with the License. | ||
| 5 | # You may obtain a copy of the License at | ||
| 6 | # | ||
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | # | ||
| 9 | # Unless required by applicable law or agreed to in writing, software | ||
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | # See the License for the specific language governing permissions and | ||
| 13 | # limitations under the License. | ||
| 14 | |||
| 15 | """Unittests for the subcmds/sync.py module.""" | ||
| 16 | |||
| 17 | from unittest import mock | ||
| 18 | |||
| 19 | import pytest | ||
| 20 | |||
| 21 | from subcmds import sync | ||
| 22 | |||
| 23 | |||
| 24 | @pytest.mark.parametrize( | ||
| 25 | 'use_superproject, cli_args, result', | ||
| 26 | [ | ||
| 27 | (True, ['--current-branch'], True), | ||
| 28 | (True, ['--no-current-branch'], True), | ||
| 29 | (True, [], True), | ||
| 30 | (False, ['--current-branch'], True), | ||
| 31 | (False, ['--no-current-branch'], False), | ||
| 32 | (False, [], None), | ||
| 33 | ] | ||
| 34 | ) | ||
| 35 | def test_get_current_branch_only(use_superproject, cli_args, result): | ||
| 36 | """Test Sync._GetCurrentBranchOnly logic. | ||
| 37 | |||
| 38 | Sync._GetCurrentBranchOnly should return True if a superproject is requested, | ||
| 39 | and otherwise the value of the current_branch_only option. | ||
| 40 | """ | ||
| 41 | cmd = sync.Sync() | ||
| 42 | opts, _ = cmd.OptionParser.parse_args(cli_args) | ||
| 43 | |||
| 44 | with mock.patch('git_superproject.UseSuperproject', return_value=use_superproject): | ||
| 45 | assert cmd._GetCurrentBranchOnly(opts) == result | ||
