Exemple #1
0
    def test_find(self):
        com = Commands('aaa')
        com.easy_map('a', local_module, 'dummy_function1')
        com.map_direct(['d'], dummy_function2)
        com.map(['g', 'h'], DirectCommand(dummy_function3))
        com.alias(['z', 'y'], ['g', 'h'])

        def ci(function, args):
            return CommandInvoker('aaa', function, CommandArgs(None, args))
        hi = HelpInvoker
        hmi = HelpMultiInvoker

        self.assert_equal(ci(dummy_function1, ['1', '2', '3']),
                          com.find(['a', '1', '2', '3']))
        self.assert_equal(ci(dummy_function3, ['1', '2', '3']),
                          com.find(['g', 'h', '1', '2', '3']))
        self.assert_equal(ci(dummy_function3, ['1', '2', '3']),
                          com.find(['z', 'y', '1', '2', '3']))
        self.assert_equal(hi(['aaa', 'a'], dummy_function1),
                          com.find(['help', 'a', '1', '2', '3']))
        self.assert_equal(hi(['aaa', 'g', 'h'], dummy_function3),
                          com.find(['g', 'help', 'h', '1', '2', '3']))
        self.assert_equal(hmi(['aaa', 'g'], com.commands['g']),
                          com.find(['help', 'g', '1', '2', '3']))
        self.assert_equal(hmi(['aaa', 'g'], com.commands['g']),
                          com.find(['g']))
        self.assert_equal(ci(dummy_function2, ['1', '2', '3']),
                          com.find(['d', '1', '2', '3']))

        try:
            com.find(['zzzzzz'])
        except InputError:
            pass
        else:
            self.fail('Should have thrown InputError!')
Exemple #2
0
    def test_iterate(self):
        commands = Commands('base')
        command = DirectCommand(dummy_function2)
        commands.map(['a'], command)
        commands.map(['b', 'c'], command)
        commands.map(['d'], command)
        commands.map(['e', 'f', 'g'], command)
        commands.alias(['zz', 'yy'], ['a'])

        expected = [(('base', 'a'), DirectCommand(dummy_function2)),
                    (('base', 'b', 'c'), DirectCommand(dummy_function2)),
                    (('base', 'd'), DirectCommand(dummy_function2)),
                    (('base', 'e', 'f', 'g'), DirectCommand(dummy_function2)),
                    (('base', 'zz', 'yy'), CommandAlias(commands, ['a']))]

        self.assert_equals_long(expected, list(commands))
Exemple #3
0
    def test_find(self):
        com = Commands('aaa')
        com.easy_map('a', local_module, 'dummy_function1')
        com.map_direct(['d'], dummy_function2)
        com.map(['g', 'h'], DirectCommand(dummy_function3))
        com.alias(['z', 'y'], ['g', 'h'])

        def ci(function, args):
            return CommandInvoker('aaa', function, CommandArgs(None, args))

        hi = HelpInvoker
        hmi = HelpMultiInvoker

        self.assert_equal(ci(dummy_function1, ['1', '2', '3']),
                          com.find(['a', '1', '2', '3']))
        self.assert_equal(ci(dummy_function3, ['1', '2', '3']),
                          com.find(['g', 'h', '1', '2', '3']))
        self.assert_equal(ci(dummy_function3, ['1', '2', '3']),
                          com.find(['z', 'y', '1', '2', '3']))
        self.assert_equal(hi(['aaa', 'a'], dummy_function1),
                          com.find(['help', 'a', '1', '2', '3']))
        self.assert_equal(hi(['aaa', 'g', 'h'], dummy_function3),
                          com.find(['g', 'help', 'h', '1', '2', '3']))
        self.assert_equal(hmi(['aaa', 'g'], com.commands['g']),
                          com.find(['help', 'g', '1', '2', '3']))
        self.assert_equal(hmi(['aaa', 'g'], com.commands['g']),
                          com.find(['g']))
        self.assert_equal(ci(dummy_function2, ['1', '2', '3']),
                          com.find(['d', '1', '2', '3']))

        try:
            com.find(['zzzzzz'])
        except InputError:
            pass
        else:
            self.fail('Should have thrown InputError!')
