Example #1
0
 def test_install_bzr_hooks(self):
     """
     L{CommandController.install_bzrlib_hooks} is called to hook the
     controller into C{bzrlib}.
     """
     main(["commandant", self.directory.path, "version"])
     self.assertEquals(all_command_names(), set(["help", "version"]))
Example #2
0
    def test_default_to_help(self):
        """
        If no command name is provided the C{help} command is used as a
        default.
        """
        self.directory.make_path()
        main(["commandant", self.directory.path])
        self.assertEquals(
            sys.stdout.getvalue(),
            """\
commandant -- A toolkit for building command-oriented tools.
https://github.com/jkakar/commandant

Basic commands:
  commandant help commands  List all commands
  commandant help topics    List all help topics
""",
        )
Example #3
0
    def test_controller_path(self):
        """
        C{CommandController.path} is set to the path specified as the first
        argument, in the entry point logic.  In the future this should be
        removed, and commands should not rely on it.
        """
        hello_path = os.path.join(self.directory.path, "hello")
        content = """\
from bzrlib.commands import Command

class cmd_test_command(Command):
    def run(self):
        file = open('%s', 'w')
        file.write('Hello, world!')
        file.close()
""" % (
            hello_path,
        )
        path = os.path.join(self.directory.path, "test_command.py")
        self.directory.make_path(content=content, path=path)
        main(["commandant", self.directory.path, "test-command"])
        self.assertEquals(open(hello_path).read(), "Hello, world!")