Exemple #1
0
 def test_locked(self):
     lock = sherlock.MCLock(self.lock_name)
     lock._acquire()
     self.assertTrue(lock._locked)
     lock._release()
     self.assertFalse(lock._locked)
Exemple #2
0
 def test_release_with_namespace(self):
     lock = sherlock.MCLock(self.lock_name, namespace='ns')
     lock._acquire()
     lock._release()
     self.assertEqual(self.client.get('ns_%s' % self.lock_name), None)
Exemple #3
0
 def test_release_own_only(self):
     lock1 = sherlock.MCLock(self.lock_name)
     lock2 = sherlock.MCLock(self.lock_name)
     lock1._acquire()
     self.assertRaises(sherlock.LockException, lock2._release)
     lock1._release()
Exemple #4
0
 def test_release(self):
     lock = sherlock.MCLock(self.lock_name)
     lock._acquire()
     lock._release()
     self.assertEqual(self.client.get(self.lock_name), None)
Exemple #5
0
 def test_acquire_check_expiry(self):
     lock = sherlock.MCLock(self.lock_name, expire=1)
     lock.acquire()
     time.sleep(2)
     self.assertFalse(lock.locked())
Exemple #6
0
 def test_acquire_once_only(self):
     lock1 = sherlock.MCLock(self.lock_name)
     lock2 = sherlock.MCLock(self.lock_name)
     self.assertTrue(lock1._acquire())
     self.assertFalse(lock2._acquire())
Exemple #7
0
 def test_acquire_with_namespace(self):
     lock = sherlock.MCLock(self.lock_name, namespace='ns')
     self.assertTrue(lock._acquire())
     self.assertEqual(self.client.get('ns_%s' % self.lock_name),
                      str(lock._owner))
Exemple #8
0
 def test_acquire(self):
     lock = sherlock.MCLock(self.lock_name)
     self.assertTrue(lock._acquire())
     self.assertEqual(self.client.get(self.lock_name), str(lock._owner))