Revision 75c3fc42 kamaki/cli/commands/test_cli.py

b/kamaki/cli/commands/test_cli.py
34 34
from kamaki.cli import get_cmd_terms, command
35 35
from kamaki.cli.commands import _command_init
36 36
from kamaki.cli.command_tree import CommandTree
37
from kamaki.cli.argument import FlagArgument
37
from kamaki.clients import tests
38 38

  
39
sample_cmds = CommandTree(
40
    'sample',
41
    'Sample commands for developing your own')
42
test_cmds = CommandTree(
43
    'test',
44
    'Test commands for testing clients')
45
_commands = [sample_cmds, test_cmds]
39
test_cmds = CommandTree('test', 'Unitest clients')
40
_commands = [test_cmds]
46 41

  
47 42

  
48
print('Command Terms: ', get_cmd_terms())
43
#print('Command Terms: ', get_cmd_terms())
49 44

  
50 45

  
51 46
class _test_init(_command_init):
52 47

  
53
    def main(self, *args, **kwargs):
54
        print(self.__class__)
55
        for v in args:
56
            print('\t\targ: %s' % v)
57
        for k, v in kwargs.items():
58
            print('\t\tkwarg: %s: %s' % (k, v))
48
    def main(self, client, method=None):
49
        if method:
50
            tests.main([client, method])
51
        else:
52
            tests.main([client])
59 53

  
60 54

  
61
@command(sample_cmds)
62
class sample_cmd0(_test_init):
63
    """ test cmd
64
    This is the zero command test and this is the long description of it
65
    """
66

  
67
    def main(self, mant):
68
        super(self.__class__, self).main(mant)
69

  
70

  
71
@command(sample_cmds)
72
class sample_cmd_all(_test_init):
73
    """test cmd all"""
55
@command(test_cmds)
56
class test_all(_test_init):
57
    """test all clients"""
74 58

  
75 59
    def main(self):
76
        super(self.__class__, self).main()
60
        for client in ('pithos', 'cyclades', 'image', 'astakos'):
61
            super(self.__class__, self).main(client)
77 62

  
78 63

  
79
@command(sample_cmds)
80
class sample_cmd_some(_test_init):
81
    """test_cmd_some"""
64
@command(test_cmds)
65
class test_pithos(_test_init):
66
    """ test Pithos client"""
82 67

  
83
    def main(self, opt='lala'):
84
        super(self.__class__, self).main(opt=opt)
68
    def main(self, method=None):
69
        super(self.__class__, self).main('pithos', method)
85 70

  
86 71

  
87 72
@command(test_cmds)
88
class test_cmd0(_test_init):
89
    """ test cmd"""
73
class test_cyclades(_test_init):
74
    """ test Cyclades client"""
90 75

  
91
    def main(self, mant):
92
        super(self.__class__, self).main(mant)
76
    def main(self, method=None):
77
        super(self.__class__, self).main('cyclades', method)
93 78

  
94 79

  
95 80
@command(test_cmds)
96
class test_cmd_all(_test_init):
97
    """test cmd all"""
98

  
99
    def __init__(self, arguments={}):
100
        super(self.__class__, self).__init__(arguments)
101
        self.arguments['testarg'] = FlagArgument('a test arg', '--test')
81
class test_image(_test_init):
82
    """ test Image client"""
102 83

  
103
    def main(self):
104
        super(self.__class__, self).main()
84
    def main(self, method=None):
85
        super(self.__class__, self).main('image', method)
105 86

  
106 87

  
107 88
@command(test_cmds)
108
class test_cmdion(_test_init):
109
    """test_cmd_some"""
89
class test_astakos(_test_init):
90
    """ test Astakos client"""
110 91

  
111
    def main(self, opt='lala'):
112
        super(self.__class__, self).main(opt=opt)
92
    def main(self, method=None):
93
        super(self.__class__, self).main('astakos', method)
113 94

  
114 95

  
115 96
@command(test_cmds)
116
class test_cmd_cmdion_comedian(_test_init):
117
    """test_cmd_some"""
97
class test_lala_lele(_test_init):
98
    """test lala lele"""
118 99

  
119
    def main(self, opt='lala'):
120
        super(self.__class__, self).main(opt=opt)
100
    def main(self, *args):
101
        print('Do smth')

Also available in: Unified diff