/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_branch.py

Add more tests for fetch code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for interfacing with a Git Branch"""
18
18
 
19
 
import git
20
 
 
21
 
from bzrlib import branch, revision
22
 
 
23
 
from bzrlib.plugins.git import tests
 
19
from bzrlib import revision
 
20
from bzrlib.branch import Branch
 
21
 
24
22
from bzrlib.plugins.git import (
25
 
    git_branch,
26
 
    ids,
 
23
    branch,
 
24
    tests,
27
25
    )
 
26
from bzrlib.plugins.git.mapping import default_mapping
 
27
 
 
28
import dulwich as git
28
29
 
29
30
 
30
31
class TestGitBranch(tests.TestCaseInTempDir):
34
35
    def test_open_existing(self):
35
36
        tests.run_git('init')
36
37
 
37
 
        thebranch = branch.Branch.open('.')
38
 
        self.assertIsInstance(thebranch, git_branch.GitBranch)
 
38
        thebranch = Branch.open('.')
 
39
        self.assertIsInstance(thebranch, branch.GitBranch)
39
40
 
40
41
    def test_last_revision_is_null(self):
41
42
        tests.run_git('init')
42
43
 
43
 
        thebranch = branch.Branch.open('.')
 
44
        thebranch = Branch.open('.')
44
45
        self.assertEqual(revision.NULL_REVISION, thebranch.last_revision())
45
46
        self.assertEqual((0, revision.NULL_REVISION),
46
47
                         thebranch.last_revision_info())
55
56
        self.simple_commit_a()
56
57
        head = tests.run_git('rev-parse', 'HEAD').strip()
57
58
 
58
 
        thebranch = branch.Branch.open('.')
59
 
        self.assertEqual(ids.convert_revision_id_git_to_bzr(head),
 
59
        thebranch = Branch.open('.')
 
60
        self.assertEqual(default_mapping.revision_id_foreign_to_bzr(head),
60
61
                         thebranch.last_revision())
61
62
 
62
63
    def test_revision_history(self):
67
68
        tests.run_git('commit', '-m', 'b')
68
69
        revb = tests.run_git('rev-parse', 'HEAD').strip()
69
70
 
70
 
        thebranch = branch.Branch.open('.')
71
 
        self.assertEqual([ids.convert_revision_id_git_to_bzr(r) for r in (reva, revb)],
 
71
        thebranch = Branch.open('.')
 
72
        self.assertEqual([default_mapping.revision_id_foreign_to_bzr(r) for r in (reva, revb)],
72
73
                         thebranch.revision_history())
73
74
 
74
75
    def test_tags(self):
77
78
        
78
79
        tests.run_git('tag', '-a', '-m', 'add tag', 'foo')
79
80
        
80
 
        newid = open('.git/refs/tags/foo').read().rstrip()
81
 
 
82
 
        thebranch = branch.Branch.open('.')
83
 
        self.assertEquals({"foo": ids.convert_revision_id_git_to_bzr(newid)},
 
81
        thebranch = Branch.open('.')
 
82
        self.assertEquals({"foo": default_mapping.revision_id_foreign_to_bzr(reva)},
84
83
                          thebranch.tags.get_tag_dict())
85
84
        
86
85
 
89
88
    def setUp(self):
90
89
        tests.TestCaseWithTransport.setUp(self)
91
90
        git.repo.Repo.create(self.test_dir)
92
 
        self.git_branch = branch.Branch.open(self.test_dir)
 
91
        self.git_branch = Branch.open(self.test_dir)
93
92
 
94
93
    def test_get_parent(self):
95
94
        self.assertIs(None, self.git_branch.get_parent())
105
104
 
106
105
    def setUp(self):
107
106
        super(TestGitBranchFormat, self).setUp()
108
 
        self.format = git_branch.GitBranchFormat()
 
107
        self.format = branch.GitBranchFormat()
109
108
 
110
109
    def test_get_format_description(self):
111
110
        self.assertEquals("Git Branch", self.format.get_format_description())