[IMP] runbot_merge: minor simplification of test_by_branch

Dedup' the application of statuses. Although it is somewhat slower do
keep applying them one by one to ensure all are required.
This commit is contained in:
Xavier Morel 2024-12-03 11:15:11 +01:00
parent ee55c8c630
commit 31f3edeea6

View File

@ -28,18 +28,11 @@ def test_status_applies(env, repo, config):
[c] = repo.make_commits(m, Commit('pr', tree={'a': '2'}), ref='heads/change')
pr = repo.make_pr(target='master', title="super change", head='change')
pr_id = to_pr(env, pr)
assert pr_id.state == 'opened'
with repo:
repo.post_status(c, 'success', 'ci')
env.run_crons(None)
for context in ['ci', 'pr', 'lint']:
assert pr_id.state == 'opened'
with repo:
repo.post_status(c, 'success', 'pr')
env.run_crons(None)
assert pr_id.state == 'opened'
with repo:
repo.post_status(c, 'success', 'lint')
repo.post_status(c, 'success', context)
env.run_crons(None)
assert pr_id.state == 'validated'
@ -48,17 +41,10 @@ def test_status_applies(env, repo, config):
env.run_crons()
st = env['runbot_merge.stagings'].search([])
for context in ['ci', 'lint', 'staging']:
assert st.state == 'pending'
with repo:
repo.post_status('staging.master', 'success', 'ci')
env.run_crons(None)
assert st.state == 'pending'
with repo:
repo.post_status('staging.master', 'success', 'lint')
env.run_crons(None)
assert st.state == 'pending'
with repo:
repo.post_status('staging.master', 'success', 'staging')
repo.post_status('staging.master', 'success', context)
env.run_crons(None)
assert st.state == 'success'
@ -75,14 +61,11 @@ def test_status_skipped(env, project, repo, config):
[c] = repo.make_commits(m, Commit('pr', tree={'a': '2'}), ref='heads/change')
pr = repo.make_pr(target='maintenance', title="super change", head='change')
pr_id = to_pr(env, pr)
assert pr_id.state == 'opened'
with repo:
repo.post_status(c, 'success', 'ci')
env.run_crons(None)
for context in ['ci', 'pr']:
assert pr_id.state == 'opened'
with repo:
repo.post_status(c, 'success', 'pr')
repo.post_status(c, 'success', context)
env.run_crons(None)
assert pr_id.state == 'validated'
@ -91,13 +74,10 @@ def test_status_skipped(env, project, repo, config):
env.run_crons()
st = env['runbot_merge.stagings'].search([])
for context in ['staging', 'ci']:
assert st.state == 'pending'
with repo:
repo.post_status('staging.maintenance', 'success', 'staging')
env.run_crons(None)
assert st.state == 'pending'
with repo:
repo.post_status('staging.maintenance', 'success', 'ci')
repo.post_status('staging.maintenance', 'success', context)
env.run_crons(None)
assert st.state == 'success'