From 31d09dacb12813f5b46aff55c03e2992f5bb3ad8 Mon Sep 17 00:00:00 2001 From: Max Bowsher Date: Wed, 4 Nov 2009 01:04:34 +0000 Subject: Make BranchMapper just map one name per call. Move building a dict to the one callsite which actually wants that. --- tests/test_branch_mapper.py | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) (limited to 'tests') diff --git a/tests/test_branch_mapper.py b/tests/test_branch_mapper.py index 0a50eec..00450c9 100644 --- a/tests/test_branch_mapper.py +++ b/tests/test_branch_mapper.py @@ -27,62 +27,38 @@ class TestBranchMapper(tests.TestCase): def test_git_to_bzr(self): m = branch_mapper.BranchMapper() - git_refs = [ - 'refs/heads/master', - 'refs/heads/foo', - 'refs/tags/master', - 'refs/tags/foo', - 'refs/remotes/origin/master', - 'refs/remotes/origin/foo', - ] - git_to_bzr_map = m.git_to_bzr(git_refs) - self.assertEqual(git_to_bzr_map, { + for git, bzr in { 'refs/heads/master': 'trunk', 'refs/heads/foo': 'foo', 'refs/tags/master': 'trunk.tag', 'refs/tags/foo': 'foo.tag', 'refs/remotes/origin/master': 'trunk.remote', 'refs/remotes/origin/foo': 'foo.remote', - }) + }.items(): + self.assertEqual(m.git_to_bzr(git), bzr) def test_git_to_bzr_with_slashes(self): m = branch_mapper.BranchMapper() - git_refs = [ - 'refs/heads/master/slave', - 'refs/heads/foo/bar', - 'refs/tags/master/slave', - 'refs/tags/foo/bar', - 'refs/remotes/origin/master/slave', - 'refs/remotes/origin/foo/bar', - ] - git_to_bzr_map = m.git_to_bzr(git_refs) - self.assertEqual(git_to_bzr_map, { + for git, bzr in { 'refs/heads/master/slave': 'master/slave', 'refs/heads/foo/bar': 'foo/bar', 'refs/tags/master/slave': 'master/slave.tag', 'refs/tags/foo/bar': 'foo/bar.tag', 'refs/remotes/origin/master/slave': 'master/slave.remote', 'refs/remotes/origin/foo/bar': 'foo/bar.remote', - }) + }.items(): + self.assertEqual(m.git_to_bzr(git), bzr) def test_git_to_bzr_for_trunk(self): # As 'master' in git is mapped to trunk in bzr, we need to handle # 'trunk' in git in a sensible way. m = branch_mapper.BranchMapper() - git_refs = [ - 'refs/heads/trunk', - 'refs/tags/trunk', - 'refs/remotes/origin/trunk', - 'refs/heads/git-trunk', - 'refs/tags/git-trunk', - 'refs/remotes/origin/git-trunk', - ] - git_to_bzr_map = m.git_to_bzr(git_refs) - self.assertEqual(git_to_bzr_map, { + for git, bzr in { 'refs/heads/trunk': 'git-trunk', 'refs/tags/trunk': 'git-trunk.tag', 'refs/remotes/origin/trunk': 'git-trunk.remote', 'refs/heads/git-trunk': 'git-git-trunk', 'refs/tags/git-trunk': 'git-git-trunk.tag', 'refs/remotes/origin/git-trunk':'git-git-trunk.remote', - }) + }.items(): + self.assertEqual(m.git_to_bzr(git), bzr) -- cgit v1.2.1