Example #1
0
 def test_lock_holder_dead_process(self):
     """Detect that the holder (this process) is still running."""
     self.overrideAttr(lockdir, 'get_host_name',
         lambda: 'aproperhostname')
     info = LockHeldInfo.for_this_process(None)
     info.info_dict['pid'] = '123123123'
     self.assertTrue(info.is_lock_holder_known_dead())
 def test_lock_holder_dead_process(self):
     """Detect that the holder (this process) is still running."""
     self.overrideAttr(lockdir, 'get_host_name',
         lambda: 'aproperhostname')
     info = LockHeldInfo.for_this_process(None)
     info.info_dict['pid'] = '123123123'
     self.assertTrue(info.is_lock_holder_known_dead())
Example #3
0
    def test_no_good_hostname(self):
        """Correctly handle ambiguous hostnames.

        If the lock's recorded with just 'localhost' we can't really trust
        it's the same 'localhost'.  (There are quite a few of them. :-)
        So even if the process is known not to be alive, we can't say that's
        known for sure.
        """
        self.overrideAttr(lockdir, 'get_host_name',
            lambda: 'localhost')
        info = LockHeldInfo.for_this_process(None)
        info.info_dict['pid'] = '123123123'
        self.assertFalse(info.is_lock_holder_known_dead())
    def test_no_good_hostname(self):
        """Correctly handle ambiguous hostnames.

        If the lock's recorded with just 'localhost' we can't really trust
        it's the same 'localhost'.  (There are quite a few of them. :-)
        So even if the process is known not to be alive, we can't say that's
        known for sure.
        """
        self.overrideAttr(lockdir, 'get_host_name',
            lambda: 'localhost')
        info = LockHeldInfo.for_this_process(None)
        info.info_dict['pid'] = '123123123'
        self.assertFalse(info.is_lock_holder_known_dead())
 def test_lock_holder_other_machine(self):
     """The lock holder isn't here so we don't know if they're alive."""
     info = LockHeldInfo.for_this_process(None)
     info.info_dict['hostname'] = 'egg.example.com'
     info.info_dict['pid'] = '123123123'
     self.assertFalse(info.is_lock_holder_known_dead())
 def test_lock_holder_live_process(self):
     """Detect that the holder (this process) is still running."""
     info = LockHeldInfo.for_this_process(None)
     self.assertFalse(info.is_lock_holder_known_dead())
 def test_is_not_locked_by_this_process(self):
     info = LockHeldInfo.for_this_process(None)
     info.info_dict['pid'] = '123123123123123'
     self.assertFalse(info.is_locked_by_this_process())
 def test_is_locked_by_this_process(self):
     info = LockHeldInfo.for_this_process(None)
     self.assertTrue(info.is_locked_by_this_process())
 def test_unicode(self):
     info = LockHeldInfo.for_this_process(None)
     self.assertContainsRe(unicode(info),
         r'held by .* on .* \(process #\d+\), acquired .* ago')
Example #10
0
 def test_unicode(self):
     info = LockHeldInfo.for_this_process(None)
     self.assertContainsRe(unicode(info),
         r'held by .* on .* \(process #\d+\), acquired .* ago')
Example #11
0
 def test_lock_holder_other_user(self):
     """Only auto-break locks held by this user."""
     info = LockHeldInfo.for_this_process(None)
     info.info_dict['user'] = '******'
     info.info_dict['pid'] = '123123123'
     self.assertFalse(info.is_lock_holder_known_dead())
Example #12
0
 def test_lock_holder_other_machine(self):
     """The lock holder isn't here so we don't know if they're alive."""
     info = LockHeldInfo.for_this_process(None)
     info.info_dict['hostname'] = 'egg.example.com'
     info.info_dict['pid'] = '123123123'
     self.assertFalse(info.is_lock_holder_known_dead())
Example #13
0
 def test_lock_holder_live_process(self):
     """Detect that the holder (this process) is still running."""
     info = LockHeldInfo.for_this_process(None)
     self.assertFalse(info.is_lock_holder_known_dead())
Example #14
0
 def test_is_not_locked_by_this_process(self):
     info = LockHeldInfo.for_this_process(None)
     info.info_dict['pid'] = '123123123123123'
     self.assertFalse(info.is_locked_by_this_process())
Example #15
0
 def test_is_locked_by_this_process(self):
     info = LockHeldInfo.for_this_process(None)
     self.assertTrue(info.is_locked_by_this_process())
 def test_lock_holder_other_user(self):
     """Only auto-break locks held by this user."""
     info = LockHeldInfo.for_this_process(None)
     info.info_dict['user'] = '******'
     info.info_dict['pid'] = '123123123'
     self.assertFalse(info.is_lock_holder_known_dead())
 def test_repr(self):
     info = LockHeldInfo.for_this_process(None)
     self.assertContainsRe(repr(info), r"LockHeldInfo\(.*\)")
Example #18
0
 def test_repr(self):
     info = LockHeldInfo.for_this_process(None)
     self.assertContainsRe(repr(info), r"LockHeldInfo\(.*\)")