Rev 3: Track some basic requirements as acceptance tests. in http://bzr.arbash-meinel.com/plugins/file_locking
John Arbash Meinel
john at arbash-meinel.com
Fri Sep 18 18:28:17 BST 2009
At http://bzr.arbash-meinel.com/plugins/file_locking
------------------------------------------------------------
revno: 3
revision-id: john at arbash-meinel.com-20090918172812-1if99mm9lx5jawkg
parent: john at arbash-meinel.com-20090918171816-ruoetqruopk9wjr1
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: file_locking
timestamp: Fri 2009-09-18 12:28:12 -0500
message:
Track some basic requirements as acceptance tests.
All, of course, fail right now.
-------------- next part --------------
=== modified file 'tests/test_acceptance.py'
--- a/tests/test_acceptance.py 2009-09-18 17:18:16 +0000
+++ b/tests/test_acceptance.py 2009-09-18 17:28:12 +0000
@@ -52,3 +52,49 @@
out, err = self.run_bzr('lock-file a', retcode=3)
self.assertEqualDiff('Cannot lock file a, it is already in use'
'by foobar.', err)
+
+ def test_locking_containing_dir_blocks(self):
+ self.fail_for_now()
+ t = self.make_branch_and_tree('.')
+ self.build_tree(['a/', 'a/b'])
+ t.add(['a', 'b'], ['a-id', 'b-id'])
+ t.commit('Creating initial work.')
+ # This is technically 'lock-dir', not sure we need the distinction
+ self.run_bzr('lock-file a')
+ out, err = self.run_bzr('lock-file a/b', retcode=3)
+ self.assertEqualDiff('Cannot lock file a/b, the directory a is locked'
+ 'by foobar.', err)
+
+ def test_locking_containing_dir_blocks_renamed(self):
+ self.fail_for_now()
+ t1 = self.make_branch_and_tree('t1')
+ self.build_tree(['t1/a/', 't1/a/b'])
+ t1.add(['a', 'b'], ['a-id', 'b-id'])
+ t1.commit('Creating initial work.')
+ t2 = t1.bzrdir.sprout('t2').open_workingtree()
+ t2.rename('a/b', 'c') # Not committed yet
+ # Another user takes out a lock on the whole directory
+ self.run_bzr('lock-file t1/a')
+ # Note that the file has been renamed out of the containing dir already
+ out, err = self.run_bzr('lock-file c', retcode=3)
+ self.assertEqualDiff('Cannot lock file c, the directory a is locked'
+ 'by foobar.', err)
+ # Even though we don't have a lock, we could still commit
+ t2.commit('rename')
+ # Even after the commit, we can't take a lock
+ out, err = self.run_bzr('lock-file c', retcode=3)
+ # Until user a unlocks
+ self.run_bzr('unlock-file t1/a')
+ # Succeeds now that it is unlocked
+ self.run_bzr('lock-file c')
+
+ def test_locking_containing_dir_fails_if_sub_locked(self):
+ self.fail_for_now()
+ t1 = self.make_branch_and_tree('t1')
+ self.build_tree(['t1/a/', 't1/a/b'])
+ t1.add(['a', 'b'], ['a-id', 'b-id'])
+ t1.commit('Creating initial work.')
+ self.run_bzr('lock-file a/b')
+ out, err = self.run_bzr('lock-file a', retcode=3)
+ self.assertEqualDiff('Cannot lock file a, the file a/b is locked'
+ 'by foobar.', err)
More information about the bazaar-commits
mailing list