Exemple #4
0
    def test_iterate(self):
        commands = Commands('base')
        command = DirectCommand(dummy_function2)
        commands.map(['a'], command)
        commands.map(['b', 'c'], command)
        commands.map(['d'], command)
        commands.map(['e', 'f', 'g'], command)
        commands.alias(['zz', 'yy'], ['a'])

        expected = [
            (('base', 'a'), DirectCommand(dummy_function2)),
            (('base', 'b', 'c'), DirectCommand(dummy_function2)),
            (('base', 'd'), DirectCommand(dummy_function2)),
            (('base', 'e', 'f', 'g'), DirectCommand(dummy_function2)),
            (('base', 'zz', 'yy'), CommandAlias(commands, ['a'])) ]

        self.assert_equals_long(expected, list(commands))
Exemple #5
0
commands.easy_map('log', ws, 'log')
#commands.easy_map('update', ws, 'update')
commands.easy_map('commit', ws, 'commit')
commands.easy_map('add', ws, 'add')
commands.easy_map('remove', ws, 'remove')
commands.easy_map('revert', ws, 'revert')
commands.easy_map('cat', ws, 'cat')
commands.easy_map('repogen', ws, 'repogen')
commands.easy_map('mediagen', ws, 'mediagen')
commands.easy_map('dumpmeta', ws, 'dumpmeta')
commands.easy_map('purge', ws, 'purge')
commands.easy_map('semdiff', ws, 'semdiff')
commands.easy_map('resolve', ws, 'resolve')
commands.easy_map('closure', ws, 'closure')
commands.easy_map('abstract', ws, 'abstract')
commands.easy_map('complete', ws, 'complete')
commands.easy_map('upgrade', ws, 'upgrade')
commands.easy_map('download', ws, 'download')
#commands.easy_map('dumplinks', ws, 'dumplinks')
#commands.easy_map('migrate', ws, 'migrate')
commands.easy_map('mv', ws, 'mv')

commands.alias(['rm'], ['remove'])
commands.alias(['create', 'workspace'], ['workspace', 'create'])

commands.map(('workspace', 'create'), Command(ws, 'create'))
commands.map(('channel', 'update'), Command(ws, 'world_update'))
commands.map(('remote', 'listen'), Command(ws, 'listen'))

# vim:set ai et sw=4 ts=4 tw=75:
Exemple #6
0
commands.easy_map('commit', ws, 'commit')
commands.easy_map('add', ws, 'add')
commands.easy_map('remove', ws, 'remove')
commands.easy_map('revert', ws, 'revert')
commands.easy_map('cat', ws, 'cat')
commands.easy_map('repogen', ws,'repogen')
commands.easy_map('mediagen', ws, 'mediagen')
commands.easy_map('dumpmeta', ws, 'dumpmeta')
commands.easy_map('listmeta', ws, 'listmeta')
commands.easy_map('listcomps', ws, 'listcomps')
commands.easy_map('purge', ws, 'purge')
commands.easy_map('semdiff', ws, 'semdiff')
commands.easy_map('resolve', ws, 'resolve')
commands.easy_map('closure', ws, 'closure')
commands.easy_map('abstract', ws, 'abstract')
commands.easy_map('complete', ws, 'complete')
commands.easy_map('upgrade', ws, 'upgrade')
commands.easy_map('download', ws, 'download')
#commands.easy_map('dumplinks', ws, 'dumplinks')
#commands.easy_map('migrate', ws, 'migrate')
commands.easy_map('mv', ws, 'mv')

commands.alias(['rm'], ['remove'])
commands.alias(['create', 'workspace'], ['workspace', 'create'])

commands.map(('workspace', 'create'), Command(ws, 'create'))
commands.map(('channel', 'update'), Command(ws, 'world_update'))
commands.map(('remote', 'listen'), Command(ws, 'listen'))

# vim:set ai et sw=4 ts=4 tw=75: