コード例 #1
0
ファイル: test_cmd.py プロジェクト: gingerkaan/serveros
    def _test_completeFiles(self, tests):
        protocol = ShellProtocol(None, commandsClass=SomeCommands)
        commands = protocol.commands

        def c(word):
            # One token
            d = commands.complete_files((word, ))
            d.addCallback(lambda c: sorted(c))
            return d

        def d(word):
            # Multiple tokens
            d = commands.complete_files(("XYZZY", word))
            d.addCallback(lambda c: sorted(c))
            return d

        def e(word):
            # No tokens
            d = commands.complete_files(())
            d.addCallback(lambda c: sorted(c))
            return d

        for word, completions in tests:
            if word is None:
                self.assertEquals((yield e(word)), completions,
                                  "Completing %r" % (word, ))
            else:
                self.assertEquals((yield c(word)), completions,
                                  "Completing %r" % (word, ))
                self.assertEquals((yield d(word)), completions,
                                  "Completing %r" % (word, ))
コード例 #2
0
ファイル: test_cmd.py プロジェクト: gingerkaan/serveros
    def test_completeCommands(self):
        protocol = ShellProtocol(None, commandsClass=SomeCommands)
        commands = protocol.commands

        def c(word):
            return sorted(commands.complete_commands(word))

        self.assertEquals(c(""), ["a", "b"])
        self.assertEquals(c("a"), [""])
        self.assertEquals(c("h"), ["idden"])
        self.assertEquals(c("f"), [])
コード例 #3
0
ファイル: test_cmd.py プロジェクト: gingerkaan/serveros
    def test_commandsSome(self):
        protocol = ShellProtocol(None, commandsClass=SomeCommands)
        commands = protocol.commands

        allCommands = commands.commands()

        self.assertEquals(sorted(allCommands), [
            ("a", commands.cmd_a),
            ("b", commands.cmd_b),
        ])

        allCommands = commands.commands(showHidden=True)

        self.assertEquals(sorted(allCommands), [
            ("a", commands.cmd_a),
            ("b", commands.cmd_b),
            ("hidden", commands.cmd_hidden),
        ])
コード例 #4
0
ファイル: test_cmd.py プロジェクト: gingerkaan/serveros
 def setUp(self):
     self.protocol = ShellProtocol(None, commandsClass=CommandsBase)
     self.commands = self.protocol.commands