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

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-06-01 21:57:00 UTC
  • mfrom: (7490.39.3 move-launchpad)
  • Revision ID: breezy.the.bot@gmail.com-20200601215700-joxuzo6w172gq74v
Move launchpad hoster support to the launchpad plugin.

Merged from https://code.launchpad.net/~jelmer/brz/move-launchpad/+merge/384931

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
from ..remote import (
40
40
    split_git_url,
41
41
    parse_git_error,
42
 
    parse_git_hangup,
43
42
    HeadUpdateFailed,
44
43
    RemoteGitError,
45
44
    RemoteGitBranchFormat,
47
46
    )
48
47
 
49
48
from dulwich import porcelain
50
 
from dulwich.errors import HangupException
51
49
from dulwich.repo import Repo as GitRepo
52
50
 
53
51
 
135
133
        self.assertEqual(e.path, 'porridge/gaduhistory.git')
136
134
        self.assertEqual(e.extra, ': denied to jelmer')
137
135
 
138
 
    def test_pre_receive_hook_declined(self):
139
 
        e = parse_git_error(
140
 
            "url",
141
 
            'pre-receive hook declined')
142
 
        self.assertIsInstance(e, PermissionDenied)
143
 
        self.assertEqual(e.path, "url")
144
 
        self.assertEqual(e.extra, ': pre-receive hook declined')
145
 
 
146
136
    def test_invalid_repo_name(self):
147
137
        e = parse_git_error(
148
138
            "url",
151
141
""")
152
142
        self.assertIsInstance(e, NotBranchError)
153
143
 
154
 
    def test_invalid_git_error(self):
155
 
        self.assertEqual(
156
 
            PermissionDenied(
157
 
                'url',
158
 
                'GitLab: You are not allowed to push code to protected '
159
 
                'branches on this project.'),
160
 
            parse_git_error(
161
 
                'url',
162
 
                RemoteGitError(
163
 
                    'GitLab: You are not allowed to push code to '
164
 
                    'protected branches on this project.')))
165
 
 
166
 
 
167
 
class ParseHangupTests(TestCase):
168
 
 
169
 
    def setUp(self):
170
 
        super(ParseHangupTests, self).setUp()
171
 
        try:
172
 
            HangupException([b'foo'])
173
 
        except TypeError:
174
 
            self.skipTest('dulwich version too old')
175
 
 
176
 
    def test_not_set(self):
177
 
        self.assertIsInstance(
178
 
            parse_git_hangup('http://', HangupException()), HangupException)
179
 
 
180
 
    def test_single_line(self):
181
 
        self.assertEqual(
182
 
            RemoteGitError('foo bar'),
183
 
            parse_git_hangup('http://', HangupException([b'foo bar'])))
184
 
 
185
 
    def test_multi_lines(self):
186
 
        self.assertEqual(
187
 
            RemoteGitError('foo bar\nbla bla'),
188
 
            parse_git_hangup(
189
 
                'http://', HangupException([b'foo bar', b'bla bla'])))
190
 
 
191
 
    def test_filter_boring(self):
192
 
        self.assertEqual(
193
 
            RemoteGitError('foo bar'), parse_git_hangup('http://', HangupException(
194
 
                [b'=======', b'foo bar', b'======'])))
195
 
        self.assertEqual(
196
 
            RemoteGitError('foo bar'), parse_git_hangup('http://', HangupException(
197
 
                [b'remote: =======', b'remote: foo bar', b'remote: ======'])))
198
 
 
199
 
    def test_permission_denied(self):
200
 
        self.assertEqual(
201
 
            PermissionDenied('http://', 'You are not allowed to push code to this project.'),
202
 
            parse_git_hangup(
203
 
                'http://',
204
 
                HangupException(
205
 
                    [b'=======',
206
 
                     b'You are not allowed to push code to this project.', b'', b'======'])))
207
 
 
208
144
 
209
145
class TestRemoteGitBranchFormat(TestCase):
210
146