~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockable_files.py

  • Committer: Jonathan Lange
  • Date: 2007-04-22 23:00:56 UTC
  • mfrom: (2440 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2446.
  • Revision ID: jml@canonical.com-20070422230056-mfu7bo3ydrbbag7p
Merge bzr.dev, resolving conflicts in error code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import bzrlib.errors as errors
21
21
from bzrlib.errors import BzrBadParameterNotString, NoSuchFile, ReadOnlyError
22
22
from bzrlib.lockable_files import LockableFiles, TransportLock
 
23
from bzrlib import lockdir
23
24
from bzrlib.lockdir import LockDir
24
25
from bzrlib.tests import TestCaseInTempDir
 
26
from bzrlib.tests.test_smart import TestCaseWithSmartMedium
25
27
from bzrlib.tests.test_transactions import DummyWeave
26
28
from bzrlib.transactions import (PassThroughTransaction,
27
29
                                 ReadOnlyTransaction,
42
44
            self.assertEqual(4, len(unicode_string))
43
45
            byte_string = unicode_string.encode('utf-8')
44
46
            self.assertEqual(6, len(byte_string))
45
 
            self.assertRaises(UnicodeEncodeError, self.lockable.put, 'foo', 
 
47
            self.assertRaises(UnicodeEncodeError, self.lockable.put, 'foo',
46
48
                              StringIO(unicode_string))
47
49
            self.lockable.put('foo', StringIO(byte_string))
48
50
            self.assertEqual(byte_string,
358
360
 
359
361
    # TODO: Test the lockdir inherits the right file and directory permissions
360
362
    # from the LockableFiles.
 
363
        
 
364
 
 
365
class TestLockableFiles_RemoteLockDir(TestCaseWithSmartMedium,
 
366
                              _TestLockableFiles_mixin):
 
367
    """LockableFile tests run with RemoteLockDir on a branch."""
 
368
 
 
369
    def setUp(self):
 
370
        TestCaseWithSmartMedium.setUp(self)
 
371
        # can only get a RemoteLockDir with some RemoteObject...
 
372
        # use a branch as thats what we want. These mixin tests test the end
 
373
        # to end behaviour, so stubbing out the backend and simulating would
 
374
        # defeat the purpose. We test the protocol implementation separately
 
375
        # in test_remote and test_smart as usual.
 
376
        b = self.make_branch('foo')
 
377
        self.addCleanup(b.bzrdir.transport.disconnect)
 
378
        self.transport = get_transport('.')
 
379
        self.lockable = self.get_lockable()
 
380
 
 
381
    def get_lockable(self):
 
382
        # getting a new lockable involves opening a new instance of the branch
 
383
        branch = bzrlib.branch.Branch.open(self.get_url('foo'))
 
384
        self.addCleanup(branch.bzrdir.transport.disconnect)
 
385
        return branch.control_files