/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 breezy/git/tests/test_git_remote_helper.py

  • Committer: Vincent Ladeuil
  • Date: 2019-03-06 14:03:19 UTC
  • mfrom: (7290.1.15 work)
  • mto: This revision was merged to the branch mainline in revision 7295.
  • Revision ID: v.ladeuil+brz@free.fr-20190306140319-zgjegynpjv3vv0jg
Merge 3.0 into trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from io import BytesIO
25
25
import os
 
26
import subprocess
 
27
import sys
26
28
 
27
29
from dulwich.repo import Repo
28
30
 
29
31
from ...tests import (
30
32
    TestCaseWithTransport,
31
33
    )
 
34
from ...tests.features import PathFeature
32
35
 
33
36
from ..object_store import get_object_store
34
37
from ..git_remote_helper import (
46
49
        return object_store._lookup_revision_sha1(bzr_revid)
47
50
 
48
51
 
 
52
git_remote_bzr_path = os.path.abspath(
 
53
    os.path.join(os.path.dirname(__file__), '..', 'git-remote-bzr'))
 
54
git_remote_bzr_feature = PathFeature(git_remote_bzr_path)
 
55
 
 
56
 
49
57
class OpenLocalDirTests(TestCaseWithTransport):
50
58
 
51
59
    def test_from_env_dir(self):
86
94
        self.assertEqual(out, b"\n")
87
95
        r = Repo('local')
88
96
        self.assertTrue(git_sha1 in r.object_store)
89
 
        self.assertEqual({
90
 
            }, r.get_refs())
 
97
        self.assertEqual({}, r.get_refs())
 
98
 
 
99
 
 
100
class ExecuteRemoteHelperTests(TestCaseWithTransport):
 
101
 
 
102
    def test_run(self):
 
103
        self.requireFeature(git_remote_bzr_feature)
 
104
        local_dir = self.make_branch_and_tree('local', format='git').controldir
 
105
        local_path = local_dir.control_transport.local_abspath('.')
 
106
        remote_tree = self.make_branch_and_tree('remote')
 
107
        remote_dir = remote_tree.controldir
 
108
        shortname = 'bzr'
 
109
        env = dict(os.environ)
 
110
        env['GIT_DIR'] = local_path
 
111
        env['PYTHONPATH'] = ':'.join(sys.path)
 
112
        p = subprocess.Popen(
 
113
            [sys.executable, git_remote_bzr_path, local_path, remote_dir.user_url],
 
114
            stdin=subprocess.PIPE, stdout=subprocess.PIPE,
 
115
            stderr=subprocess.PIPE, env=env)
 
116
        (out, err) = p.communicate(b'capabilities\n')
 
117
        lines = out.splitlines()
 
118
        self.assertIn(b'push', lines, "no 'push' in %r, error: %r" % (lines, err))
 
119
        self.assertEqual(b'', err)
91
120
 
92
121
 
93
122
class RemoteHelperTests(TestCaseWithTransport):