833
833
os.readlink(path_2))
834
834
self.assertFalse(os.path.lexists(path_3))
836
def test_sync_without_user_db(self):
837
with self.run_in_subprocess(
838
"click_get_hooks_dir", "click_get_user_home",
839
) as (enter, preloads):
841
preloads["click_get_user_home"].return_value = "/home/test-user"
843
os.path.join(self.temp_dir, "hooks", "test.hook")) as f:
844
print("User-Level: yes", file=f)
845
print("Pattern: %s/${id}.test" % self.temp_dir, file=f)
846
with mkfile(os.path.join(
847
self.temp_dir, "test-package", "1.0", ".click", "info",
848
"test-package.manifest")) as f:
849
json.dump({"hooks": {"test-app": {"test": "target"}}}, f)
850
all_users_db = Click.User.for_all_users(self.db)
851
all_users_db.set_version("test-package", "1.0")
852
self._setup_hooks_dir(
853
preloads, hooks_dir=os.path.join(self.temp_dir, "hooks"))
854
hook = Click.Hook.open(self.db, "test")
855
hook.sync(user_name="test-user")
856
self.assertFalse(os.path.exists(os.path.join(
857
self.temp_dir, ".click", "users", "test-user",
836
860
def test_sync_uses_deepest_copy(self):
837
861
# If the same version of a package is unpacked in multiple
838
862
# databases, then we make sure the user link points to the deepest