/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_clean_tree.py

  • Committer: Vincent Ladeuil
  • Date: 2007-06-06 14:26:08 UTC
  • mto: (2485.8.44 bzr.connection.sharing)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070606142608-i9ufaqewadslf1cn
Finish sftp refactoring. Test suite passing.

* bzrlib/transport/sftp.py:
(clear_connection_cache): Deprecated.
(_sftp_connect, _sftp_connect_uncached): Deleted.
(SFTPTransport.__init__): Simplified.
(SFTPTransport._create_connection): New method. Copied from
_sftp_connect_uncached
(SFTPTransport._get_sftp): New method. Ensures that the connection
is established.
(SFTPTransport.clone): Deleted.
(SFTPTransport.has, SFTPTransport.get, SFTPTransport.readv,
SFTPTransport._put,
SFTPTransport._put_non_atomic_helper._open_and_write_file,
SFTPTransport._mkdir, SFTPTransport.append_file,
SFTPTransport.rename, SFTPTransport._rename_and_overwrite,
SFTPTransport.delete, SFTPTransport.rmdir, SFTPTransport.stat):
Use _get_sftp.

* bzrlib/tests/test_transport_implementations.py:
(TransportTests.test_connection_error): Simplified now that sftp
does not connection on construction.

* bzrlib/tests/test_sftp_transport.py:
(SFTPLockTests.test_sftp_locks): Delete test_multiple_connections.
(FakeSFTPTransport): Deleted.
(SFTPNonServerTest.test_parse_url_with_home_dir,
SFTPNonServerTest.test_relpath,
SSHVendorBadConnection.test_bad_connection_paramiko): Delete the
from_transport parameter as it's not needed anymore.
(SFTPLatencyKnob.test_latency_knob_slows_transport,
SFTPLatencyKnob.test_default): Force connection by issuing a
request.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2009 Canonical Ltd
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
 
18
 
import os
19
 
from StringIO import StringIO
20
 
 
21
 
from bzrlib.bzrdir import (
22
 
    BzrDir,
23
 
    )
24
 
from bzrlib.clean_tree import (
25
 
    clean_tree,
26
 
    iter_deletables,
27
 
    )
28
 
from bzrlib.osutils import (
29
 
    has_symlinks,
30
 
    )
31
 
from bzrlib.tests import (
32
 
    TestCaseInTempDir,
33
 
    )
34
 
 
35
 
 
36
 
class TestCleanTree(TestCaseInTempDir):
37
 
 
38
 
    def test_symlinks(self):
39
 
        if has_symlinks() is False:
40
 
            return
41
 
        os.mkdir('branch')
42
 
        BzrDir.create_standalone_workingtree('branch')
43
 
        os.symlink(os.path.realpath('no-die-please'), 'branch/die-please')
44
 
        os.mkdir('no-die-please')
45
 
        self.failUnlessExists('branch/die-please')
46
 
        os.mkdir('no-die-please/child')
47
 
 
48
 
        clean_tree('branch', unknown=True, no_prompt=True)
49
 
        self.failUnlessExists('no-die-please')
50
 
        self.failUnlessExists('no-die-please/child')
51
 
 
52
 
    def test_iter_deletable(self):
53
 
        """Files are selected for deletion appropriately"""
54
 
        os.mkdir('branch')
55
 
        tree = BzrDir.create_standalone_workingtree('branch')
56
 
        transport = tree.bzrdir.root_transport
57
 
        transport.put_bytes('.bzrignore', '*~\n*.pyc\n.bzrignore\n')
58
 
        transport.put_bytes('file.BASE', 'contents')
59
 
        tree.lock_write()
60
 
        try:
61
 
            self.assertEqual(len(list(iter_deletables(tree, unknown=True))), 1)
62
 
            transport.put_bytes('file', 'contents')
63
 
            transport.put_bytes('file~', 'contents')
64
 
            transport.put_bytes('file.pyc', 'contents')
65
 
            dels = sorted([r for a,r in iter_deletables(tree, unknown=True)])
66
 
            self.assertEqual(['file', 'file.BASE'], dels)
67
 
 
68
 
            dels = [r for a,r in iter_deletables(tree, detritus=True)]
69
 
            self.assertEqual(sorted(['file~', 'file.BASE']), dels)
70
 
 
71
 
            dels = [r for a,r in iter_deletables(tree, ignored=True)]
72
 
            self.assertEqual(sorted(['file~', 'file.pyc', '.bzrignore']),
73
 
                             dels)
74
 
 
75
 
            dels = [r for a,r in iter_deletables(tree, unknown=False)]
76
 
            self.assertEqual([], dels)
77
 
        finally:
78
 
            tree.unlock()