/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

Better (but still incomplete) design for bogus servers.

* bzrlib/transport/http/_urllib2_wrappers.py:
(AbstractHTTPHandler): Add 'Accept: */*' again to default headers
until I fully understand why and when it's needed or not (curl add
it if no Accept header is present).

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport._curl_perform): CURLE_GOT_NOTHING may be
considered as a ConnectionError, inspection of curl code reveals
that the case is sufficiently rare and low level related to not be
considered an http error per se.

* bzrlib/transport/http/__init__.py:
(WallHttpServer): Deleted.

* bzrlib/tests/test_http.py:
(TestBogusServer): Factor out the tests common to the bogus
servers.

* bzrlib/tests/__init__.py:
(TestCaseWithTransport.create_transport_server,
TestCaseWithTransport.create_transport_readonly_server): New
methods, allows test cases to specify the transport servers
without defining useless classes.
(TestCaseWithTransport.get_readonly_server): Use
create_transport_readonly_server.
(TestCaseWithTransport.get_server): Use create_transport_server.

* bzrlib/tests/HTTPTestUtil.py:
(TestCaseWithWebserver): Fix typo in doc string.
(TestCaseWithWallserver): Deleted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005, 2006 by 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
 
 
18
import os
 
19
 
 
20
from bzrlib.tests.blackbox import ExternalBase
 
21
from bzrlib.workingtree import WorkingTree
 
22
 
 
23
 
 
24
class TestRemove(ExternalBase):
 
25
 
 
26
    def test_remove_deleted(self):
 
27
        self.runbzr("init")
 
28
        self.build_tree(['a'])
 
29
        self.runbzr(['add', 'a'])
 
30
        self.runbzr(['commit', '-m', 'added a'])
 
31
        os.unlink('a')
 
32
        self.runbzr(['remove', 'a'])
 
33
 
 
34
    def test_remove_new(self):
 
35
        self.build_tree(['filefile',
 
36
                         'dir/',
 
37
                         'dir/filefilefile'])
 
38
        wt = self.make_branch_and_tree('.')
 
39
        wt.add(['filefile', 'dir', 'dir/filefilefile'], 
 
40
               ['filefile-id', 'dir-id', 'filefilefile-id'])
 
41
        self.assertEqual(wt.path2id('filefile'), 'filefile-id')
 
42
        self.assertEqual(wt.path2id('dir/filefilefile'), 'filefilefile-id')
 
43
        self.assertEqual(wt.path2id('dir'), 'dir-id')
 
44
        self.runbzr('remove --new')
 
45
        wt = WorkingTree.open('.')
 
46
        self.assertIs(wt.path2id('filefile'), None)
 
47
        self.assertIs(wt.path2id('dir/filefilefile'), None)
 
48
        self.assertIs(wt.path2id('dir'), None)
 
49
        wt.add(['filefile', 'dir', 'dir/filefilefile'], 
 
50
               ['filefile-id', 'dir-id', 'filefilefile-id'])
 
51
        self.assertEqual(wt.path2id('filefile'), 'filefile-id')
 
52
        self.assertEqual(wt.path2id('dir/filefilefile'), 'filefilefile-id')
 
53
        self.assertEqual(wt.path2id('dir'), 'dir-id')
 
54
        self.runbzr('remove --new dir')
 
55
        wt = WorkingTree.open('.')
 
56
        self.assertEqual(wt.path2id('filefile'), 'filefile-id')
 
57
        self.assertIs(wt.path2id('dir/filefilefile'), None)
 
58
        self.assertIs(wt.path2id('dir'), None)
 
59
        self.runbzr('remove --new .')
 
60
        wt = WorkingTree.open('.')
 
61
        self.assertIs(wt.path2id('filefile'), None)
 
62
        self.runbzr('remove --new .', retcode=3)