/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_sftp_transport.py

merge integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from bzrlib.branch import Branch
22
22
import bzrlib.errors as errors
23
 
from bzrlib.tests import TestCaseInTempDir, TestCase
 
23
from bzrlib.osutils import pathjoin, lexists
 
24
from bzrlib.tests import TestCaseInTempDir, TestCase, TestSkipped
24
25
from bzrlib.tests.test_transport import TestTransportMixIn
25
26
import bzrlib.transport
26
27
 
35
36
    """A test case base class that provides a sftp server on localhost."""
36
37
 
37
38
    def setUp(self):
 
39
        if not paramiko_loaded:
 
40
            raise TestSkipped('you must have paramiko to run this test')
38
41
        super(TestCaseWithSFTPServer, self).setUp()
39
42
        from bzrlib.transport.sftp import SFTPAbsoluteServer, SFTPHomeDirServer
40
43
        if getattr(self, '_get_remote_is_absolute', None) is None:
85
88
        self.assertRaises(LockError, t.lock_write, 'bogus')
86
89
 
87
90
        l.unlock()
88
 
        self.failIf(os.path.lexists('bogus.write-lock'))
 
91
        self.failIf(lexists('bogus.write-lock'))
89
92
 
90
93
        open('something.write-lock', 'wb').write('fake lock\n')
91
94
        self.assertRaises(LockError, t.lock_write, 'something')
156
159
 
157
160
 
158
161
class SFTPNonServerTest(TestCase):
 
162
    def setUp(self):
 
163
        TestCase.setUp(self)
 
164
        if not paramiko_loaded:
 
165
            raise TestSkipped('you must have paramiko to run this test')
 
166
 
159
167
    def test_parse_url(self):
160
168
        from bzrlib.transport.sftp import SFTPTransport
161
169
        s = SFTPTransport('sftp://simple.example.com/%2fhome/source', clone_from=fake)
234
242
        self.failUnlessExists('.bzr/branch-format')
235
243
        self.failUnlessExists('.bzr/branch-lock')
236
244
 
237
 
        self.failIf(os.path.lexists('.bzr/branch-lock.write-lock'))
 
245
        self.failIf(lexists('.bzr/branch-lock.write-lock'))
238
246
        b.lock_write()
239
247
        self.failUnlessExists('.bzr/branch-lock.write-lock')
240
248
        b.unlock()
241
 
        self.failIf(os.path.lexists('.bzr/branch-lock.write-lock'))
 
249
        self.failIf(lexists('.bzr/branch-lock.write-lock'))
242
250
 
243
251
    def test_no_working_tree(self):
244
252
        b = Branch.initialize(self._sftp_url)
257
265
 
258
266
        self.assertEquals(b2.revision_history(), ['a1'])
259
267
 
260
 
 
261
 
if not paramiko_loaded:
262
 
    # TODO: Skip these
263
 
    del SFTPTransportTest
264
 
    del SFTPNonServerTest
265
 
    del SFTPBranchTest
 
268
        open('a/foo', 'wt').write('something new in foo\n')
 
269
        t.commit('new', rev_id='a2')
 
270
        b2.pull(b)
 
271
 
 
272
        self.assertEquals(b2.revision_history(), ['a1', 'a2'])
 
273
 
 
274