Commit 7645a177 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Converted many tests to the HGRC api

This means they don't need file system access anymore, and
we greatly extend our coverage in remote server tests.
parent 087996f36a3d
from .utils import needs
from .utils.hg import LocalRepo
@needs.fs_access
def test_push_bookmarks_default_branch(test_project, tmpdir):
repo_path = tmpdir.join('repo1')
url = test_project.owner_basic_auth_url
......@@ -25,11 +23,7 @@ def test_push_bookmarks_default_branch(test_project, tmpdir):
assert 'book1' in out
# now let's allow bookmarks on non-topic changesets
# for the time being, bookmarks are still considered to create
# multiple heads, i.e., branchmap() ignores them
test_project.extend_hgrc("[experimental]",
"single-head-per-branch = no",
"hg-git.bookmarks-on-named-branches = yes")
test_project.owner_api_hgrc_set(inherit=True, allow_bookmarks=True)
repo.hg('push', '-B', 'book1', url)
branches = test_project.api_branches()
......@@ -70,7 +64,6 @@ def test_push_bookmarks_default_branch(test_project, tmpdir):
assert branches['book2']['commit']['title'] == 'Commit 2'
@needs.fs_access
def test_push_bookmarks_non_default_branch(test_project, tmpdir):
repo_path = tmpdir.join('repo1')
url = test_project.owner_basic_auth_url
......@@ -100,11 +93,7 @@ def test_push_bookmarks_non_default_branch(test_project, tmpdir):
assert 'forbidden' in out.lower()
# now let's allow bookmarks on non-topic changesets
# for the time being, bookmarks are still considered to create
# multiple heads, i.e., branchmap() ignores them
test_project.extend_hgrc("[experimental]",
"single-head-per-branch = no",
"hg-git.bookmarks-on-named-branches = yes")
test_project.owner_api_hgrc_set(inherit=True, allow_bookmarks=True)
repo.hg('push', '-B', 'book1', url)
......@@ -161,7 +150,6 @@ def test_push_bookmarks_non_default_branch(test_project, tmpdir):
assert branches['branch/other']['commit']['title'] == 'Not bookmarked'
@needs.fs_access
def test_implicit_move(test_project, tmpdir):
repo_path = tmpdir.join('repo1')
url = test_project.owner_basic_auth_url
......@@ -186,14 +174,10 @@ def test_implicit_move(test_project, tmpdir):
repo.hg('bookmark', '-r', '.', 'book')
print(repo.graphlog())
test_project.extend_hgrc("[experimental]",
"hg-git.bookmarks-on-named-branches = yes")
test_project.owner_api_hgrc_set(allow_bookmarks=True)
repo.hg('push', '-B', 'book', url)
branches = test_project.api_branch_titles()
test_project.extend_hgrc("[experimental]",
"hg-git.bookmarks-on-named-branches = no")
test_project.owner_api_hgrc_set(allow_bookmarks=False)
repo_path.join('foo').write('foo2')
repo.hg('commit', '-m', "Commit 2")
......@@ -215,13 +199,12 @@ def test_implicit_move(test_project, tmpdir):
}
# now imagine a bookmark slides to the head of a branch
test_project.extend_hgrc("[experimental]",
"hg-git.bookmarks-on-named-branches = yes")
# first, prepare it
test_project.owner_api_hgrc_set(allow_bookmarks=True)
repo.hg('bookmark', '-r', '1', 'sliding')
code, out, err = repo.hg_unchecked('push', '-B', 'sliding', url)
assert code == 1 # "no changes"
test_project.extend_hgrc("[experimental]",
"hg-git.bookmarks-on-named-branches = no")
test_project.owner_api_hgrc_set(allow_bookmarks=False)
# let's move it to the head of 'other'
repo.hg('bookmark', '-r', 'other', 'sliding')
......
# -*- coding: utf-8 -*-
from .utils import needs
from .utils.hg import LocalRepo
from .utils.project import Project
......@@ -27,11 +26,10 @@ def prepare_import_source(project, tmpdir, tweak_hgrc=True):
(see app/validators/importable_url_validator.rb in heptapod-rails)
"""
if tweak_hgrc:
project.extend_hgrc("[experimental]",
"single-head-per-branch = no",
"hg-git.bookmarks-on-named-branches = yes",
"topic.publish-bare-branch = no",
)
project.owner_api_hgrc_set(inherit=True,
allow_multiple_heads=True,
allow_bookmarks=True,
auto_publish='nothing')
repo = LocalRepo.init(tmpdir.join('import_src'),
default_url=project.owner_basic_auth_url)
repo.path.join('kitten').write("A lion is stronger than a kitten\n")
......@@ -85,7 +83,6 @@ def test_import_basic(public_project, tmpdir):
# echo 'Route.where(path: "test_basic/test_import_small").destroy_all()' | gitlab-rails console # noqa
@needs.fs_access
def test_import_non_topic_draft(public_project, tmpdir):
"""Draft non topic changesets should not been published by import."""
......@@ -121,7 +118,6 @@ def test_import_non_topic_draft(public_project, tmpdir):
# echo 'Route.where(path: "test_basic/test_import_small").destroy_all()' | gitlab-rails console # noqa
@needs.fs_access
def test_import_multiple_heads(public_project, tmpdir):
"""Test import, using Heptapod instance itself as source."""
......@@ -154,7 +150,6 @@ def test_import_multiple_heads(public_project, tmpdir):
project.api_destroy()
@needs.fs_access
def test_import_bookmarks(public_project, tmpdir):
"""Test import, using Heptapod instance itself as source."""
......
......@@ -3,7 +3,6 @@ import pytest
from .utils import (
hg,
needs,
)
parametrize = pytest.mark.parametrize
......@@ -554,7 +553,6 @@ def test_mergerequest_child_amend_publish(test_project, tmpdir):
assert_merge_detected(test_project, mr_id)
@needs.fs_access
def test_mergerequest_api_obsolete_multiple_heads(public_project, tmpdir):
"""Reproduction for heptapod#86
......@@ -570,8 +568,7 @@ def test_mergerequest_api_obsolete_multiple_heads(public_project, tmpdir):
existing one and add a new visible head. For that, we need to lift the
auto-publishing of non-topic drafts in the first place.
"""
public_project.extend_hgrc("[experimental]",
"topic.publish-bare-branch = no")
public_project.owner_api_hgrc_set(inherit=True, auto_publish='nothing')
repo = hg.LocalRepo.init(tmpdir.join('repo'),
default_url=public_project.owner_basic_auth_url)
topic = prepare_topic(repo)
......
from .utils import needs
from .utils.hg import LocalRepo
@needs.fs_access
def test_push_multiple_heads_merge(test_project, tmpdir):
repo_path = tmpdir.join('repo1')
owner_url = test_project.owner_basic_auth_url
......@@ -31,8 +29,7 @@ def test_push_multiple_heads_merge(test_project, tmpdir):
assert 'rejecting multiple heads' in out
# let's allow it
test_project.extend_hgrc("[experimental]",
"single-head-per-branch = no")
test_project.owner_api_hgrc_set(inherit=True, allow_multiple_heads=True)
repo.hg('push', '-f', owner_url)
......@@ -55,7 +52,6 @@ def test_push_multiple_heads_merge(test_project, tmpdir):
assert branches['branch/default']['commit']['title'] == merge_msg
@needs.fs_access
def test_push_multiple_heads_with_branch(test_project, tmpdir):
"""Linear branch history and and multiple heads in a single push.
......@@ -63,8 +59,7 @@ def test_push_multiple_heads_with_branch(test_project, tmpdir):
wouldn't even exist if we refused to account for the linear history.
In other words, this is what's explained in heptapod#101
"""
test_project.extend_hgrc("[experimental]",
"single-head-per-branch = no")
test_project.owner_api_hgrc_set(inherit=True, allow_multiple_heads=True)
repo_path = tmpdir.join('repo1')
owner_url = test_project.owner_basic_auth_url
......@@ -96,11 +91,9 @@ def test_push_multiple_heads_with_branch(test_project, tmpdir):
if name.startswith('wild/')) == heads_titles
@needs.fs_access
def test_push_multiple_heads_switch_branch(test_project, tmpdir):
"""Multiple heads, with one having a child on another branch."""
test_project.extend_hgrc("[experimental]",
"single-head-per-branch = no")
test_project.owner_api_hgrc_set(inherit=True, allow_multiple_heads=True)
repo_path = tmpdir.join('repo1')
# a first public changeset, pushed as the owner
......@@ -166,7 +159,6 @@ def test_push_multiple_heads_switch_branch(test_project, tmpdir):
assert branches['topic/default/zzetop']['commit']['title'] == 'On topic'
@needs.fs_access
def test_push_multiple_closed_heads(test_project, tmpdir):
repo_path = tmpdir.join('repo1')
# a first public changeset, pushed as the owner
......@@ -191,16 +183,16 @@ def test_push_multiple_closed_heads(test_project, tmpdir):
# *new* closed heads. The point of this test is to make sure that
# if closed heads should not be in the way of pushing children of the
# one that's not closed.
test_project.extend_hgrc("[experimental]",
"single-head-per-branch = no")
test_project.owner_api_hgrc_set(inherit=True, allow_multiple_heads=True)
repo.hg('push', '-f')
branches = test_project.api_branches()
assert len(branches) == 1
assert branches['branch/default']['commit']['title'] == 'Head 1'
# let's forbid multiple heads again, and be sure of that
test_project.extend_hgrc("[experimental]",
"single-head-per-branch = yes")
test_project.owner_api_hgrc_set(inherit=True, allow_multiple_heads=False)
repo.hg('update', '0')
repo_path.join('bar').write('baz')
repo.hg('commit', '-Am', "Head 3")
......@@ -220,7 +212,6 @@ def test_push_multiple_closed_heads(test_project, tmpdir):
assert branches['branch/default']['commit']['title'] == 'follow-up'
@needs.fs_access
def test_push_multiple_heads_topic_merge(test_project, tmpdir):
"""Same as test_push_multiple_heads_merge, within a topic."""
repo_path = tmpdir.join('repo1')
......@@ -251,8 +242,7 @@ def test_push_multiple_heads_topic_merge(test_project, tmpdir):
assert 'rejecting multiple heads' in out
# let's allow it
test_project.extend_hgrc("[experimental]",
"single-head-per-branch = no")
test_project.owner_api_hgrc_set(inherit=True, allow_multiple_heads=True)
repo.hg('push', '-f', owner_url)
......
......@@ -337,7 +337,6 @@ def test_topic_branch_change(test_project, tmpdir):
}
@needs.fs_access
def test_internal_force_push_default_branch(test_project, tmpdir):
"""
Although protected, but still accept internal Git force-pushes.
......@@ -347,9 +346,7 @@ def test_internal_force_push_default_branch(test_project, tmpdir):
url = test_project.owner_basic_auth_url
# internal force pushes occur upon amending of drafts without topics.
test_project.extend_hgrc("[experimental]",
"topic.publish-bare-branch = no",
)
test_project.owner_api_hgrc_set(inherit=True, auto_publish='nothing')
repo = LocalRepo.init(repo_path)
in_repo = repo_path.join('foo')
in_repo.write('foo0')
......
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