Revision 0962adb7

b/kamaki/cli/command_tree/test.py
40 40

  
41 41
class Command(TestCase):
42 42

  
43
    def setUp(self):
44
        pass
45

  
46
    def tearDown(self):
47
        pass
48

  
49 43
    def test___init__(self):
50 44
        for args in product(
51 45
                (None, '', 'cmd'),
......
169 163
            self.assertEqual((expc, expl), c.parse_out(l))
170 164

  
171 165

  
166
class CommandTree(TestCase):
167

  
168
    def setUp(self):
169
        cmd = command_tree.Command('cmd', subcommands=dict(
170
            cmd0a=command_tree.Command('cmd_cmd0a', subcommands=dict(
171
                cmd1a=command_tree.Command(
172
                    'cmd_cmd0a_cmd1a', subcommands=dict(
173
                        cmd2=command_tree.Command('cmd_cmd0a_cmd1a_cmd2'),
174
                    )
175
                ),
176
                cmd1b=command_tree.Command(
177
                    'cmd_cmd0a_cmd1b', subcommands=dict(
178
                        cmd2=command_tree.Command('cmd_cmd0a_cmd1b_cmd2'),
179
                    )
180
                )
181
            )),
182
            cmd0b=command_tree.Command('cmd_cmd0b'),
183
            cmd0c=command_tree.Command('cmd_cmd0c', subcommands=dict(
184
                cmd1a=command_tree.Command('cmd_cmd0c_cmd1a'),
185
                cmd1b=command_tree.Command(
186
                    'cmd_cmd0c_cmd1b', subcommands=dict(
187
                        cmd2=command_tree.Command('cmd_cmd0c_cmd1b_cmd2'),
188
                    )
189
                )
190
            ))
191
        ))
192
        self.commands = [
193
            cmd,
194
            cmd.subcommands['cmd0a'],
195
            cmd.subcommands['cmd0a'].subcommands['cmd1a'],
196
            cmd.subcommands['cmd0a'].subcommands['cmd1a'].subcommands['cmd2'],
197
            cmd.subcommands['cmd0a'].subcommands['cmd1b'],
198
            cmd.subcommands['cmd0a'].subcommands['cmd1b'].subcommands['cmd2'],
199
            cmd.subcommands['cmd0b'],
200
            cmd.subcommands['cmd0c'],
201
            cmd.subcommands['cmd0c'].subcommands['cmd1a'],
202
            cmd.subcommands['cmd0c'].subcommands['cmd1b'],
203
            cmd.subcommands['cmd0c'].subcommands['cmd1b'].subcommands['cmd2'],
204
        ]
205

  
206
    def tearDown(self):
207
        for cmd in self.commands:
208
            del cmd
209
        del self.commands
210

  
211
    def test___init__(self):
212
        ctree = command_tree.CommandTree('sampleTree', 'a sample Tree')
213
        ctree.pretty_print()
214

  
215

  
172 216
if __name__ == '__main__':
173 217
    from sys import argv
174 218
    from kamaki.cli.test import runTestCase
175 219
    runTestCase(Command, 'Command', argv[1:])
220
    runTestCase(CommandTree, 'CommandTree', argv[1:])
b/kamaki/cli/test.py
38 38
from itertools import product
39 39
from random import randint
40 40

  
41
from kamaki.cli.command_tree.test import Command
41
from kamaki.cli.command_tree.test import Command, CommandTree
42 42

  
43 43

  
44 44
#  TestCase auxiliary methods

Also available in: Unified diff