~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/blackbox.py

  • Committer: Aaron Bentley
  • Date: 2007-07-12 20:42:54 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070712204254-7xk9fvrxj7cdzku5
Update version number

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
 
1
from bzrlib.tests.blackbox import ExternalBase
 
2
from unittest import makeSuite
2
3
import os.path
3
 
from unittest import makeSuite
4
 
 
5
 
from bzrlib import branch, osutils, workingtree
6
 
from bzrlib.config import LocationConfig
7
 
from bzrlib.transport import get_transport
8
 
from bzrlib.tests import TestCaseWithTransport, HardlinkFeature
9
 
 
10
 
 
11
 
class TestBzrTools(TestCaseWithTransport):
 
4
class TestBzrTools(ExternalBase):
12
5
    @staticmethod
13
6
    def touch(filename):
14
7
        file(filename, 'wb').write('')
98
91
        self.assertIs(False, os.path.exists('checkout'))
99
92
        self.assertIs(True, os.path.exists('source'))
100
93
 
101
 
    def test_zap_modified(self):
102
 
        tree = self.make_branch_and_tree('source')
103
 
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
104
 
        self.build_tree(['checkout/file'])
105
 
        checkout.add('file')
106
 
        self.run_bzr_error(('This checkout has uncommitted changes',),
107
 
                           'zap checkout')
108
 
        self.failUnlessExists('checkout')
109
 
        self.run_bzr('zap checkout --force')
110
 
        self.failIfExists('checkout')
111
 
        self.failUnlessExists('source')
112
 
 
113
94
    def test_zap_branch(self):
114
95
        self.run_bzr('init source')
115
96
        self.run_bzr('checkout --lightweight source checkout')
134
115
        self.assertIs(True, 'source/subsource' in lines)
135
116
        self.assertIs(True, 'checkout/subcheckout' in lines)
136
117
        self.assertIs(True, 'checkout' not in lines)
 
118
        self.assertIs(True, 'checkout/.bzr/subcheckout' not in lines)
137
119
 
138
120
    def test_import_upstream(self):
139
121
        self.run_bzr('init source')
166
148
        self.run_bzr('import source-0.1 import5')
167
149
        self.failUnlessExists('import5/src/myfile')
168
150
 
169
 
    def test_cbranch(self):
170
 
        source = self.make_branch_and_tree('source')
171
 
        config = LocationConfig(osutils.abspath('target'))
172
 
        config.set_user_option('cbranch_target', 'target_branch')
173
 
        self.run_bzr('cbranch source target')
174
 
        checkout = workingtree.WorkingTree.open('target')
175
 
        self.assertEqual(checkout.branch.base,
176
 
                         get_transport('target').base)
177
 
        self.assertEqual(checkout.branch.get_master_branch().base,
178
 
                         get_transport('target_branch').base)
179
 
        self.assertEqual(checkout.branch.get_master_branch().get_parent(),
180
 
                         get_transport('source').base)
181
 
 
182
 
    def test_cbranch_hardlink(self):
183
 
        self.requireFeature(HardlinkFeature)
184
 
        source = self.make_branch_and_tree('source')
185
 
        self.build_tree(['source/file'])
186
 
        source.add('file')
187
 
        source.commit('added file')
188
 
        config = LocationConfig(osutils.abspath('target'))
189
 
        config.set_user_option('cbranch_target', 'target_branch')
190
 
        self.run_bzr('cbranch source target --lightweight')
191
 
        checkout = workingtree.WorkingTree.open('target')
192
 
        self.assertNotEqual(os.lstat(checkout.abspath('file')).st_ino,
193
 
                            os.lstat(source.abspath('file')).st_ino)
194
 
        config = LocationConfig(osutils.abspath('target2'))
195
 
        config.set_user_option('cbranch_target', 'target_branch2')
196
 
        self.run_bzr('cbranch source target2 --lightweight --hardlink')
197
 
        checkout2 = workingtree.WorkingTree.open('target2')
198
 
        self.assertEqual(os.lstat(checkout2.abspath('file')).st_ino,
199
 
                         os.lstat(source.abspath('file')).st_ino)
200
 
 
201
 
 
202
151
def test_suite():
203
152
    return makeSuite(TestBzrTools)