runbot/runbot_merge/tests/conftest.py
Xavier Morel 679d556c90 [FIX] project creation: handling of mergebot info
- don't *fail* in `_compute_identity`, it causes issues when the token
  is valid but doesn't have `user:email` access as the request is
  aborted and saving doesn't work
- make `github_name` and `github_email` required rather than ad-hoc
  requiring them in `_compute_identity` (which doesn't work correctly)
- force copy of `github_name` and `github_email`, with o2ms being
  !copy this means duplicating projects now works out of the box (or
  should...)

Currently errors in `_compute_identity` are reported via logging which
is not great as it's not UI visible, should probably get moved to
chatter eventually but that's not currently enabled on projects.

Fixes #990
2024-12-02 16:32:53 +01:00

44 lines
1.2 KiB
Python

import pytest
@pytest.fixture()
def module():
return 'runbot_merge'
@pytest.fixture
def project(env, config):
return env['runbot_merge.project'].create({
'name': 'odoo',
'github_token': config['github']['token'],
'github_prefix': 'hansen',
'github_name': config['github']['name'],
'github_email': "foo@example.org",
'branch_ids': [(0, 0, {'name': 'master'})],
})
@pytest.fixture
def make_repo2(env, project, make_repo, users, setreviewers):
"""Layer over ``make_repo`` which also:
- adds the new repo to ``project`` (with no group and the ``'default'`` status required)
- sets the standard reviewers on the repo
- and creates an event source for the repo
"""
def mr(name):
r = make_repo(name)
rr = env['runbot_merge.repository'].create({
'project_id': project.id,
'name': r.name,
'group_id': False,
'required_statuses': 'default',
})
setreviewers(rr)
env['runbot_merge.events_sources'].create({'repository': r.name})
return r
return mr
@pytest.fixture
def repo(make_repo2):
return make_repo2('repo')