~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2009-05-04 14:48:21 UTC
  • mto: (4349.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4350.
  • Revision ID: v.ladeuil+lp@free.fr-20090504144821-39dvqkikmd3zqkdg
Handle servers proposing several authentication schemes.

* bzrlib/transport/http/_urllib2_wrappers.py:
(AbstractAuthHandler.auth_required): Several schemes can be
proposed by the server, try to match each one in turn.
(BasicAuthHandler.auth_match): Delete dead code.

* bzrlib/tests/test_http.py:
(load_tests): Separate proxy and http authentication tests as they
require different server setups.
(TestAuth.create_transport_readonly_server): Simplified by using
parameter provided by load_tests.
(TestAuth.test_changing_nonce): Adapt to new parametrization.
(TestProxyAuth.create_transport_readonly_server): Deleted.

* bzrlib/tests/http_utils.py:
(DigestAndBasicAuthRequestHandler, HTTPBasicAndDigestAuthServer,
ProxyBasicAndDigestAuthServer): Add a test server proposing both
basic and digest auth schemes but accepting only digest as valid.

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 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
 
30
from bzrlib.tests.test_win32utils import NeedsGlobExpansionFeature
26
31
 
27
32
 
28
33
def load_tests(standard_tests, module, loader):
29
34
    """Parameterize tests for view-aware vs not."""
30
 
    to_adapt, result = tests.split_suite_by_condition(
31
 
        standard_tests, tests.condition_isinstance(TestAdd))
 
35
    to_adapt, result = split_suite_by_condition(
 
36
        standard_tests, condition_isinstance(TestAdd))
32
37
    scenarios = [
33
38
        ('pre-views', {'branch_tree_format': 'pack-0.92'}),
34
39
        ('view-aware', {'branch_tree_format': 'development6-rich-root'}),
35
40
        ]
36
 
    return tests.multiply_tests(to_adapt, scenarios, result)
37
 
 
38
 
 
39
 
class TestAdd(tests.TestCaseWithTransport):
 
41
    return multiply_tests(to_adapt, scenarios, result)
 
42
 
 
43
 
 
44
class TestAdd(ExternalBase):
40
45
 
41
46
    def make_branch_and_tree(self, dir):
42
 
        return super(TestAdd, self).make_branch_and_tree(
43
 
            dir, format=self.branch_tree_format)
 
47
        return ExternalBase.make_branch_and_tree(self, dir,
 
48
            format=self.branch_tree_format)
44
49
 
45
50
    def test_add_reports(self):
46
51
        """add command prints the names of added files."""
50
55
        out = self.run_bzr('add')[0]
51
56
        # the ordering is not defined at the moment
52
57
        results = sorted(out.rstrip('\n').split('\n'))
53
 
        self.assertEquals(['adding .bzrignore',
 
58
        self.assertEquals(['If you wish to add some of these files, please'\
 
59
                           ' add them by name.',
 
60
                           'adding .bzrignore',
54
61
                           'adding dir',
55
62
                           'adding dir/sub.txt',
56
 
                           'adding top.txt'],
 
63
                           'adding top.txt',
 
64
                           'ignored 1 file(s).'],
57
65
                          results)
58
66
        out = self.run_bzr('add -v')[0]
59
67
        results = sorted(out.rstrip('\n').split('\n'))
60
 
        self.assertEquals(['ignored CVS matching "CVS"'],
 
68
        self.assertEquals(['If you wish to add some of these files, please'\
 
69
                           ' add them by name.',
 
70
                           'ignored CVS matching "CVS"'],
61
71
                          results)
62
72
 
63
73
    def test_add_quiet_is(self):
111
121
 
112
122
        eq = self.assertEqual
113
123
        ass = self.assertTrue
 
124
        chdir = os.chdir
114
125
 
115
126
        t = self.make_branch_and_tree('.')
116
127
        b = t.branch
125
136
 
126
137
        # add with no arguments in a subdirectory gets only files below that
127
138
        # subdirectory
128
 
        self.run_bzr('add', working_dir='src')
129
 
        self.assertEquals('README\n',
130
 
                          self.run_bzr('unknowns', working_dir='src')[0])
 
139
        chdir('src')
 
140
        self.run_bzr('add')
 
141
        self.assertEquals(self.run_bzr('unknowns')[0], 'README\n')
131
142
        # reopen to see the new changes
132
 
        t = t.bzrdir.open_workingtree('src')
 
143
        t = t.bzrdir.open_workingtree()
133
144
        versioned = [path for path, entry in t.iter_entries_by_dir()]
134
 
        self.assertEquals(versioned, ['', 'src', 'src/foo.c'])
 
145
        self.assertEquals(versioned,
 
146
            ['', 'src', 'src/foo.c'])
135
147
 
136
148
        # add from the parent directory should pick up all file names
 
149
        chdir('..')
137
150
        self.run_bzr('add')
138
151
        self.assertEquals(self.run_bzr('unknowns')[0], '')
139
152
        self.run_bzr('check')
203
216
        err = self.run_bzr('add .bzr/crescent', retcode=3)[1]
204
217
        self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')
205
218
 
 
219
    def test_add_with_wildcards(self):
 
220
        self.requireFeature(NeedsGlobExpansionFeature)
 
221
        self.make_branch_and_tree('.')
 
222
        self.build_tree(['a1', 'a2', 'b', 'c33'])
 
223
        self.run_bzr(['add', 'a?', 'c*'])
 
224
        self.assertEquals(self.run_bzr('unknowns')[0], 'b\n')
 
225
 
 
226
    def test_add_with_wildcards_unicode(self):
 
227
        self.requireFeature(NeedsGlobExpansionFeature)
 
228
        self.make_branch_and_tree('.')
 
229
        self.build_tree([u'\u1234A', u'\u1235A', u'\u1235AA', 'cc'])
 
230
        self.run_bzr(['add', u'\u1234?', u'\u1235*'])
 
231
        self.assertEquals(self.run_bzr('unknowns')[0], 'cc\n')
 
232
 
206
233
    def test_add_via_symlink(self):
207
 
        self.requireFeature(tests.SymlinkFeature)
 
234
        self.requireFeature(SymlinkFeature)
208
235
        self.make_branch_and_tree('source')
209
236
        self.build_tree(['source/top.txt'])
210
237
        os.symlink('source', 'link')
212
239
        self.assertEquals(out, 'adding top.txt\n')
213
240
 
214
241
    def test_add_symlink_to_abspath(self):
215
 
        self.requireFeature(tests.SymlinkFeature)
 
242
        self.requireFeature(SymlinkFeature)
216
243
        self.make_branch_and_tree('tree')
217
244
        os.symlink(osutils.abspath('target'), 'tree/link')
218
245
        out = self.run_bzr(['add', 'tree/link'])[0]