~bzr-pqm/bzr/bzr.dev

5816.4.2 by Jelmer Vernooij
Move source-specific fetch tests to per_repository_vf.
1
# Copyright (C) 2007-2011 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 fetch between repositories of the same type."""
18
19
from bzrlib import (
20
    graph,
21
    )
22
from bzrlib.tests.per_repository_vf import (
23
    TestCaseWithRepository,
24
    all_repository_vf_format_scenarios,
25
    )
26
from bzrlib.tests.scenarios import load_tests_apply_scenarios
27
28
load_tests = load_tests_apply_scenarios
29
30
31
class TestSource(TestCaseWithRepository):
32
    """Tests for/about the results of Repository._get_source."""
33
34
    scenarios = all_repository_vf_format_scenarios()
35
36
    def test_no_absent_records_in_stream_with_ghosts(self):
37
        # XXX: Arguably should be in per_interrepository but
38
        # doesn't actually gain coverage there; need a specific set of
39
        # permutations to cover it.
40
        # bug lp:376255 was reported about this.
41
        builder = self.make_branch_builder('repo')
42
        builder.start_series()
43
        builder.build_snapshot('tip', ['ghost'],
44
            [('add', ('', 'ROOT_ID', 'directory', ''))],
45
            allow_leftmost_as_ghost=True)
46
        builder.finish_series()
47
        b = builder.get_branch()
48
        b.lock_read()
49
        self.addCleanup(b.unlock)
50
        repo = b.repository
51
        source = repo._get_source(repo._format)
52
        search = graph.PendingAncestryResult(['tip'], repo)
53
        stream = source.get_stream(search)
54
        for substream_type, substream in stream:
55
            for record in substream:
56
                self.assertNotEqual('absent', record.storage_kind,
57
                    "Absent record for %s" % (((substream_type,) + record.key),))