Commit 3565e276 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

test_import: rewrote with the new assert_matching_changesets()

It's actually a bit longer, but it's more explicit. The fact
that I found it tedious to track for this change whether phase
is there or not is a good example of why it's probably better.

As with all assertions based on `LocalRepo.changeset_extracts()`
I hope future failures will be clearer for investigation.
parent 8e1eaef66e57
Pipeline #14882 waiting for manual action with stages
in 22 seconds
# -*- coding: utf-8 -*-
from .utils import unique_name
from .utils.hg import LocalRepo
from .utils.hg import (
assert_matching_changesets,
LocalRepo,
)
from .utils.project import Project
def hg_log_set(repo, phase=True, bookmarks=False):
"""Return hg log of repo, as a set.
After an import, no assumption about ordering can be made, whence the set
"""
template = '{desc}:'
if phase:
template += '{phase}:'
template += '{bookmarks}' if bookmarks else '{topic}'
return set(repo.hg('log', '-T', template + '\n').splitlines())
def prepare_import_source(project, tmpdir, tweak_hgrc=True):
"""Prepare given project to be the import source for tests.
......@@ -70,8 +61,9 @@ def test_import_basic(public_project, tmpdir):
assert status == 'finished'
clone = LocalRepo.clone(project.owner_basic_auth_url,
tmpdir.join('repo'))
assert hg_log_set(clone, phase=False) == hg_log_set(src_repo,
phase=False)
assert_matching_changesets(clone, src_repo,
('node', 'desc', 'topic'),
ordered=False)
assert project.api_default_branch() == 'branch/default'
......@@ -98,7 +90,9 @@ def test_import_non_topic_draft(public_project, tmpdir):
assert clone.hg('log', '-T', '{phase}', '-r', 0) == 'draft', (
"draft non-topic changeset should not become public "
"in imported repo")
assert hg_log_set(clone) == hg_log_set(src_repo)
assert_matching_changesets(clone, src_repo,
('node', 'desc', 'topic', 'phase'),
ordered=False)
assert project.api_default_branch() == 'branch/default'
......@@ -128,7 +122,9 @@ def test_import_multiple_heads(public_project, tmpdir):
assert status == 'finished'
clone = LocalRepo.clone(project.owner_basic_auth_url,
tmpdir.join('repo'))
assert hg_log_set(clone) == hg_log_set(src_repo)
assert_matching_changesets(clone, src_repo,
('node', 'desc', 'topic', 'phase'),
ordered=False)
def test_import_bookmarks(public_project, tmpdir):
......@@ -156,5 +152,6 @@ def test_import_bookmarks(public_project, tmpdir):
assert status == 'finished'
clone = LocalRepo.clone(project.owner_basic_auth_url,
tmpdir.join('repo'))
assert (hg_log_set(clone, bookmarks=True)
== hg_log_set(src_repo, bookmarks=True))
assert_matching_changesets(clone, src_repo,
('node', 'desc', 'phase', 'bookmarks'),
ordered=False)
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