aboutsummaryrefslogtreecommitdiff
path: root/test/test_config/test_option.py
blob: 3fc9e6f4d1aa61d81672489970fb40fcda3b3df7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright (C) 2010  Leonard Thomas
#
# This file is part of Dodai.
#
# Dodai is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dodai is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dodai.  If not, see <http://www.gnu.org/licenses/>.

import unittest
from dodai.config.option import ConfigOption
from optparse import OptionParser

class TestConfigOption(unittest.TestCase):

    def setUp(self):
        self.obj = ConfigOption()

    def test_parser(self):
        self.assertTrue(isinstance(self.obj.parser, OptionParser))

    def test_add_quiet(self):
        self.obj.add_quiet()
        self.assertTrue(self.obj.parser.has_option('-q'))

    def test_add_verbose(self):
        self.obj.add_verbose()
        self.assertTrue(self.obj.parser.has_option('-v'))

    def test_add_log_level(self):
        self.obj.add_log_level('critical')
        self.assertTrue(self.obj.parser.has_option('-l'))

    def test_add_setup(self):
        self.obj.add_setup()
        self.assertTrue(self.obj.parser.has_option('--setup'))

    def test_get_args(self):
        args = self.obj.get_args()
        self.assertTrue(args == [])

    def test_get_options(self):
        self.obj.add_quiet()
        options = self.obj.get_options()
        self.assertTrue(options.verbose == True)