~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_versioning.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-11 04:02:41 UTC
  • mfrom: (5017.2.2 tariff)
  • Revision ID: pqm@pqm.ubuntu.com-20100211040241-w6n021dz0uus341n
(mbp) add import-tariff tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
29
29
from bzrlib.workingtree import WorkingTree
30
30
 
31
31
 
32
 
class TestMkdir(TestCaseWithTransport):
33
 
 
34
 
    def test_mkdir_fails_cleanly(self):
35
 
        """'mkdir' fails cleanly when no working tree is available.
36
 
        https://bugs.launchpad.net/bzr/+bug/138600
37
 
        """
38
 
        # Since there is a safety working tree above us, we create a bare repo
39
 
        # here locally.
40
 
        shared_repo = self.make_repository('.')
41
 
        self.run_bzr(['mkdir', 'abc'], retcode=3)
42
 
        self.assertPathDoesNotExist('abc')
43
 
 
44
 
 
45
32
class TestVersioning(TestCaseInTempDir):
46
33
 
47
34
    def test_mkdir(self):
48
35
        """Basic 'bzr mkdir' operation"""
49
36
 
50
37
        self.run_bzr('init')
51
 
        self.run_bzr(['mkdir', 'foo'])
 
38
        self.run_bzr('mkdir foo')
52
39
        self.assert_(os.path.isdir('foo'))
53
40
 
54
 
        self.run_bzr(['mkdir', 'foo'], retcode=3)
 
41
        self.run_bzr('mkdir foo', retcode=3)
55
42
 
56
43
        wt = WorkingTree.open('.')
57
44
 
61
48
 
62
49
        self.assertEquals(len(delta.added), 1)
63
50
        self.assertEquals(delta.added[0][0], 'foo')
64
 
        self.assertFalse(delta.modified)
 
51
        self.failIf(delta.modified)
65
52
 
66
53
    def test_mkdir_in_subdir(self):
67
54
        """'bzr mkdir' operation in subdirectory"""
68
55
 
69
56
        self.run_bzr('init')
70
 
        self.run_bzr(['mkdir', 'dir'])
 
57
        self.run_bzr('mkdir dir')
71
58
        self.assert_(os.path.isdir('dir'))
72
59
 
73
60
        os.chdir('dir')
74
61
        self.log('Run mkdir in subdir')
75
 
        self.run_bzr(['mkdir', 'subdir'])
 
62
        self.run_bzr('mkdir subdir')
76
63
        self.assert_(os.path.isdir('subdir'))
77
64
        os.chdir('..')
78
65
 
85
72
        self.assertEquals(len(delta.added), 2)
86
73
        self.assertEquals(delta.added[0][0], 'dir')
87
74
        self.assertEquals(delta.added[1][0], pathjoin('dir','subdir'))
88
 
        self.assertFalse(delta.modified)
 
75
        self.failIf(delta.modified)
89
76
 
90
77
    def test_mkdir_w_nested_trees(self):
91
78
        """'bzr mkdir' with nested trees"""
99
86
        self.run_bzr('init')
100
87
        os.chdir('../..')
101
88
 
102
 
        self.run_bzr(['mkdir', 'dir', 'a/dir', 'a/b/dir'])
103
 
        self.assertTrue(os.path.isdir('dir'))
104
 
        self.assertTrue(os.path.isdir('a/dir'))
105
 
        self.assertTrue(os.path.isdir('a/b/dir'))
 
89
        self.run_bzr('mkdir dir a/dir a/b/dir')
 
90
        self.failUnless(os.path.isdir('dir'))
 
91
        self.failUnless(os.path.isdir('a/dir'))
 
92
        self.failUnless(os.path.isdir('a/b/dir'))
106
93
 
107
94
        wt = WorkingTree.open('.')
108
95
        wt_a = WorkingTree.open('a')
111
98
        delta = wt.changes_from(wt.basis_tree())
112
99
        self.assertEquals(len(delta.added), 1)
113
100
        self.assertEquals(delta.added[0][0], 'dir')
114
 
        self.assertFalse(delta.modified)
 
101
        self.failIf(delta.modified)
115
102
 
116
103
        delta = wt_a.changes_from(wt_a.basis_tree())
117
104
        self.assertEquals(len(delta.added), 1)
118
105
        self.assertEquals(delta.added[0][0], 'dir')
119
 
        self.assertFalse(delta.modified)
 
106
        self.failIf(delta.modified)
120
107
 
121
108
        delta = wt_b.changes_from(wt_b.basis_tree())
122
109
        self.assertEquals(len(delta.added), 1)
123
110
        self.assertEquals(delta.added[0][0], 'dir')
124
 
        self.assertFalse(delta.modified)
 
111
        self.failIf(delta.modified)
125
112
 
126
113
    def check_branch(self):
127
114
        """After all the above changes, run the check and upgrade commands.