Commit 4c922a0263a by Georges Racinet

Testing Merge Request over SSH

This is reproduction for heptapod#154. The SSH and HTTP codepath
are different enough that it's worthwile to test them separately.
That was an obvious candidate for parametrization.
parent 59d71efa73b
Pipeline #2308 passed with stage
in 14 seconds
# -*- coding: utf-8 -*-
import pytest
from .utils import (
parametrize = pytest.mark.parametrize
def prepare_topic(repo, needing_rebase=True):
def prepare_topic(repo, needing_rebase=True, ssh_cmd=None):
"""Prepare a topic to submit merge request.
Graph after preparation of topic if needing_rebase is True:
......@@ -27,13 +31,16 @@ def prepare_topic(repo, needing_rebase=True):
if needing_rebase:
repo.path.join('horse').write("A lion is stronger than a horse\n")
repo.hg('commit', '-Am', "Even a horse!")
push_cmd = ['push']
if ssh_cmd is not None:
push_cmd.extend(('--ssh', ssh_cmd))
repo.hg('up', '0')
repo.hg('topic', topic_name)
repo.path.join('antelope').write("A lion is stronger than an antelope\n")
repo.hg('commit', '-Am', "Même une antilope !",
'--user', 'Raphaël <raphael@heptapod.test>')
out = repo.hg('push')
out = repo.hg(*push_cmd)
assert 'create a merge request for topic/default/antelope' in out
print("Graph after preparation of topic:")
......@@ -262,7 +269,9 @@ def test_mergerequest_api_fast_forward(test_project, tmpdir):
assert log.splitlines() == ['1:public', '0:public']
def test_mergerequest_api_explicit_merge_message(test_project, tmpdir):
@parametrize('push_proto', ['ssh', 'http'])
def test_mergerequest_api_explicit_merge_message(test_project, tmpdir,
"""Accepting the MR via API with rebase scenario.
see `test_mergerequest_api()` for relevance of API call for testing.
......@@ -271,13 +280,17 @@ def test_mergerequest_api_explicit_merge_message(test_project, tmpdir):
with the MR created through the webdriver, it gets title and
description, which end up in the merge commit message.
if push_proto == 'http':
ssh_cmd, default_url = None, test_project.owner_basic_auth_url
elif push_proto == 'ssh':
ssh_cmd, default_url = test_project.owner_ssh_params
repo = hg.LocalRepo.init(tmpdir.join('repo'),
topic = prepare_topic(repo)
topic = prepare_topic(repo, ssh_cmd=ssh_cmd)
mr_id = create_mr(test_project, topic=topic)
api_accept_merge_request(test_project, mr_id)
repo.hg('pull', test_project.owner_basic_auth_url)
print("Graph after API merge:")
log = repo.hg('log', '-T', '{desc|firstline}:{phase}\n')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment