blob: 9cbb5b83fd48f099a235f59a808d65797acd0cbd [file] [log] [blame]
Doug Hellmannc0a088d2015-09-04 18:28:59 +00001#!/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
15import logging
16import os
17
18import testtools
19import zuul.cmd.cloner
20
21logging.basicConfig(level=logging.DEBUG,
22 format='%(asctime)s %(name)-32s '
23 '%(levelname)-8s %(message)s')
24
25
26class TestClonerCmdArguments(testtools.TestCase):
27
28 def setUp(self):
29 super(TestClonerCmdArguments, self).setUp()
30 self.app = zuul.cmd.cloner.Cloner()
31
32 def test_default_cache_dir_empty(self):
33 self.app.parse_arguments(['base', 'repo'])
34 self.assertEqual(None, self.app.args.cache_dir)
35
36 def test_default_cache_dir_environ(self):
37 try:
38 os.environ['ZUUL_CACHE_DIR'] = 'fromenviron'
39 self.app.parse_arguments(['base', 'repo'])
40 self.assertEqual('fromenviron', self.app.args.cache_dir)
41 finally:
42 del os.environ['ZUUL_CACHE_DIR']
43
44 def test_default_cache_dir_override_environ(self):
45 try:
46 os.environ['ZUUL_CACHE_DIR'] = 'fromenviron'
47 self.app.parse_arguments(['--cache-dir', 'argument',
48 'base', 'repo'])
49 self.assertEqual('argument', self.app.args.cache_dir)
50 finally:
51 del os.environ['ZUUL_CACHE_DIR']
52
53 def test_default_cache_dir_argument(self):
54 self.app.parse_arguments(['--cache-dir', 'argument',
55 'base', 'repo'])
56 self.assertEqual('argument', self.app.args.cache_dir)