/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: Jelmer Vernooij
  • Date: 2020-05-24 00:39:50 UTC
  • mto: This revision was merged to the branch mainline in revision 7504.
  • Revision ID: jelmer@jelmer.uk-20200524003950-bbc545r76vc5yajg
Add github action.

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
 
143
141
""")
144
142
        self.assertIsInstance(e, NotBranchError)
145
143
 
146
 
    def test_invalid_git_error(self):
147
 
        self.assertEqual(
148
 
            PermissionDenied(
149
 
                'url',
150
 
                'GitLab: You are not allowed to push code to protected '
151
 
                'branches on this project.'),
152
 
            parse_git_error(
153
 
                'url',
154
 
                RemoteGitError(
155
 
                    'GitLab: You are not allowed to push code to '
156
 
                    'protected branches on this project.')))
157
 
 
158
 
 
159
 
class ParseHangupTests(TestCase):
160
 
 
161
 
    def setUp(self):
162
 
        super(ParseHangupTests, self).setUp()
163
 
        try:
164
 
            HangupException([b'foo'])
165
 
        except TypeError:
166
 
            self.skipTest('dulwich version too old')
167
 
 
168
 
    def test_not_set(self):
169
 
        self.assertIsInstance(
170
 
            parse_git_hangup('http://', HangupException()), HangupException)
171
 
 
172
 
    def test_single_line(self):
173
 
        self.assertEqual(
174
 
            RemoteGitError('foo bar'),
175
 
            parse_git_hangup('http://', HangupException([b'foo bar'])))
176
 
 
177
 
    def test_multi_lines(self):
178
 
        self.assertEqual(
179
 
            RemoteGitError('foo bar\nbla bla'),
180
 
            parse_git_hangup(
181
 
                'http://', HangupException([b'foo bar', b'bla bla'])))
182
 
 
183
 
    def test_filter_boring(self):
184
 
        self.assertEqual(
185
 
            RemoteGitError('foo bar'), parse_git_hangup('http://', HangupException(
186
 
                [b'=======', b'foo bar', b'======'])))
187
 
        self.assertEqual(
188
 
            RemoteGitError('foo bar'), parse_git_hangup('http://', HangupException(
189
 
                [b'remote: =======', b'remote: foo bar', b'remote: ======'])))
190
 
 
191
 
    def test_permission_denied(self):
192
 
        self.assertEqual(
193
 
            PermissionDenied('http://', 'You are not allowed to push code to this project.'),
194
 
            parse_git_hangup(
195
 
                'http://',
196
 
                HangupException(
197
 
                    [b'=======',
198
 
                     b'You are not allowed to push code to this project.', b'', b'======'])))
199
 
 
200
144
 
201
145
class TestRemoteGitBranchFormat(TestCase):
202
146