/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_blackbox.py

Merge foreign branch utility code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Black-box tests for bzr-git."""
18
18
 
19
 
from dulwich.repo import (
20
 
    Repo as GitRepo,
21
 
    )
22
 
 
23
19
import os
24
20
 
25
 
from bzrlib.bzrdir import (
26
 
    BzrDir,
27
 
    )
28
 
 
 
21
from bzrlib.tests import KnownFailure
29
22
from bzrlib.tests.blackbox import ExternalBase
30
23
 
31
24
from bzrlib.plugins.git import (
37
30
 
38
31
    def simple_commit(self):
39
32
        # Create a git repository with a revision.
40
 
        repo = GitRepo.init(self.test_dir)
 
33
        tests.run_git('init')
41
34
        builder = tests.GitBranchBuilder()
42
35
        builder.set_file('a', 'text for a\n', False)
43
 
        r1 = builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
44
 
        return repo, builder.finish()[r1]
45
 
 
46
 
    def test_nick(self):
47
 
        GitRepo.init(self.test_dir)
48
 
        dir = BzrDir.open(self.test_dir)
49
 
        dir.create_branch()
50
 
        output, error = self.run_bzr(['nick'])
51
 
        self.assertEquals("HEAD\n", output)
 
36
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
 
37
        builder.finish()
52
38
 
53
39
    def test_info(self):
54
40
        self.simple_commit()
55
41
        output, error = self.run_bzr(['info'])
56
42
        self.assertEqual(error, '')
57
 
        self.assertTrue("Standalone tree (format: git)" in output)
 
43
        self.assertTrue("Repository tree (format: git)" in output)
58
44
 
59
45
    def test_branch(self):
60
46
        os.mkdir("gitbranch")
61
 
        GitRepo.init(os.path.join(self.test_dir, "gitbranch"))
62
 
        os.chdir('gitbranch')
 
47
        os.chdir("gitbranch")
 
48
        tests.run_git('init')
63
49
        builder = tests.GitBranchBuilder()
64
50
        builder.set_file('a', 'text for a\n', False)
65
51
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
66
52
        builder.finish()
67
 
        os.chdir('..')
68
53
 
 
54
        os.chdir("..")
69
55
        output, error = self.run_bzr(['branch', 'gitbranch', 'bzrbranch'])
70
56
        self.assertEqual(error, 'Branched 1 revision(s).\n')
 
57
        self.assertEqual(output, '')
71
58
 
72
59
    def test_branch_ls(self):
73
60
        self.simple_commit()
75
62
        self.assertEqual(error, '')
76
63
        self.assertEqual(output, "a\n")
77
64
 
78
 
    def test_init(self):
79
 
        self.run_bzr("init-repo --git repo") 
80
 
 
81
65
    def test_info_verbose(self):
82
66
        self.simple_commit()
83
67
 
84
68
        output, error = self.run_bzr(['info', '-v'])
85
69
        self.assertEqual(error, '')
86
 
        self.assertTrue("Standalone tree (format: git)" in output)
 
70
        self.assertTrue("Repository tree (format: git)" in output)
87
71
        self.assertTrue("control: Local Git Repository" in output)
88
72
        self.assertTrue("branch: Git Branch" in output)
89
73
        self.assertTrue("repository: Git Repository" in output)
90
74
 
91
 
    def test_push(self):
92
 
        os.mkdir("bla")
93
 
        GitRepo.init(os.path.join(self.test_dir, "bla"))
94
 
        self.run_bzr(['init', 'foo'])
95
 
        self.run_bzr(['commit', '--unchanged', '-m', 'bla', 'foo'])
96
 
        output, error = self.run_bzr(['push', '-d', 'foo', 'bla'])
97
 
        self.assertEquals("", output)
98
 
        self.assertTrue(error.endswith("Created new branch.\n"))
99
 
 
100
75
    def test_log(self):
101
76
        # Smoke test for "bzr log" in a git repository.
102
77
        self.simple_commit()
116
91
        output, error = self.run_bzr(['log', '-v'])
117
92
 
118
93
    def test_tags(self):
119
 
        git_repo, commit_sha1 = self.simple_commit()
120
 
        git_repo.refs["refs/tags/foo"] = commit_sha1
 
94
        self.simple_commit()
 
95
 
 
96
        tests.run_git("tag", "foo")
121
97
 
122
98
        output, error = self.run_bzr(['tags'])
123
99
        self.assertEquals(error, '')
124
100
        self.assertEquals(output, "foo                  1\n")
125
101
 
126
102
    def test_tag(self):
 
103
        raise KnownFailure("setting tags not supported by git-python yet")
127
104
        self.simple_commit()
128
105
 
129
106
        output, error = self.run_bzr(["tag", "bar"])
130
107
 
131
108
        self.assertEquals(error, '')
132
 
        self.assertEquals(output, 'Created tag bar.\n')
133
 
 
134
 
    def test_init_repo(self):
135
 
        output, error = self.run_bzr(["init-repo", "--git", "bla.git"])
136
 
        self.assertEquals(error, '')
137
 
        self.assertEquals(output, 'Unshared repository with trees (format: git)\nLocation:\n  repository: bla.git\n')
 
109
        self.assertEquals(output, '')
138
110