~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2009-12-08 21:37:36 UTC
  • mto: This revision was merged to the branch mainline in revision 4885.
  • Revision ID: john@arbash-meinel.com-20091208213736-vje7ublg3xzp1bs2
Now that we return files directly from the working tree
the windows 'attrib' test needed to be updated.
If we used the working tree for both old and new, then the test wasn't
really testing what we expected, which was that the newly generated
content was readable.

But using basis_tree gets us that. Also, test that the content is
properly marked as readonly, and that we have available content from
the working tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2009 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
19
19
 
20
20
import os
21
21
 
22
 
from bzrlib import (
23
 
    osutils,
24
 
    tests,
 
22
from bzrlib import osutils
 
23
from bzrlib.tests import (
 
24
    condition_isinstance,
 
25
    split_suite_by_condition,
 
26
    multiply_tests,
 
27
    SymlinkFeature
25
28
    )
 
29
from bzrlib.tests.blackbox import ExternalBase
26
30
 
27
31
 
28
32
def load_tests(standard_tests, module, loader):
29
33
    """Parameterize tests for view-aware vs not."""
30
 
    to_adapt, result = tests.split_suite_by_condition(
31
 
        standard_tests, tests.condition_isinstance(TestAdd))
 
34
    to_adapt, result = split_suite_by_condition(
 
35
        standard_tests, condition_isinstance(TestAdd))
32
36
    scenarios = [
33
37
        ('pre-views', {'branch_tree_format': 'pack-0.92'}),
34
38
        ('view-aware', {'branch_tree_format': 'development6-rich-root'}),
35
39
        ]
36
 
    return tests.multiply_tests(to_adapt, scenarios, result)
37
 
 
38
 
 
39
 
class TestAdd(tests.TestCaseWithTransport):
 
40
    return multiply_tests(to_adapt, scenarios, result)
 
41
 
 
42
 
 
43
class TestAdd(ExternalBase):
40
44
 
41
45
    def make_branch_and_tree(self, dir):
42
 
        return super(TestAdd, self).make_branch_and_tree(
43
 
            dir, format=self.branch_tree_format)
 
46
        return ExternalBase.make_branch_and_tree(self, dir,
 
47
            format=self.branch_tree_format)
44
48
 
45
49
    def test_add_reports(self):
46
50
        """add command prints the names of added files."""
111
115
 
112
116
        eq = self.assertEqual
113
117
        ass = self.assertTrue
 
118
        chdir = os.chdir
114
119
 
115
120
        t = self.make_branch_and_tree('.')
116
121
        b = t.branch
125
130
 
126
131
        # add with no arguments in a subdirectory gets only files below that
127
132
        # subdirectory
128
 
        self.run_bzr('add', working_dir='src')
129
 
        self.assertEquals('README\n',
130
 
                          self.run_bzr('unknowns', working_dir='src')[0])
 
133
        chdir('src')
 
134
        self.run_bzr('add')
 
135
        self.assertEquals(self.run_bzr('unknowns')[0], 'README\n')
131
136
        # reopen to see the new changes
132
 
        t = t.bzrdir.open_workingtree('src')
 
137
        t = t.bzrdir.open_workingtree()
133
138
        versioned = [path for path, entry in t.iter_entries_by_dir()]
134
 
        self.assertEquals(versioned, ['', 'src', 'src/foo.c'])
 
139
        self.assertEquals(versioned,
 
140
            ['', 'src', 'src/foo.c'])
135
141
 
136
142
        # add from the parent directory should pick up all file names
 
143
        chdir('..')
137
144
        self.run_bzr('add')
138
145
        self.assertEquals(self.run_bzr('unknowns')[0], '')
139
146
        self.run_bzr('check')
204
211
        self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')
205
212
 
206
213
    def test_add_via_symlink(self):
207
 
        self.requireFeature(tests.SymlinkFeature)
 
214
        self.requireFeature(SymlinkFeature)
208
215
        self.make_branch_and_tree('source')
209
216
        self.build_tree(['source/top.txt'])
210
217
        os.symlink('source', 'link')
212
219
        self.assertEquals(out, 'adding top.txt\n')
213
220
 
214
221
    def test_add_symlink_to_abspath(self):
215
 
        self.requireFeature(tests.SymlinkFeature)
 
222
        self.requireFeature(SymlinkFeature)
216
223
        self.make_branch_and_tree('tree')
217
224
        os.symlink(osutils.abspath('target'), 'tree/link')
218
225
        out = self.run_bzr(['add', 'tree/link'])[0]