コード例 #1
0
def test_git_post_pull():
    extras = {
        'hooks': ['pull'],
        'hooks_uri': 'fake_hook_uri',
    }
    with mock_hook_response(status=1, output='foo'):
        assert hooks.git_post_pull(extras) == hooks.HookResponse(1, 'foo')
コード例 #2
0
def test_pre_pull_hook_fails_with_sideband(pygrack_app, sideband):
    request = ''.join([
        '0054want 74730d410fcb6603ace96f1dc55ea6196122532d ',
        'multi_ack %s ofs-delta\n' % sideband,
        '0000',
        '0009done\n',
    ])
    with mock.patch('vcsserver.hooks.git_pre_pull',
                    return_value=hooks.HookResponse(1, 'foo')):
        response = pygrack_app.post(
            '/git-upload-pack',
            params=request,
            content_type='application/x-git-upload-pack')

    data = io.BytesIO(response.body)
    proto = dulwich.protocol.Protocol(data.read, None)
    packets = list(proto.read_pkt_seq())

    expected_packets = [
        'NAK\n',
        '\x02foo',
        '\x02Pre pull hook failed: aborting\n',
        '\x01' + pygrack.GitRepository.EMPTY_PACK,
    ]
    assert packets == expected_packets
コード例 #3
0
def test_pull_has_hook_messages(pygrack_app):
    request = ''.join([
        '0054want 74730d410fcb6603ace96f1dc55ea6196122532d ' +
        'multi_ack side-band-64k ofs-delta\n'
        '0000',
        '0009done\n',
    ])
    with mock.patch('vcsserver.hooks.git_pre_pull',
                    return_value=hooks.HookResponse(0, 'foo')):
        with mock.patch('vcsserver.hooks.git_post_pull',
                        return_value=hooks.HookResponse(1, 'bar')):
            with mock.patch('vcsserver.subprocessio.SubprocessIOChunker',
                            return_value=['0008NAK\n0009subp\n0000']):
                response = pygrack_app.post(
                    '/git-upload-pack', params=request,
                    content_type='application/x-git-upload-pack')

    data = io.BytesIO(response.body)
    proto = dulwich.protocol.Protocol(data.read, None)
    packets = list(proto.read_pkt_seq())

    assert packets == ['NAK\n', '\x02foo', 'subp\n', '\x02bar']
コード例 #4
0
def test_pre_pull_hook_fails_no_sideband(pygrack_app):
    request = ''.join([
        '0054want 74730d410fcb6603ace96f1dc55ea6196122532d ' +
        'multi_ack ofs-delta\n'
        '0000',
        '0009done\n',
    ])
    with mock.patch('vcsserver.hooks.git_pre_pull',
                    return_value=hooks.HookResponse(1, 'foo')):
        response = pygrack_app.post(
            '/git-upload-pack', params=request,
            content_type='application/x-git-upload-pack')

    assert response.body == pygrack.GitRepository.EMPTY_PACK
コード例 #5
0
def test_git_post_pull_is_disabled():
    assert (hooks.git_post_pull({'hooks':
                                 ['push']}) == hooks.HookResponse(0, ''))