Rev 14: Basic acceptance test of what we want to be able to do in lp:~jameinel/+junk/file_locking
John Arbash Meinel
john at arbash-meinel.com
Mon Sep 21 17:31:06 BST 2009
At lp:~jameinel/+junk/file_locking
------------------------------------------------------------
revno: 14
revision-id: john at arbash-meinel.com-20090921163059-wiyn43m8e060b413
parent: john at arbash-meinel.com-20090921161149-dg0v4x5ewpt5qzm4
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: file_locking
timestamp: Mon 2009-09-21 11:30:59 -0500
message:
Basic acceptance test of what we want to be able to do
with the manager when all is said and done.
Note we may need to add some sort of 'refresh_info()' to the tests
once we figure out what sort of lifetime we want the state to keep.
-------------- next part --------------
=== modified file 'tests/test_file_lock.py'
--- a/tests/test_file_lock.py 2009-09-21 15:43:46 +0000
+++ b/tests/test_file_lock.py 2009-09-21 16:30:59 +0000
@@ -135,6 +135,63 @@
manager.initialize_lock_store('.')
self.assertFalse(manager.is_tracked(''))
+ def test_basic_acceptance(self):
+ builder = self.make_branch_builder('path')
+ builder.build_snapshot('A', None, [
+ ('add', ('', 'TREE_ROOT', 'directory', None)),
+ ('add', ('a', 'a-id', 'file', 'content\n')),
+ ('add', ('b', 'b-id', 'directory', None)),
+ ('add', ('b/c', 'c-id', 'file', 'content\n')),
+ ])
+ tree, manager = self.make_tree_and_manager('tree')
+ tree.branch.pull(builder.get_branch())
+ # Refresh the memory tree
+ tree.unlock()
+ tree.lock_write()
+ manager.initialize_lock_store('lock-store')
+ self.knownFailure('not implemented yet.')
+ manager.track('b')
+ self.assertFalse(manager.is_locked('b'))
+ self.assertFalse(manager.is_tracked('a'))
+ self.assertTrue(manager.is_tracked('b'))
+ self.assertTrue(manager.is_tracked('b/c'))
+ self.assertFalse(manager.is_locked('b/c'))
+ manager.take_lock('b')
+ self.assertTrue(manager.is_locked('b'))
+ self.assertTrue(manager.is_locked('b/c'))
+ self.assertTrue(manager.have_lock('b'))
+ self.assertTrue(manager.have_lock('b/c'))
+ tree2, manager2 = self.make_tree_and_manager('tree2')
+ tree2.branch.pull(builder.get_branch())
+ tree2.unlock()
+ tree2.lock_write()
+ # Share the lock store
+ manager2.initialize_lock_store('lock-store')
+ self.assertTrue(manager2.is_locked('b'))
+ self.assertTrue(manager2.is_locked('b/c'))
+ self.assertFalse(manager2.have_lock('b'))
+ self.assertFalse(manager2.have_lock('b/c'))
+ manager2.steal_lock('b')
+ self.assertTrue(manager.is_locked('b'))
+ self.assertTrue(manager.is_locked('b/c'))
+ self.assertFalse(manager.have_lock('b'))
+ self.assertFalse(manager.have_lock('b/c'))
+ self.assertTrue(manager2.is_locked('b'))
+ self.assertTrue(manager2.is_locked('b/c'))
+ self.assertTrue(manager2.have_lock('b'))
+ self.assertTrue(manager2.have_lock('b/c'))
+ # manager doesn't control the lock
+ self.assertRaises(errors.BzrError,
+ manager.unlock, 'b')
+ manager2.unlock('b')
+ self.assertFalse(manager.is_locked('b'))
+ self.assertFalse(manager.is_locked('b/c'))
+ self.assertFalse(manager.have_lock('b'))
+ self.assertFalse(manager.have_lock('b/c'))
+ self.assertFalse(manager2.is_locked('b'))
+ self.assertFalse(manager2.is_locked('b/c'))
+ self.assertFalse(manager2.have_lock('b'))
+ self.assertFalse(manager2.have_lock('b/c'))
class TestFileLockStore(tests.TestCaseWithMemoryTransport):
More information about the bazaar-commits
mailing list