Beispiel #1
0
 def test_lock_version_context_manager(self):
     with Locking.with_version_lock(VersionUid('v1'),
                                    reason='locking test'):
         with self.assertRaises(InternalError):
             Locking.lock_version(VersionUid('v1'), reason='locking test')
     Locking.lock_version(VersionUid('v1'), reason='locking test')
     Locking.unlock_version(VersionUid('v1'))
Beispiel #2
0
 def test_lock_override(self):
     Locking.lock_version(VersionUid('v1'), reason='locking test')
     self.assertRaises(
         InternalError, lambda: Locking.lock_version(VersionUid('v1'),
                                                     reason='locking test'))
     old_uuid = Locking._uuid
     new_uuid = uuid.uuid1().hex
     # This fakes the appearance of another instance
     Locking._uuid = new_uuid
     self.assertRaises(
         AlreadyLocked, lambda: Locking.lock_version(VersionUid('v1'),
                                                     reason='locking test'))
     Locking.lock_version(VersionUid('v1'),
                          reason='locking test',
                          override_lock=True)
     self.assertRaises(
         InternalError, lambda: Locking.lock_version(VersionUid('v1'),
                                                     reason='locking test'))
     Locking._uuid = old_uuid
     self.assertRaises(
         AlreadyLocked, lambda: Locking.lock_version(VersionUid('v1'),
                                                     reason='locking test'))
     Locking._uuid = new_uuid
     Locking.unlock_version(VersionUid('v1'))
Beispiel #3
0
 def test_lock_context_manager(self):
     with Locking.with_lock(lock_name='test', reason='locking test'):
         with self.assertRaises(InternalError):
             Locking.lock(lock_name='test', reason='locking test')
     Locking.lock(lock_name='test', reason='locking test')
     Locking.unlock(lock_name='test')
Beispiel #4
0
 def test_is_version_locked(self):
     Locking.lock_version(VersionUid('v1'), reason='locking test')
     self.assertTrue(Locking.is_version_locked(VersionUid('v1')))
     Locking.unlock_version(VersionUid('v1'))
     self.assertFalse(Locking.is_version_locked(VersionUid('v1')))
Beispiel #5
0
 def test_is_locked(self):
     Locking.lock(lock_name='test', reason='locking test')
     self.assertTrue(Locking.is_locked(lock_name='test'))
     Locking.unlock(lock_name='test')
     self.assertFalse(Locking.is_locked(lock_name='test'))
Beispiel #6
0
 def test_lock_version(self):
     Locking.lock_version(VersionUid('v1'), reason='locking test')
     self.assertRaises(
         InternalError, lambda: Locking.lock_version(VersionUid('v1'),
                                                     reason='locking test'))
     Locking.unlock_version(VersionUid('v1'))