示例#1
0
 def test_install_hook_negative(self, install_hook):
     """ Negative test for install-hook subcommand """
     result = self.cli.invoke(cli.cli, ["install-hook"])
     self.assertEqual(result.exit_code, self.GIT_CONTEXT_ERROR_CODE)
     self.assertEqual(result.output, u"tëst\n")
     expected_config = config.LintConfig()
     expected_config.target = os.path.abspath(os.getcwd())
     install_hook.assert_called_once_with(expected_config)
示例#2
0
 def test_uninstall_hook(self, uninstall_hook):
     result = self.cli.invoke(cli.cli, ["uninstall-hook"])
     expected_path = os.path.realpath(
         os.path.join(os.getcwd(), hooks.COMMIT_MSG_HOOK_DST_PATH))
     expected = "Successfully uninstalled gitlint commit-msg hook from {0}\n".format(
         expected_path)
     self.assertEqual(result.exit_code, 0)
     self.assertEqual(result.output, expected)
     uninstall_hook.assert_called_once_with(config.LintConfig())
示例#3
0
    def test_install_hook(self, install_hook):
        result = self.cli.invoke(cli.cli, ["install-hook"])
        expected_path = os.path.join(os.getcwd(),
                                     hooks.COMMIT_MSG_HOOK_DST_PATH)
        expected = "Successfully installed gitlint commit-msg hook in {0}\n".format(
            expected_path)
        self.assertEqual(result.exit_code, 0)
        self.assertEqual(result.output, expected)
        install_hook.assert_called_once_with(config.LintConfig())

        # Specified target
        install_hook.reset_mock()
        result = self.cli.invoke(cli.cli, ["--target", "/tmp", "install-hook"])
        expected_path = os.path.realpath("/tmp/.git/hooks/commit-msg")
        expected = "Successfully installed gitlint commit-msg hook in %s\n" % expected_path
        self.assertEqual(result.exit_code, 0)
        self.assertEqual(result.output, expected)
        install_hook.assert_called_once_with(
            config.LintConfig(target=os.path.realpath("/tmp")))
示例#4
0
 def test_install_hook(self, install_hook):
     result = self.cli.invoke(cli.cli, ["install-hook"])
     expected_path = os.path.join(os.getcwd(),
                                  hooks.COMMIT_MSG_HOOK_DST_PATH)
     expected = "Successfully installed gitlint commit-msg hook in {0}\n".format(
         expected_path)
     self.assertEqual(result.exit_code, 0)
     self.assertEqual(result.output, expected)
     expected_config = config.LintConfig()
     expected_config.target = os.path.abspath(os.getcwd())
     install_hook.assert_called_once_with(expected_config)
示例#5
0
 def test_uninstall_hook(self, _, uninstall_hook):
     """ Test for uninstall-hook subcommand """
     result = self.cli.invoke(cli.cli, ["uninstall-hook"])
     expected_path = os.path.join("/hür", "dur",
                                  hooks.COMMIT_MSG_HOOK_DST_PATH)
     expected = f"Successfully uninstalled gitlint commit-msg hook from {expected_path}\n"
     self.assertEqual(result.exit_code, 0)
     self.assertEqual(result.output, expected)
     expected_config = config.LintConfig()
     expected_config.target = os.path.realpath(os.getcwd())
     uninstall_hook.assert_called_once_with(expected_config)
示例#6
0
    def test_install_hook_target(self, install_hook):
        # Specified target
        result = self.cli.invoke(
            cli.cli, ["--target", self.SAMPLES_DIR, "install-hook"])
        expected_path = os.path.realpath(
            os.path.join(self.SAMPLES_DIR, hooks.COMMIT_MSG_HOOK_DST_PATH))
        expected = "Successfully installed gitlint commit-msg hook in %s\n" % expected_path
        self.assertEqual(result.exit_code, 0)
        self.assertEqual(result.output, expected)

        expected_config = config.LintConfig()
        expected_config.target = self.SAMPLES_DIR
        install_hook.assert_called_once_with(expected_config)
示例#7
0
    def test_install_hook_target(self, _, install_hook):
        """  Test for install-hook subcommand with a specific --target option specified """
        # Specified target
        result = self.cli.invoke(
            cli.cli, ["--target", self.SAMPLES_DIR, "install-hook"])
        expected_path = os.path.join(u"/hür", u"dur",
                                     hooks.COMMIT_MSG_HOOK_DST_PATH)
        expected = "Successfully installed gitlint commit-msg hook in %s\n" % expected_path
        self.assertEqual(result.exit_code, 0)
        self.assertEqual(result.output, expected)

        expected_config = config.LintConfig()
        expected_config.target = self.SAMPLES_DIR
        install_hook.assert_called_once_with(expected_config)
示例#8
0
 def test_uninstall_hook_negative(self, uninstall_hook):
     result = self.cli.invoke(cli.cli, ["uninstall-hook"])
     self.assertEqual(result.exit_code, self.GIT_CONTEXT_ERROR_CODE)
     self.assertEqual(result.output, "test\n")
     uninstall_hook.assert_called_once_with(config.LintConfig())