~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_sftp_transport.py

  • Committer: Robert Collins
  • Date: 2006-01-02 22:37:32 UTC
  • mfrom: (1185.50.33 bzr-jam-integration)
  • Revision ID: robertc@robertcollins.net-20060102223732-d5221b37ff0f7888
Merge in John Meinels integration branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import socket
19
19
import threading
20
20
 
21
 
from bzrlib.tests import TestCaseInTempDir, TestCase
 
21
from bzrlib.tests import TestCaseInTempDir, TestCase, TestSkipped
22
22
from bzrlib.tests.test_transport import TestTransportMixIn
23
23
import bzrlib.errors as errors
 
24
from bzrlib.osutils import pathjoin, lexists
24
25
 
25
26
try:
26
27
    import paramiko
90
91
    
91
92
    def _run_server(self, s, stop_event):
92
93
        ssh_server = paramiko.Transport(s)
93
 
        key_file = os.path.join(self._root, 'test_rsa.key')
 
94
        key_file = pathjoin(self._root, 'test_rsa.key')
94
95
        file(key_file, 'w').write(STUB_SERVER_KEY)
95
96
        host_key = paramiko.RSAKey.from_private_key_file(key_file)
96
97
        ssh_server.add_server_key(host_key)
102
103
        stop_event.wait(30.0)
103
104
 
104
105
    def setUp(self):
 
106
        if not paramiko_loaded:
 
107
            raise TestSkipped('you must have paramiko to run this test')
105
108
        TestCaseInTempDir.setUp(self)
106
109
        self._root = self.test_dir
107
110
        self._is_setup = False
157
160
        self.assertRaises(LockError, t.lock_write, 'bogus')
158
161
 
159
162
        l.unlock()
160
 
        self.failIf(os.path.lexists('bogus.write-lock'))
 
163
        self.failIf(lexists('bogus.write-lock'))
161
164
 
162
165
        open('something.write-lock', 'wb').write('fake lock\n')
163
166
        self.assertRaises(LockError, t.lock_write, 'something')
189
192
 
190
193
 
191
194
class SFTPNonServerTest(TestCase):
 
195
    def setUp(self):
 
196
        TestCase.setUp(self)
 
197
        if not paramiko_loaded:
 
198
            raise TestSkipped('you must have paramiko to run this test')
 
199
 
192
200
    def test_parse_url(self):
193
201
        from bzrlib.transport.sftp import SFTPTransport
194
202
        s = SFTPTransport('sftp://simple.example.com/%2fhome/source', clone_from=fake)
270
278
        self.failUnlessExists('.bzr/branch-format')
271
279
        self.failUnlessExists('.bzr/branch-lock')
272
280
 
273
 
        self.failIf(os.path.lexists('.bzr/branch-lock.write-lock'))
 
281
        self.failIf(lexists('.bzr/branch-lock.write-lock'))
274
282
        b.lock_write()
275
283
        self.failUnlessExists('.bzr/branch-lock.write-lock')
276
284
        b.unlock()
277
 
        self.failIf(os.path.lexists('.bzr/branch-lock.write-lock'))
 
285
        self.failIf(lexists('.bzr/branch-lock.write-lock'))
278
286
 
279
287
    def test_no_working_tree(self):
280
288
        from bzrlib.branch import Branch
298
306
 
299
307
        self.assertEquals(b2.revision_history(), ['a1'])
300
308
 
301
 
 
302
 
if not paramiko_loaded:
303
 
    # TODO: Skip these
304
 
    del SFTPTransportTest
305
 
    del SFTPNonServerTest
306
 
    del SFTPBranchTest
 
309
        open('a/foo', 'wt').write('something new in foo\n')
 
310
        t.commit('new', rev_id='a2')
 
311
        b2.pull(b)
 
312
 
 
313
        self.assertEquals(b2.revision_history(), ['a1', 'a2'])
 
314
 
 
315