~ubuntu-branches/ubuntu/utopic/click/utopic-proposed

« back to all changes in this revision

Viewing changes to click/tests/test_hooks.py

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Colin Watson
  • Date: 2014-03-12 12:02:47 UTC
  • Revision ID: package-import@ubuntu.com-20140312120247-4x328x3ebc8tdg79
Tags: 0.4.18.3
[ Colin Watson ]
Take a slightly different approach to fixing "click hook run-user": only
try to update user registration symlinks if they already exist in the
overlay database.

Show diffs side-by-side

added added

removed removed

Lines of Context:
833
833
                os.readlink(path_2))
834
834
            self.assertFalse(os.path.lexists(path_3))
835
835
 
 
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):
 
840
            enter()
 
841
            preloads["click_get_user_home"].return_value = "/home/test-user"
 
842
            with mkfile(
 
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",
 
858
                "test-package")))
 
859
 
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