Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
0962adb7
Commit
0962adb7
authored
Jul 15, 2013
by
Stavros Sachtouris
Browse files
Setup test example commands for CommandTree
Refs: #4058
parent
9a22e094
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/command_tree/test.py
View file @
0962adb7
...
...
@@ -40,12 +40,6 @@ from kamaki.cli import command_tree
class
Command
(
TestCase
):
def
setUp
(
self
):
pass
def
tearDown
(
self
):
pass
def
test___init__
(
self
):
for
args
in
product
(
(
None
,
''
,
'cmd'
),
...
...
@@ -169,7 +163,58 @@ class Command(TestCase):
self
.
assertEqual
((
expc
,
expl
),
c
.
parse_out
(
l
))
class
CommandTree
(
TestCase
):
def
setUp
(
self
):
cmd
=
command_tree
.
Command
(
'cmd'
,
subcommands
=
dict
(
cmd0a
=
command_tree
.
Command
(
'cmd_cmd0a'
,
subcommands
=
dict
(
cmd1a
=
command_tree
.
Command
(
'cmd_cmd0a_cmd1a'
,
subcommands
=
dict
(
cmd2
=
command_tree
.
Command
(
'cmd_cmd0a_cmd1a_cmd2'
),
)
),
cmd1b
=
command_tree
.
Command
(
'cmd_cmd0a_cmd1b'
,
subcommands
=
dict
(
cmd2
=
command_tree
.
Command
(
'cmd_cmd0a_cmd1b_cmd2'
),
)
)
)),
cmd0b
=
command_tree
.
Command
(
'cmd_cmd0b'
),
cmd0c
=
command_tree
.
Command
(
'cmd_cmd0c'
,
subcommands
=
dict
(
cmd1a
=
command_tree
.
Command
(
'cmd_cmd0c_cmd1a'
),
cmd1b
=
command_tree
.
Command
(
'cmd_cmd0c_cmd1b'
,
subcommands
=
dict
(
cmd2
=
command_tree
.
Command
(
'cmd_cmd0c_cmd1b_cmd2'
),
)
)
))
))
self
.
commands
=
[
cmd
,
cmd
.
subcommands
[
'cmd0a'
],
cmd
.
subcommands
[
'cmd0a'
].
subcommands
[
'cmd1a'
],
cmd
.
subcommands
[
'cmd0a'
].
subcommands
[
'cmd1a'
].
subcommands
[
'cmd2'
],
cmd
.
subcommands
[
'cmd0a'
].
subcommands
[
'cmd1b'
],
cmd
.
subcommands
[
'cmd0a'
].
subcommands
[
'cmd1b'
].
subcommands
[
'cmd2'
],
cmd
.
subcommands
[
'cmd0b'
],
cmd
.
subcommands
[
'cmd0c'
],
cmd
.
subcommands
[
'cmd0c'
].
subcommands
[
'cmd1a'
],
cmd
.
subcommands
[
'cmd0c'
].
subcommands
[
'cmd1b'
],
cmd
.
subcommands
[
'cmd0c'
].
subcommands
[
'cmd1b'
].
subcommands
[
'cmd2'
],
]
def
tearDown
(
self
):
for
cmd
in
self
.
commands
:
del
cmd
del
self
.
commands
def
test___init__
(
self
):
ctree
=
command_tree
.
CommandTree
(
'sampleTree'
,
'a sample Tree'
)
ctree
.
pretty_print
()
if
__name__
==
'__main__'
:
from
sys
import
argv
from
kamaki.cli.test
import
runTestCase
runTestCase
(
Command
,
'Command'
,
argv
[
1
:])
runTestCase
(
CommandTree
,
'CommandTree'
,
argv
[
1
:])
kamaki/cli/test.py
View file @
0962adb7
...
...
@@ -38,7 +38,7 @@ from inspect import getmembers, isclass
from
itertools
import
product
from
random
import
randint
from
kamaki.cli.command_tree.test
import
Command
from
kamaki.cli.command_tree.test
import
Command
,
CommandTree
# TestCase auxiliary methods
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment