~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_remove.py

  • Committer: Marius Kruger
  • Date: 2007-04-13 18:45:26 UTC
  • mto: This revision was merged to the branch mainline in revision 2455.
  • Revision ID: amanic@gmail.com-20070413184526-6xhpgyvqz2u18l2q
move test_workingtree.TestRemove to workingtree_implementations/test_remove

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006, 2007 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""Tests for interface conformance of 'WorkingTree.remove'"""
 
18
 
 
19
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
 
20
 
 
21
class TestRemove(TestCaseWithWorkingTree):
 
22
    """Tests WorkingTree.remove"""
 
23
 
 
24
    files=['a','b/','b/c']
 
25
    b = ['b']
 
26
    b_c = ['b','b/c']
 
27
    
 
28
    def getTree(self):
 
29
        self.makeAndChdirToTestDir()
 
30
        tree = self.make_branch_and_tree('.')
 
31
        self.build_tree(TestRemove.files)
 
32
        return tree
 
33
 
 
34
    def test_remove_unchanged_files(self):
 
35
        """check that unchanged files are removed and deleted."""
 
36
        tree = self.getTree()
 
37
        tree.add(TestRemove.files)
 
38
        tree.commit("files must not have changes")
 
39
 
 
40
        self.assertInWorkingTree(TestRemove.files)
 
41
 
 
42
        tree.remove(TestRemove.files, keep_files=False)
 
43
 
 
44
        self.assertNotInWorkingTree(TestRemove.files)
 
45
        self.failIfExists(TestRemove.files)
 
46
 
 
47
    def test_remove_changed_files(self):
 
48
        """check that changed files are removed but not deleted."""
 
49
        tree = self.getTree()
 
50
        tree.add(TestRemove.files)
 
51
        self.assertInWorkingTree(TestRemove.files)
 
52
 
 
53
        tree.remove(TestRemove.files, keep_files=False)
 
54
 
 
55
        self.assertNotInWorkingTree(TestRemove.files)
 
56
        self.failUnlessExists(TestRemove.files)
 
57
 
 
58
    def test_force_remove_changed_files(self):
 
59
        """check that changed files are removed and deleted when forced."""
 
60
        tree = self.getTree()
 
61
        tree.add(TestRemove.files)
 
62
        self.assertInWorkingTree(TestRemove.files)
 
63
 
 
64
        tree.remove(TestRemove.files, keep_files=False, force=True)
 
65
 
 
66
        self.assertNotInWorkingTree(TestRemove.files)
 
67
        self.failIfExists(TestRemove.files)
 
68
 
 
69
    def test_remove_nonexisting_files(self):
 
70
        """delete files which does not exist."""
 
71
        tree = self.getTree()
 
72
        tree.remove(TestRemove.files, keep_files=False)
 
73
        tree.remove([''], keep_files=False)
 
74
        tree.remove(TestRemove.b, keep_files=False)
 
75
 
 
76
    def test_remove_nonempty_directory(self):
 
77
        tree = self.getTree()
 
78
        tree.add(TestRemove.files)
 
79
        tree.commit("make sure b is versioned")
 
80
        self.assertInWorkingTree(TestRemove.files)
 
81
        self.failUnlessExists(TestRemove.files)
 
82
        tree.remove(TestRemove.b, keep_files=False)
 
83
        self.assertNotInWorkingTree(TestRemove.b)
 
84
        self.failUnlessExists(TestRemove.b)
 
85
 
 
86
    def test_force_remove_nonempty_directory(self):
 
87
        tree = self.getTree()
 
88
        tree.add(TestRemove.files)
 
89
        tree.commit("make sure b is versioned")
 
90
        self.assertInWorkingTree(TestRemove.files)
 
91
        self.failUnlessExists(TestRemove.files)
 
92
        tree.remove(TestRemove.b, keep_files=False, force=True)
 
93
        self.assertNotInWorkingTree(TestRemove.b_c)
 
94
        self.failIfExists(TestRemove.b_c)
 
95
 
 
96
    def test_remove_keep(self):
 
97
        """check that files are unversioned but not delete."""
 
98
        tree = self.getTree()
 
99
        tree.add(TestRemove.files)
 
100
        self.assertInWorkingTree(TestRemove.files)
 
101
 
 
102
        tree.remove(TestRemove.files)
 
103
        self.assertNotInWorkingTree(TestRemove.files)
 
104
        self.failUnlessExists(TestRemove.files)