Rev 29: Some testing of the tracking functionality. in lp:~jameinel/+junk/file_locking
John Arbash Meinel
john at arbash-meinel.com
Tue Sep 22 21:46:22 BST 2009
At lp:~jameinel/+junk/file_locking
------------------------------------------------------------
revno: 29
revision-id: john at arbash-meinel.com-20090922204611-kmrtvpe5oyjs73zm
parent: john at arbash-meinel.com-20090922160233-dbl84kieei920hmx
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: file_locking
timestamp: Tue 2009-09-22 15:46:11 -0500
message:
Some testing of the tracking functionality.
-------------- next part --------------
=== modified file 'file_lock.py'
--- a/file_lock.py 2009-09-22 16:02:33 +0000
+++ b/file_lock.py 2009-09-22 20:46:11 +0000
@@ -402,6 +402,8 @@
lock_store = FileLockStore.open(trans)
except errors.NoSuchFile: # TODO: Custom exception
lock_store = FileLockStore.initialize(trans)
+ # TODO: we probably shouldn't auto-unlock, it would probably be
+ # nice to do a couple operations, and then unlock
lock_store.unlock()
# TODO: We should support relative paths to lock stores
conf = self._wt.branch.get_config()
=== modified file 'tests/test_file_lock.py'
--- a/tests/test_file_lock.py 2009-09-22 16:02:33 +0000
+++ b/tests/test_file_lock.py 2009-09-22 20:46:11 +0000
@@ -222,6 +222,16 @@
manager = file_lock.FileLockManager(tree)
return tree, manager
+ def make_simple_tree_and_manager(self, path):
+ tree, manager = self.make_tree_and_manager('tree')
+ tree.mkdir('adir', 'dir-id')
+ tree.add(['afile', 'adir/subfile'],
+ ['file-id', 'subfile-id'],
+ ['file', 'file'])
+ tree.put_file_bytes_non_atomic('file-id', 'content')
+ tree.put_file_bytes_non_atomic('subfile-id', 'content')
+ return tree, manager
+
def test_already_initialized(self):
tree, manager = self.make_tree_and_manager('.')
manager.initialize_lock_store(self.get_transport('lock-store'))
@@ -240,12 +250,6 @@
lock_store = file_lock.FileLockStore.open(
self.get_transport('lock-store'))
- def test_is_tracked_no_tracking(self):
- tree, manager = self.make_tree_and_manager('.')
- self.assertFalse(manager.is_tracked(''))
- manager.initialize_lock_store(self.get_transport('lock-store'))
- self.assertFalse(manager.is_tracked(''))
-
def test__get_lock_store_open_existing(self):
tree, manager = self.make_tree_and_manager('.')
manager.initialize_lock_store(self.get_transport('lock-store'))
@@ -317,6 +321,22 @@
self.assertFalse(manager2.have_lock('b'))
self.assertFalse(manager2.have_lock('b/c'))
+ def test_is_tracked(self):
+ tree, manager = self.make_simple_tree_and_manager('tree')
+ # If we have no locking store configured, then obviously it isn't
+ # tracked yet
+ self.assertFalse(manager.is_tracked('file-id'))
+ self.assertFalse(manager.is_tracked('dir-id'))
+ self.assertFalse(manager.is_tracked('subfile-id'))
+ manager.initialize_lock_store(self.get_transport('lock-store'))
+ # Still not tracked
+ self.assertFalse(manager.is_tracked('file-id'))
+ manager.track('adir')
+
+ def test_is_locked(self):
+ tree, manager = self.make_simple_tree_and_manager('tree')
+ self.assertFalse(manager.is_locked('file-id'))
+
class TestFileLockStore(tests.TestCaseWithMemoryTransport):
More information about the bazaar-commits
mailing list