Commit cfef3152 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

test_push: rewrote some assertions with new changeset_extracts

Not the best time to do *all* of them.

Also spotted a use-case for `repo.node()`, much more recent than
the test.
parent d586b25aa4d2
......@@ -47,8 +47,11 @@ def test_push_basic(test_project, tmpdir):
url = test_project.owner_basic_auth_url
clone = LocalRepo.clone(url, tmpdir.join('repo2'))
log = clone.hg('log', '-T', '{desc}:{phase}:{topic}\n')
assert log.splitlines() == ['Commit 1:draft:zetop', 'Commit 0:public:']
Extract, extracts = clone.changeset_extracts(('desc', 'phase', 'topic'))
assert extracts == (
Extract(desc='Commit 1', phase='draft', topic='zetop'),
Extract(desc='Commit 0', phase='public', topic=''),
)
def test_push_webdriver(test_project, tmpdir):
......@@ -65,10 +68,12 @@ def test_push_webdriver(test_project, tmpdir):
repo.hg('push', url)
clone.hg('pull', url)
log = clone.hg('log', '-T', '{desc}:{phase}:{topic}\n')
assert log.splitlines() == ['Commit 2:draft:zetop',
'Commit 1:draft:zetop',
'Commit 0:public:']
Extract, extracts = clone.changeset_extracts(('desc', 'phase', 'topic'))
assert extracts == (
Extract(desc='Commit 2', phase='draft', topic='zetop'),
Extract(desc='Commit 1', phase='draft', topic='zetop'),
Extract(desc='Commit 0', phase='public', topic=''),
)
# now GitLab side:
......@@ -89,8 +94,7 @@ def test_push_webdriver(test_project, tmpdir):
assert_webdriver_not_error(webdriver)
assert 'Commit 0' in webdriver.title
hgsha = repo.hg('log', '-T', '{node}', '-r', '0')
assert hgsha[:11] in webdriver.title
assert repo.node('0')[:11] in webdriver.title
@needs.reverse_call
......@@ -289,12 +293,13 @@ def test_protected_branch_refusal(test_project, tmpdir):
# the failed pushes had indeed no effect on the hg repo
clone = LocalRepo.clone(url, tmpdir.join('repo2'))
log = clone.hg('log', '-T', '{desc}:{branch}\n').splitlines()
assert set(l.strip() for l in log) == {
'Commit 0:default',
'Commit 1:default',
'Commit in branch:a_branch',
}
Extract, extracts = clone.changeset_extracts(('desc', 'branch'))
assert extracts == (
Extract(desc='Commit in branch', branch='a_branch'),
Extract(desc='Commit 1', branch='default'),
Extract(desc='Commit 0', branch='default'),
)
def test_protected_branch_ultimate(test_project, tmpdir):
......@@ -349,12 +354,12 @@ def test_protected_branch_ultimate(test_project, tmpdir):
# the failed pushes had indeed no effect on the hg repo
clone = LocalRepo.clone(url, tmpdir.join('repo2'))
log = clone.hg('log', '-T', '{desc}:{branch}\n').splitlines()
assert set(l.strip() for l in log) == {
'Commit 0:default',
'Commit 1:default',
'Commit in branch:a_branch',
}
Extract, extracts = clone.changeset_extracts(('desc', 'branch'))
assert extracts == (
Extract(desc='Commit in branch', branch='a_branch'),
Extract(desc='Commit 1', branch='default'),
Extract(desc='Commit 0', branch='default'),
)
# far from being completely blocked the newly appointed Maintainer
# can still accept MRs
......@@ -387,12 +392,15 @@ def test_protected_branch_ultimate(test_project, tmpdir):
assert resp.status_code < 300
assert resp.json()['state'] == 'merged'
clone.hg('pull')
log = clone.hg('log', '-T', '{desc}:{branch}:{phase}\n').splitlines()
assert set(l.strip() for l in log) == {
'Commit 0:default:public',
'Commit 1:default:public',
'Commit in branch:a_branch:public',
'New commit that even Owner cannot push:a_branch:public',
Extract, extracts = clone.changeset_extracts(('desc', 'branch', 'phase'),
collection=set)
assert extracts == {
Extract(desc='New commit that even Owner cannot push',
branch='a_branch',
phase='public'),
Extract(desc='Commit in branch', branch='a_branch', phase='public'),
Extract(desc='Commit 1', branch='default', phase='public'),
Extract(desc='Commit 0', branch='default', phase='public'),
}
......
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