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

Avoid revision_history if it's not necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# vim: expandtab
 
3
 
 
4
# Copyright (C) 2011 Jelmer Vernooij <jelmer@apache.org>
 
5
 
 
6
# This program is free software; you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; either version 2 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program; if not, write to the Free Software
 
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 
 
20
from cStringIO import StringIO
 
21
import os
 
22
 
 
23
from bzrlib.tests import TestCaseWithTransport
 
24
 
 
25
from bzrlib.plugins.git.git_remote_helper import (
 
26
    RemoteHelper,
 
27
    open_local_dir,
 
28
    )
 
29
 
 
30
 
 
31
class OpenLocalDirTests(TestCaseWithTransport):
 
32
 
 
33
    def test_from_env(self):
 
34
        self.make_branch_and_tree('bla', format='git')
 
35
        self.overrideEnv('GIT_DIR', os.path.join(self.test_dir, 'bla'))
 
36
        open_local_dir()
 
37
 
 
38
    def test_from_env_dir(self):
 
39
        self.make_branch_and_tree('bla', format='git')
 
40
        self.overrideEnv('GIT_DIR', os.path.join(self.test_dir, 'bla', '.git'))
 
41
        open_local_dir()
 
42
 
 
43
    def test_from_dir(self):
 
44
        self.make_branch_and_tree('.', format='git')
 
45
        open_local_dir()
 
46
 
 
47
 
 
48
class RemoteHelperTests(TestCaseWithTransport):
 
49
 
 
50
    def setUp(self):
 
51
        super(RemoteHelperTests, self).setUp()
 
52
        self.local_dir = self.make_branch_and_tree('local', format='git').bzrdir
 
53
        self.remote_dir = self.make_branch_and_tree('remote').bzrdir
 
54
        self.shortname = 'bzr'
 
55
        self.helper = RemoteHelper(self.local_dir, self.shortname, self.remote_dir)
 
56
 
 
57
    def test_capabilities(self):
 
58
        f = StringIO()
 
59
        self.helper.cmd_capabilities(f, [])
 
60
        capabs = f.getvalue()
 
61
        base = "fetch\noption\npush\n"
 
62
        self.assertTrue(capabs in (base+"\n", base+"import\n\n"), capabs)
 
63
 
 
64
    def test_option(self):
 
65
        f = StringIO()
 
66
        self.helper.cmd_option(f, [])
 
67
        self.assertEquals("unsupported\n", f.getvalue())
 
68
 
 
69
    def test_list_basic(self):
 
70
        f = StringIO()
 
71
        self.helper.cmd_list(f, [])
 
72
        self.assertEquals(
 
73
            '0000000000000000000000000000000000000000 HEAD\n'
 
74
            '0000000000000000000000000000000000000000 refs/heads/master\n\n',
 
75
            f.getvalue())