Revision 1f0370c9 kamaki/cli/commands/test_cli.py
b/kamaki/cli/commands/test_cli.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A.command |
33 | 33 |
|
34 |
from kamaki.cli.commands import errors |
|
34 | 35 |
from kamaki.cli import command |
35 | 36 |
from kamaki.cli.commands import _command_init |
36 | 37 |
from kamaki.cli.command_tree import CommandTree |
37 | 38 |
from kamaki.clients import tests |
39 |
from kamaki.cli.errors import raiseCLIError |
|
38 | 40 |
|
39 | 41 |
test_cmds = CommandTree('test', 'Unitest clients') |
40 | 42 |
_commands = [test_cmds] |
... | ... | |
54 | 56 |
class test_error(_test_init): |
55 | 57 |
"""Create an error message with optional message""" |
56 | 58 |
|
57 |
def main(self, errmsg='', importance=0, index=0):
|
|
58 |
from kamaki.cli.errors import raiseCLIError
|
|
59 |
@errors.generic.all
|
|
60 |
def _run(self, errmsg='', importance=0, index=0):
|
|
59 | 61 |
l = [1, 2] |
60 | 62 |
try: |
61 | 63 |
l[int(index)] |
... | ... | |
63 | 65 |
raiseCLIError(err, errmsg, importance) |
64 | 66 |
raiseCLIError(None, errmsg, importance) |
65 | 67 |
|
68 |
def main(self, errmsg='', importance=0, index=0): |
|
69 |
self._run(errmsg, importance, index) |
|
70 |
|
|
66 | 71 |
|
67 | 72 |
@command(test_cmds) |
68 | 73 |
class test_args(_test_init): |
69 | 74 |
"""Test how arguments are treated by kamaki""" |
70 | 75 |
|
71 |
def main(self, *args): |
|
76 |
@errors.generic.all |
|
77 |
def _run(self, *args): |
|
72 | 78 |
print(args) |
73 | 79 |
|
80 |
def main(self, *args): |
|
81 |
self._run(args) |
|
82 |
|
|
74 | 83 |
|
75 | 84 |
@command(test_cmds) |
76 | 85 |
class test_all(_test_init): |
77 | 86 |
"""test all clients""" |
78 | 87 |
|
79 |
def main(self): |
|
88 |
@errors.generic.all |
|
89 |
def _run(self): |
|
80 | 90 |
for client in ('pithos', 'cyclades', 'image', 'astakos'): |
81 | 91 |
super(self.__class__, self).main(client) |
82 | 92 |
|
93 |
def main(self): |
|
94 |
self._run() |
|
95 |
|
|
83 | 96 |
|
84 | 97 |
@command(test_cmds) |
85 | 98 |
class test_pithos(_test_init): |
86 | 99 |
""" test Pithos client""" |
87 | 100 |
|
88 |
def main(self, method=None): |
|
101 |
@errors.generic.all |
|
102 |
def _run(self, method=None): |
|
89 | 103 |
super(self.__class__, self).main('pithos', method) |
90 | 104 |
|
105 |
def main(self, method=None): |
|
106 |
self._run(method) |
|
107 |
|
|
91 | 108 |
|
92 | 109 |
@command(test_cmds) |
93 | 110 |
class test_cyclades(_test_init): |
94 | 111 |
""" test Cyclades client""" |
95 | 112 |
|
96 |
def main(self, method=None): |
|
113 |
@errors.generic.all |
|
114 |
def _run(self, method=None): |
|
97 | 115 |
super(self.__class__, self).main('cyclades', method) |
98 | 116 |
|
117 |
def main(self, method=None): |
|
118 |
self._run(method) |
|
119 |
|
|
99 | 120 |
|
100 | 121 |
@command(test_cmds) |
101 | 122 |
class test_image(_test_init): |
102 | 123 |
""" test Image client""" |
103 | 124 |
|
104 |
def main(self, method=None): |
|
125 |
@errors.generic.all |
|
126 |
def _run(self, method=None): |
|
105 | 127 |
super(self.__class__, self).main('image', method) |
106 | 128 |
|
129 |
def main(self, method=None): |
|
130 |
self._run(method) |
|
131 |
|
|
107 | 132 |
|
108 | 133 |
@command(test_cmds) |
109 | 134 |
class test_astakos(_test_init): |
110 | 135 |
""" test Astakos client""" |
111 | 136 |
|
112 |
def main(self, method=None): |
|
137 |
@errors.generic.all |
|
138 |
def _run(self, method=None): |
|
113 | 139 |
super(self.__class__, self).main('astakos', method) |
114 | 140 |
|
141 |
def main(self, method=None): |
|
142 |
self._run(method) |
|
143 |
|
|
115 | 144 |
|
116 | 145 |
@command(test_cmds) |
117 | 146 |
class test_prints(_test_init): |
... | ... | |
129 | 158 |
'long key of size 75 characters is used to' +\ |
130 | 159 |
' check the effects on total result': l1} |
131 | 160 |
|
132 |
def main(self): |
|
161 |
@errors.generic.all |
|
162 |
def _run(self): |
|
133 | 163 |
from kamaki.cli.utils import print_dict, print_list, print_items |
134 | 164 |
print('Test simple dict:\n- - -') |
135 | 165 |
print_dict(self.d1) |
... | ... | |
176 | 206 |
print('\nTest print_items with lists- - -') |
177 | 207 |
print_items([['i00', 'i01', 'i02'], [self.l2, 'i11', self.d1], 3]) |
178 | 208 |
print('- - -') |
209 |
|
|
210 |
def main(self): |
|
211 |
self._run() |
Also available in: Unified diff