/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1558.5.1 by Aaron Bentley
Added make-repository command
1
# Copyright (C) 2005 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
"""Black-box tests for repositories with shared branches"""
18
19
import os
20
21
from bzrlib.tests import TestCaseInTempDir
1558.5.9 by Aaron Bentley
Updated tests per Robert Collins' suggestions
22
import bzrlib.bzrdir
23
import bzrlib.errors as errors
1558.5.1 by Aaron Bentley
Added make-repository command
24
25
class TestSharedRepo(TestCaseInTempDir):
1558.5.9 by Aaron Bentley
Updated tests per Robert Collins' suggestions
26
1558.5.4 by Aaron Bentley
Added bzr init test
27
    def test_make_repository(self):
1558.5.9 by Aaron Bentley
Updated tests per Robert Collins' suggestions
28
        out, err = self.run_bzr("init-repository", "a")
29
        self.assertEqual(out, "")
30
        self.assertEqual(err, "")
31
        dir = bzrlib.bzrdir.BzrDir.open('a')
32
        self.assertIs(dir.open_repository().is_shared(), True)
33
        self.assertRaises(errors.NotBranchError, dir.open_branch)
34
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)        
1558.5.4 by Aaron Bentley
Added bzr init test
35
36
    def test_init(self):
1558.5.6 by Aaron Bentley
Renamed make-repo init-repo
37
        self.run_bzr("init-repo", "a")
1558.5.4 by Aaron Bentley
Added bzr init test
38
        self.run_bzr("init", "--format=metadir", "a/b")
1558.5.9 by Aaron Bentley
Updated tests per Robert Collins' suggestions
39
        dir = bzrlib.bzrdir.BzrDir.open('a')
40
        self.assertIs(dir.open_repository().is_shared(), True)
41
        self.assertRaises(errors.NotBranchError, dir.open_branch)
42
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
43
        bdir = bzrlib.bzrdir.BzrDir.open('a/b')
44
        bdir.open_branch()
45
        self.assertRaises(errors.NoRepositoryPresent, bdir.open_repository)
46
        self.assertRaises(errors.NoWorkingTree, bdir.open_workingtree)
1558.5.5 by Aaron Bentley
Added tests for branch
47
48
    def test_branch(self):
1558.5.6 by Aaron Bentley
Renamed make-repo init-repo
49
        self.run_bzr("init-repo", "a")
1558.5.5 by Aaron Bentley
Added tests for branch
50
        self.run_bzr("init", "--format=metadir", "a/b")
51
        self.run_bzr('branch', 'a/b', 'a/c')
1558.5.9 by Aaron Bentley
Updated tests per Robert Collins' suggestions
52
        cdir = bzrlib.bzrdir.BzrDir.open('a/c')
53
        cdir.open_branch()
54
        self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository)
55
        self.assertRaises(errors.NoWorkingTree, cdir.open_workingtree)