Doug Hellmann | c0a088d | 2015-09-04 18:28:59 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # 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, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
Doug Hellmann | c0a088d | 2015-09-04 18:28:59 +0000 | [diff] [blame] | 15 | import os |
| 16 | |
| 17 | import testtools |
| 18 | import zuul.cmd.cloner |
| 19 | |
Doug Hellmann | c0a088d | 2015-09-04 18:28:59 +0000 | [diff] [blame] | 20 | |
| 21 | class TestClonerCmdArguments(testtools.TestCase): |
| 22 | |
| 23 | def setUp(self): |
| 24 | super(TestClonerCmdArguments, self).setUp() |
| 25 | self.app = zuul.cmd.cloner.Cloner() |
| 26 | |
| 27 | def test_default_cache_dir_empty(self): |
| 28 | self.app.parse_arguments(['base', 'repo']) |
| 29 | self.assertEqual(None, self.app.args.cache_dir) |
| 30 | |
| 31 | def test_default_cache_dir_environ(self): |
| 32 | try: |
| 33 | os.environ['ZUUL_CACHE_DIR'] = 'fromenviron' |
| 34 | self.app.parse_arguments(['base', 'repo']) |
| 35 | self.assertEqual('fromenviron', self.app.args.cache_dir) |
| 36 | finally: |
| 37 | del os.environ['ZUUL_CACHE_DIR'] |
| 38 | |
| 39 | def test_default_cache_dir_override_environ(self): |
| 40 | try: |
| 41 | os.environ['ZUUL_CACHE_DIR'] = 'fromenviron' |
| 42 | self.app.parse_arguments(['--cache-dir', 'argument', |
| 43 | 'base', 'repo']) |
| 44 | self.assertEqual('argument', self.app.args.cache_dir) |
| 45 | finally: |
| 46 | del os.environ['ZUUL_CACHE_DIR'] |
| 47 | |
| 48 | def test_default_cache_dir_argument(self): |
| 49 | self.app.parse_arguments(['--cache-dir', 'argument', |
| 50 | 'base', 'repo']) |
| 51 | self.assertEqual('argument', self.app.args.cache_dir) |