예제 #1
0
def test_git_mergetool(git_repo, unique_port, popen_with_terminator):
    gitmergetool.main(['config', '--enable'])
    cmd = get_output('git config --get --local mergetool.nbdime.cmd').strip()

    # pick a non-random port so we can connect later, and avoid opening a browser
    port = unique_port
    cmd = cmd + ' --port=%i --browser=disabled' % port
    call(['git', 'config', 'mergetool.nbdime.cmd', cmd])
    call(['git', 'config', 'mergetool.nbdime.trustExitCode', 'true'])

    with pytest.raises(CalledProcessError):
        call('git merge remote-conflict')
    process = popen_with_terminator([
        'git', 'mergetool', '--no-prompt', '--tool=nbdime',
        'merge-conflict.ipynb'
    ])

    # 3 total web calls: mergetool, api/store, api/closetool
    url = 'http://127.0.0.1:%i' % port
    wait_up(url, check=lambda: process.poll() is None)
    # server started
    r = requests.get(url + '/mergetool')
    r.raise_for_status()
    r = requests.post(url_concat(url + '/api/store',
                                 {'outputfilename': 'merge-conflict.ipynb'}),
                      data=json.dumps({
                          'merged': nbformat.v4.new_notebook(),
                      }))
    r.raise_for_status()
    # close it
    r = requests.post(url + '/api/closetool', headers={'exit_code': '0'})
    r.raise_for_status()
    # wait for exit
    process.wait()
    assert process.poll() == 0
예제 #2
0
def test_git_mergetool(git_repo, unique_port, popen_with_terminator):
    gitmergetool.main(['config', '--enable'])
    cmd = get_output('git config --get --local mergetool.nbdime.cmd').strip()

    # pick a non-random port so we can connect later, and avoid opening a browser
    port = unique_port
    cmd = cmd + ' --port=%i --browser=disabled' % port
    call(['git', 'config', 'mergetool.nbdime.cmd', cmd])
    call(['git', 'config', 'mergetool.nbdime.trustExitCode', 'true'])

    with pytest.raises(CalledProcessError):
        call('git merge remote-conflict')
    process = popen_with_terminator([
        'git', 'mergetool', '--no-prompt', '--tool=nbdime', 'merge-conflict.ipynb'])

    # 3 total web calls: mergetool, api/store, api/closetool
    url = 'http://127.0.0.1:%i' % port
    wait_up(url, check=lambda: process.poll() is None)
    # server started
    r = requests.get(url + '/mergetool')
    r.raise_for_status()
    r = requests.post(
        url_concat(url + '/api/store', {'outputfilename': 'merge-conflict.ipynb'}),
        data=json.dumps({
            'merged': nbformat.v4.new_notebook(),
        })
    )
    r.raise_for_status()
    # close it
    r = requests.post(url + '/api/closetool', headers={'exit_code': '0'})
    r.raise_for_status()
    # wait for exit
    process.wait()
    assert process.poll() == 0