Read about our upcoming Code of Conduct on this issue

Commit 656de370 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

New test_project_with_runner fixture

It's a bit cleaner: we can have the tear down, without
the extra indention that the `with` statement would need.
parent 770ee7e555e3
......@@ -9,6 +9,7 @@ import os
from tests.utils import unique_name
from tests.utils.project import Project
from tests.utils.group import Group
from tests.utils.runner import Runner
from tests.utils.user import User
from tests.utils import git
from tests.utils import hg
......@@ -250,6 +251,12 @@ def test_project(heptapod, accepts_concurrent):
yield proj
@pytest.fixture()
def test_project_with_runner(test_project):
with Runner.api_register(test_project, unique_name('fixt')) as runner:
yield test_project, runner
@pytest.fixture()
def test_group(heptapod, accepts_concurrent):
with group_fixture(heptapod, 'test_group', 'root') as group:
......@@ -278,6 +285,12 @@ def git_project(heptapod, accepts_concurrent):
yield proj
@pytest.fixture()
def git_project_with_runner(git_project):
with Runner.api_register(git_project, unique_name('fixt')) as runner:
yield git_project, runner
@pytest.fixture()
def public_project_breaks_concurrent(heptapod, breaks_concurrent):
with project_fixture(heptapod, 'public_project', 'test_basic') as proj:
......
import json
from .utils.git import LocalRepo as GitRepo
from .utils.runner import Runner
from .utils.project import ProjectAccess
from .test_merge_requests import api_accept_merge_request
......@@ -146,7 +145,8 @@ def prepare_mr_source_branch(repo,
return source_branch
def test_mergerequest_api_explicit_merge_message(git_project, tmpdir):
def test_mergerequest_api_explicit_merge_message(git_project_with_runner,
tmpdir):
"""Accepting the MR via API with an explicit merge changeset.
see `test_merge_requests.test_mergerequest_api()` for relevance of API
......@@ -156,9 +156,8 @@ def test_mergerequest_api_explicit_merge_message(git_project, tmpdir):
to GitLab. What matters is the Rails logic that is triggered by
those hooks.
"""
proj = git_project
proj, runner = git_project_with_runner
runner = Runner.api_register(git_project, 'explicit')
default_url = proj.owner_basic_auth_url
repo = GitRepo.init(tmpdir.join('repo'),
default_url=default_url)
......@@ -198,12 +197,11 @@ def test_mergerequest_api_explicit_merge_message(git_project, tmpdir):
assert vcs_info.get('hgsha') is None
def test_mergerequest_cli(git_project, tmpdir):
def test_mergerequest_cli(git_project_with_runner, tmpdir):
"""Accepting the MR via a manual push, with an explicit merge changeset.
"""
proj = git_project
proj, runner = git_project_with_runner
runner = Runner.api_register(git_project, 'explicit')
default_url = proj.owner_basic_auth_url
repo = GitRepo.init(tmpdir.join('repo'),
default_url=default_url)
......
......@@ -12,7 +12,6 @@ from .utils.project import (
extract_gitlab_branch_titles,
ProjectAccess,
)
from .utils.runner import Runner
from .utils.selenium import could_click_element
parametrize = pytest.mark.parametrize
......@@ -474,7 +473,8 @@ def test_mergerequest_rebase_push_then_publish(test_project, tmpdir):
"Commit summaries don't contain %r" % expected)
def test_mergerequest_api_fast_forward_result(test_project, tmpdir):
def test_mergerequest_api_fast_forward_result(test_project_with_runner,
tmpdir):
"""Accepting the MR via API.
In this test, Heptapod does it without a merge (Git equivalent would be a
......@@ -490,9 +490,9 @@ def test_mergerequest_api_fast_forward_result(test_project, tmpdir):
and actually, we go through hg-git etc anyway: GitLab after all just
calls the hg executable
"""
test_project, runner = test_project_with_runner
repo = hg.LocalRepo.init(tmpdir.join('repo'),
default_url=test_project.owner_basic_auth_url)
runner = Runner.api_register(test_project, 'merge_ff_de_facto')
topic = prepare_topic(repo, needing_rebase=False, with_ci=True)
mr_id = create_mr(test_project, topic=topic)
......@@ -694,7 +694,8 @@ def test_mergerequest_api_target_topic(test_project, tmpdir, fast_forward):
@parametrize('push_proto', ['ssh', 'http'])
def test_mergerequest_api_explicit_merge_message(test_project, tmpdir,
def test_mergerequest_api_explicit_merge_message(test_project_with_runner,
tmpdir,
push_proto):
"""Accepting the MR via API with rebase scenario.
......@@ -704,7 +705,7 @@ 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.
"""
runner = Runner.api_register(test_project, 'explicit')
test_project, runner = test_project_with_runner
if push_proto == 'http':
ssh_cmd, default_url = None, test_project.owner_basic_auth_url
elif push_proto == 'ssh':
......
......@@ -11,7 +11,6 @@ from .utils.project import (
extract_gitlab_branch_titles,
ProjectAccess,
)
from .utils.runner import Runner
parametrize = pytest.mark.parametrize
......@@ -462,12 +461,11 @@ def test_push_tags_branch_heads(test_project, tmpdir):
assert tags['other-1.0']['commit']['title'] == "Commit 2"
def test_push_tag_ci_job(test_project, tmpdir):
def test_push_tag_ci_job(test_project_with_runner, tmpdir):
proj, runner = test_project_with_runner
repo_path = tmpdir.join('repo1')
repo = LocalRepo.init(repo_path,
default_url=test_project.owner_basic_auth_url)
runner = Runner.api_register(test_project, 'test_tags')
repo = LocalRepo.init(repo_path, default_url=proj.owner_basic_auth_url)
repo.init_gitlab_ci()
repo.hg('tag', '1.0')
repo.hg('push')
......
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