def test_dont_install_in_non_git(self): assert_that(not install()) for hook in self.hooks: filename = os.path.join(self.path, HOOK_PATH, hook) assert_that(not os.path.exists(filename), filename) assert_that(not uninstall())
def test_install_hooks_and_overrides(self): precommit = os.path.join(HOOK_PATH, "pre-commit") self.call("git", "init") self.call("touch", precommit) assert_that(install(force=True)) for hook in self.hooks: filename = os.path.join(self.path, HOOK_PATH, hook) assert_that(os.path.exists(filename), filename) with open(precommit, "r") as f: assert_that(f.read(), is_not(has_length(0)), "precommit should have been overridden") assert_that(uninstall()) for hook in self.hooks: filename = os.path.join(self.path, HOOK_PATH, hook) assert_that(not os.path.exists(filename), filename)
def test_install_hooks(self): precommit = os.path.join(HOOK_PATH, "pre-commit") self.call("git", "init") self.call("touch", precommit) assert_that(install()) for hook in self.hooks: filename = os.path.join(self.path, HOOK_PATH, hook) assert_that(os.path.exists(filename), filename) with open(precommit, "r") as f: assert_that(f.read(), has_length(0), "precommit should be have been left as is") assert_that(uninstall()) for hook in self.hooks: filename = os.path.join(self.path, HOOK_PATH, hook) assert_that(not os.path.exists(filename), filename)