/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4379.2.2 by John Arbash Meinel
Change the Repository.add_fallback_repository() contract slightly.
1
# Copyright (C) 2009 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17
"""Tests for initializing a repository with external references."""
18
19
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
20
from breezy import (
4379.2.2 by John Arbash Meinel
Change the Repository.add_fallback_repository() contract slightly.
21
    errors,
4343.3.36 by John Arbash Meinel
Some review feedback from Andrew.
22
    tests,
4379.2.2 by John Arbash Meinel
Change the Repository.add_fallback_repository() contract slightly.
23
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
24
from breezy.tests.per_repository_reference import (
4379.2.2 by John Arbash Meinel
Change the Repository.add_fallback_repository() contract slightly.
25
    TestCaseWithExternalReferenceRepository,
26
    )
27
28
29
class TestInitialize(TestCaseWithExternalReferenceRepository):
30
4343.3.36 by John Arbash Meinel
Some review feedback from Andrew.
31
    def initialize_and_check_on_transport(self, base, trans):
4379.2.2 by John Arbash Meinel
Change the Repository.add_fallback_repository() contract slightly.
32
        network_name = base.repository._format.network_name()
33
        result = self.bzrdir_format.initialize_on_transport_ex(
34
            trans, use_existing_dir=False, create_prefix=False,
35
            stacked_on='../base', stack_on_pwd=base.base,
36
            repo_format_name=network_name)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
37
        result_repo, a_controldir, require_stacking, repo_policy = result
4343.3.36 by John Arbash Meinel
Some review feedback from Andrew.
38
        self.addCleanup(result_repo.unlock)
39
        self.assertEqual(1, len(result_repo._fallback_repositories))
40
        return result_repo
41
42
    def test_initialize_on_transport_ex(self):
43
        base = self.make_branch('base')
44
        trans = self.get_transport('stacked')
45
        repo = self.initialize_and_check_on_transport(base, trans)
46
        self.assertEqual(base.repository._format.network_name(),
47
                         repo._format.network_name())
48
49
    def test_remote_initialize_on_transport_ex(self):
50
        # All formats can be initialized appropriately over bzr://
51
        base = self.make_branch('base')
52
        trans = self.make_smart_server('stacked')
53
        repo = self.initialize_and_check_on_transport(base, trans)
54
        network_name = base.repository._format.network_name()
55
        self.assertEqual(network_name, repo._format.network_name())