/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
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
0.64.334 by Jelmer Vernooij
Remove old FSF address. Thanks Dan Callaghan.
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
15
16
"""Test the BranchMapper methods."""
17
6628.1.2 by Jelmer Vernooij
Fix imports, move exporter.py, drop explorer metadata.
18
from .... import tests
19
20
from .. import (
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
21
    branch_mapper,
22
    )
23
6628.1.2 by Jelmer Vernooij
Fix imports, move exporter.py, drop explorer metadata.
24
from . import (
0.123.13 by Jelmer Vernooij
Check for availability of fastimport before running tests.
25
    FastimportFeature,
26
    )
27
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
28
29
class TestBranchMapper(tests.TestCase):
30
0.123.13 by Jelmer Vernooij
Check for availability of fastimport before running tests.
31
    _test_needs_features = [FastimportFeature]
32
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
33
    def test_git_to_bzr(self):
34
        m = branch_mapper.BranchMapper()
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
35
        for git, bzr in {
7143.15.2 by Jelmer Vernooij
Run autopep8.
36
                b'refs/heads/master': 'trunk',
37
                b'refs/heads/foo': 'foo',
38
                b'refs/tags/master': 'trunk.tag',
39
                b'refs/tags/foo': 'foo.tag',
40
                b'refs/remotes/origin/master': 'trunk.remote',
41
                b'refs/remotes/origin/foo': 'foo.remote',
42
                }.items():
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
43
            self.assertEqual(m.git_to_bzr(git), bzr)
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
44
0.64.256 by Ian Clatworthy
handle git ref names with slashes in them
45
    def test_git_to_bzr_with_slashes(self):
46
        m = branch_mapper.BranchMapper()
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
47
        for git, bzr in {
7143.15.2 by Jelmer Vernooij
Run autopep8.
48
                b'refs/heads/master/slave': 'master/slave',
49
                b'refs/heads/foo/bar': 'foo/bar',
50
                b'refs/tags/master/slave': 'master/slave.tag',
51
                b'refs/tags/foo/bar': 'foo/bar.tag',
52
                b'refs/remotes/origin/master/slave': 'master/slave.remote',
53
                b'refs/remotes/origin/foo/bar': 'foo/bar.remote',
54
                }.items():
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
55
            self.assertEqual(m.git_to_bzr(git), bzr)
0.64.256 by Ian Clatworthy
handle git ref names with slashes in them
56
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
57
    def test_git_to_bzr_for_trunk(self):
58
        # As 'master' in git is mapped to trunk in bzr, we need to handle
59
        # 'trunk' in git in a sensible way.
60
        m = branch_mapper.BranchMapper()
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
61
        for git, bzr in {
7143.15.2 by Jelmer Vernooij
Run autopep8.
62
                b'refs/heads/trunk': 'git-trunk',
63
                b'refs/tags/trunk': 'git-trunk.tag',
64
                b'refs/remotes/origin/trunk': 'git-trunk.remote',
65
                b'refs/heads/git-trunk': 'git-git-trunk',
66
                b'refs/tags/git-trunk': 'git-git-trunk.tag',
67
                b'refs/remotes/origin/git-trunk': 'git-git-trunk.remote',
68
                }.items():
0.112.3 by Max Bowsher
Make BranchMapper just map one name per call.
69
            self.assertEqual(m.git_to_bzr(git), bzr)